1 #include <unistd.h> 2 #include <stdio.h> 3 #include <stdlib.h> 4 #include <selinux/selinux.h> 5 main(int argc,char ** argv)6int main(int argc __attribute__ ((unused)), 7 char **argv __attribute__ ((unused))) 8 { 9 int rc; 10 11 rc = is_selinux_enabled(); 12 if (rc < 0) { 13 fputs("getenforce: is_selinux_enabled() failed", stderr); 14 return 2; 15 } 16 if (rc == 1) { 17 rc = security_getenforce(); 18 if (rc < 0) { 19 fputs("getenforce: getenforce() failed", stderr); 20 return 2; 21 } 22 23 if (rc) 24 puts("Enforcing"); 25 else 26 puts("Permissive"); 27 } else { 28 puts("Disabled"); 29 } 30 31 return 0; 32 } 33