diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:45 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:45 +0000 |
commit | efeb864cb547a2cbf96dc0053a8bdb4d9190b364 (patch) | |
tree | c0b83368f18be983fcc763200c4c24d633244588 /src/test/test-acl-util.c | |
parent | Releasing progress-linux version 255.5-1~progress7.99u1. (diff) | |
download | systemd-efeb864cb547a2cbf96dc0053a8bdb4d9190b364.tar.xz systemd-efeb864cb547a2cbf96dc0053a8bdb4d9190b364.zip |
Merging upstream version 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); |