1625
|
1 /* getenforce.c - Get the current SELinux mode
|
|
2 *
|
|
3 * Copyright 2014 The Android Open Source Project
|
|
4
|
|
5 USE_GETENFORCE(NEWTOY(getenforce, "", TOYFLAG_USR|TOYFLAG_SBIN))
|
|
6
|
|
7 config GETENFORCE
|
|
8 bool "getenforce"
|
|
9 default n
|
|
10 help
|
|
11 usage: getenforce
|
|
12
|
|
13 Shows whether SELinux is disabled, enforcing, or permissive.
|
|
14 */
|
|
15
|
|
16 #define FOR_getenforce
|
|
17 #include "toys.h"
|
|
18 #include <selinux/selinux.h>
|
|
19
|
|
20 void getenforce_main(void)
|
|
21 {
|
|
22 if (!is_selinux_enabled())
|
|
23 printf("Disabled\n");
|
|
24 else {
|
|
25 int ret = security_getenforce();
|
|
26 if (ret == -1)
|
|
27 perror_exit("Couldn't get enforcing status");
|
|
28 else
|
|
29 printf(ret ? "Enforcing\n" : "Permissive\n");
|
|
30 }
|
|
31 }
|