Home | History | Annotate | Download | only in toolbox
      1 #include <unistd.h>
      2 #include <stdio.h>
      3 #include <stdlib.h>
      4 #include <errno.h>
      5 #include <selinux/selinux.h>
      6 
      7 int getenforce_main(int argc, char **argv)
      8 {
      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",
     20                 strerror(errno));
     21         return 2;
     22     }
     23 
     24     if (rc)
     25         printf("Enforcing\n");
     26     else
     27         printf("Permissive\n");
     28 
     29     return 0;
     30 }
     31