diff options
author | Mark Salyzyn <salyzyn@google.com> | 2015-12-04 10:59:45 -0800 |
---|---|---|
committer | Mark Salyzyn <salyzyn@google.com> | 2015-12-08 16:46:29 -0800 |
commit | 083b037c0740ca00f72429e4457bfdd4b4d4dfa7 (patch) | |
tree | 6748f9f8bcaebd495df77604dfeba68e0b65b5be /logcat | |
parent | cb3e6ef15459388fc8fee2b4a3157ff0eac0714a (diff) | |
download | system_core-083b037c0740ca00f72429e4457bfdd4b4d4dfa7.tar.gz system_core-083b037c0740ca00f72429e4457bfdd4b4d4dfa7.tar.bz2 system_core-083b037c0740ca00f72429e4457bfdd4b4d4dfa7.zip |
logd: liblog: logcat: Add LOG_ID_SECURITY
- Largish commit, buffer and access controls done together
- Add LOG_ID_SECURITY binary content log
- Add "default" meta buffer
- allow LOG_ID_SECURITY only from AID_SYSTEM and AID_ROOT UID & GID
- Use __android_log_security() to gate logging
- Add __android_log_security_bwrite() native access to security
logging.
- Add liblog.__security_buffer end-to-end gTest
Bug: 26029733
Change-Id: Ibcf5b4660c17c1aa6902c0d93f8ffd29c93d9a93
Diffstat (limited to 'logcat')
-rw-r--r-- | logcat/logcat.cpp | 96 |
1 files changed, 80 insertions, 16 deletions
diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp index 059916e78..8ceeba5fc 100644 --- a/logcat/logcat.cpp +++ b/logcat/logcat.cpp @@ -283,10 +283,12 @@ static void show_help(const char *cmd) " --buffer_size=<size>\n" " -L dump logs from prior to last reboot\n" " --last\n" + // Leave security (Device Owner only installations) and + // kernel (userdebug and eng) buffers undocumented. " -b <buffer> Request alternate ring buffer, 'main', 'system', 'radio',\n" - " --buffer=<buffer> 'events', 'crash' or 'all'. Multiple -b parameters are\n" - " allowed and results are interleaved. The default is\n" - " -b main -b system -b crash.\n" + " --buffer=<buffer> 'events', 'crash', 'default' or 'all'. Multiple -b\n" + " parameters are allowed and results are interleaved. The\n" + " default is -b main -b system -b crash.\n" " -B output the log in binary.\n" " --binary\n" " -S output statistics.\n" @@ -696,16 +698,56 @@ int main(int argc, char **argv) break; case 'b': { - if (strcmp(optarg, "all") == 0) { - while (devices) { - dev = devices; - devices = dev->next; - delete dev; + if (strcmp(optarg, "default") == 0) { + for (int i = LOG_ID_MIN; i < LOG_ID_MAX; ++i) { + switch (i) { + case LOG_ID_SECURITY: + case LOG_ID_EVENTS: + continue; + case LOG_ID_MAIN: + case LOG_ID_SYSTEM: + case LOG_ID_CRASH: + break; + default: + continue; + } + + const char *name = android_log_id_to_name((log_id_t)i); + log_id_t log_id = android_name_to_log_id(name); + + if (log_id != (log_id_t)i) { + continue; + } + + bool found = false; + for (dev = devices; dev; dev = dev->next) { + if (!strcmp(optarg, dev->device)) { + found = true; + break; + } + if (!dev->next) { + break; + } + } + if (found) { + break; + } + + log_device_t* d = new log_device_t(name, false); + + if (dev) { + dev->next = d; + dev = d; + } else { + devices = dev = d; + } + g_devCount++; } + break; + } - devices = dev = NULL; - g_devCount = 0; - for(int i = LOG_ID_MIN; i < LOG_ID_MAX; ++i) { + if (strcmp(optarg, "all") == 0) { + for (int i = LOG_ID_MIN; i < LOG_ID_MAX; ++i) { const char *name = android_log_id_to_name((log_id_t)i); log_id_t log_id = android_name_to_log_id(name); @@ -713,7 +755,22 @@ int main(int argc, char **argv) continue; } - bool binary = strcmp(name, "events") == 0; + bool found = false; + for (dev = devices; dev; dev = dev->next) { + if (!strcmp(optarg, dev->device)) { + found = true; + break; + } + if (!dev->next) { + break; + } + } + if (found) { + break; + } + + bool binary = !strcmp(name, "events") || + !strcmp(name, "security"); log_device_t* d = new log_device_t(name, binary); if (dev) { @@ -727,14 +784,21 @@ int main(int argc, char **argv) break; } - bool binary = strcmp(optarg, "events") == 0; + bool binary = !(strcmp(optarg, "events") && + strcmp(optarg, "security")); if (devices) { dev = devices; while (dev->next) { + if (!strcmp(optarg, dev->device)) { + dev = NULL; + break; + } dev = dev->next; } - dev->next = new log_device_t(optarg, binary); + if (dev) { + dev->next = new log_device_t(optarg, binary); + } } else { devices = new log_device_t(optarg, binary); } @@ -1004,7 +1068,7 @@ int main(int argc, char **argv) size_t len = 8192; char *buf; - for(int retry = 32; + for (int retry = 32; (retry >= 0) && ((buf = new char [len])); delete [] buf, buf = NULL, --retry) { if (getPruneList) { @@ -1094,7 +1158,7 @@ int main(int argc, char **argv) logcat_panic(false, "logcat read failure"); } - for(d = devices; d; d = d->next) { + for (d = devices; d; d = d->next) { if (android_name_to_log_id(d->device) == log_msg.id()) { break; } |