test-execute: use the "nogroup" group if it exists for testing

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.
This commit is contained in:
Lennart Poettering 2017-12-05 10:59:44 +01:00
parent 05fd2156b7
commit 66d73cc728
3 changed files with 11 additions and 2 deletions

View 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) {

View 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

View File

@ -0,0 +1,7 @@
[Unit]
Description=Test for Group
[Service]
ExecStart=/bin/sh -x -c 'test "$$(id -n -g)" = "nogroup"'
Type=oneshot
Group=nogroup