Fix run-as for non-owner users

bug: 118501138
bug: 80126373
Test: cts-tradefed run cts-dev -a arm64-v8a -m CtsJvmtiRunTest1908HostTestCases
Change-Id: Iee25afbffc6990b46f508bfe8a9953bd2a35d118
This commit is contained in:
Nicholas Sauer 2018-11-02 17:04:52 -07:00
parent abd6627983
commit 0c5411c7ca

View file

@ -167,6 +167,15 @@ int main(int argc, char* argv[]) {
if (!packagelist_parse(packagelist_parse_callback, &info)) {
error(1, errno, "packagelist_parse failed");
}
// 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);
}