Skip to content

Commit 1fa3352

Browse files
BoardzMasterl0kod
authored andcommitted
selftests/landlock: Share enforce_ruleset() helper
Move enforce_ruleset() helper function to common.h so that it can be used both by filesystem tests and network ones. Signed-off-by: Konstantin Meskhidze <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mickaël Salaün <[email protected]>
1 parent fff69fb commit 1fa3352

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

tools/testing/selftests/landlock/common.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,13 @@ static int __maybe_unused send_fd(int usock, int fd_tx)
256256
return -errno;
257257
return 0;
258258
}
259+
260+
static void __maybe_unused
261+
enforce_ruleset(struct __test_metadata *const _metadata, const int ruleset_fd)
262+
{
263+
ASSERT_EQ(0, prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0));
264+
ASSERT_EQ(0, landlock_restrict_self(ruleset_fd, 0))
265+
{
266+
TH_LOG("Failed to enforce ruleset: %s", strerror(errno));
267+
}
268+
}

tools/testing/selftests/landlock/fs_test.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -677,16 +677,6 @@ static int create_ruleset(struct __test_metadata *const _metadata,
677677
return ruleset_fd;
678678
}
679679

680-
static void enforce_ruleset(struct __test_metadata *const _metadata,
681-
const int ruleset_fd)
682-
{
683-
ASSERT_EQ(0, prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0));
684-
ASSERT_EQ(0, landlock_restrict_self(ruleset_fd, 0))
685-
{
686-
TH_LOG("Failed to enforce ruleset: %s", strerror(errno));
687-
}
688-
}
689-
690680
TEST_F_FORK(layout0, proc_nsfs)
691681
{
692682
const struct rule rules[] = {

0 commit comments

Comments
 (0)