2007-02-07 00:58:50 +05:30
|
|
|
/*
|
|
|
|
* getsebool
|
|
|
|
*
|
|
|
|
* Based on libselinux 1.33.1
|
|
|
|
* Port to BusyBox Hiroshi Shinji <shiroshi@my.email.ne.jp>
|
|
|
|
*
|
2010-08-16 23:44:46 +05:30
|
|
|
* Licensed under GPLv2, see file LICENSE in this source tree.
|
2007-02-07 00:58:50 +05:30
|
|
|
*/
|
2016-11-23 23:16:40 +05:30
|
|
|
//config:config GETSEBOOL
|
|
|
|
//config: bool "getsebool"
|
|
|
|
//config: default n
|
|
|
|
//config: depends on SELINUX
|
|
|
|
//config: help
|
|
|
|
//config: Enable support to get SELinux boolean values.
|
|
|
|
|
|
|
|
//applet:IF_GETSEBOOL(APPLET(getsebool, BB_DIR_USR_SBIN, BB_SUID_DROP))
|
|
|
|
|
|
|
|
//kbuild:lib-$(CONFIG_GETSEBOOL) += getsebool.o
|
2007-02-07 00:58:50 +05:30
|
|
|
|
2011-04-11 06:59:49 +05:30
|
|
|
//usage:#define getsebool_trivial_usage
|
|
|
|
//usage: "-a or getsebool boolean..."
|
|
|
|
//usage:#define getsebool_full_usage "\n\n"
|
|
|
|
//usage: " -a Show all selinux booleans"
|
|
|
|
|
2007-05-27 00:30:18 +05:30
|
|
|
#include "libbb.h"
|
2007-02-07 00:58:50 +05:30
|
|
|
|
2007-10-11 15:35:36 +05:30
|
|
|
int getsebool_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
2007-02-07 00:58:50 +05:30
|
|
|
int getsebool_main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
int i, rc = 0, active, pending, len = 0;
|
|
|
|
char **names;
|
|
|
|
unsigned opt;
|
|
|
|
|
|
|
|
selinux_or_die();
|
2007-08-18 21:02:12 +05:30
|
|
|
opt = getopt32(argv, "a");
|
2007-02-07 00:58:50 +05:30
|
|
|
|
|
|
|
if (opt) { /* -a */
|
|
|
|
if (argc > 2)
|
|
|
|
bb_show_usage();
|
|
|
|
|
|
|
|
rc = security_get_boolean_names(&names, &len);
|
|
|
|
if (rc)
|
2009-11-13 13:38:27 +05:30
|
|
|
bb_perror_msg_and_die("can't get boolean names");
|
2007-02-07 00:58:50 +05:30
|
|
|
|
|
|
|
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"));
|
2007-09-27 15:50:47 +05:30
|
|
|
bb_putchar('\n');
|
2007-02-07 00:58:50 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
if (ENABLE_FEATURE_CLEAN_UP) {
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
free(names[i]);
|
|
|
|
free(names);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|