Use user_from_uid(3) instead of getpwuid(3) and keep the passwd
authormillert <millert@openbsd.org>
Tue, 18 Sep 2018 03:09:55 +0000 (03:09 +0000)
committermillert <millert@openbsd.org>
Tue, 18 Sep 2018 03:09:55 +0000 (03:09 +0000)
file open.  OK tb@

usr.sbin/quot/quot.c

index 56a2a83..1617ce4 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: quot.c,v 1.31 2018/07/26 13:37:40 mestre Exp $        */
+/*     $OpenBSD: quot.c,v 1.32 2018/09/18 03:09:55 millert Exp $       */
 
 /*
  * Copyright (C) 1991, 1994 Wolfgang Solfrank.
@@ -227,8 +227,8 @@ static struct user *
 user(uid_t uid)
 {
        int i;
-       struct passwd *pwd;
        struct user *usr;
+       const char *name;
 
        while (1) {
                for (usr = users + (uid&(nusers - 1)), i = nusers;
@@ -237,10 +237,10 @@ user(uid_t uid)
                        if (!usr->name) {
                                usr->uid = uid;
 
-                               if (!(pwd = getpwuid(uid)))
+                               if ((name = user_from_uid(uid, 1)) == NULL)
                                        asprintf(&usr->name, "#%u", uid);
                                else
-                                       usr->name = strdup(pwd->pw_name);
+                                       usr->name = strdup(name);
                                if (!usr->name)
                                        err(1, "allocate users");
                                return usr;
@@ -369,6 +369,8 @@ douser(int fd, struct fs *super, char *name)
        union dinode *dp;
        int n;
 
+       setpassent(1);
+
        maxino = super->fs_ncg * super->fs_ipg - 1;
        for (inode = 0; inode < maxino; inode++) {
                errno = 0;