WHR | cbbf07c | 2015-02-04 22:58:05 +0800 | [diff] [blame] | 1 | #include <unistd.h> |
2 | #include <stdio.h> | ||||
3 | #include <string.h> | ||||
4 | #include <stdlib.h> | ||||
5 | #include <errno.h> | ||||
6 | #include <selinux/selinux.h> | ||||
7 | |||||
8 | int getenforce_main() { | ||||
9 | int rc; | ||||
10 | |||||
11 | rc = is_selinux_enabled(); | ||||
12 | if(rc <= 0) { | ||||
13 | printf("Disabled\n"); | ||||
14 | return 0; | ||||
15 | } | ||||
16 | |||||
17 | rc = security_getenforce(); | ||||
18 | if(rc < 0) { | ||||
19 | fprintf(stderr, "Could not get enforcing status: %s\n", strerror(errno)); | ||||
20 | return 2; | ||||
21 | } | ||||
22 | puts(rc ? "Enforcing" : "Permissive"); | ||||
23 | |||||
24 | return 0; | ||||
25 | } |