Loading logd/LogAudit.cpp +15 −4 Original line number Original line Diff line number Diff line Loading @@ -22,16 +22,25 @@ #include <sys/klog.h> #include <sys/klog.h> #include <sys/prctl.h> #include <sys/prctl.h> #include <sys/uio.h> #include <sys/uio.h> #include <syslog.h> #include "libaudit.h" #include "libaudit.h" #include "LogAudit.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) LogAudit::LogAudit(LogBuffer *buf, LogReader *reader, int fdDmsg) : SocketListener(getLogSocket(), false) : SocketListener(getLogSocket(), false) , logbuf(buf) , logbuf(buf) , reader(reader) , reader(reader) , fdDmesg(-1) { , 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)); write(fdDmsg, auditd_message, sizeof(auditd_message)); logDmesg(); logDmesg(); fdDmesg = fdDmsg; fdDmesg = fdDmsg; Loading Loading @@ -80,10 +89,12 @@ int LogAudit::logPrint(const char *fmt, ...) { bool info = strstr(str, " permissive=1") || strstr(str, " policy loaded "); bool info = strstr(str, " permissive=1") || strstr(str, " policy loaded "); if (fdDmesg >= 0) { if (fdDmesg >= 0) { struct iovec iov[3]; 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<char *>("<6>") iov[0].iov_base = info ? const_cast<char *>(log_info) : const_cast<char *>("<4>"); : const_cast<char *>(log_warning); iov[0].iov_len = 3; iov[0].iov_len = info ? sizeof(log_info) : sizeof(log_warning); iov[1].iov_base = str; iov[1].iov_base = str; iov[1].iov_len = strlen(str); iov[1].iov_len = strlen(str); iov[2].iov_base = const_cast<char *>("\n"); iov[2].iov_base = const_cast<char *>("\n"); Loading Loading
logd/LogAudit.cpp +15 −4 Original line number Original line Diff line number Diff line Loading @@ -22,16 +22,25 @@ #include <sys/klog.h> #include <sys/klog.h> #include <sys/prctl.h> #include <sys/prctl.h> #include <sys/uio.h> #include <sys/uio.h> #include <syslog.h> #include "libaudit.h" #include "libaudit.h" #include "LogAudit.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) LogAudit::LogAudit(LogBuffer *buf, LogReader *reader, int fdDmsg) : SocketListener(getLogSocket(), false) : SocketListener(getLogSocket(), false) , logbuf(buf) , logbuf(buf) , reader(reader) , reader(reader) , fdDmesg(-1) { , 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)); write(fdDmsg, auditd_message, sizeof(auditd_message)); logDmesg(); logDmesg(); fdDmesg = fdDmsg; fdDmesg = fdDmsg; Loading Loading @@ -80,10 +89,12 @@ int LogAudit::logPrint(const char *fmt, ...) { bool info = strstr(str, " permissive=1") || strstr(str, " policy loaded "); bool info = strstr(str, " permissive=1") || strstr(str, " policy loaded "); if (fdDmesg >= 0) { if (fdDmesg >= 0) { struct iovec iov[3]; 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<char *>("<6>") iov[0].iov_base = info ? const_cast<char *>(log_info) : const_cast<char *>("<4>"); : const_cast<char *>(log_warning); iov[0].iov_len = 3; iov[0].iov_len = info ? sizeof(log_info) : sizeof(log_warning); iov[1].iov_base = str; iov[1].iov_base = str; iov[1].iov_len = strlen(str); iov[1].iov_len = strlen(str); iov[2].iov_base = const_cast<char *>("\n"); iov[2].iov_base = const_cast<char *>("\n"); Loading