summaryrefslogtreecommitdiffstats
path: root/usr.sbin/quot/quot.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2018-09-18 03:09:55 +0000
committermillert <millert@openbsd.org>2018-09-18 03:09:55 +0000
commit147c695943c78482a34871dfa76759d332bf347b (patch)
tree9c987b1c6c7c96b867e1f6b4c169c1cefb17fa5c /usr.sbin/quot/quot.c
parentAccount from the fact that we store ech entry three times when (diff)
downloadwireguard-openbsd-147c695943c78482a34871dfa76759d332bf347b.tar.xz
wireguard-openbsd-147c695943c78482a34871dfa76759d332bf347b.zip
Use user_from_uid(3) instead of getpwuid(3) and keep the passwd
file open. OK tb@
Diffstat (limited to 'usr.sbin/quot/quot.c')
-rw-r--r--usr.sbin/quot/quot.c10
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;