mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-29 08:08:37 +00:00
capsicum: Verify that openat("/", "..") fails with ENOTCAPABLE
Add a regression test for a718431c30
("lookup(): ensure that
openat("/", "..", O_RESOLVE_BENEATH) fails").
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
8a271827e7
commit
2d252934da
@ -233,6 +233,31 @@ ATF_TC_BODY(lookup_cap_dotdot__negative, tc)
|
||||
ATF_REQUIRE_ERRNO(ENOTCAPABLE, openat(dirfd, "../testdir/d1/f1", O_RDONLY) < 0);
|
||||
}
|
||||
|
||||
ATF_TC(lookup_cap_dotdot__root);
|
||||
ATF_TC_HEAD(lookup_cap_dotdot__root, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "Validate cap-mode /.. lookup fails");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(lookup_cap_dotdot__root, tc)
|
||||
{
|
||||
int dfd, dfd2;
|
||||
|
||||
check_capsicum();
|
||||
|
||||
dfd = open("/", O_DIRECTORY);
|
||||
ATF_REQUIRE(dfd >= 0);
|
||||
|
||||
dfd2 = openat(dfd, "..", O_DIRECTORY);
|
||||
ATF_REQUIRE(dfd2 >= 0);
|
||||
ATF_REQUIRE(close(dfd2) == 0);
|
||||
|
||||
ATF_REQUIRE(cap_enter() >= 0);
|
||||
|
||||
dfd2 = openat(dfd, "..", O_DIRECTORY);
|
||||
ATF_REQUIRE_ERRNO(ENOTCAPABLE, openat(dfd, "..", O_DIRECTORY));
|
||||
}
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
|
||||
@ -244,6 +269,7 @@ ATF_TP_ADD_TCS(tp)
|
||||
ATF_TP_ADD_TC(tp, lookup_cap_dotdot__basic);
|
||||
ATF_TP_ADD_TC(tp, lookup_cap_dotdot__advanced);
|
||||
ATF_TP_ADD_TC(tp, lookup_cap_dotdot__negative);
|
||||
ATF_TP_ADD_TC(tp, lookup_cap_dotdot__root);
|
||||
|
||||
return (atf_no_error());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user