hexdump: accept hex numbers in -n, closes 16195
[busybox-git.git] / selinux / getenforce.c
blobf082ba61451e0d2b04e4b6c0573d40ec662be3cc
1 /*
2 * getenforce
4 * Based on libselinux 1.33.1
5 * Port to BusyBox Hiroshi Shinji <shiroshi@my.email.ne.jp>
7 * Licensed under GPLv2, see file LICENSE in this source tree.
8 */
9 //config:config GETENFORCE
10 //config: bool "getenforce (1.7 kb)"
11 //config: default n
12 //config: depends on SELINUX
13 //config: help
14 //config: Enable support to get the current mode of SELinux.
16 //applet:IF_GETENFORCE(APPLET(getenforce, BB_DIR_USR_SBIN, BB_SUID_DROP))
18 //kbuild:lib-$(CONFIG_GETENFORCE) += getenforce.o
20 //usage:#define getenforce_trivial_usage NOUSAGE_STR
21 //usage:#define getenforce_full_usage ""
23 #include "libbb.h"
25 int getenforce_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
26 int getenforce_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
28 int rc;
30 rc = is_selinux_enabled();
31 if (rc < 0)
32 bb_simple_error_msg_and_die("is_selinux_enabled() failed");
34 if (rc == 1) {
35 rc = security_getenforce();
36 if (rc < 0)
37 bb_simple_error_msg_and_die("getenforce() failed");
39 if (rc)
40 puts("Enforcing");
41 else
42 puts("Permissive");
43 } else {
44 puts("Disabled");
47 return 0;