-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathtest-whitelist.c
More file actions
66 lines (59 loc) · 1.66 KB
/
Copy pathtest-whitelist.c
File metadata and controls
66 lines (59 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// SPDX-License-Identifier: LGPL-2.1-or-later
/*
* Copyright © 2026 Donald Buczek
*/
#include <stdlib.h>
#include "testsuite.h"
static int whitelist_inactive(void)
{
return EXEC_TOOL(modprobe, "mod-simple");
}
DEFINE_TEST(whitelist_inactive,
.description = "check that modules load normally when no whitelist directive is configured",
.config = {
[TC_UNAME_R] = "3.3.3",
[TC_ROOTFS] = TESTSUITE_ROOTFS "test-whitelist/no-directives",
[TC_INIT_MODULE_RETCODES] = "",
},
.modules_loaded = "mod-simple",
);
static int whitelist_deny_all(void)
{
return EXEC_TOOL(modprobe, "mod-simple");
}
DEFINE_TEST(whitelist_deny_all,
.description = "check that modules are denied when whitelist-enable is set with no entries",
.config = {
[TC_UNAME_R] = "3.3.3",
[TC_ROOTFS] = TESTSUITE_ROOTFS "test-whitelist/deny-all",
[TC_INIT_MODULE_RETCODES] = "",
},
.expected_fail = true,
);
static int whitelist_allowed(void)
{
return EXEC_TOOL(modprobe, "mod-simple");
}
DEFINE_TEST(whitelist_allowed,
.description = "check that a listed module loads, also verifying hyphen/underscore normalisation",
.config = {
[TC_UNAME_R] = "3.3.3",
[TC_ROOTFS] = TESTSUITE_ROOTFS "test-whitelist/allowed",
[TC_INIT_MODULE_RETCODES] = "",
},
.modules_loaded = "mod-simple",
);
static int whitelist_test_mode(void)
{
return EXEC_TOOL(modprobe, "mod-simple");
}
DEFINE_TEST(whitelist_test_mode,
.description = "check that whitelist-test-mode permits loading a module that would otherwise be denied",
.config = {
[TC_UNAME_R] = "3.3.3",
[TC_ROOTFS] = TESTSUITE_ROOTFS "test-whitelist/test-mode",
[TC_INIT_MODULE_RETCODES] = "",
},
.modules_loaded = "mod-simple",
);
TESTSUITE_MAIN();