Skip to content

Commit 8adf2e3

Browse files
authored
Fix zoneid when USER_NS is disabled
getzoneid() should return GLOBAL_ZONEID instead of 0 when USER_NS is disabled. Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ilkka Sovanto <github@ilkka.kapsi.fi> Closes #15560
1 parent 7d68900 commit 8adf2e3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/libspl/os/linux/zone.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,20 @@ getzoneid(void)
4242
int c = snprintf(path, sizeof (path), "/proc/self/ns/user");
4343
/* This API doesn't have any error checking... */
4444
if (c < 0 || c >= sizeof (path))
45-
return (0);
45+
return (GLOBAL_ZONEID);
4646

4747
ssize_t r = readlink(path, buf, sizeof (buf) - 1);
4848
if (r < 0)
49-
return (0);
49+
return (GLOBAL_ZONEID);
5050

5151
cp = strchr(buf, '[');
5252
if (cp == NULL)
53-
return (0);
53+
return (GLOBAL_ZONEID);
5454
cp++;
5555

5656
unsigned long n = strtoul(cp, NULL, 10);
5757
if (n == ULONG_MAX && errno == ERANGE)
58-
return (0);
58+
return (GLOBAL_ZONEID);
5959
zoneid_t z = (zoneid_t)n;
6060

6161
return (z);

0 commit comments

Comments
 (0)