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.
9 //config:config GETSEBOOL
10 //config: bool "getsebool"
12 //config: depends on SELINUX
14 //config: Enable support to get SELinux boolean values.
16 //applet:IF_GETSEBOOL(APPLET(getsebool, BB_DIR_USR_SBIN, BB_SUID_DROP))
18 //kbuild:lib-$(CONFIG_GETSEBOOL) += getsebool.o
20 //usage:#define getsebool_trivial_usage
21 //usage: "-a or getsebool boolean..."
22 //usage:#define getsebool_full_usage "\n\n"
23 //usage: " -a Show all selinux booleans"
27 int getsebool_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
28 int getsebool_main(int argc, char **argv)
30 int i, rc = 0, active, pending, len = 0;
35 opt = getopt32(argv, "a");
41 rc = security_get_boolean_names(&names, &len);
43 bb_perror_msg_and_die("can't get boolean names");
55 names = xmalloc(sizeof(char *) * len);
56 for (i = 0; i < len; i++)
57 names[i] = xstrdup(argv[i + 1]);
60 for (i = 0; i < len; i++) {
61 active = security_get_boolean_active(names[i]);
63 bb_error_msg_and_die("error getting active value for %s", names[i]);
65 pending = security_get_boolean_pending(names[i]);
67 bb_error_msg_and_die("error getting pending value for %s", names[i]);
69 printf("%s --> %s", names[i], (active ? "on" : "off"));
70 if (pending != active)
71 printf(" pending: %s", (pending ? "on" : "off"));
75 if (ENABLE_FEATURE_CLEAN_UP) {
76 for (i = 0; i < len; i++)