aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libzfs
diff options
context:
space:
mode:
authorRichard Kojedzinszky <[email protected]>2024-01-17 20:48:02 +0100
committerBrian Behlendorf <[email protected]>2024-01-29 09:54:43 -0800
commit692f0daba3fbb725148d6ac9d5e69acfb1fadadf (patch)
tree4b38ee41e21a60f07526ad7558030364aa19b105 /lib/libzfs
parent0cbf135293b07f821ff427de62e01e6f113bde98 (diff)
libzfs: make userquota_propname_decode threadsafe
Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Tino Reichardt <[email protected]> Signed-off-by: Richard Kojedzinszky <[email protected]> Closes #15793
Diffstat (limited to 'lib/libzfs')
-rw-r--r--lib/libzfs/libzfs_dataset.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c
index 727efc5a9..eaceabd23 100644
--- a/lib/libzfs/libzfs_dataset.c
+++ b/lib/libzfs/libzfs_dataset.c
@@ -67,6 +67,10 @@
#include "libzfs_impl.h"
#include "zfs_deleg.h"
+static __thread struct passwd gpwd;
+static __thread struct group ggrp;
+static __thread char rpbuf[2048];
+
static int userquota_propname_decode(const char *propname, boolean_t zoned,
zfs_userquota_prop_t *typep, char *domain, int domainlen, uint64_t *ridp);
@@ -3195,11 +3199,15 @@ userquota_propname_decode(const char *propname, boolean_t zoned,
cp = strchr(propname, '@') + 1;
- if (isuser && (pw = getpwnam(cp)) != NULL) {
+ if (isuser &&
+ getpwnam_r(cp, &gpwd, rpbuf, sizeof (rpbuf), &pw) == 0 &&
+ pw != NULL) {
if (zoned && getzoneid() == GLOBAL_ZONEID)
return (ENOENT);
*ridp = pw->pw_uid;
- } else if (isgroup && (gr = getgrnam(cp)) != NULL) {
+ } else if (isgroup &&
+ getgrnam_r(cp, &ggrp, rpbuf, sizeof (rpbuf), &gr) == 0 &&
+ gr != NULL) {
if (zoned && getzoneid() == GLOBAL_ZONEID)
return (ENOENT);
*ridp = gr->gr_gid;