Denis Vlasenko | 644849a | 2007-03-24 15:38:49 +0000 | [diff] [blame] | 1 | /* |
| 2 | * load_policy |
| 3 | * This implementation is based on old load_policy to be small. |
| 4 | * Author: Yuichi Nakamura <ynakam@hitachisoft.jp> |
| 5 | */ |
Denis Vlasenko | b6adbf1 | 2007-05-26 19:00:18 +0000 | [diff] [blame] | 6 | #include "libbb.h" |
Denis Vlasenko | 644849a | 2007-03-24 15:38:49 +0000 | [diff] [blame] | 7 | |
Bernhard Reutner-Fischer | febe3c4 | 2007-04-04 20:52:03 +0000 | [diff] [blame] | 8 | int load_policy_main(int argc, char **argv); |
| 9 | int load_policy_main(int argc, char **argv) |
Denis Vlasenko | 644849a | 2007-03-24 15:38:49 +0000 | [diff] [blame] | 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 | } |