2007-02-07 00:58:50 +05:30
|
|
|
/*
|
|
|
|
* setenforce
|
|
|
|
*
|
|
|
|
* 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
|
|
|
*/
|
|
|
|
|
2007-05-27 00:30:18 +05:30
|
|
|
#include "libbb.h"
|
2007-02-07 00:58:50 +05:30
|
|
|
|
2007-02-08 03:38:42 +05:30
|
|
|
/* These strings are arranged so that odd ones
|
|
|
|
* result in security_setenforce(1) being done,
|
|
|
|
* the rest will do security_setenforce(0) */
|
2007-02-07 00:58:50 +05:30
|
|
|
static const char *const setenforce_cmd[] = {
|
|
|
|
"0",
|
|
|
|
"1",
|
|
|
|
"permissive",
|
|
|
|
"enforcing",
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2007-10-11 15:35:36 +05:30
|
|
|
int setenforce_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
2010-01-04 18:45:38 +05:30
|
|
|
int setenforce_main(int argc UNUSED_PARAM, char **argv)
|
2007-02-07 00:58:50 +05:30
|
|
|
{
|
|
|
|
int i, rc;
|
|
|
|
|
2010-01-04 18:45:38 +05:30
|
|
|
if (!argv[1] || argv[2])
|
2007-02-07 00:58:50 +05:30
|
|
|
bb_show_usage();
|
|
|
|
|
|
|
|
selinux_or_die();
|
|
|
|
|
|
|
|
for (i = 0; setenforce_cmd[i]; i++) {
|
|
|
|
if (strcasecmp(argv[1], setenforce_cmd[i]) != 0)
|
|
|
|
continue;
|
2007-02-08 03:38:42 +05:30
|
|
|
rc = security_setenforce(i & 1);
|
2007-02-07 00:58:50 +05:30
|
|
|
if (rc < 0)
|
|
|
|
bb_perror_msg_and_die("setenforce() failed");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bb_show_usage();
|
|
|
|
}
|