From 93ba7019cb473158bdea1b8fc73a1db34ea9a129 Mon Sep 17 00:00:00 2001 From: Sandeep Patil Date: Tue, 27 Dec 2016 12:40:45 -0800 Subject: [PATCH] servicemanager: selinux: set selinux callbacks early SELinux library error logs are never be shown in logcat if there's a failure before the callbacks are set. We missed all logs from service context initialization because of this. Bug: 33746484 Test: Restart new service manager to make sure context init logs show up in logcat. Change-Id: I5479cf5fe10ceb1a210eda26946b6ea344792e24 Signed-off-by: Sandeep Patil --- cmds/servicemanager/service_manager.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cmds/servicemanager/service_manager.c b/cmds/servicemanager/service_manager.c index a31e3c73d0..43c4c8b3c4 100644 --- a/cmds/servicemanager/service_manager.c +++ b/cmds/servicemanager/service_manager.c @@ -363,6 +363,7 @@ static int audit_callback(void *data, __unused security_class_t cls, char *buf, int main() { struct binder_state *bs; + union selinux_callback cb; bs = binder_open(128*1024); if (!bs) { @@ -375,6 +376,11 @@ int main() return -1; } + cb.func_audit = audit_callback; + selinux_set_callback(SELINUX_CB_AUDIT, cb); + cb.func_log = selinux_log_callback; + selinux_set_callback(SELINUX_CB_LOG, cb); + sehandle = selinux_android_service_context_handle(); selinux_status_open(true); @@ -388,11 +394,6 @@ int main() abort(); } - union selinux_callback cb; - cb.func_audit = audit_callback; - selinux_set_callback(SELINUX_CB_AUDIT, cb); - cb.func_log = selinux_log_callback; - selinux_set_callback(SELINUX_CB_LOG, cb); binder_loop(bs, svcmgr_handler); -- 2.11.0