Skip to content

Commit

Permalink
Skip setuid test if systemd doesn't support disabling RDRAND
Browse files Browse the repository at this point in the history
setuid.c calls getgrnam which can call nss-systemd which uses random bytes via systemd's `random_bytes()`. This will use RDRAND if systemd is too old to support SYSTEMD_RDRAND=0.
  • Loading branch information
rocallahan committed Aug 1, 2023
1 parent 795ba07 commit ceb05ee
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,6 @@ set(BASIC_TESTS
setgid
setgroups
setsid
setuid
shared_exec
shared_monitor
shared_offset
Expand Down Expand Up @@ -1475,6 +1474,7 @@ set(TESTS_WITH_PROGRAM
seccomp_open
seccomp_signals
segfault
setuid
shared_map
shared_persistent_file
signal_numbers
Expand Down
4 changes: 4 additions & 0 deletions src/test/setuid.run
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source `dirname $0`/util.sh
skip_if_old_systemd
compare_test EXIT-SUCCESS

10 changes: 10 additions & 0 deletions src/test/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,16 @@ function skip_if_no_syscall_buf {
fi
}

# If the systemd version doesn't allow disabling RDRAND, skip the test,
# because it might trigger systemd code.
function skip_if_old_systemd {
systemd_version=`systemctl --version | head -n1 | cut -d' ' -f2`
if [[ $systemd_version != "" && $systemd_version < 247 ]]; then
echo "can't disable RDRAND for systemd, skipping test"
exit 0
fi
}

function skip_if_test_32_bit {
if [[ "_32" == $bitness ]]; then
echo NOTE: Skipping "'$TESTNAME'" because 32-bit test
Expand Down

0 comments on commit ceb05ee

Please sign in to comment.