mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
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 <konstantin.meskhidze@huawei.com> Link: https://lore.kernel.org/r/20231026014751.414649-10-konstantin.meskhidze@huawei.com Signed-off-by: Mickaël Salaün <mic@digikod.net>
This commit is contained in:
parent
fff69fb03d
commit
1fa335209f
2 changed files with 10 additions and 10 deletions
|
@ -256,3 +256,13 @@ static int __maybe_unused send_fd(int usock, int fd_tx)
|
||||||
return -errno;
|
return -errno;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void __maybe_unused
|
||||||
|
enforce_ruleset(struct __test_metadata *const _metadata, const int ruleset_fd)
|
||||||
|
{
|
||||||
|
ASSERT_EQ(0, prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0));
|
||||||
|
ASSERT_EQ(0, landlock_restrict_self(ruleset_fd, 0))
|
||||||
|
{
|
||||||
|
TH_LOG("Failed to enforce ruleset: %s", strerror(errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -677,16 +677,6 @@ static int create_ruleset(struct __test_metadata *const _metadata,
|
||||||
return ruleset_fd;
|
return ruleset_fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void enforce_ruleset(struct __test_metadata *const _metadata,
|
|
||||||
const int ruleset_fd)
|
|
||||||
{
|
|
||||||
ASSERT_EQ(0, prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0));
|
|
||||||
ASSERT_EQ(0, landlock_restrict_self(ruleset_fd, 0))
|
|
||||||
{
|
|
||||||
TH_LOG("Failed to enforce ruleset: %s", strerror(errno));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F_FORK(layout0, proc_nsfs)
|
TEST_F_FORK(layout0, proc_nsfs)
|
||||||
{
|
{
|
||||||
const struct rule rules[] = {
|
const struct rule rules[] = {
|
||||||
|
|
Loading…
Add table
Reference in a new issue