diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:40 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:40 +0000 |
commit | fc53809803cd2bc2434e312b19a18fa36776da12 (patch) | |
tree | b4b43bd6538f51965ce32856e9c053d0f90919c8 /src/test/test-acl-util.c | |
parent | Adding upstream version 255.5. (diff) | |
download | systemd-fc53809803cd2bc2434e312b19a18fa36776da12.tar.xz systemd-fc53809803cd2bc2434e312b19a18fa36776da12.zip |
Adding upstream version 256.upstream/256
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/test-acl-util.c')
-rw-r--r-- | src/test/test-acl-util.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/test/test-acl-util.c b/src/test/test-acl-util.c index eb9678a..0cc9afc 100644 --- a/src/test/test-acl-util.c +++ b/src/test/test-acl-util.c @@ -10,6 +10,7 @@ #include "fd-util.h" #include "format-util.h" #include "fs-util.h" +#include "path-util.h" #include "string-util.h" #include "tests.h" #include "tmpfile-util.h" @@ -22,6 +23,12 @@ TEST_RET(add_acls_for_user) { uid_t uid; int r; + FOREACH_STRING(s, "capsh", "getfacl", "ls") { + r = find_executable(s, NULL); + if (r < 0) + return log_tests_skipped_errno(r, "Could not find %s binary: %m", s); + } + fd = mkostemp_safe(fn); assert_se(fd >= 0); @@ -69,11 +76,18 @@ TEST_RET(add_acls_for_user) { return 0; } -TEST(fd_acl_make_read_only) { +TEST_RET(fd_acl_make_read_only) { _cleanup_(unlink_tempfilep) char fn[] = "/tmp/test-empty.XXXXXX"; _cleanup_close_ int fd = -EBADF; const char *cmd; struct stat st; + int r; + + FOREACH_STRING(s, "capsh", "getfacl", "ls", "stat") { + r = find_executable(s, NULL); + if (r < 0) + return log_tests_skipped_errno(r, "Could not find %s binary: %m", s); + } fd = mkostemp_safe(fn); assert_se(fd >= 0); @@ -81,8 +95,8 @@ TEST(fd_acl_make_read_only) { /* make it more exciting */ (void) fd_add_uid_acl_permission(fd, 1, ACL_READ|ACL_WRITE|ACL_EXECUTE); - assert_se(fstat(fd, &st) >= 0); - assert_se((st.st_mode & 0200) == 0200); + ASSERT_OK_ERRNO(fstat(fd, &st)); + assert_se(FLAGS_SET(st.st_mode, 0200)); cmd = strjoina("getfacl -p ", fn); assert_se(system(cmd) == 0); @@ -93,7 +107,7 @@ TEST(fd_acl_make_read_only) { log_info("read-only"); assert_se(fd_acl_make_read_only(fd)); - assert_se(fstat(fd, &st) >= 0); + ASSERT_OK_ERRNO(fstat(fd, &st)); assert_se((st.st_mode & 0222) == 0000); cmd = strjoina("getfacl -p ", fn); @@ -105,7 +119,7 @@ TEST(fd_acl_make_read_only) { log_info("writable"); assert_se(fd_acl_make_writable(fd)); - assert_se(fstat(fd, &st) >= 0); + ASSERT_OK_ERRNO(fstat(fd, &st)); assert_se((st.st_mode & 0222) == 0200); cmd = strjoina("getfacl -p ", fn); @@ -117,7 +131,7 @@ TEST(fd_acl_make_read_only) { log_info("read-only"); assert_se(fd_acl_make_read_only(fd)); - assert_se(fstat(fd, &st) >= 0); + ASSERT_OK_ERRNO(fstat(fd, &st)); assert_se((st.st_mode & 0222) == 0000); cmd = strjoina("getfacl -p ", fn); @@ -125,6 +139,8 @@ TEST(fd_acl_make_read_only) { cmd = strjoina("stat ", fn); assert_se(system(cmd) == 0); + + return 0; } DEFINE_TEST_MAIN(LOG_INFO); |