test-execute: add a test for the case that NOBODY_GROUP_NAME is nogroup
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 1 Mar 2018 09:31:26 +0000 (18:31 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 1 Mar 2018 09:31:26 +0000 (18:31 +0900)
src/test/test-execute.c
test/meson.build
test/test-execute/exec-runtimedirectory-owner-nogroup.service [new file with mode: 0644]

index a1a588b..b2d668d 100644 (file)
@@ -514,6 +514,8 @@ static void test_exec_runtimedirectory(Manager *m) {
                 test(m, "exec-runtimedirectory-owner.service", 0, CLD_EXITED);
         else if (streq(NOBODY_GROUP_NAME, "nfsnobody"))
                 test(m, "exec-runtimedirectory-owner-nfsnobody.service", 0, CLD_EXITED);
+        else if (streq(NOBODY_GROUP_NAME, "nogroup"))
+                test(m, "exec-runtimedirectory-owner-nogroup.service", 0, CLD_EXITED);
         else
                 log_error("Unsupported nobody group name '%s', skipping %s", NOBODY_GROUP_NAME, __func__);
 }
index 060e7ee..8159146 100644 (file)
@@ -113,6 +113,7 @@ test_data_files = '''
         test-execute/exec-restrictnamespaces-yes.service
         test-execute/exec-runtimedirectory-mode.service
         test-execute/exec-runtimedirectory-owner-nfsnobody.service
+        test-execute/exec-runtimedirectory-owner-nogroup.service
         test-execute/exec-runtimedirectory-owner.service
         test-execute/exec-runtimedirectory.service
         test-execute/exec-specifier-interpolation.service
diff --git a/test/test-execute/exec-runtimedirectory-owner-nogroup.service b/test/test-execute/exec-runtimedirectory-owner-nogroup.service
new file mode 100644 (file)
index 0000000..663afe1
--- /dev/null
@@ -0,0 +1,9 @@
+[Unit]
+Description=Test for RuntimeDirectory owner (must not be the default group of the user if Group is set)
+
+[Service]
+ExecStart=/bin/sh -x -c 'group=$$(stat -c %%G %t/test-exec_runtimedirectory-owner); test "$$group" = "nogroup"'
+Type=oneshot
+Group=nogroup
+User=root
+RuntimeDirectory=test-exec_runtimedirectory-owner