diff options
author | Stephen Smalley <sds@tycho.nsa.gov> | 2015-04-20 15:55:34 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-04-20 15:55:34 +0000 |
commit | cad7ad66bf4bae72c42b507e7d06907fd07dd7fe (patch) | |
tree | a04048942a2e201ed8406e87f3fe08a41224f104 | |
parent | 3d0ee672186f9ce224808758b2651c55d8bba616 (diff) | |
parent | 801cd60478e994c505ff740271b5506e2036278c (diff) | |
download | android_external_libselinux-cad7ad66bf4bae72c42b507e7d06907fd07dd7fe.tar.gz android_external_libselinux-cad7ad66bf4bae72c42b507e7d06907fd07dd7fe.tar.bz2 android_external_libselinux-cad7ad66bf4bae72c42b507e7d06907fd07dd7fe.zip |
am 801cd604: libselinux: is_selinux_enabled(): drop no-policy-loaded test.
* commit '801cd60478e994c505ff740271b5506e2036278c':
libselinux: is_selinux_enabled(): drop no-policy-loaded test.
-rw-r--r-- | src/enabled.c | 48 |
1 files changed, 1 insertions, 47 deletions
diff --git a/src/enabled.c b/src/enabled.c index ab015a4..c60eb19 100644 --- a/src/enabled.c +++ b/src/enabled.c @@ -10,56 +10,10 @@ int is_selinux_enabled(void) { - char buf[BUFSIZ]; - FILE *fp; - char *bufp; - int enabled = 0; - char * con; - /* init_selinuxmnt() gets called before this function. We * will assume that if a selinux file system is mounted, then * selinux is enabled. */ - if (selinux_mnt) { - - /* Since a file system is mounted, we consider selinux - * enabled. If getcon fails, selinux is still enabled. - * We only consider it disabled if no policy is loaded. */ - enabled = 1; - if (getcon(&con) == 0) { - if (!strcmp(con, "kernel")) - enabled = 0; - freecon(con); - } - return enabled; - } - - /* Drop back to detecting it the long way. */ - fp = fopen("/proc/filesystems", "r"); - if (!fp) - return -1; - - while ((bufp = fgets(buf, sizeof buf - 1, fp)) != NULL) { - if (strstr(buf, "selinuxfs")) { - enabled = 1; - break; - } - } - - if (!bufp) - goto out; - - /* Since an selinux file system is available, we consider - * selinux enabled. If getcon fails, selinux is still - * enabled. We only consider it disabled if no policy is loaded. */ - if (getcon(&con) == 0) { - if (!strcmp(con, "kernel")) - enabled = 0; - freecon(con); - } - - out: - fclose(fp); - return enabled; + return (selinux_mnt ? 1 : 0); } hidden_def(is_selinux_enabled) |