summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2014-03-26 15:44:14 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-03-26 15:44:15 +0000
commitb1a8c016371282a3cd3b113e6b2c0310372babf2 (patch)
treeeb88462af949cfa720c919426d2daa38aabe2bc9
parent01502981cddb69b9ab7e4bf8bc66366ae0eb7035 (diff)
parent7abb52bcafa2f7b422dfe22c5ea275c2fa9e6201 (diff)
downloadnative-b1a8c016371282a3cd3b113e6b2c0310372babf2.tar.gz
Merge "Send libselinux logging to logcat."
-rw-r--r--cmds/installd/installd.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/cmds/installd/installd.c b/cmds/installd/installd.c
index 40fc13f0eb..a080ee6185 100644
--- a/cmds/installd/installd.c
+++ b/cmds/installd/installd.c
@@ -541,6 +541,27 @@ static void drop_privileges() {
}
}
+static int log_callback(int type, const char *fmt, ...) {
+ va_list ap;
+ int priority;
+
+ switch (type) {
+ case SELINUX_WARNING:
+ priority = ANDROID_LOG_WARN;
+ break;
+ case SELINUX_INFO:
+ priority = ANDROID_LOG_INFO;
+ break;
+ default:
+ priority = ANDROID_LOG_ERROR;
+ break;
+ }
+ va_start(ap, fmt);
+ LOG_PRI_VA(priority, "SELinux", fmt, ap);
+ va_end(ap);
+ return 0;
+}
+
int main(const int argc, const char *argv[]) {
char buf[BUFFER_MAX];
struct sockaddr addr;
@@ -550,6 +571,10 @@ int main(const int argc, const char *argv[]) {
ALOGI("installd firing up\n");
+ union selinux_callback cb;
+ cb.func_log = log_callback;
+ selinux_set_callback(SELINUX_CB_LOG, cb);
+
if (initialize_globals() < 0) {
ALOGE("Could not initialize globals; exiting.\n");
exit(1);