diff options
author | John Michelau <john.michelau@motorola.com> | 2011-07-05 15:20:03 -0500 |
---|---|---|
committer | Wink Saville <wink@google.com> | 2011-07-06 09:30:28 -0700 |
commit | 790d2e4d69fd6794cdeec4dccd841149b7c38db3 (patch) | |
tree | 4e19db9855cf0020b3ba0103db43c998a6abf9b3 /cmds/dumpstate | |
parent | 012b86d4294182497c4c72a318e0f4cbe5075a44 (diff) | |
download | frameworks_base-790d2e4d69fd6794cdeec4dccd841149b7c38db3.zip frameworks_base-790d2e4d69fd6794cdeec4dccd841149b7c38db3.tar.gz frameworks_base-790d2e4d69fd6794cdeec4dccd841149b7c38db3.tar.bz2 |
Allow vril-dump to work on user builds
Run vril-dump without "su root" when ro.build.type=user. Also add inet
perms for dumpstate, so that it can communicate with basebands that
have IP-based interfaces.
Bug: 4993955
Change-Id: Icc65ba0f80756db1f63f12f89f9973a55bf405f2
Diffstat (limited to 'cmds/dumpstate')
-rw-r--r-- | cmds/dumpstate/dumpstate.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c index ccc4fd7..209417b 100644 --- a/cmds/dumpstate/dumpstate.c +++ b/cmds/dumpstate/dumpstate.c @@ -47,9 +47,11 @@ static void dumpstate() { char build[PROPERTY_VALUE_MAX], fingerprint[PROPERTY_VALUE_MAX]; char radio[PROPERTY_VALUE_MAX], bootloader[PROPERTY_VALUE_MAX]; char network[PROPERTY_VALUE_MAX], date[80]; + char build_type[PROPERTY_VALUE_MAX]; property_get("ro.build.display.id", build, "(unknown)"); property_get("ro.build.fingerprint", fingerprint, "(unknown)"); + property_get("ro.build.type", build_type, "(unknown)"); property_get("ro.baseband", radio, "(unknown)"); property_get("ro.bootloader", bootloader, "(unknown)"); property_get("gsm.operator.alpha", network, "(unknown)"); @@ -126,9 +128,17 @@ static void dumpstate() { char ril_dumpstate_timeout[PROPERTY_VALUE_MAX] = {0}; property_get("ril.dumpstate.timeout", ril_dumpstate_timeout, "30"); - if (strlen(ril_dumpstate_timeout) > 0) { - run_command("DUMP VENDOR RIL LOGS", atoi(ril_dumpstate_timeout), - "su", "root", "vril-dump", NULL); + if (strnlen(ril_dumpstate_timeout, PROPERTY_VALUE_MAX - 1) > 0) { + if (0 == strncmp(build_type, "user", PROPERTY_VALUE_MAX - 1)) { + // su does not exist on user builds, so try running without it. + // This way any implementations of vril-dump that do not require + // root can run on user builds. + run_command("DUMP VENDOR RIL LOGS", atoi(ril_dumpstate_timeout), + "vril-dump", NULL); + } else { + run_command("DUMP VENDOR RIL LOGS", atoi(ril_dumpstate_timeout), + "su", "root", "vril-dump", NULL); + } } print_properties(); @@ -264,7 +274,7 @@ int main(int argc, char *argv[]) { if (getuid() == 0) { /* switch to non-root user and group */ - gid_t groups[] = { AID_LOG, AID_SDCARD_RW, AID_MOUNT }; + gid_t groups[] = { AID_LOG, AID_SDCARD_RW, AID_MOUNT, AID_INET }; if (setgroups(sizeof(groups)/sizeof(groups[0]), groups) != 0) { LOGE("Unable to setgroups, aborting: %s\n", strerror(errno)); return -1; |