Merge "logd: switch from android_ids to getpwuid"
This commit is contained in:
commit
9a3e238a60
1 changed files with 16 additions and 7 deletions
|
|
@ -15,8 +15,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <pwd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <log/logger.h>
|
#include <log/logger.h>
|
||||||
|
|
@ -159,14 +161,13 @@ const char *LogStatistics::uidToName(uid_t uid) const {
|
||||||
return strdup("auditd");
|
return strdup("auditd");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Android hard coded
|
// Android system
|
||||||
const struct android_id_info *info = android_ids;
|
if (uid < AID_APP) {
|
||||||
|
// in bionic, thread safe as long as we copy the results
|
||||||
for (size_t i = 0; i < android_id_count; ++i) {
|
struct passwd *pwd = getpwuid(uid);
|
||||||
if (info->aid == uid) {
|
if (pwd) {
|
||||||
return strdup(info->name);
|
return strdup(pwd->pw_name);
|
||||||
}
|
}
|
||||||
++info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse /data/system/packages.list
|
// Parse /data/system/packages.list
|
||||||
|
|
@ -179,6 +180,14 @@ const char *LogStatistics::uidToName(uid_t uid) const {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Android application
|
||||||
|
if (uid >= AID_APP) {
|
||||||
|
struct passwd *pwd = getpwuid(uid);
|
||||||
|
if (pwd) {
|
||||||
|
return strdup(pwd->pw_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// report uid -> pid(s) -> pidToName if unique
|
// report uid -> pid(s) -> pidToName if unique
|
||||||
for(pidTable_t::const_iterator it = pidTable.begin(); it != pidTable.end(); ++it) {
|
for(pidTable_t::const_iterator it = pidTable.begin(); it != pidTable.end(); ++it) {
|
||||||
const PidEntry &entry = it->second;
|
const PidEntry &entry = it->second;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue