blob: 670e3008630812ac88e33f36c3fe0609a5476d13 [file] [log] [blame]
Denis Vlasenkod46d3c22007-02-06 19:28:50 +00001/*
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 "busybox.h"
10
11static const smallint setenforce_mode[] = {
12 0,
13 1,
14 0,
15 1,
16};
17static const char *const setenforce_cmd[] = {
18 "0",
19 "1",
20 "permissive",
21 "enforcing",
22 NULL,
23};
24
25int setenforce_main(int argc, char **argv)
26{
27 int i, rc;
28
29 if (argc != 2)
30 bb_show_usage();
31
32 selinux_or_die();
33
34 for (i = 0; setenforce_cmd[i]; i++) {
35 if (strcasecmp(argv[1], setenforce_cmd[i]) != 0)
36 continue;
37 rc = security_setenforce(setenforce_mode[i]);
38 if (rc < 0)
39 bb_perror_msg_and_die("setenforce() failed");
40 return 0;
41 }
42
43 bb_show_usage();
44}