ueventd: convert to use pwd family of functions

Switch ueventd to use the grp.h and pwd.h family of
functions for converting strings to uids. This removes the
need for using android_filesystem_config.h.

Change-Id: I25a6f536bb11683d5cd69a0d7b348d25a272dd3b
Bug: 27999086
Signed-off-by: William Roberts <william.c.roberts@intel.com>
diff --git a/init/ueventd.cpp b/init/ueventd.cpp
index 249739b..73b2136 100644
--- a/init/ueventd.cpp
+++ b/init/ueventd.cpp
@@ -16,14 +16,17 @@
 
 #include <ctype.h>
 #include <fcntl.h>
+#include <grp.h>
 #include <poll.h>
+#include <pwd.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
+#include <sys/types.h>
+
 #include <android-base/stringprintf.h>
-#include <private/android_filesystem_config.h>
 #include <selinux/selinux.h>
 
 #include "ueventd.h"
@@ -84,15 +87,6 @@
     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)
 {
     char *name;
@@ -103,7 +97,6 @@
     int prefix = 0;
     int wildcard = 0;
     char *endptr;
-    int ret;
     char *tmp = 0;
 
     if (nargs == 0)
@@ -151,21 +144,21 @@
         return;
     }
 
-    ret = get_android_id(args[2]);
-    if (ret < 0) {
+    struct passwd* pwd = getpwnam(args[2]);
+    if (!pwd) {
         ERROR("invalid uid '%s'\n", args[2]);
         free(tmp);
         return;
     }
-    uid = ret;
+    uid = pwd->pw_uid;
 
-    ret = get_android_id(args[3]);
-    if (ret < 0) {
+    struct group* grp = getgrnam(args[3]);
+    if (!grp) {
         ERROR("invalid gid '%s'\n", args[3]);
         free(tmp);
         return;
     }
-    gid = ret;
+    gid = grp->gr_gid;
 
     add_dev_perms(name, attr, perm, uid, gid, prefix, wildcard);
     free(tmp);