Denis Vlasenko | 740eae0 | 2007-10-18 10:46:42 +0000 | [diff] [blame] | 1 | /* |
| 2 | * setsebool |
| 3 | * Simple setsebool |
| 4 | * NOTE: -P option requires libsemanage, so this feature is |
| 5 | * omitted in this version |
| 6 | * Yuichi Nakamura <ynakam@hitachisoft.jp> |
Denis Vlasenko | db12d1d | 2008-12-07 00:52:58 +0000 | [diff] [blame] | 7 | * |
Denys Vlasenko | 0ef64bd | 2010-08-16 20:14:46 +0200 | [diff] [blame] | 8 | * Licensed under GPLv2, see file LICENSE in this source tree. |
Denis Vlasenko | 740eae0 | 2007-10-18 10:46:42 +0000 | [diff] [blame] | 9 | */ |
Denys Vlasenko | a8e52da | 2016-11-23 18:46:40 +0100 | [diff] [blame^] | 10 | //config:config SETSEBOOL |
| 11 | //config: bool "setsebool" |
| 12 | //config: default n |
| 13 | //config: depends on SELINUX |
| 14 | //config: help |
| 15 | //config: Enable support for change boolean. |
| 16 | //config: semanage and -P option is not supported yet. |
| 17 | |
| 18 | //applet:IF_SETSEBOOL(APPLET(setsebool, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
| 19 | |
| 20 | //kbuild:lib-$(CONFIG_SETSEBOOL) += setsebool.o |
Denis Vlasenko | 740eae0 | 2007-10-18 10:46:42 +0000 | [diff] [blame] | 21 | |
Pere Orga | 5bc8c00 | 2011-04-11 03:29:49 +0200 | [diff] [blame] | 22 | //usage:#define setsebool_trivial_usage |
| 23 | //usage: "boolean value" |
| 24 | //usage:#define setsebool_full_usage "\n\n" |
| 25 | //usage: "Change boolean setting" |
| 26 | |
Denis Vlasenko | 740eae0 | 2007-10-18 10:46:42 +0000 | [diff] [blame] | 27 | #include "libbb.h" |
| 28 | |
| 29 | int setsebool_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
| 30 | int setsebool_main(int argc, char **argv) |
| 31 | { |
| 32 | char *p; |
| 33 | int value; |
| 34 | |
| 35 | if (argc != 3) |
| 36 | bb_show_usage(); |
| 37 | |
| 38 | p = argv[2]; |
| 39 | |
| 40 | if (LONE_CHAR(p, '1') || strcasecmp(p, "true") == 0 || strcasecmp(p, "on") == 0) { |
| 41 | value = 1; |
| 42 | } else if (LONE_CHAR(p, '0') || strcasecmp(p, "false") == 0 || strcasecmp(p, "off") == 0) { |
| 43 | value = 0; |
| 44 | } else { |
| 45 | bb_show_usage(); |
| 46 | } |
| 47 | |
| 48 | if (security_set_boolean(argv[1], value) < 0) |
| 49 | bb_error_msg_and_die("can't set boolean"); |
| 50 | |
| 51 | return 0; |
| 52 | } |