From 147c695943c78482a34871dfa76759d332bf347b Mon Sep 17 00:00:00 2001 From: millert Date: Tue, 18 Sep 2018 03:09:55 +0000 Subject: [PATCH] Use user_from_uid(3) instead of getpwuid(3) and keep the passwd file open. OK tb@ --- usr.sbin/quot/quot.c | 10 ++++++---- 1 file 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; -- 2.20.1