blob: 56611d6936e4e43da4c89b1092cc87493629baae [file] [log] [blame]
Denis Vlasenkod46d3c22007-02-06 19:28:50 +00001/*
2 * getenforce
3 *
4 * Based on libselinux 1.33.1
5 * Port to BusyBox Hiroshi Shinji <shiroshi@my.email.ne.jp>
6 *
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +02007 * Licensed under GPLv2, see file LICENSE in this source tree.
Denis Vlasenkod46d3c22007-02-06 19:28:50 +00008 */
9
Pere Orga5bc8c002011-04-11 03:29:49 +020010//usage:#define getenforce_trivial_usage NOUSAGE_STR
11//usage:#define getenforce_full_usage ""
12
Denis Vlasenkob6adbf12007-05-26 19:00:18 +000013#include "libbb.h"
Denis Vlasenkod46d3c22007-02-06 19:28:50 +000014
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000015int getenforce_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Denis Vlasenkoa60f84e2008-07-05 09:18:54 +000016int getenforce_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
Denis Vlasenkod46d3c22007-02-06 19:28:50 +000017{
18 int rc;
19
20 rc = is_selinux_enabled();
21 if (rc < 0)
22 bb_error_msg_and_die("is_selinux_enabled() failed");
23
24 if (rc == 1) {
25 rc = security_getenforce();
26 if (rc < 0)
27 bb_error_msg_and_die("getenforce() failed");
28
29 if (rc)
30 puts("Enforcing");
31 else
32 puts("Permissive");
33 } else {
34 puts("Disabled");
35 }
36
37 return 0;
38}