Skip to content

Commit

Permalink
libcasper: fix cap_rights_init usage
Browse files Browse the repository at this point in the history
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:		faaf43b ("fileargs: add tests")
Sponsored by:	The FreeBSD Foundation
  • Loading branch information
emaste committed Feb 15, 2024
1 parent 25a5bb7 commit 3733d82
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/libcasper/services/cap_fileargs/tests/fileargs_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,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);
Expand Down Expand Up @@ -338,7 +338,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);
Expand Down Expand Up @@ -385,7 +385,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);
Expand Down Expand Up @@ -466,7 +466,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);
Expand Down Expand Up @@ -516,7 +516,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);
Expand Down Expand Up @@ -566,7 +566,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);
Expand Down Expand Up @@ -672,7 +672,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);
Expand Down Expand Up @@ -720,7 +720,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);
Expand Down

0 comments on commit 3733d82

Please sign in to comment.