test-execute: add a test for the case that NOBODY_GROUP_NAME is nogroup

This commit is contained in:
Yu Watanabe 2018-03-01 18:31:26 +09:00
parent 57c2efa0c3
commit d2f95a223f
3 changed files with 12 additions and 0 deletions

View 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__);
}

View 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

View File

@ -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