OSDN Git Service

service_manager.c: remove is_selinux_enabled calls
authorNick Kralevich <nnk@google.com>
Sat, 10 Dec 2016 01:05:09 +0000 (17:05 -0800)
committerNick Kralevich <nnk@google.com>
Sat, 10 Dec 2016 01:05:33 +0000 (17:05 -0800)
SELinux is always enabled. No need to check for it.

Test: Device boots and service manager works without errors.
Change-Id: I12be7336e7c31a5f5796ea1383f3dc934eb3c97c

cmds/servicemanager/service_manager.c

index 68e3ceb..ea41558 100644 (file)
@@ -60,7 +60,6 @@ int str16eq(const uint16_t *a, const char *b)
     return 1;
 }
 
-static int selinux_enabled;
 static char *service_manager_context;
 static struct selabel_handle* sehandle;
 
@@ -89,10 +88,6 @@ static bool check_mac_perms(pid_t spid, uid_t uid, const char *tctx, const char
 
 static bool check_mac_perms_from_getcon(pid_t spid, uid_t uid, const char *perm)
 {
-    if (selinux_enabled <= 0) {
-        return true;
-    }
-
     return check_mac_perms(spid, uid, service_manager_context, perm, NULL);
 }
 
@@ -101,10 +96,6 @@ static bool check_mac_perms_from_lookup(pid_t spid, uid_t uid, const char *perm,
     bool allowed;
     char *tctx = NULL;
 
-    if (selinux_enabled <= 0) {
-        return true;
-    }
-
     if (!sehandle) {
         ALOGE("SELinux: Failed to find sehandle. Aborting service_manager.\n");
         abort();
@@ -384,20 +375,17 @@ int main()
         return -1;
     }
 
-    selinux_enabled = is_selinux_enabled();
     sehandle = selinux_android_service_context_handle();
     selinux_status_open(true);
 
-    if (selinux_enabled > 0) {
-        if (sehandle == NULL) {
-            ALOGE("SELinux: Failed to acquire sehandle. Aborting.\n");
-            abort();
-        }
+    if (sehandle == NULL) {
+        ALOGE("SELinux: Failed to acquire sehandle. Aborting.\n");
+        abort();
+    }
 
-        if (getcon(&service_manager_context) != 0) {
-            ALOGE("SELinux: Failed to acquire service_manager context. Aborting.\n");
-            abort();
-        }
+    if (getcon(&service_manager_context) != 0) {
+        ALOGE("SELinux: Failed to acquire service_manager context. Aborting.\n");
+        abort();
     }
 
     union selinux_callback cb;