From 7ee2aef8e0fd8aaa601c8c17e5429fa65b22e00d Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Sun, 28 Sep 2014 14:41:50 -0700 Subject: [PATCH] logd: auditd: report facility LOG_AUTH Change-Id: Ie325e1b58f52b6c728d5cfd6f6b87287fcf32e10 --- logd/LogAudit.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/logd/LogAudit.cpp b/logd/LogAudit.cpp index 998817882..51feff396 100644 --- a/logd/LogAudit.cpp +++ b/logd/LogAudit.cpp @@ -22,16 +22,25 @@ #include #include #include +#include #include "libaudit.h" #include "LogAudit.h" +#define KMSG_PRIORITY(PRI) \ + '<', \ + '0' + (LOG_AUTH | (PRI)) / 10, \ + '0' + (LOG_AUTH | (PRI)) % 10, \ + '>' + LogAudit::LogAudit(LogBuffer *buf, LogReader *reader, int fdDmsg) : SocketListener(getLogSocket(), false) , logbuf(buf) , reader(reader) , fdDmesg(-1) { - static const char auditd_message[] = "<6>logd.auditd: start\n"; + static const char auditd_message[] = { KMSG_PRIORITY(LOG_INFO), + 'l', 'o', 'g', 'd', '.', 'a', 'u', 'd', 'i', 't', 'd', ':', + ' ', 's', 't', 'a', 'r', 't', '\n' }; write(fdDmsg, auditd_message, sizeof(auditd_message)); logDmesg(); fdDmesg = fdDmsg; @@ -80,10 +89,12 @@ int LogAudit::logPrint(const char *fmt, ...) { bool info = strstr(str, " permissive=1") || strstr(str, " policy loaded "); if (fdDmesg >= 0) { struct iovec iov[3]; + static const char log_info[] = { KMSG_PRIORITY(LOG_INFO) }; + static const char log_warning[] = { KMSG_PRIORITY(LOG_WARNING) }; - iov[0].iov_base = info ? const_cast("<6>") - : const_cast("<4>"); - iov[0].iov_len = 3; + iov[0].iov_base = info ? const_cast(log_info) + : const_cast(log_warning); + iov[0].iov_len = info ? sizeof(log_info) : sizeof(log_warning); iov[1].iov_base = str; iov[1].iov_len = strlen(str); iov[2].iov_base = const_cast("\n");