summaryrefslogtreecommitdiff
path: root/cleopatre/busybox-1.11.1-spc300/selinux/getsebool.c
diff options
context:
space:
mode:
authorYacine Belkadi2012-05-03 11:01:33 +0200
committerYacine Belkadi2012-06-27 11:07:22 +0200
commitb31db02df546187d7b2f27e14eb587b4561dda8d (patch)
treeb5b259dba96a419de4d2d55e51acf270374717fd /cleopatre/busybox-1.11.1-spc300/selinux/getsebool.c
parent4d7cb28e1ab17aad9145278c05d48eed0623a1da (diff)
cleo: add directory for busybox sources, refs #3085
Create a source directory for busybox, by extracting the content of busybox-1.11.1.tar.bz2.
Diffstat (limited to 'cleopatre/busybox-1.11.1-spc300/selinux/getsebool.c')
-rw-r--r--cleopatre/busybox-1.11.1-spc300/selinux/getsebool.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/cleopatre/busybox-1.11.1-spc300/selinux/getsebool.c b/cleopatre/busybox-1.11.1-spc300/selinux/getsebool.c
new file mode 100644
index 0000000000..ea080d483a
--- /dev/null
+++ b/cleopatre/busybox-1.11.1-spc300/selinux/getsebool.c
@@ -0,0 +1,66 @@
+/*
+ * getsebool
+ *
+ * Based on libselinux 1.33.1
+ * Port to BusyBox Hiroshi Shinji <shiroshi@my.email.ne.jp>
+ *
+ */
+
+#include "libbb.h"
+
+int getsebool_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int getsebool_main(int argc, char **argv)
+{
+ int i, rc = 0, active, pending, len = 0;
+ char **names;
+ unsigned opt;
+
+ selinux_or_die();
+ opt = getopt32(argv, "a");
+
+ if (opt) { /* -a */
+ if (argc > 2)
+ bb_show_usage();
+
+ rc = security_get_boolean_names(&names, &len);
+ if (rc)
+ bb_perror_msg_and_die("cannot get boolean names");
+
+ if (!len) {
+ puts("No booleans");
+ return 0;
+ }
+ }
+
+ if (!len) {
+ if (argc < 2)
+ bb_show_usage();
+ len = argc - 1;
+ names = xmalloc(sizeof(char *) * len);
+ for (i = 0; i < len; i++)
+ names[i] = xstrdup(argv[i + 1]);
+ }
+
+ for (i = 0; i < len; i++) {
+ active = security_get_boolean_active(names[i]);
+ if (active < 0) {
+ bb_error_msg_and_die("error getting active value for %s", names[i]);
+ }
+ pending = security_get_boolean_pending(names[i]);
+ if (pending < 0) {
+ bb_error_msg_and_die("error getting pending value for %s", names[i]);
+ }
+ printf("%s --> %s", names[i], (active ? "on" : "off"));
+ if (pending != active)
+ printf(" pending: %s", (pending ? "on" : "off"));
+ bb_putchar('\n');
+ }
+
+ if (ENABLE_FEATURE_CLEAN_UP) {
+ for (i = 0; i < len; i++)
+ free(names[i]);
+ free(names);
+ }
+
+ return rc;
+}