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
This commit is contained in:
parent
7d68900af3
commit
8adf2e3066
|
@ -42,20 +42,20 @@ getzoneid(void)
|
||||||
int c = snprintf(path, sizeof (path), "/proc/self/ns/user");
|
int c = snprintf(path, sizeof (path), "/proc/self/ns/user");
|
||||||
/* This API doesn't have any error checking... */
|
/* This API doesn't have any error checking... */
|
||||||
if (c < 0 || c >= sizeof (path))
|
if (c < 0 || c >= sizeof (path))
|
||||||
return (0);
|
return (GLOBAL_ZONEID);
|
||||||
|
|
||||||
ssize_t r = readlink(path, buf, sizeof (buf) - 1);
|
ssize_t r = readlink(path, buf, sizeof (buf) - 1);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return (0);
|
return (GLOBAL_ZONEID);
|
||||||
|
|
||||||
cp = strchr(buf, '[');
|
cp = strchr(buf, '[');
|
||||||
if (cp == NULL)
|
if (cp == NULL)
|
||||||
return (0);
|
return (GLOBAL_ZONEID);
|
||||||
cp++;
|
cp++;
|
||||||
|
|
||||||
unsigned long n = strtoul(cp, NULL, 10);
|
unsigned long n = strtoul(cp, NULL, 10);
|
||||||
if (n == ULONG_MAX && errno == ERANGE)
|
if (n == ULONG_MAX && errno == ERANGE)
|
||||||
return (0);
|
return (GLOBAL_ZONEID);
|
||||||
zoneid_t z = (zoneid_t)n;
|
zoneid_t z = (zoneid_t)n;
|
||||||
|
|
||||||
return (z);
|
return (z);
|
||||||
|
|
Loading…
Reference in New Issue