Skip to content

Commit

Permalink
Fix zoneid when USER_NS is disabled
Browse files Browse the repository at this point in the history
getzoneid() should return GLOBAL_ZONEID instead of 0 when USER_NS is disabled.
  • Loading branch information
Wraithh committed Nov 22, 2023
1 parent a94860a commit 5bb068c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/libspl/os/linux/zone.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ getzoneid(void)
int c = snprintf(path, sizeof (path), "/proc/self/ns/user");
/* This API doesn't have any error checking... */
if (c < 0 || c >= sizeof (path))
return (0);
return (GLOBAL_ZONEID);

ssize_t r = readlink(path, buf, sizeof (buf) - 1);
if (r < 0)
return (0);
return (GLOBAL_ZONEID);

cp = strchr(buf, '[');
if (cp == NULL)
return (0);
return (GLOBAL_ZONEID);
cp++;

unsigned long n = strtoul(cp, NULL, 10);
if (n == ULONG_MAX && errno == ERANGE)
return (0);
return (GLOBAL_ZONEID);
zoneid_t z = (zoneid_t)n;

return (z);
Expand Down

0 comments on commit 5bb068c

Please sign in to comment.