Last change
on this file since 1782 was 1765, checked in by Bruno Cornec, 17 years ago |
Update to busybox 1.7.2
|
-
Property svn:eol-style
set to
native
|
File size:
1.3 KB
|
Line | |
---|
1 | /*
|
---|
2 | * getsebool
|
---|
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 | int getsebool_main(int argc, char **argv);
|
---|
12 | int getsebool_main(int argc, char **argv)
|
---|
13 | {
|
---|
14 | int i, rc = 0, active, pending, len = 0;
|
---|
15 | char **names;
|
---|
16 | unsigned opt;
|
---|
17 |
|
---|
18 | selinux_or_die();
|
---|
19 | opt = getopt32(argv, "a");
|
---|
20 |
|
---|
21 | if (opt) { /* -a */
|
---|
22 | if (argc > 2)
|
---|
23 | bb_show_usage();
|
---|
24 |
|
---|
25 | rc = security_get_boolean_names(&names, &len);
|
---|
26 | if (rc)
|
---|
27 | bb_perror_msg_and_die("cannot get boolean names");
|
---|
28 |
|
---|
29 | if (!len) {
|
---|
30 | puts("No booleans");
|
---|
31 | return 0;
|
---|
32 | }
|
---|
33 | }
|
---|
34 |
|
---|
35 | if (!len) {
|
---|
36 | if (argc < 2)
|
---|
37 | bb_show_usage();
|
---|
38 | len = argc - 1;
|
---|
39 | names = xmalloc(sizeof(char *) * len);
|
---|
40 | for (i = 0; i < len; i++)
|
---|
41 | names[i] = xstrdup(argv[i + 1]);
|
---|
42 | }
|
---|
43 |
|
---|
44 | for (i = 0; i < len; i++) {
|
---|
45 | active = security_get_boolean_active(names[i]);
|
---|
46 | if (active < 0) {
|
---|
47 | bb_error_msg_and_die("error getting active value for %s", names[i]);
|
---|
48 | }
|
---|
49 | pending = security_get_boolean_pending(names[i]);
|
---|
50 | if (pending < 0) {
|
---|
51 | bb_error_msg_and_die("error getting pending value for %s", names[i]);
|
---|
52 | }
|
---|
53 | printf("%s --> %s", names[i], (active ? "on" : "off"));
|
---|
54 | if (pending != active)
|
---|
55 | printf(" pending: %s", (pending ? "on" : "off"));
|
---|
56 | putchar('\n');
|
---|
57 | }
|
---|
58 |
|
---|
59 | if (ENABLE_FEATURE_CLEAN_UP) {
|
---|
60 | for (i = 0; i < len; i++)
|
---|
61 | free(names[i]);
|
---|
62 | free(names);
|
---|
63 | }
|
---|
64 |
|
---|
65 | return rc;
|
---|
66 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.