Loading logd/LogAudit.cpp +7 −5 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ #include <ctype.h> #include <errno.h> #include <limits.h> #include <stdarg.h> #include <stdlib.h> #include <sys/klog.h> Loading @@ -39,6 +40,10 @@ bool LogAudit::onDataAvailable(SocketClient *cli) { struct audit_message rep; rep.nlh.nlmsg_type = 0; rep.nlh.nlmsg_len = 0; rep.data[0] = '\0'; if (audit_get_reply(cli->getSocket(), &rep, GET_REPLY_BLOCKING, 0) < 0) { SLOGE("Failed on audit_get_reply with error: %s", strerror(errno)); return false; Loading Loading @@ -146,11 +151,8 @@ int LogAudit::logPrint(const char *fmt, ...) { strcpy(newstr + 1 + l, str); free(str); unsigned short len = n; // cap to internal maximum if (len != n) { len = -1; } logbuf->log(AUDIT_LOG_ID, now, uid, pid, tid, newstr, len); logbuf->log(AUDIT_LOG_ID, now, uid, pid, tid, newstr, (n <= USHRT_MAX) ? (unsigned short) n : USHRT_MAX); reader->notifyNewLog(); free(newstr); Loading logd/LogListener.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ * limitations under the License. */ #include <limits.h> #include <sys/prctl.h> #include <sys/socket.h> #include <sys/types.h> Loading Loading @@ -100,11 +101,10 @@ bool LogListener::onDataAvailable(SocketClient *cli) { // NB: hdr.msg_flags & MSG_TRUNC is not tested, silently passing a // truncated message to the logs. unsigned short len = n; // cap to internal maximum if (len == n) { logbuf->log(log_id, realtime, cred->uid, cred->pid, tid, msg, len); logbuf->log(log_id, realtime, cred->uid, cred->pid, tid, msg, (n <= USHRT_MAX) ? (unsigned short) n : USHRT_MAX); reader->notifyNewLog(); } return true; } Loading logd/README.property +3 −2 Original line number Diff line number Diff line The properties that logd responds to are: name type default description logd.auditd bool true Enable selinux audit daemon logd.auditd.dmesg bool true selinux audit messages duplicated and sent on to dmesg log logd.dgram_qlen.statistics bool false Record dgram_qlen statistics. This logd.statistics.dgram_qlen bool false Record dgram_qlen statistics. This represents a performance impact and is used to determine the platform's minimum domain socket network FIFO size (see source for details) based on typical load (logcat -S) on typical load (logcat -S to view) logd/main.cpp +26 −11 Original line number Diff line number Diff line Loading @@ -107,16 +107,31 @@ static int drop_privs() { return 0; } // Property helper static bool property_get_bool(const char *key, bool def) { char property[PROPERTY_VALUE_MAX]; property_get(key, property, ""); if (!strcasecmp(property, "true")) { return true; } if (!strcasecmp(property, "false")) { return false; } return def; } // Foreground waits for exit of the three main persistent threads that // are started here. The three threads are created to manage UNIX // domain client sockets for writing, reading and controlling the user // space logger. Additional transitory per-client threads are created // for each reader once they register. int main() { bool auditd = property_get_bool("logd.auditd", true); int fdDmesg = -1; char dmesg[PROPERTY_VALUE_MAX]; property_get("logd.auditd.dmesg", dmesg, "1"); if (atol(dmesg)) { if (auditd && property_get_bool("logd.auditd.dmesg", true)) { fdDmesg = open("/dev/kmsg", O_WRONLY); } Loading @@ -135,9 +150,7 @@ int main() { LogBuffer *logBuf = new LogBuffer(times); char dgram_qlen_statistics[PROPERTY_VALUE_MAX]; property_get("logd.dgram_qlen.statistics", dgram_qlen_statistics, ""); if (atol(dgram_qlen_statistics)) { if (property_get_bool("logd.statistics.dgram_qlen", false)) { logBuf->enableDgramQlenStatistics(); } Loading Loading @@ -171,12 +184,14 @@ int main() { // initiated log messages. New log entries are added to LogBuffer // and LogReader is notified to send updates to connected clients. if (auditd) { // failure is an option ... messages are in dmesg (required by standard) LogAudit *al = new LogAudit(logBuf, reader, fdDmesg); if (al->startListener()) { delete al; close(fdDmesg); } } pause(); exit(0); Loading Loading
logd/LogAudit.cpp +7 −5 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ #include <ctype.h> #include <errno.h> #include <limits.h> #include <stdarg.h> #include <stdlib.h> #include <sys/klog.h> Loading @@ -39,6 +40,10 @@ bool LogAudit::onDataAvailable(SocketClient *cli) { struct audit_message rep; rep.nlh.nlmsg_type = 0; rep.nlh.nlmsg_len = 0; rep.data[0] = '\0'; if (audit_get_reply(cli->getSocket(), &rep, GET_REPLY_BLOCKING, 0) < 0) { SLOGE("Failed on audit_get_reply with error: %s", strerror(errno)); return false; Loading Loading @@ -146,11 +151,8 @@ int LogAudit::logPrint(const char *fmt, ...) { strcpy(newstr + 1 + l, str); free(str); unsigned short len = n; // cap to internal maximum if (len != n) { len = -1; } logbuf->log(AUDIT_LOG_ID, now, uid, pid, tid, newstr, len); logbuf->log(AUDIT_LOG_ID, now, uid, pid, tid, newstr, (n <= USHRT_MAX) ? (unsigned short) n : USHRT_MAX); reader->notifyNewLog(); free(newstr); Loading
logd/LogListener.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ * limitations under the License. */ #include <limits.h> #include <sys/prctl.h> #include <sys/socket.h> #include <sys/types.h> Loading Loading @@ -100,11 +101,10 @@ bool LogListener::onDataAvailable(SocketClient *cli) { // NB: hdr.msg_flags & MSG_TRUNC is not tested, silently passing a // truncated message to the logs. unsigned short len = n; // cap to internal maximum if (len == n) { logbuf->log(log_id, realtime, cred->uid, cred->pid, tid, msg, len); logbuf->log(log_id, realtime, cred->uid, cred->pid, tid, msg, (n <= USHRT_MAX) ? (unsigned short) n : USHRT_MAX); reader->notifyNewLog(); } return true; } Loading
logd/README.property +3 −2 Original line number Diff line number Diff line The properties that logd responds to are: name type default description logd.auditd bool true Enable selinux audit daemon logd.auditd.dmesg bool true selinux audit messages duplicated and sent on to dmesg log logd.dgram_qlen.statistics bool false Record dgram_qlen statistics. This logd.statistics.dgram_qlen bool false Record dgram_qlen statistics. This represents a performance impact and is used to determine the platform's minimum domain socket network FIFO size (see source for details) based on typical load (logcat -S) on typical load (logcat -S to view)
logd/main.cpp +26 −11 Original line number Diff line number Diff line Loading @@ -107,16 +107,31 @@ static int drop_privs() { return 0; } // Property helper static bool property_get_bool(const char *key, bool def) { char property[PROPERTY_VALUE_MAX]; property_get(key, property, ""); if (!strcasecmp(property, "true")) { return true; } if (!strcasecmp(property, "false")) { return false; } return def; } // Foreground waits for exit of the three main persistent threads that // are started here. The three threads are created to manage UNIX // domain client sockets for writing, reading and controlling the user // space logger. Additional transitory per-client threads are created // for each reader once they register. int main() { bool auditd = property_get_bool("logd.auditd", true); int fdDmesg = -1; char dmesg[PROPERTY_VALUE_MAX]; property_get("logd.auditd.dmesg", dmesg, "1"); if (atol(dmesg)) { if (auditd && property_get_bool("logd.auditd.dmesg", true)) { fdDmesg = open("/dev/kmsg", O_WRONLY); } Loading @@ -135,9 +150,7 @@ int main() { LogBuffer *logBuf = new LogBuffer(times); char dgram_qlen_statistics[PROPERTY_VALUE_MAX]; property_get("logd.dgram_qlen.statistics", dgram_qlen_statistics, ""); if (atol(dgram_qlen_statistics)) { if (property_get_bool("logd.statistics.dgram_qlen", false)) { logBuf->enableDgramQlenStatistics(); } Loading Loading @@ -171,12 +184,14 @@ int main() { // initiated log messages. New log entries are added to LogBuffer // and LogReader is notified to send updates to connected clients. if (auditd) { // failure is an option ... messages are in dmesg (required by standard) LogAudit *al = new LogAudit(logBuf, reader, fdDmesg); if (al->startListener()) { delete al; close(fdDmesg); } } pause(); exit(0); Loading