summaryrefslogtreecommitdiffstats
path: root/cmds/dumpstate/dumpstate.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmds/dumpstate/dumpstate.c')
-rw-r--r--cmds/dumpstate/dumpstate.c42
1 files changed, 39 insertions, 3 deletions
diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c
index afa4f4d..16dc517 100644
--- a/cmds/dumpstate/dumpstate.c
+++ b/cmds/dumpstate/dumpstate.c
@@ -25,6 +25,8 @@
#include <sys/time.h>
#include <sys/wait.h>
#include <unistd.h>
+#include <linux/capability.h>
+#include <linux/prctl.h>
#include <cutils/properties.h>
@@ -63,6 +65,7 @@ static void dumpstate() {
printf("\n");
printf("Build: %s\n", build);
+ printf("Build fingerprint: '%s'\n", fingerprint); /* format is important for other tools */
printf("Bootloader: %s\n", bootloader);
printf("Radio: %s\n", radio);
printf("Network: %s\n", network);
@@ -89,6 +92,9 @@ static void dumpstate() {
ALOGI("wrote screenshot: %s\n", screenshot_path);
}
+ run_command("SYSTEM SETTINGS", 20, "su", "root", "sqlite3",
+ "/data/data/com.android.providers.settings/databases/settings.db",
+ "pragma user_version; select * from system; select * from secure;", NULL);
run_command("SYSTEM LOG", 20, "logcat", "-v", "threadtime", "-d", "*:v", NULL);
/* show the traces we collected in main(), if that was done */
@@ -116,7 +122,7 @@ static void dumpstate() {
dump_file("NETWORK DEV INFO", "/proc/net/dev");
dump_file("QTAGUID NETWORK INTERFACES INFO", "/proc/net/xt_qtaguid/iface_stat_all");
dump_file("QTAGUID CTRL INFO", "/proc/net/xt_qtaguid/ctrl");
- run_command("QTAGUID STATS INFO", 10, "su", "root", "cat", "/proc/net/xt_qtaguid/stats", NULL);
+ dump_file("QTAGUID STATS INFO", "/proc/net/xt_qtaguid/stats");
dump_file("NETWORK ROUTES", "/proc/net/route");
dump_file("NETWORK ROUTES IPV6", "/proc/net/ipv6_route");
@@ -168,7 +174,7 @@ static void dumpstate() {
print_properties();
- run_command("KERNEL LOG", 20, "dmesg", NULL);
+ do_dmesg();
dump_file("KERNEL WAKELOCKS", "/proc/wakelocks");
dump_file("KERNEL CPUFREQ", "/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state");
@@ -191,6 +197,7 @@ static void dumpstate() {
dump_file("PACKAGE SETTINGS", "/data/system/packages.xml");
dump_file("PACKAGE UID ERRORS", "/data/system/uiderrors.txt");
+ /* TODO: Make last_kmsg CAP_SYSLOG protected. b/5555691 */
dump_file("LAST KMSG", "/proc/last_kmsg");
run_command("LAST RADIO LOG", 10, "parse_radio_log", "/proc/last_radio_log", NULL);
dump_file("LAST PANIC CONSOLE", "/data/dontpanic/apanic_console");
@@ -246,6 +253,13 @@ static void dumpstate() {
run_command("APP SERVICES", 30, "dumpsys", "activity", "service", "all", NULL);
printf("========================================================\n");
+ printf("== Running Application Providers\n");
+ printf("========================================================\n");
+
+ run_command("APP SERVICES", 30, "dumpsys", "activity", "provider", "all", NULL);
+
+
+ printf("========================================================\n");
printf("== dumpstate: done\n");
printf("========================================================\n");
}
@@ -314,8 +328,13 @@ int main(int argc, char *argv[]) {
}
if (getuid() == 0) {
+ if (prctl(PR_SET_KEEPCAPS, 1) < 0) {
+ ALOGE("prctl(PR_SET_KEEPCAPS) failed: %s\n", strerror(errno));
+ return -1;
+ }
+
/* switch to non-root user and group */
- gid_t groups[] = { AID_LOG, AID_SDCARD_RW, AID_MOUNT, AID_INET };
+ gid_t groups[] = { AID_LOG, AID_SDCARD_RW, AID_MOUNT, AID_INET, AID_NET_BW_STATS };
if (setgroups(sizeof(groups)/sizeof(groups[0]), groups) != 0) {
ALOGE("Unable to setgroups, aborting: %s\n", strerror(errno));
return -1;
@@ -328,6 +347,23 @@ int main(int argc, char *argv[]) {
ALOGE("Unable to setuid, aborting: %s\n", strerror(errno));
return -1;
}
+
+ struct __user_cap_header_struct capheader;
+ struct __user_cap_data_struct capdata[2];
+ memset(&capheader, 0, sizeof(capheader));
+ memset(&capdata, 0, sizeof(capdata));
+ capheader.version = _LINUX_CAPABILITY_VERSION_3;
+ capheader.pid = 0;
+
+ capdata[CAP_TO_INDEX(CAP_SYSLOG)].permitted = CAP_TO_MASK(CAP_SYSLOG);
+ capdata[CAP_TO_INDEX(CAP_SYSLOG)].effective = CAP_TO_MASK(CAP_SYSLOG);
+ capdata[0].inheritable = 0;
+ capdata[1].inheritable = 0;
+
+ if (capset(&capheader, &capdata[0]) < 0) {
+ ALOGE("capset failed: %s\n", strerror(errno));
+ return -1;
+ }
}
char path[PATH_MAX], tmp_path[PATH_MAX];