aboutsummaryrefslogtreecommitdiff
path: root/toys/android
diff options
context:
space:
mode:
Diffstat (limited to 'toys/android')
-rw-r--r--toys/android/getenforce.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/toys/android/getenforce.c b/toys/android/getenforce.c
new file mode 100644
index 00000000..465452e4
--- /dev/null
+++ b/toys/android/getenforce.c
@@ -0,0 +1,29 @@
+/* getenforce.c - Get the current SELinux mode
+ *
+ * Copyright 2014 The Android Open Source Project
+
+USE_GETENFORCE(NEWTOY(getenforce, "", TOYFLAG_USR|TOYFLAG_SBIN))
+
+config GETENFORCE
+ bool "getenforce"
+ default y
+ depends on TOYBOX_SELINUX
+ help
+ usage: getenforce
+
+ Shows whether SELinux is disabled, enforcing, or permissive.
+*/
+
+#define FOR_getenforce
+#include "toys.h"
+
+void getenforce_main(void)
+{
+ if (!is_selinux_enabled()) puts("Disabled");
+ else {
+ int ret = security_getenforce();
+
+ if (ret == -1) perror_exit("Couldn't get enforcing status");
+ else puts(ret ? "Enforcing" : "Permissive");
+ }
+}