Tomato 1.28
[tomato.git] / release / src / router / busybox / selinux / setenforce.c
bloba2d04288bd2dd0be7f6473f3efd65b00e698c759
1 /*
2 * setenforce
4 * Based on libselinux 1.33.1
5 * Port to BusyBox Hiroshi Shinji <shiroshi@my.email.ne.jp>
7 * Licensed under GPLv2, see file LICENSE in this tarball for details.
8 */
10 #include "libbb.h"
12 /* These strings are arranged so that odd ones
13 * result in security_setenforce(1) being done,
14 * the rest will do security_setenforce(0) */
15 static const char *const setenforce_cmd[] = {
16 "0",
17 "1",
18 "permissive",
19 "enforcing",
20 NULL,
23 int setenforce_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
24 int setenforce_main(int argc, char **argv)
26 int i, rc;
28 if (argc != 2)
29 bb_show_usage();
31 selinux_or_die();
33 for (i = 0; setenforce_cmd[i]; i++) {
34 if (strcasecmp(argv[1], setenforce_cmd[i]) != 0)
35 continue;
36 rc = security_setenforce(i & 1);
37 if (rc < 0)
38 bb_perror_msg_and_die("setenforce() failed");
39 return 0;
42 bb_show_usage();