* commit 'c01915fd04dc352c77d4e2a0fbc906b515d2533c': Print out shared app gids correctly Add tests for Android-specific stubs
This commit is contained in:
@@ -264,25 +264,30 @@ static unsigned app_id_from_name(const char* name) {
|
||||
return (unsigned)(appid + userid*AID_USER);
|
||||
}
|
||||
|
||||
static void print_app_uid_name(uid_t uid, char* buffer, int bufferlen) {
|
||||
uid_t appid = uid % AID_USER;
|
||||
uid_t userid = uid / AID_USER;
|
||||
|
||||
if (appid < AID_ISOLATED_START) {
|
||||
if (appid < AID_APP) {
|
||||
for (size_t n = 0; n < android_id_count; n++) {
|
||||
if (android_ids[n].aid == appid) {
|
||||
snprintf(buffer, bufferlen, "u%u_%s", userid, android_ids[n].name);
|
||||
return;
|
||||
}
|
||||
static void print_app_name_from_appid_userid(const uid_t appid,
|
||||
const uid_t userid, char* buffer, const int bufferlen) {
|
||||
if (appid >= AID_ISOLATED_START) {
|
||||
snprintf(buffer, bufferlen, "u%u_i%u", userid, appid - AID_ISOLATED_START);
|
||||
} else if (userid == 0 && appid >= AID_SHARED_GID_START) {
|
||||
snprintf(buffer, bufferlen, "all_a%u", appid - AID_SHARED_GID_START);
|
||||
} else if (appid < AID_APP) {
|
||||
for (size_t n = 0; n < android_id_count; n++) {
|
||||
if (android_ids[n].aid == appid) {
|
||||
snprintf(buffer, bufferlen, "u%u_%s", userid, android_ids[n].name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
snprintf(buffer, bufferlen, "u%u_a%u", userid, appid - AID_APP);
|
||||
} else {
|
||||
snprintf(buffer, bufferlen, "u%u_i%u", userid, appid - AID_ISOLATED_START);
|
||||
snprintf(buffer, bufferlen, "u%u_a%u", userid, appid - AID_APP);
|
||||
}
|
||||
}
|
||||
|
||||
static void print_app_name_from_uid(const uid_t uid, char* buffer, const int bufferlen) {
|
||||
const uid_t appid = uid % AID_USER;
|
||||
const uid_t userid = uid / AID_USER;
|
||||
return print_app_name_from_appid_userid(appid, userid, buffer, bufferlen);
|
||||
}
|
||||
|
||||
// Translate a uid into the corresponding name.
|
||||
// 0 to AID_APP-1 -> "system", "radio", etc.
|
||||
// AID_APP to AID_ISOLATED_START-1 -> u0_a1234
|
||||
@@ -297,10 +302,18 @@ static passwd* app_id_to_passwd(uid_t uid, stubs_state_t* state) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
print_app_uid_name(uid, state->app_name_buffer_,
|
||||
sizeof(state->app_name_buffer_));
|
||||
const uid_t appid = uid % AID_USER;
|
||||
const uid_t userid = uid / AID_USER;
|
||||
|
||||
print_app_name_from_appid_userid(appid, userid, state->app_name_buffer_,
|
||||
sizeof(state->app_name_buffer_));
|
||||
|
||||
if (appid < AID_APP) {
|
||||
snprintf(state->dir_buffer_, sizeof(state->dir_buffer_), "/");
|
||||
} else {
|
||||
snprintf(state->dir_buffer_, sizeof(state->dir_buffer_), "/data");
|
||||
}
|
||||
|
||||
snprintf(state->dir_buffer_, sizeof(state->dir_buffer_), "/data");
|
||||
snprintf(state->sh_buffer_, sizeof(state->sh_buffer_), "/system/bin/sh");
|
||||
|
||||
pw->pw_name = state->app_name_buffer_;
|
||||
@@ -320,8 +333,8 @@ static group* app_id_to_group(gid_t gid, stubs_state_t* state) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
print_app_uid_name(gid, state->group_name_buffer_,
|
||||
sizeof(state->group_name_buffer_));
|
||||
print_app_name_from_uid(gid, state->group_name_buffer_,
|
||||
sizeof(state->group_name_buffer_));
|
||||
|
||||
group* gr = &state->group_;
|
||||
gr->gr_name = state->group_name_buffer_;
|
||||
|
||||
Reference in New Issue
Block a user