Magellan Linux

Contents of /tags/mkinitrd-6_1_11/busybox/selinux/setenforce.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 928 - (show annotations) (download)
Wed Oct 28 13:31:19 2009 UTC (14 years, 7 months ago) by niro
File MIME type: text/plain
File size: 797 byte(s)
tagged 'mkinitrd-6_1_11'
1 /*
2 * setenforce
3 *
4 * Based on libselinux 1.33.1
5 * Port to BusyBox Hiroshi Shinji <shiroshi@my.email.ne.jp>
6 *
7 */
8
9 #include "libbb.h"
10
11 /* These strings are arranged so that odd ones
12 * result in security_setenforce(1) being done,
13 * the rest will do security_setenforce(0) */
14 static const char *const setenforce_cmd[] = {
15 "0",
16 "1",
17 "permissive",
18 "enforcing",
19 NULL,
20 };
21
22 int setenforce_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
23 int setenforce_main(int argc, char **argv)
24 {
25 int i, rc;
26
27 if (argc != 2)
28 bb_show_usage();
29
30 selinux_or_die();
31
32 for (i = 0; setenforce_cmd[i]; i++) {
33 if (strcasecmp(argv[1], setenforce_cmd[i]) != 0)
34 continue;
35 rc = security_setenforce(i & 1);
36 if (rc < 0)
37 bb_perror_msg_and_die("setenforce() failed");
38 return 0;
39 }
40
41 bb_show_usage();
42 }