Index: include/usage.h =================================================================== --- include/usage.h (revision 20175) +++ include/usage.h (working copy) @@ -3047,6 +3047,12 @@ #define setlogcons_full_usage \ "Redirect the kernel output to console N (0 for current)" +#define setsebool_trivial_usage \ + "boolean value" + +#define setsebool_full_usage \ + "Change boolean setting" + #define setsid_trivial_usage \ "program [arg ...]" #define setsid_full_usage \ Index: include/applets.h =================================================================== --- include/applets.h (revision 20175) +++ include/applets.h (working copy) @@ -296,6 +296,7 @@ USE_SETFILES(APPLET(setfiles, _BB_DIR_SBIN, _BB_SUID_NEVER)) USE_SETKEYCODES(APPLET(setkeycodes, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_SETLOGCONS(APPLET(setlogcons, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) +USE_SETSEBOOL(APPLET(setsebool, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) USE_SETSID(APPLET(setsid, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_SETUIDGID(APPLET_ODDNAME(setuidgid, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, setuidgid)) USE_FEATURE_SH_IS_ASH(APPLET_NOUSAGE(sh, ash, _BB_DIR_BIN, _BB_SUID_NEVER)) Index: selinux/setsebool.c =================================================================== --- selinux/setsebool.c (revision 0) +++ selinux/setsebool.c (revision 0) @@ -0,0 +1,40 @@ +/* + * setsebool + * Simple setsebool + * NOTE: -P option requires libsemanage, so this feature is + * omitted in this version + * Yuichi Nakamura + */ + +#include "busybox.h" + +int setsebool_main(int argc, char **argv); + +int setsebool_main(int argc, char **argv) +{ + int flags; + char *boolean; + char *p; + int value; + + if (argc != 3) + bb_show_usage(); + + boolean = argv[1]; + p = argv[2]; + + if(strcmp(p, "1") == 0 || strcasecmp(p, "true") == 0 + || strcasecmp(p, "on") == 0) { + value = 1; + } else if (strcmp(p, "0") == 0 || strcasecmp(p, "false") == 0 + || strcasecmp(p, "off") == 0) { + value = 0; + } else { + bb_show_usage(); + } + + if (security_set_boolean(boolean, value) < 0) + bb_error_msg_and_die("could not set boolean"); + + return 0; +} Index: selinux/Config.in =================================================================== --- selinux/Config.in (revision 20175) +++ selinux/Config.in (working copy) @@ -104,5 +104,13 @@ Support "-c" option (check the validity of the contexts against the specified binary policy) for setfiles. Requires libsepol. +config SETSEBOOL + bool "setsebool" + default n + depends on SELINUX + help + Enable support for change boolean. + semanage and -P option is not supported yet. + endmenu Index: selinux/Kbuild =================================================================== --- selinux/Kbuild (revision 20175) +++ selinux/Kbuild (working copy) @@ -16,3 +16,4 @@ lib-$(CONFIG_SETENFORCE) += setenforce.o lib-$(CONFIG_SETFILES) += setfiles.o lib-$(CONFIG_RESTORECON) += setfiles.o +lib-$(CONFIG_SETSEBOOL) += setsebool.o