summaryrefslogtreecommitdiffstats
path: root/logd/main.cpp
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2014-04-28 16:39:04 -0700
committerMark Salyzyn <salyzyn@google.com>2014-04-29 07:25:27 -0700
commite0fa291e898b451dc198ed52cebac3ffefac066e (patch)
tree602b61b224b6630c12129def669ebc4aa6cfab3b /logd/main.cpp
parent4095853133745ddaa1e37b46f9e7d4e8a2cdee28 (diff)
downloadsystem_core-e0fa291e898b451dc198ed52cebac3ffefac066e.zip
system_core-e0fa291e898b451dc198ed52cebac3ffefac066e.tar.gz
system_core-e0fa291e898b451dc198ed52cebac3ffefac066e.tar.bz2
logd: add logd.auditd property
- permit us a mechanism to disable auditd - standardize property boolean Bug: 14275676 Change-Id: I76f245c6aee511ed44274159e0ea55915b484dda
Diffstat (limited to 'logd/main.cpp')
-rw-r--r--logd/main.cpp37
1 files changed, 26 insertions, 11 deletions
diff --git a/logd/main.cpp b/logd/main.cpp
index 04eef4a..ece5a3a 100644
--- a/logd/main.cpp
+++ b/logd/main.cpp
@@ -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);
}
@@ -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();
}
@@ -171,11 +184,13 @@ int main() {
// initiated log messages. New log entries are added to LogBuffer
// 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, fdDmesg);
- if (al->startListener()) {
- delete al;
- close(fdDmesg);
+ 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();