summaryrefslogtreecommitdiffstats
path: root/src/test/test-socket-util.c
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2024-08-18 13:20:14 +0200
committerDaan De Meyer <daan.j.demeyer@gmail.com>2024-08-18 21:53:52 +0200
commitef31767ed7e21672a50b77e7b3935948aaba114c (patch)
treeac617a66279a64d61a6d42a4badae80017eb39bf /src/test/test-socket-util.c
parenttest-netlink: Gracefully handle the loopback interface being down (diff)
downloadsystemd-ef31767ed7e21672a50b77e7b3935948aaba114c.tar.xz
systemd-ef31767ed7e21672a50b77e7b3935948aaba114c.zip
test: Gracefully handle running within user namespace with single user
Unprivileged users often make themselves root by unsharing a user namespace and then mapping their current user to root which does not require privileges. Let's make sure our tests don't fail in such an environment by adding checks where required to see if we're not running in a user namespace with only a single user.
Diffstat (limited to '')
-rw-r--r--src/test/test-socket-util.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/test/test-socket-util.c b/src/test/test-socket-util.c
index 516bddefbe..f7b31aeb46 100644
--- a/src/test/test-socket-util.c
+++ b/src/test/test-socket-util.c
@@ -170,7 +170,7 @@ TEST(getpeercred_getpeergroups) {
struct ucred ucred;
int pair[2] = EBADF_PAIR;
- if (geteuid() == 0) {
+ if (geteuid() == 0 && !userns_has_single_user()) {
test_uid = 1;
test_gid = 2;
test_gids = (gid_t*) gids;