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
This commit is contained in:
Elliott Hughes 2023-11-10 22:02:00 +00:00
parent 0ac91e1f02
commit 84e41ca0e2

View file

@ -196,14 +196,6 @@ int main(int argc, char* argv[]) {
}
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 @@ int main(int argc, char* argv[]) {
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);