run-as: remove a special case.
This is a change for some system apps that have /data/user_de/0/ in the
package list, but it's easier to reason about and more consistent to
always go down the same path.
Bug: http://b/308990322
Test: treehugger
Change-Id: I479485655c61e8a31fb23f779c66d54b0bb476c0
diff --git a/run-as/run-as.cpp b/run-as/run-as.cpp
index e7c6e04..32057b4 100644
--- a/run-as/run-as.cpp
+++ b/run-as/run-as.cpp
@@ -196,14 +196,6 @@
}
if (setegid(old_egid) == -1) error(1, errno, "couldn't restore egid");
- // Handle a multi-user data path
- if (userId > 0) {
- free(info.data_dir);
- if (asprintf(&info.data_dir, "/data/user/%d/%s", userId, pkgname) == -1) {
- error(1, errno, "asprintf failed");
- }
- }
-
if (info.uid == 0) {
error(1, 0, "unknown package: %s", pkgname);
}
@@ -226,6 +218,12 @@
error(1, 0, "package not debuggable: %s", pkgname);
}
+ // Ensure we have the right data path for the specific user.
+ free(info.data_dir);
+ if (asprintf(&info.data_dir, "/data/user/%d/%s", userId, pkgname) == -1) {
+ error(1, errno, "asprintf failed");
+ }
+
// Check that the data directory path is valid.
check_data_path(pkgname, info.data_dir, userAppId);