@@ -47,6 +47,7 @@ static int pipes[2] = {-1, -1};
static int fanotify_fd;
static int ignore_mark_unsupported;
static int filesystem_mark_unsupported;
+static int se_enforcing;
static unsigned int supported_init_flags;
struct test_case_flags_t {
@@ -274,6 +275,7 @@ static void do_test(unsigned int number)
/* Set mark on non-dir only when expecting error ENOTDIR */
const char *path = tc->expected_errno == ENOTDIR ? FILE1 : MNTPOINT;
+ const int exp_errs[] = {tc->expected_errno, EACCES};
int dirfd = AT_FDCWD;
if (tc->pfd) {
@@ -283,9 +285,9 @@ static void do_test(unsigned int number)
tst_res(TINFO, "Testing %s with %s",
tc->mark.desc, tc->mask.desc);
- TST_EXP_FD_OR_FAIL(fanotify_mark(fanotify_fd, FAN_MARK_ADD | tc->mark.flags,
- tc->mask.flags, dirfd, path),
- tc->expected_errno);
+
+ TST_EXP_FAIL_ARR(fanotify_mark(fanotify_fd, FAN_MARK_ADD | tc->mark.flags,
+ tc->mask.flags, dirfd, path), exp_errs, se_enforcing ? 2 : 1);
/*
* ENOTDIR are errors for events/flags not allowed on a non-dir inode.
@@ -334,6 +336,8 @@ static void do_setup(void)
SAFE_FILE_PRINTF(FILE1, "0");
/* Create anonymous pipes to place marks on */
SAFE_PIPE2(pipes, O_CLOEXEC);
+
+ se_enforcing = tst_selinux_enforcing();
}
static void do_cleanup(void)