diff options
author | Daan De Meyer <daan.j.demeyer@gmail.com> | 2024-09-19 12:21:55 +0200 |
---|---|---|
committer | Daan De Meyer <daan.j.demeyer@gmail.com> | 2024-09-19 13:42:05 +0200 |
commit | e5c6dcac8768ac88a58095072d407327f7de0116 (patch) | |
tree | 48b00d9ecaed6b6757a8336c28449e469a220cc7 /src/test/test-process-util.c | |
parent | test-process-util: Use FORK_REOPEN_LOG everywhere we close all fds (diff) | |
download | systemd-e5c6dcac8768ac88a58095072d407327f7de0116.tar.xz systemd-e5c6dcac8768ac88a58095072d407327f7de0116.zip |
test-process-util: Ignore EINVAL from setresuid() and setresgid()
If we're running in a user namespace with a single user and without
the nobody user, we'll get EINVAL from these system calls so make
sure we handle those gracefully.
Diffstat (limited to 'src/test/test-process-util.c')
-rw-r--r-- | src/test/test-process-util.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/test/test-process-util.c b/src/test/test-process-util.c index bf4d94e8c0..e6ba6fea70 100644 --- a/src/test/test-process-util.c +++ b/src/test/test-process-util.c @@ -729,11 +729,13 @@ TEST(setpriority_closest) { /* However, if the hard limit was above 30, setrlimit would succeed unprivileged, so * check if the UID/GID can be changed before enabling the full test. */ if (setresgid(GID_NOBODY, GID_NOBODY, GID_NOBODY) < 0) { - if (!ERRNO_IS_PRIVILEGE(errno)) + /* If the nobody user does not exist (user namespace) we get EINVAL. */ + if (!ERRNO_IS_PRIVILEGE(errno) && errno != EINVAL) ASSERT_OK_ERRNO(-1); full_test = false; } else if (setresuid(UID_NOBODY, UID_NOBODY, UID_NOBODY) < 0) { - if (!ERRNO_IS_PRIVILEGE(errno)) + /* If the nobody user does not exist (user namespace) we get EINVAL. */ + if (!ERRNO_IS_PRIVILEGE(errno) && errno != EINVAL) ASSERT_OK_ERRNO(-1); full_test = false; } else |