Stephen Smalley | f074036 | 2012-01-04 12:30:47 -0500 | [diff] [blame] | 1 | #include <unistd.h> |
| 2 | #include <sys/types.h> |
| 3 | #include <sys/stat.h> |
| 4 | #include <sys/mman.h> |
| 5 | #include <sys/mount.h> |
| 6 | #include <sys/utsname.h> |
| 7 | #include <fcntl.h> |
| 8 | #include <stdlib.h> |
| 9 | #include <stdio.h> |
| 10 | #include <ctype.h> |
| 11 | #include <string.h> |
| 12 | #include <errno.h> |
| 13 | #include "selinux_internal.h" |
| 14 | #include <dlfcn.h> |
| 15 | #include "policy.h" |
| 16 | #include <limits.h> |
| 17 | #include "callbacks.h" |
| 18 | |
| 19 | int security_load_policy(void *data, size_t len) |
| 20 | { |
| 21 | char path[PATH_MAX]; |
| 22 | int fd, ret; |
| 23 | |
| 24 | if (!selinux_mnt) { |
| 25 | errno = ENOENT; |
| 26 | return -1; |
| 27 | } |
| 28 | |
| 29 | snprintf(path, sizeof path, "%s/load", selinux_mnt); |
| 30 | fd = open(path, O_RDWR); |
| 31 | if (fd < 0) |
| 32 | return -1; |
| 33 | |
| 34 | ret = write(fd, data, len); |
| 35 | close(fd); |
| 36 | if (ret < 0) |
| 37 | return -1; |
| 38 | return 0; |
| 39 | } |
| 40 | |
| 41 | hidden_def(security_load_policy) |