Fixed and improve RunCommand() when running as root.
Improved it by not try to run 'su root' on user builds.
Fixed the logic that creates the args.
BUG: 29319732
BUG: 26379932
Test: manual
Change-Id: I6b39abc8ee907f638905913425218c0a50d767c6
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index b5a3352..d1a96c1 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -110,6 +110,9 @@
static int DumpFile(const std::string& title, const std::string& path) {
return ds.DumpFile(title, path);
}
+bool IsUserBuild() {
+ return ds.IsUserBuild();
+}
/*
* List of supported zip format versions.
@@ -124,7 +127,7 @@
static constexpr char PROPERTY_EXTRA_OPTIONS[] = "dumpstate.options";
static constexpr char PROPERTY_LAST_ID[] = "dumpstate.last_id";
-bool is_user_build() {
+bool Dumpstate::IsUserBuild() {
return "user" == buildType;
}
@@ -381,7 +384,7 @@
}
static void dump_raft() {
- if (is_user_build()) {
+ if (IsUserBuild()) {
return;
}
@@ -1103,7 +1106,7 @@
// root can run on user builds.
CommandOptions::CommandOptionsBuilder options =
CommandOptions::WithTimeout(rilDumpstateTimeout);
- if (!is_user_build()) {
+ if (!IsUserBuild()) {
options.AsRoot();
}
RunCommand("DUMP VENDOR RIL LOGS", {"vril-dump"}, options.Build());
@@ -1244,7 +1247,7 @@
return false;
}
- if (is_user_build()) {
+ if (IsUserBuild()) {
MYLOGD("Removing temporary file %s\n", bugreport_path.c_str())
if (remove(bugreport_path.c_str())) {
ALOGW("remove(%s): %s\n", bugreport_path.c_str(), strerror(errno));
@@ -1610,7 +1613,7 @@
add_dir(RECOVERY_DIR, true);
add_dir(RECOVERY_DATA_DIR, true);
add_dir(LOGPERSIST_DATA_DIR, false);
- if (!is_user_build()) {
+ if (!IsUserBuild()) {
add_dir(PROFILE_DATA_DIR_CUR, true);
add_dir(PROFILE_DATA_DIR_REF, true);
}