audit(4): add test cases for chflagsat(2), lgetfh(2), setfib(2)
These three syscalls aren't currently audited correctly, so the tests are marked as expected failures. PR: 228374 Submitted by: aniketp MFC after: 2 weeks Sponsored by: Google, Inc. (GSoC 2018) Differential Revision: https://reviews.freebsd.org/D16379
This commit is contained in:
parent
0f1d973c8e
commit
55cd452396
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=336580
@ -374,6 +374,57 @@ ATF_TC_CLEANUP(getfsstat_failure, tc)
|
||||
}
|
||||
|
||||
|
||||
ATF_TC_WITH_CLEANUP(lgetfh_success);
|
||||
ATF_TC_HEAD(lgetfh_success, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
|
||||
"lgetfh(2) call");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(lgetfh_success, tc)
|
||||
{
|
||||
/* BSM conversion requested for unknown event 43061 */
|
||||
atf_tc_expect_fail("PR 228374: lgetfh(2) does not get audited in success mode");
|
||||
|
||||
/* Symbolic link needs to exist to get a file-handle */
|
||||
ATF_REQUIRE_EQ(0, symlink("symlink", path));
|
||||
const char *regex = "lgetfh.*return,success";
|
||||
FILE *pipefd = setup(fds, "fa");
|
||||
ATF_REQUIRE_EQ(0, lgetfh(path, &fht));
|
||||
check_audit(fds, regex, pipefd);
|
||||
}
|
||||
|
||||
ATF_TC_CLEANUP(lgetfh_success, tc)
|
||||
{
|
||||
cleanup();
|
||||
}
|
||||
|
||||
|
||||
ATF_TC_WITH_CLEANUP(lgetfh_failure);
|
||||
ATF_TC_HEAD(lgetfh_failure, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
|
||||
"lgetfh(2) call");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(lgetfh_failure, tc)
|
||||
{
|
||||
/* BSM conversion requested for unknown event 43061 */
|
||||
atf_tc_expect_fail("PR 228374: lgetfh(2) does not get audited in failure mode");
|
||||
|
||||
const char *regex = "lgetfh.*return,failure";
|
||||
FILE *pipefd = setup(fds, "fa");
|
||||
/* Failure reason: symbolic link does not exist */
|
||||
ATF_REQUIRE_EQ(-1, lgetfh(errpath, &fht));
|
||||
check_audit(fds, regex, pipefd);
|
||||
}
|
||||
|
||||
ATF_TC_CLEANUP(lgetfh_failure, tc)
|
||||
{
|
||||
cleanup();
|
||||
}
|
||||
|
||||
|
||||
ATF_TC_WITH_CLEANUP(fhopen_success);
|
||||
ATF_TC_HEAD(fhopen_success, tc)
|
||||
{
|
||||
@ -1155,6 +1206,8 @@ ATF_TP_ADD_TCS(tp)
|
||||
ATF_TP_ADD_TC(tp, getfsstat_success);
|
||||
ATF_TP_ADD_TC(tp, getfsstat_failure);
|
||||
|
||||
ATF_TP_ADD_TC(tp, lgetfh_success);
|
||||
ATF_TP_ADD_TC(tp, lgetfh_failure);
|
||||
ATF_TP_ADD_TC(tp, fhopen_success);
|
||||
ATF_TP_ADD_TC(tp, fhopen_failure);
|
||||
ATF_TP_ADD_TC(tp, fhstat_success);
|
||||
|
@ -692,6 +692,56 @@ ATF_TC_CLEANUP(lchflags_failure, tc)
|
||||
}
|
||||
|
||||
|
||||
ATF_TC_WITH_CLEANUP(chflagsat_success);
|
||||
ATF_TC_HEAD(chflagsat_success, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
|
||||
"chflagsat(2) call");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(chflagsat_success, tc)
|
||||
{
|
||||
/* BSM conversion requested for unknown event 43209 */
|
||||
atf_tc_expect_fail("PR 228374: chflagsat(2) does not get audited in success mode");
|
||||
|
||||
/* File needs to exist to call chflagsat(2) */
|
||||
ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
|
||||
FILE *pipefd = setup(fds, auclass);
|
||||
ATF_REQUIRE_EQ(0, chflagsat(AT_FDCWD, path, SF_IMMUTABLE, 0));
|
||||
check_audit(fds, successreg, pipefd);
|
||||
close(filedesc);
|
||||
}
|
||||
|
||||
ATF_TC_CLEANUP(chflagsat_success, tc)
|
||||
{
|
||||
cleanup();
|
||||
}
|
||||
|
||||
|
||||
ATF_TC_WITH_CLEANUP(chflagsat_failure);
|
||||
ATF_TC_HEAD(chflagsat_failure, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
|
||||
"chflagsat(2) call");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(chflagsat_failure, tc)
|
||||
{
|
||||
/* BSM conversion requested for unknown event 43209 */
|
||||
atf_tc_expect_fail("PR 228374: chflagsat(2) does not get audited in failure mode");
|
||||
|
||||
FILE *pipefd = setup(fds, auclass);
|
||||
/* Failure reason: file does not exist */
|
||||
ATF_REQUIRE_EQ(-1, chflagsat(AT_FDCWD, errpath, SF_IMMUTABLE, 0));
|
||||
check_audit(fds, failurereg, pipefd);
|
||||
}
|
||||
|
||||
ATF_TC_CLEANUP(chflagsat_failure, tc)
|
||||
{
|
||||
cleanup();
|
||||
}
|
||||
|
||||
|
||||
ATF_TC_WITH_CLEANUP(utimes_success);
|
||||
ATF_TC_HEAD(utimes_success, tc)
|
||||
{
|
||||
@ -1303,6 +1353,8 @@ ATF_TP_ADD_TCS(tp)
|
||||
ATF_TP_ADD_TC(tp, fchflags_failure);
|
||||
ATF_TP_ADD_TC(tp, lchflags_success);
|
||||
ATF_TP_ADD_TC(tp, lchflags_failure);
|
||||
ATF_TP_ADD_TC(tp, chflagsat_success);
|
||||
ATF_TP_ADD_TC(tp, chflagsat_failure);
|
||||
|
||||
ATF_TP_ADD_TC(tp, utimes_success);
|
||||
ATF_TP_ADD_TC(tp, utimes_failure);
|
||||
|
@ -1088,6 +1088,58 @@ ATF_TC_CLEANUP(sendfile_failure, tc)
|
||||
}
|
||||
|
||||
|
||||
ATF_TC_WITH_CLEANUP(setfib_success);
|
||||
ATF_TC_HEAD(setfib_success, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
|
||||
"setfib(2) call");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(setfib_success, tc)
|
||||
{
|
||||
/* BSM conversion requested for unknown event 43228 */
|
||||
atf_tc_expect_fail("PR 228374: setfib(2) does not get audited in success mode");
|
||||
|
||||
pid = getpid();
|
||||
snprintf(extregex, sizeof(extregex), "setfib.*%d.*return,success", pid);
|
||||
|
||||
FILE *pipefd = setup(fds, auclass);
|
||||
ATF_REQUIRE_EQ(0, setfib(0));
|
||||
check_audit(fds, extregex, pipefd);
|
||||
}
|
||||
|
||||
ATF_TC_CLEANUP(setfib_success, tc)
|
||||
{
|
||||
cleanup();
|
||||
}
|
||||
|
||||
|
||||
ATF_TC_WITH_CLEANUP(setfib_failure);
|
||||
ATF_TC_HEAD(setfib_failure, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
|
||||
"setfib(2) call");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(setfib_failure, tc)
|
||||
{
|
||||
/* BSM conversion requested for unknown event 43228 */
|
||||
atf_tc_expect_fail("PR 228374: setfib(2) does not get audited in failure mode");
|
||||
|
||||
pid = getpid();
|
||||
snprintf(extregex, sizeof(extregex), "setfib.*%d.*return,failure", pid);
|
||||
|
||||
FILE *pipefd = setup(fds, auclass);
|
||||
ATF_REQUIRE_EQ(-1, setfib(-1));
|
||||
check_audit(fds, extregex, pipefd);
|
||||
}
|
||||
|
||||
ATF_TC_CLEANUP(setfib_failure, tc)
|
||||
{
|
||||
cleanup();
|
||||
}
|
||||
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
ATF_TP_ADD_TC(tp, socket_success);
|
||||
@ -1130,6 +1182,8 @@ ATF_TP_ADD_TCS(tp)
|
||||
ATF_TP_ADD_TC(tp, shutdown_failure);
|
||||
ATF_TP_ADD_TC(tp, sendfile_success);
|
||||
ATF_TP_ADD_TC(tp, sendfile_failure);
|
||||
ATF_TP_ADD_TC(tp, setfib_success);
|
||||
ATF_TP_ADD_TC(tp, setfib_failure);
|
||||
|
||||
return (atf_no_error());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user