git: ea3910c452cf - stable/14 - path_test: fix cap_rights_init usage

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Fri, 22 Mar 2024 13:33:11 UTC
The branch stable/14 has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=ea3910c452cf44342e0b65d6283aebeb77a10863

commit ea3910c452cf44342e0b65d6283aebeb77a10863
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2024-02-15 00:45:42 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2024-03-22 13:30:32 +0000

    path_test: 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:          e5e1d9c7b781 ("path_test: Add a test case for...")
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 8d1348f55aed6873f34f54bc3b275b73ef0ff66d)
---
 tests/sys/file/path_test.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/sys/file/path_test.c b/tests/sys/file/path_test.c
index bd98d7a6955a..911c7c7075f0 100644
--- a/tests/sys/file/path_test.c
+++ b/tests/sys/file/path_test.c
@@ -235,7 +235,7 @@ ATF_TC_BODY(path_capsicum_empty, tc)
 	/*
 	 * CAP_READ and CAP_LOOKUP should be sufficient to open a directory.
 	 */
-	cap_rights_init(&rights, CAP_READ | CAP_LOOKUP);
+	cap_rights_init(&rights, CAP_READ, CAP_LOOKUP);
 	ATF_REQUIRE(cap_rights_limit(pathdfd, &rights) == 0);
 	dfd = openat(pathdfd, "", O_DIRECTORY | O_EMPTY_PATH);
 	ATF_REQUIRE(dfd >= 0);
@@ -256,7 +256,7 @@ ATF_TC_BODY(path_capsicum_empty, tc)
 	ATF_REQUIRE(fd >= 0);
 	CHECKED_CLOSE(fd);
 
-	cap_rights_init(&rights, CAP_READ | CAP_LOOKUP | CAP_WRITE);
+	cap_rights_init(&rights, CAP_READ, CAP_LOOKUP, CAP_WRITE);
 	ATF_REQUIRE(cap_rights_limit(pathfd, &rights) == 0);
 	fd = openat(pathfd, "", O_RDWR | O_EMPTY_PATH | O_APPEND);
 	ATF_REQUIRE(fd >= 0);
@@ -265,7 +265,7 @@ ATF_TC_BODY(path_capsicum_empty, tc)
 	/*
 	 * CAP_SEEK is needed to open a file for writing without O_APPEND.
 	 */
-	cap_rights_init(&rights, CAP_READ | CAP_LOOKUP | CAP_WRITE);
+	cap_rights_init(&rights, CAP_READ, CAP_LOOKUP, CAP_WRITE);
 	ATF_REQUIRE(cap_rights_limit(pathfd, &rights) == 0);
 	fd = openat(pathfd, "", O_RDWR | O_EMPTY_PATH);
 	ATF_REQUIRE_ERRNO(ENOTCAPABLE, fd == -1);