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>
|
|
|
|
*
|
2008-12-07 06:22:58 +05:30
|
|
|
* Licensed under GPLv2, see file LICENSE in this tarball for details.
|
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;
|
2007-02-07 00:58:50 +05:30
|
|
|
int setenforce_main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
int i, rc;
|
|
|
|
|
|
|
|
if (argc != 2)
|
|
|
|
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();
|
|
|
|
}
|