Contents of /tags/mkinitrd-6_1_3/busybox/selinux/getsebool.c
Parent Directory | Revision Log
Revision 846 -
(show annotations)
(download)
Mon May 4 18:51:23 2009 UTC (15 years, 4 months ago) by niro
File MIME type: text/plain
File size: 1374 byte(s)
Mon May 4 18:51:23 2009 UTC (15 years, 4 months ago) by niro
File MIME type: text/plain
File size: 1374 byte(s)
tagged 'mkinitrd-6_1_3'
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) MAIN_EXTERNALLY_VISIBLE; |
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 | bb_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 | } |