logd: auditd: add logd.auditd.dmesg property

Change-Id: If4a579c2221eec99cf3f6acf59ead8c2d5230517
diff --git a/logd/main.cpp b/logd/main.cpp
index 83ec6c0..7346e2f 100644
--- a/logd/main.cpp
+++ b/logd/main.cpp
@@ -84,6 +84,13 @@
 // space logger.  Additional transitory per-client threads are created
 // for each reader once they register.
 int main() {
+    int fdDmesg = -1;
+    char dmesg[PROPERTY_VALUE_MAX];
+    property_get("logd.auditd.dmesg", dmesg, "1");
+    if (atol(dmesg)) {
+        fdDmesg = open("/dev/kmsg", O_WRONLY);
+    }
+
     if (drop_privs() != 0) {
         return -1;
     }
@@ -136,9 +143,10 @@
     // and LogReader is notified to send updates to connected clients.
 
     // failure is an option ... messages are in dmesg (required by standard)
-    LogAudit *al = new LogAudit(logBuf, reader);
+    LogAudit *al = new LogAudit(logBuf, reader, fdDmesg);
     if (al->startListener()) {
         delete al;
+        close(fdDmesg);
     }
 
     pause();