From 84e41ca0e2d39f71dde58e8cd594537c0e4b6c64 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 10 Nov 2023 22:02:00 +0000 Subject: [PATCH] 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 --- run-as/run-as.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/run-as/run-as.cpp b/run-as/run-as.cpp index e7c6e04d4..32057b491 100644 --- a/run-as/run-as.cpp +++ b/run-as/run-as.cpp @@ -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);