Mercurial > hg > toybox
comparison toys/pending/getenforce.c @ 1761:563ec6dfc751 draft
Cleanup getenforce.
author | Rob Landley <rob@landley.net> |
---|---|
date | Fri, 27 Mar 2015 21:52:24 -0500 |
parents | 1cc305c51cde |
children |
comparison
equal
deleted
inserted
replaced
1760:c21fe4bc2249 | 1761:563ec6dfc751 |
---|---|
5 USE_GETENFORCE(NEWTOY(getenforce, "", TOYFLAG_USR|TOYFLAG_SBIN)) | 5 USE_GETENFORCE(NEWTOY(getenforce, "", TOYFLAG_USR|TOYFLAG_SBIN)) |
6 | 6 |
7 config GETENFORCE | 7 config GETENFORCE |
8 bool "getenforce" | 8 bool "getenforce" |
9 default n | 9 default n |
10 depends on TOYBOX_SELINUX | |
10 help | 11 help |
11 usage: getenforce | 12 usage: getenforce |
12 | 13 |
13 Shows whether SELinux is disabled, enforcing, or permissive. | 14 Shows whether SELinux is disabled, enforcing, or permissive. |
14 */ | 15 */ |
15 | 16 |
16 #define FOR_getenforce | 17 #define FOR_getenforce |
17 #include "toys.h" | 18 #include "toys.h" |
18 #include <selinux/selinux.h> | |
19 | 19 |
20 void getenforce_main(void) | 20 void getenforce_main(void) |
21 { | 21 { |
22 if (!is_selinux_enabled()) | 22 if (!is_selinux_enabled()) puts("Disabled"); |
23 printf("Disabled\n"); | |
24 else { | 23 else { |
25 int ret = security_getenforce(); | 24 int ret = security_getenforce(); |
26 if (ret == -1) | 25 |
27 perror_exit("Couldn't get enforcing status"); | 26 if (ret == -1) perror_exit("Couldn't get enforcing status"); |
28 else | 27 else puts(ret ? "Enforcing" : "Permissive"); |
29 printf(ret ? "Enforcing\n" : "Permissive\n"); | |
30 } | 28 } |
31 } | 29 } |