diff options
author | Andy Fiddaman <andy@omniosce.org> | 2020-04-29 10:38:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-29 10:38:31 +0100 |
commit | 07f59955ed70f8875b7d89dd494defd7f0b1337d (patch) | |
tree | 4fd9ece004fda0d88e7a2ec480e91b9c80fb11e2 | |
parent | a6f7c4f2a8d87ac0d0b9c042f7b574988c4093de (diff) | |
download | illumos-joyent-07f59955ed70f8875b7d89dd494defd7f0b1337d.tar.gz |
OS-8166 /etc/zones/did.txt should be alternate-root aware (#295)
Reviewed by: John Levon <john.levon@joyent.com>
Approved by: Tim Foster <tim.foster@joyent.com>
-rw-r--r-- | usr/src/lib/libzonecfg/common/libzonecfg.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/usr/src/lib/libzonecfg/common/libzonecfg.c b/usr/src/lib/libzonecfg/common/libzonecfg.c index e709b7dba8..7dc3f9ccb8 100644 --- a/usr/src/lib/libzonecfg/common/libzonecfg.c +++ b/usr/src/lib/libzonecfg/common/libzonecfg.c @@ -6066,9 +6066,16 @@ new_zone_did() int len; int val; struct flock lck; + char pathbuf[PATH_MAX]; char buf[80]; - if ((fd = open(DEBUGID_FILE, O_RDWR | O_CREAT, + if (snprintf(pathbuf, sizeof (pathbuf), "%s%s", zonecfg_get_root(), + DEBUGID_FILE) >= sizeof (pathbuf)) { + printf(gettext("alternate root path is too long")); + return (-1); + } + + if ((fd = open(pathbuf, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0) { perror("new_zone_did open failed"); return (-1); |