blob: 5d140bc963261e5e4c4bf55fbf57da026d857802 [file] [log] [blame]
Denis Vlasenko644849a2007-03-24 15:38:49 +00001/*
2 * load_policy
3 * This implementation is based on old load_policy to be small.
4 * Author: Yuichi Nakamura <ynakam@hitachisoft.jp>
5 */
Denis Vlasenkob6adbf12007-05-26 19:00:18 +00006#include "libbb.h"
Denis Vlasenko644849a2007-03-24 15:38:49 +00007
Bernhard Reutner-Fischerfebe3c42007-04-04 20:52:03 +00008int load_policy_main(int argc, char **argv);
9int load_policy_main(int argc, char **argv)
Denis Vlasenko644849a2007-03-24 15:38:49 +000010{
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}