diff options
author | Nick Kralevich <nnk@google.com> | 2010-10-21 15:31:07 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-10-21 15:31:07 -0700 |
commit | c7912444448d84d0fc70554a1a36e18a882c8f62 (patch) | |
tree | 77e8278a9d616037bcf7e283f7f909b8d26aecca /cmds/dumpstate | |
parent | a35827a8e92c79e200610e93549d7191fe701b19 (diff) | |
parent | 9a430d8c0e376160f287e50cdad99177e69ec384 (diff) | |
download | frameworks_base-c7912444448d84d0fc70554a1a36e18a882c8f62.zip frameworks_base-c7912444448d84d0fc70554a1a36e18a882c8f62.tar.gz frameworks_base-c7912444448d84d0fc70554a1a36e18a882c8f62.tar.bz2 |
am 9a430d8c: am 62d0970c: Merge "allow dumpstate to work for non-root users." into gingerbread
Merge commit '9a430d8c0e376160f287e50cdad99177e69ec384'
* commit '9a430d8c0e376160f287e50cdad99177e69ec384':
allow dumpstate to work for non-root users.
Diffstat (limited to 'cmds/dumpstate')
-rw-r--r-- | cmds/dumpstate/dumpstate.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c index 67bd9f7..35f0249 100644 --- a/cmds/dumpstate/dumpstate.c +++ b/cmds/dumpstate/dumpstate.c @@ -239,19 +239,21 @@ int main(int argc, char *argv[]) { fclose(cmdline); } - /* switch to non-root user and group */ - gid_t groups[] = { AID_LOG, AID_SDCARD_RW, AID_MOUNT }; - if (setgroups(sizeof(groups)/sizeof(groups[0]), groups) != 0) { - LOGE("Unable to setgroups, aborting: %s\n", strerror(errno)); - return -1; - } - if (setgid(AID_SHELL) != 0) { - LOGE("Unable to setgid, aborting: %s\n", strerror(errno)); - return -1; - } - if (setuid(AID_SHELL) != 0) { - LOGE("Unable to setuid, aborting: %s\n", strerror(errno)); - return -1; + if (getuid() == 0) { + /* switch to non-root user and group */ + gid_t groups[] = { AID_LOG, AID_SDCARD_RW, AID_MOUNT }; + if (setgroups(sizeof(groups)/sizeof(groups[0]), groups) != 0) { + LOGE("Unable to setgroups, aborting: %s\n", strerror(errno)); + return -1; + } + if (setgid(AID_SHELL) != 0) { + LOGE("Unable to setgid, aborting: %s\n", strerror(errno)); + return -1; + } + if (setuid(AID_SHELL) != 0) { + LOGE("Unable to setuid, aborting: %s\n", strerror(errno)); + return -1; + } } char path[PATH_MAX], tmp_path[PATH_MAX]; |