2007-10-18 16:16:42 +05:30
|
|
|
/*
|
|
|
|
* setsebool
|
|
|
|
* Simple setsebool
|
|
|
|
* NOTE: -P option requires libsemanage, so this feature is
|
|
|
|
* omitted in this version
|
|
|
|
* Yuichi Nakamura <ynakam@hitachisoft.jp>
|
2008-12-07 06:22:58 +05:30
|
|
|
*
|
2010-08-16 23:44:46 +05:30
|
|
|
* Licensed under GPLv2, see file LICENSE in this source tree.
|
2007-10-18 16:16:42 +05:30
|
|
|
*/
|
2016-11-23 23:16:40 +05:30
|
|
|
//config:config SETSEBOOL
|
2017-07-19 18:02:54 +05:30
|
|
|
//config: bool "setsebool (1.7 kb)"
|
2016-11-23 23:16:40 +05:30
|
|
|
//config: default n
|
|
|
|
//config: depends on SELINUX
|
|
|
|
//config: help
|
2017-07-21 13:20:55 +05:30
|
|
|
//config: Enable support for change boolean.
|
|
|
|
//config: semanage and -P option is not supported yet.
|
2016-11-23 23:16:40 +05:30
|
|
|
|
|
|
|
//applet:IF_SETSEBOOL(APPLET(setsebool, BB_DIR_USR_SBIN, BB_SUID_DROP))
|
|
|
|
|
|
|
|
//kbuild:lib-$(CONFIG_SETSEBOOL) += setsebool.o
|
2007-10-18 16:16:42 +05:30
|
|
|
|
2011-04-11 06:59:49 +05:30
|
|
|
//usage:#define setsebool_trivial_usage
|
|
|
|
//usage: "boolean value"
|
|
|
|
//usage:#define setsebool_full_usage "\n\n"
|
|
|
|
//usage: "Change boolean setting"
|
|
|
|
|
2007-10-18 16:16:42 +05:30
|
|
|
#include "libbb.h"
|
|
|
|
|
|
|
|
int setsebool_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
|
|
|
int setsebool_main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
int value;
|
|
|
|
|
|
|
|
if (argc != 3)
|
|
|
|
bb_show_usage();
|
|
|
|
|
|
|
|
p = argv[2];
|
|
|
|
|
|
|
|
if (LONE_CHAR(p, '1') || strcasecmp(p, "true") == 0 || strcasecmp(p, "on") == 0) {
|
|
|
|
value = 1;
|
|
|
|
} else if (LONE_CHAR(p, '0') || strcasecmp(p, "false") == 0 || strcasecmp(p, "off") == 0) {
|
|
|
|
value = 0;
|
|
|
|
} else {
|
|
|
|
bb_show_usage();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (security_set_boolean(argv[1], value) < 0)
|
|
|
|
bb_error_msg_and_die("can't set boolean");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|