Merge "ueventd: convert to use pwd family of functions"
This commit is contained in:
commit
2c78f62638
1 changed files with 10 additions and 17 deletions
|
|
@ -16,14 +16,17 @@
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <grp.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
#include <pwd.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <android-base/stringprintf.h>
|
#include <android-base/stringprintf.h>
|
||||||
#include <private/android_filesystem_config.h>
|
|
||||||
#include <selinux/selinux.h>
|
#include <selinux/selinux.h>
|
||||||
|
|
||||||
#include "ueventd.h"
|
#include "ueventd.h"
|
||||||
|
|
@ -84,15 +87,6 @@ int ueventd_main(int argc, char **argv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_android_id(const char *id)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
for (i = 0; i < ARRAY_SIZE(android_ids); i++)
|
|
||||||
if (!strcmp(id, android_ids[i].name))
|
|
||||||
return android_ids[i].aid;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_device_permission(int nargs, char **args)
|
void set_device_permission(int nargs, char **args)
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
|
|
@ -103,7 +97,6 @@ void set_device_permission(int nargs, char **args)
|
||||||
int prefix = 0;
|
int prefix = 0;
|
||||||
int wildcard = 0;
|
int wildcard = 0;
|
||||||
char *endptr;
|
char *endptr;
|
||||||
int ret;
|
|
||||||
char *tmp = 0;
|
char *tmp = 0;
|
||||||
|
|
||||||
if (nargs == 0)
|
if (nargs == 0)
|
||||||
|
|
@ -151,21 +144,21 @@ void set_device_permission(int nargs, char **args)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = get_android_id(args[2]);
|
struct passwd* pwd = getpwnam(args[2]);
|
||||||
if (ret < 0) {
|
if (!pwd) {
|
||||||
ERROR("invalid uid '%s'\n", args[2]);
|
ERROR("invalid uid '%s'\n", args[2]);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uid = ret;
|
uid = pwd->pw_uid;
|
||||||
|
|
||||||
ret = get_android_id(args[3]);
|
struct group* grp = getgrnam(args[3]);
|
||||||
if (ret < 0) {
|
if (!grp) {
|
||||||
ERROR("invalid gid '%s'\n", args[3]);
|
ERROR("invalid gid '%s'\n", args[3]);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gid = ret;
|
gid = grp->gr_gid;
|
||||||
|
|
||||||
add_dev_perms(name, attr, perm, uid, gid, prefix, wildcard);
|
add_dev_perms(name, attr, perm, uid, gid, prefix, wildcard);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue