Fix the pwd and group functions. The bb_ stuff was a leftover from
[oweals/busybox.git] / utility.c
index 13b8065d3945d63410a9fd99b68c86d5ba2d5110..568b5f21832a5a16acecee23d9175e8a2d867dbb 100644 (file)
--- a/utility.c
+++ b/utility.c
 #include <utime.h>
 #include <unistd.h>
 #include <ctype.h>
+#include <stdlib.h>
 #include <sys/ioctl.h>
 #include <sys/utsname.h>               /* for uname(2) */
+
 #include "pwd_grp/pwd.h"
 #include "pwd_grp/grp.h"
 
+/* for the _syscall() macros */
+#include <sys/syscall.h>
+#include <linux/unistd.h>
+
 /* Busybox mount uses either /proc/filesystems or /dev/mtab to get the 
  * list of available filesystems used for the -t auto option */ 
 #if defined BB_FEATURE_USE_PROCFS && defined BB_FEATURE_USE_DEVPS_PATCH
@@ -865,7 +871,7 @@ long my_getpwnam(char *name)
 
        myuser  = getpwnam(name);
        if (myuser==NULL)
-               error_msg_and_die( "unknown username: %s\n", name);
+               return(-1);
 
        return myuser->pw_uid;
 }
@@ -877,7 +883,7 @@ long my_getgrnam(char *name)
 
        mygroup  = getgrnam(name);
        if (mygroup==NULL)
-               error_msg_and_die( "unknown group: %s\n", name);
+               return(-1);
 
        return (mygroup->gr_gid);
 }
@@ -889,9 +895,9 @@ void my_getpwuid(char *name, long uid)
 
        myuser  = getpwuid(uid);
        if (myuser==NULL)
-               error_msg_and_die( "unknown uid %ld\n", (long)uid);
-
-       strcpy(name, myuser->pw_name);
+               sprintf(name, "%-8ld ", (long)uid);
+       else
+               strcpy(name, myuser->pw_name);
 }
 
 /* gets a groupname given a gid */
@@ -901,9 +907,9 @@ void my_getgrgid(char *group, long gid)
 
        mygroup  = getgrgid(gid);
        if (mygroup==NULL)
-               error_msg_and_die( "unknown gid %ld\n", (long)gid);
-
-       strcpy(group, mygroup->gr_name);
+               sprintf(group, "%-8ld ", (long)gid);
+       else
+               strcpy(group, mygroup->gr_name);
 }
 
 #if defined BB_ID
@@ -1123,6 +1129,7 @@ extern int check_wildcard_match(const char *text, const char *pattern)
 
 
 #if defined BB_DF || defined BB_MTAB
+#include <mntent.h>
 /*
  * Given a block device, find the mount table entry if that block device
  * is mounted.
@@ -1645,6 +1652,7 @@ char *get_last_path_component(char *path)
 #endif
 
 #if defined BB_GREP || defined BB_SED
+#include <regex.h>
 void xregcomp(regex_t *preg, const char *regex, int cflags)
 {
        int ret;