diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2018-09-18 03:09:56 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2018-09-18 03:09:56 +0000 |
commit | 092266803843957321968fb53f653c740a48c9a0 (patch) | |
tree | d402796e26154877965e954dbcbcad26fe6403bb /usr.sbin | |
parent | ece76c3493b40388819fa1e942a820fb8e23b158 (diff) |
Use user_from_uid(3) instead of getpwuid(3) and keep the passwd
file open. OK tb@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/quot/quot.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.sbin/quot/quot.c b/usr.sbin/quot/quot.c index 56a2a83a39b..1617ce4f5a9 100644 --- a/usr.sbin/quot/quot.c +++ b/usr.sbin/quot/quot.c @@ -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; |