diff options
-rw-r--r-- | selinux/load_policy.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/selinux/load_policy.c b/selinux/load_policy.c new file mode 100644 index 000000000..83051e697 --- /dev/null +++ b/selinux/load_policy.c | |||
@@ -0,0 +1,31 @@ | |||
1 | /* | ||
2 | * load_policy | ||
3 | * This implementation is based on old load_policy to be small. | ||
4 | * Author: Yuichi Nakamura <ynakam@hitachisoft.jp> | ||
5 | */ | ||
6 | #include "busybox.h" | ||
7 | |||
8 | int load_policy_main(int argc, char *argv[]); | ||
9 | int load_policy_main(int argc, char *argv[]) | ||
10 | { | ||
11 | int fd; | ||
12 | struct stat st; | ||
13 | void *data; | ||
14 | if (argc != 2) { | ||
15 | bb_show_usage(); | ||
16 | } | ||
17 | |||
18 | fd = xopen(argv[1], O_RDONLY); | ||
19 | if (fstat(fd, &st) < 0) { | ||
20 | bb_perror_msg_and_die("can't fstat"); | ||
21 | } | ||
22 | data = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0); | ||
23 | if (data == MAP_FAILED) { | ||
24 | bb_perror_msg_and_die("can't mmap"); | ||
25 | } | ||
26 | if (security_load_policy(data, st.st_size) < 0) { | ||
27 | bb_perror_msg_and_die("can't load policy"); | ||
28 | } | ||
29 | |||
30 | return 0; | ||
31 | } | ||