]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-execute: use the "nogroup" group if it exists for testing
authorLennart Poettering <lennart@poettering.net>
Tue, 5 Dec 2017 09:59:44 +0000 (10:59 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 6 Dec 2017 12:40:50 +0000 (13:40 +0100)
We currently look for "nobody" and "nfsnobody" when testing groups, both
of which do not exist on Ubuntu, our main testing environment. Let's
extend the tests slightly to also use "nogroup" if it exists.

src/test/test-execute.c
test/meson.build
test/test-execute/exec-group-nogroup.service [new file with mode: 0644]

index 2bff00a9f7fc36275cda4eaf60116f492b568113..fba798e22b01794ff533601733d1474425d0960f 100644 (file)
@@ -324,7 +324,6 @@ static void test_exec_systemcallfilter_system(Manager *m) {
                 log_notice("Seccomp not available, skipping %s", __func__);
                 return;
         }
-
         if (getpwnam("nobody"))
                 test(m, "exec-systemcallfilter-system-user.service", 0, CLD_EXITED);
         else if (getpwnam("nfsnobody"))
@@ -348,8 +347,10 @@ static void test_exec_group(Manager *m) {
                 test(m, "exec-group.service", 0, CLD_EXITED);
         else if (getgrnam("nfsnobody"))
                 test(m, "exec-group-nfsnobody.service", 0, CLD_EXITED);
+        else if (getgrnam("nogroup"))
+                test(m, "exec-group-nogroup.service", 0, CLD_EXITED);
         else
-                log_error_errno(errno, "Skipping %s, could not find nobody/nfsnobody group: %m", __func__);
+                log_error_errno(errno, "Skipping %s, could not find nobody/nfsnobody/nogroup group: %m", __func__);
 }
 
 static void test_exec_supplementarygroups(Manager *m) {
index 750f5c037964871a59b69d72c6f30b53e5c4df92..5c533f4833a1d0a47f5c8931d42effafad6a6f42 100644 (file)
@@ -68,6 +68,7 @@ test_data_files = '''
         test-execute/exec-environment.service
         test-execute/exec-environmentfile.service
         test-execute/exec-group-nfsnobody.service
+        test-execute/exec-group-nogroup.service
         test-execute/exec-group.service
         test-execute/exec-ignoresigpipe-no.service
         test-execute/exec-ignoresigpipe-yes.service
diff --git a/test/test-execute/exec-group-nogroup.service b/test/test-execute/exec-group-nogroup.service
new file mode 100644 (file)
index 0000000..cf07732
--- /dev/null
@@ -0,0 +1,7 @@
+[Unit]
+Description=Test for Group
+
+[Service]
+ExecStart=/bin/sh -x -c 'test "$$(id -n -g)" = "nogroup"'
+Type=oneshot
+Group=nogroup