From 0becca32bca16cb98477c91a46ab4c4ca22d426c Mon Sep 17 00:00:00 2001 From: Luis Hector Chavez Date: Fri, 8 Jun 2018 15:02:40 -0700 Subject: [PATCH] bootstat: Remove the CAP_SYSLOG capability This change removes the CAP_SYSLOG file based capability from bootstat, since the intention is that it should not be accessing the logs in the long term. In order to avoid bitrot, the fallback code that depends on CAP_SYSLOG has also been removed. Bug: 62845925 Test: system/core/bootstat/boot_reason_test.sh Change-Id: I899be44ef3ac1c4d81072f801d55c928ae09bb15 --- bootstat/bootstat.cpp | 21 ++------------------- libcutils/fs_config.cpp | 2 -- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/bootstat/bootstat.cpp b/bootstat/bootstat.cpp index d5fb0472f..11e14dd6a 100644 --- a/bootstat/bootstat.cpp +++ b/bootstat/bootstat.cpp @@ -925,27 +925,10 @@ std::string BootReasonStrToReason(const std::string& boot_reason) { } android_logcat_pclose(&ctx, fp); static const char logcat_battery[] = "W/healthd ( 0): battery l="; - const char* match = logcat_battery; - if (content == "") { - // Service logd.klog not running, go to smaller buffer in the kernel. - int rc = klogctl(KLOG_SIZE_BUFFER, nullptr, 0); - if (rc > 0) { - ssize_t len = rc + 1024; // 1K Margin should it grow between calls. - std::unique_ptr buf(new char[len]); - rc = klogctl(KLOG_READ_ALL, buf.get(), len); - if (rc < len) { - len = rc + 1; - } - buf[--len] = '\0'; - content = buf.get(); - } - match = battery; - } - - pos = content.find(match); // The first one it finds. + pos = content.find(logcat_battery); // The first one it finds. if (pos != std::string::npos) { - digits = content.substr(pos + strlen(match), strlen("100 ")); + digits = content.substr(pos + strlen(logcat_battery), strlen("100 ")); } endptr = digits.c_str(); level = 0; diff --git a/libcutils/fs_config.cpp b/libcutils/fs_config.cpp index 341dfe314..267b7b356 100644 --- a/libcutils/fs_config.cpp +++ b/libcutils/fs_config.cpp @@ -180,8 +180,6 @@ static const struct fs_path_config android_files[] = { // in user builds. { 00700, AID_SYSTEM, AID_SHELL, CAP_MASK_LONG(CAP_BLOCK_SUSPEND), "system/bin/inputflinger" }, - { 00550, AID_SYSTEM, AID_LOG, CAP_MASK_LONG(CAP_SYSLOG), - "system/bin/bootstat" }, { 00750, AID_ROOT, AID_SHELL, CAP_MASK_LONG(CAP_SETUID) | CAP_MASK_LONG(CAP_SETGID), "system/bin/run-as" },