Last change
on this file since 3630 was 3232, checked in by Bruno Cornec, 11 years ago |
- Update mindi-busybox to 1.21.1
|
-
Property svn:eol-style
set to
native
|
File size:
1016 bytes
|
Rev | Line | |
---|
[1765] | 1 | /*
|
---|
| 2 | * setenforce
|
---|
| 3 | *
|
---|
| 4 | * Based on libselinux 1.33.1
|
---|
| 5 | * Port to BusyBox Hiroshi Shinji <shiroshi@my.email.ne.jp>
|
---|
| 6 | *
|
---|
[2725] | 7 | * Licensed under GPLv2, see file LICENSE in this source tree.
|
---|
[1765] | 8 | */
|
---|
| 9 |
|
---|
[3232] | 10 | //usage:#define setenforce_trivial_usage
|
---|
| 11 | //usage: "[Enforcing | Permissive | 1 | 0]"
|
---|
| 12 | //usage:#define setenforce_full_usage ""
|
---|
| 13 |
|
---|
[1765] | 14 | #include "libbb.h"
|
---|
| 15 |
|
---|
| 16 | /* These strings are arranged so that odd ones
|
---|
| 17 | * result in security_setenforce(1) being done,
|
---|
| 18 | * the rest will do security_setenforce(0) */
|
---|
| 19 | static const char *const setenforce_cmd[] = {
|
---|
| 20 | "0",
|
---|
| 21 | "1",
|
---|
| 22 | "permissive",
|
---|
| 23 | "enforcing",
|
---|
| 24 | NULL,
|
---|
| 25 | };
|
---|
| 26 |
|
---|
[2725] | 27 | int setenforce_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
---|
| 28 | int setenforce_main(int argc UNUSED_PARAM, char **argv)
|
---|
[1765] | 29 | {
|
---|
| 30 | int i, rc;
|
---|
| 31 |
|
---|
[2725] | 32 | if (!argv[1] || argv[2])
|
---|
[1765] | 33 | bb_show_usage();
|
---|
| 34 |
|
---|
| 35 | selinux_or_die();
|
---|
| 36 |
|
---|
| 37 | for (i = 0; setenforce_cmd[i]; i++) {
|
---|
| 38 | if (strcasecmp(argv[1], setenforce_cmd[i]) != 0)
|
---|
| 39 | continue;
|
---|
| 40 | rc = security_setenforce(i & 1);
|
---|
| 41 | if (rc < 0)
|
---|
| 42 | bb_perror_msg_and_die("setenforce() failed");
|
---|
| 43 | return 0;
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | bb_show_usage();
|
---|
| 47 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.