git: ec44cc4e2882 - stable/13 - libcasper: fix cap_rights_init usage
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 22 Mar 2024 13:36:28 UTC
The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=ec44cc4e28824b83b2b53b4afd39663345823613 commit ec44cc4e28824b83b2b53b4afd39663345823613 Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2024-02-15 00:42:48 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2024-03-22 13:35:44 +0000 libcasper: fix cap_rights_init usage Capability rights passed to cap_rights_* are not simple bitmaks and cannot be ORed together in general (although it will work for certain subsets of rights). PR: 277057 Fixes: faaf43b2a750 ("fileargs: add tests") Sponsored by: The FreeBSD Foundation (cherry picked from commit 3733d82c4deb49035a39e18744085d1e3e9b8dc5) (cherry picked from commit be83aa2a01b35f9e7aa94a3d45a851305fa22c83) --- .../services/cap_fileargs/tests/fileargs_test.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/libcasper/services/cap_fileargs/tests/fileargs_test.c b/lib/libcasper/services/cap_fileargs/tests/fileargs_test.c index 0b4857f6ed07..a9f2dd90e1af 100644 --- a/lib/libcasper/services/cap_fileargs/tests/fileargs_test.c +++ b/lib/libcasper/services/cap_fileargs/tests/fileargs_test.c @@ -281,7 +281,7 @@ ATF_TC_BODY(fileargs__open_read, tc) prepare_files(MAX_FILES, true); - cap_rights_init(&rights, CAP_READ | CAP_FCNTL); + cap_rights_init(&rights, CAP_READ, CAP_FCNTL); cap_rights_init(&norights, CAP_WRITE); fa = fileargs_init(MAX_FILES, files, O_RDONLY, 0, &rights, FA_OPEN); @@ -326,7 +326,7 @@ ATF_TC_BODY(fileargs__open_write, tc) prepare_files(MAX_FILES, true); - cap_rights_init(&rights, CAP_WRITE | CAP_FCNTL); + cap_rights_init(&rights, CAP_WRITE, CAP_FCNTL); cap_rights_init(&norights, CAP_READ); fa = fileargs_init(MAX_FILES, files, O_WRONLY, 0, &rights, FA_OPEN); @@ -371,7 +371,7 @@ ATF_TC_BODY(fileargs__open_create, tc) prepare_files(MAX_FILES, false); - cap_rights_init(&rights, CAP_WRITE | CAP_FCNTL | CAP_READ); + cap_rights_init(&rights, CAP_WRITE, CAP_FCNTL, CAP_READ); cap_rights_init(&norights, CAP_FCHMOD); fa = fileargs_init(MAX_FILES, files, O_RDWR | O_CREAT, 666, &rights, FA_OPEN); @@ -448,7 +448,7 @@ ATF_TC_BODY(fileargs__fopen_read, tc) prepare_files(MAX_FILES, true); - cap_rights_init(&rights, CAP_READ | CAP_FCNTL); + cap_rights_init(&rights, CAP_READ, CAP_FCNTL); cap_rights_init(&norights, CAP_WRITE); fa = fileargs_init(MAX_FILES, files, O_RDONLY, 0, &rights, FA_OPEN); @@ -496,7 +496,7 @@ ATF_TC_BODY(fileargs__fopen_write, tc) prepare_files(MAX_FILES, true); - cap_rights_init(&rights, CAP_WRITE | CAP_FCNTL); + cap_rights_init(&rights, CAP_WRITE, CAP_FCNTL); cap_rights_init(&norights, CAP_READ); fa = fileargs_init(MAX_FILES, files, O_WRONLY, 0, &rights, FA_OPEN); @@ -544,7 +544,7 @@ ATF_TC_BODY(fileargs__fopen_create, tc) prepare_files(MAX_FILES, false); - cap_rights_init(&rights, CAP_READ | CAP_WRITE | CAP_FCNTL); + cap_rights_init(&rights, CAP_READ, CAP_WRITE, CAP_FCNTL); fa = fileargs_init(MAX_FILES, files, O_RDWR | O_CREAT, 0, &rights, FA_OPEN); ATF_REQUIRE(fa != NULL); @@ -646,7 +646,7 @@ ATF_TC_BODY(fileargs__open_lstat, tc) prepare_files(MAX_FILES, true); - cap_rights_init(&rights, CAP_READ | CAP_FCNTL); + cap_rights_init(&rights, CAP_READ, CAP_FCNTL); cap_rights_init(&norights, CAP_WRITE); fa = fileargs_init(MAX_FILES, files, O_RDONLY, 0, &rights, FA_OPEN | FA_LSTAT); @@ -692,7 +692,7 @@ ATF_TC_BODY(fileargs__open_realpath, tc) prepare_files(MAX_FILES, true); - cap_rights_init(&rights, CAP_READ | CAP_FCNTL); + cap_rights_init(&rights, CAP_READ, CAP_FCNTL); cap_rights_init(&norights, CAP_WRITE); fa = fileargs_init(MAX_FILES, files, O_RDONLY, 0, &rights, FA_OPEN | FA_REALPATH);