Skip to content

Commit 085f500

Browse files
committed
libzfs: make userquota_propname_decode threadsafe
Signed-off-by: Richard Kojedzinszky <[email protected]>
1 parent fb1101a commit 085f500

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/libzfs/libzfs_dataset.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@
6868
#include "libzfs_impl.h"
6969
#include "zfs_deleg.h"
7070

71+
static __thread struct passwd gpwd;
72+
static __thread struct group ggrp;
73+
static __thread char rpbuf[2048];
74+
7175
static int userquota_propname_decode(const char *propname, boolean_t zoned,
7276
zfs_userquota_prop_t *typep, char *domain, int domainlen, uint64_t *ridp);
7377

@@ -3196,11 +3200,15 @@ userquota_propname_decode(const char *propname, boolean_t zoned,
31963200

31973201
cp = strchr(propname, '@') + 1;
31983202

3199-
if (isuser && (pw = getpwnam(cp)) != NULL) {
3203+
if (isuser &&
3204+
getpwnam_r(cp, &gpwd, rpbuf, sizeof (rpbuf), &pw) == 0 &&
3205+
pw != NULL) {
32003206
if (zoned && getzoneid() == GLOBAL_ZONEID)
32013207
return (ENOENT);
32023208
*ridp = pw->pw_uid;
3203-
} else if (isgroup && (gr = getgrnam(cp)) != NULL) {
3209+
} else if (isgroup &&
3210+
getgrnam_r(cp, &ggrp, rpbuf, sizeof (rpbuf), &gr) == 0 &&
3211+
gr != NULL) {
32043212
if (zoned && getzoneid() == GLOBAL_ZONEID)
32053213
return (ENOENT);
32063214
*ridp = gr->gr_gid;

0 commit comments

Comments
 (0)