Blame libselinux/utils/getenforce.c
|
Chris PeBenito |
473ea7 |
#include <unistd.h>
|
|
Chris PeBenito |
473ea7 |
#include <stdio.h>
|
|
Chris PeBenito |
473ea7 |
#include <stdlib.h>
|
|
Chris PeBenito |
473ea7 |
#include <selinux/selinux.h>
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
int main(int argc __attribute__((unused)), char **argv)
|
|
Chris PeBenito |
473ea7 |
{
|
|
Chris PeBenito |
473ea7 |
int rc;
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
rc = is_selinux_enabled();
|
|
Chris PeBenito |
473ea7 |
if (rc < 0) {
|
|
Chris PeBenito |
473ea7 |
fputs("getenforce: is_selinux_enabled() failed", stderr);
|
|
Chris PeBenito |
473ea7 |
return 2;
|
|
Chris PeBenito |
473ea7 |
}
|
|
Chris PeBenito |
473ea7 |
if (rc == 1) {
|
|
Chris PeBenito |
473ea7 |
rc = security_getenforce();
|
|
Chris PeBenito |
473ea7 |
if (rc < 0) {
|
|
Chris PeBenito |
473ea7 |
fputs("getenforce: getenforce() failed", stderr);
|
|
Chris PeBenito |
473ea7 |
return 2;
|
|
Chris PeBenito |
473ea7 |
}
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
if (rc)
|
|
Chris PeBenito |
473ea7 |
puts("Enforcing");
|
|
Chris PeBenito |
473ea7 |
else
|
|
Chris PeBenito |
473ea7 |
puts("Permissive");
|
|
Chris PeBenito |
473ea7 |
} else {
|
|
Chris PeBenito |
473ea7 |
puts("Disabled");
|
|
Chris PeBenito |
473ea7 |
}
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
return 0;
|
|
Chris PeBenito |
473ea7 |
}
|