diff options
author | Alexander Eremin <a.eremin@nexenta.com> | 2014-12-26 13:08:29 +0100 |
---|---|---|
committer | Robert Mustacchi <rm@joyent.com> | 2014-12-26 11:36:13 -0800 |
commit | b6831eafa2ec2cb283f783b06ee86bf79d5a17c3 (patch) | |
tree | d613f9d71a88df08eb7291b1e69f658a8e7b71d4 /usr/src/cmd | |
parent | a5261312fc4eed6b5595eca994c6cfec602829cd (diff) | |
download | illumos-gate-b6831eafa2ec2cb283f783b06ee86bf79d5a17c3.tar.gz |
5432 zoneadm install could fix zonepath permissions automatically
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Diffstat (limited to 'usr/src/cmd')
-rw-r--r-- | usr/src/cmd/zoneadm/zoneadm.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/usr/src/cmd/zoneadm/zoneadm.c b/usr/src/cmd/zoneadm/zoneadm.c index 2c25e18a53..6d80fcd8c3 100644 --- a/usr/src/cmd/zoneadm/zoneadm.c +++ b/usr/src/cmd/zoneadm/zoneadm.c @@ -1023,6 +1023,18 @@ validate_zonepath(char *path, int cmd_num) (void) fprintf(stderr, gettext("%s is not owned by root.\n"), rpath); err = B_TRUE; + + /* Try to change owner */ + if (cmd_num != CMD_VERIFY) { + (void) fprintf(stderr, gettext("%s: changing owner " + "to root.\n"), rpath); + if (chown(rpath, 0, -1) != 0) { + zperror(rpath, B_FALSE); + return (Z_ERR); + } else { + err = B_FALSE; + } + } } err |= bad_mode_bit(stbuf.st_mode, S_IRUSR, B_TRUE, rpath); err |= bad_mode_bit(stbuf.st_mode, S_IWUSR, B_TRUE, rpath); @@ -1034,6 +1046,17 @@ validate_zonepath(char *path, int cmd_num) err |= bad_mode_bit(stbuf.st_mode, S_IWOTH, B_FALSE, rpath); err |= bad_mode_bit(stbuf.st_mode, S_IXOTH, B_FALSE, rpath); + /* If the group perms are wrong, fix them */ + if (err && (cmd_num != CMD_VERIFY)) { + (void) fprintf(stderr, gettext("%s: changing permissions " + "to 0700.\n"), rpath); + if (chmod(rpath, S_IRWXU) != 0) { + zperror(path, B_FALSE); + } else { + err = B_FALSE; + } + } + (void) snprintf(ppath, sizeof (ppath), "%s/..", path); if ((res = resolvepath(ppath, rppath, sizeof (rppath))) == -1) { zperror(ppath, B_FALSE); |