diff options
author | Topi Miettinen <toiwoton@gmail.com> | 2020-04-23 13:12:23 +0300 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-04-26 20:18:48 +0200 |
commit | 3c14dc61f7782d8eca0ff7b55e9f60fef176fe82 (patch) | |
tree | 3296fc428ff2b84635404b6702250c11b2232f81 /src/test/test-clock.c | |
parent | 7b679a188ee2f643e47938e8f287347399f2e083 (diff) | |
download | systemd-3c14dc61f7782d8eca0ff7b55e9f60fef176fe82.tar.gz |
tests: various small fixes for strict systems
Don't assume that 4MB can be allocated from stack since there could be smaller
DefaultLimitSTACK= in force, so let's use malloc(). NUL terminate the huge
strings by hand, also ensure termination in test_lz4_decompress_partial() and
optimize the memset() for the string.
Some items in /proc and /etc may not be accessible to poor unprivileged users
due to e.g. SELinux, BOFH or both, so check for EACCES and EPERM.
/var/tmp may be a symlink to /tmp and then path_compare() will always fail, so
let's stick to /tmp like elsewhere.
/tmp may be mounted with noexec option and then trying to execute scripts from
there would fail.
Detect and warn if seccomp is already in use, which could make seccomp test
fail if the syscalls are already blocked.
Unset $TMPDIR so it will not break specifier tests where %T is assumed to be
/tmp and %V /var/tmp.
Diffstat (limited to 'src/test/test-clock.c')
-rw-r--r-- | src/test/test-clock.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/test/test-clock.c b/src/test/test-clock.c index 018e679b45..e5a3de8a59 100644 --- a/src/test/test-clock.c +++ b/src/test/test-clock.c @@ -60,14 +60,14 @@ static void test_clock_is_localtime_system(void) { int r; r = clock_is_localtime(NULL); - if (access("/etc/adjtime", F_OK) == 0) { - log_info("/etc/adjtime exists, clock_is_localtime() == %i", r); + if (access("/etc/adjtime", R_OK) == 0) { + log_info("/etc/adjtime is readable, clock_is_localtime() == %i", r); /* if /etc/adjtime exists we expect some answer, no error or * crash */ assert_se(IN_SET(r, 0, 1)); } else /* default is UTC if there is no /etc/adjtime */ - assert_se(r == 0); + assert_se(r == 0 || ERRNO_IS_PRIVILEGE(r)); } int main(int argc, char *argv[]) { |