diff options
author | Mark Salyzyn <salyzyn@google.com> | 2014-09-19 11:59:42 -0700 |
---|---|---|
committer | Mark Salyzyn <salyzyn@google.com> | 2014-10-08 14:01:45 -0700 |
commit | 327cac6e0c9f09a9fe163c85530d749876dd9db7 (patch) | |
tree | 378ae1367d5ebbcf21bc024dfe910a2eda970c19 | |
parent | 33b335495c7b8eea4b9af13a7157cf83cd085129 (diff) | |
download | core-327cac6e0c9f09a9fe163c85530d749876dd9db7.tar.gz core-327cac6e0c9f09a9fe163c85530d749876dd9db7.tar.bz2 core-327cac6e0c9f09a9fe163c85530d749876dd9db7.zip |
logd: auditd: kmsg priority
(cherry pick from commit 6bdeee0ce6898abd3873a758c47601efcdcc1b7c)
Change-Id: I2016fe140e2daf6c69efbd10aef205fffb931aa1
-rw-r--r-- | logd/LogAudit.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/logd/LogAudit.cpp b/logd/LogAudit.cpp index f8d61621c..998817882 100644 --- a/logd/LogAudit.cpp +++ b/logd/LogAudit.cpp @@ -31,6 +31,8 @@ LogAudit::LogAudit(LogBuffer *buf, LogReader *reader, int fdDmsg) , logbuf(buf) , reader(reader) , fdDmesg(-1) { + static const char auditd_message[] = "<6>logd.auditd: start\n"; + write(fdDmsg, auditd_message, sizeof(auditd_message)); logDmesg(); fdDmesg = fdDmsg; } @@ -75,13 +77,17 @@ int LogAudit::logPrint(const char *fmt, ...) { memmove(cp, cp + 1, strlen(cp + 1) + 1); } + bool info = strstr(str, " permissive=1") || strstr(str, " policy loaded "); if (fdDmesg >= 0) { - struct iovec iov[2]; + struct iovec iov[3]; - iov[0].iov_base = str; - iov[0].iov_len = strlen(str); - iov[1].iov_base = const_cast<char *>("\n"); - iov[1].iov_len = 1; + iov[0].iov_base = info ? const_cast<char *>("<6>") + : const_cast<char *>("<4>"); + iov[0].iov_len = 3; + iov[1].iov_base = str; + iov[1].iov_len = strlen(str); + iov[2].iov_base = const_cast<char *>("\n"); + iov[2].iov_len = 1; writev(fdDmesg, iov, sizeof(iov) / sizeof(iov[0])); } @@ -175,10 +181,7 @@ int LogAudit::logPrint(const char *fmt, ...) { if (!newstr) { rc = -ENOMEM; } else { - *newstr = (strstr(str, " permissive=1") - || strstr(str, " policy loaded ")) - ? ANDROID_LOG_INFO - : ANDROID_LOG_WARN; + *newstr = info ? ANDROID_LOG_INFO : ANDROID_LOG_WARN; strlcpy(newstr + 1, comm, l); strncpy(newstr + 1 + l, str, estr - str); strcpy(newstr + 1 + l + (estr - str), ecomm); |