summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Wilsdon <jwilsdon@joyent.com>2014-10-29 18:15:16 +0000
committerJosh Wilsdon <jwilsdon@joyent.com>2014-10-29 18:16:27 +0000
commite7225aa358c52af4e3ba284399ea8b34fb8348df (patch)
treedf81b46ad6bb713b8f61b7314be7c4f575f8c666
parentbc8b7496f2f65bf43851aa5fb56d895a67d0db1b (diff)
downloadillumos-joyent-e7225aa358c52af4e3ba284399ea8b34fb8348df.tar.gz
OS-3491 lx_boot should bypass distro detection when 'docker' flag set
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
-rw-r--r--usr/src/lib/brand/lx/zone/lx_boot.ksh8
-rw-r--r--usr/src/lib/brand/shared/zone/common.ksh26
2 files changed, 26 insertions, 8 deletions
diff --git a/usr/src/lib/brand/lx/zone/lx_boot.ksh b/usr/src/lib/brand/lx/zone/lx_boot.ksh
index 3edf51f7ec..3aff4c6b16 100644
--- a/usr/src/lib/brand/lx/zone/lx_boot.ksh
+++ b/usr/src/lib/brand/lx/zone/lx_boot.ksh
@@ -120,7 +120,9 @@ setup_native_cmd() {
# Determine the distro.
#
distro=""
-if [[ -f $ZONEROOT/etc/redhat-release ]]; then
+if [[ $(zonecfg -z $ZONENAME info attr name=docker) =~ "value: true" ]]; then
+ distro="docker"
+elif [[ -f $ZONEROOT/etc/redhat-release ]]; then
distro="redhat"
elif [[ -f $ZONEROOT/etc/lsb-release ]]; then
if egrep -s Ubuntu $ZONEROOT/etc/lsb-release; then
@@ -170,8 +172,8 @@ safe_dir /lib
safe_dir /bin
safe_dir /sbin
safe_dir /etc
-safe_dir /etc/init
-safe_dir /etc/update-motd.d
+safe_opt_dir /etc/init
+safe_opt_dir /etc/update-motd.d
#
# STEP TWO
diff --git a/usr/src/lib/brand/shared/zone/common.ksh b/usr/src/lib/brand/shared/zone/common.ksh
index 667a1cc1ff..0f87686414 100644
--- a/usr/src/lib/brand/shared/zone/common.ksh
+++ b/usr/src/lib/brand/shared/zone/common.ksh
@@ -97,9 +97,27 @@ vlog()
safe_dir()
{
typeset dir="$1"
+ typeset pwd_dir=""
- if [[ -h $ZONEROOT/$dir || ! -d $ZONEROOT/$dir ]]; then
- fatal "$e_baddir" "$dir"
+ if [[ -d $ZONEROOT/$dir ]]; then
+ if [[ -h $ZONEROOT/$dir ]]; then
+ #
+ # When dir is a symlink to a directory, we 'cd' to that
+ # directory to ensure that's under $ZONEROOT. We use pwd
+ # from /usr/bin instead of built-in because they give
+ # different results.
+ #
+ pwd_dir=$(cd $ZONEROOT/$dir && /usr/bin/pwd)
+ if [[ $pwd_dir =~ "^$ZONEROOT" ]]; then
+ return;
+ else
+ fatal \
+ "$e_baddir: symlink out of zoneroot" "$dir"
+ fi
+ else
+ # it's a dir and not a symlink, so that's ok.
+ return
+ fi
fi
}
@@ -110,9 +128,7 @@ safe_opt_dir()
[[ ! -e $ZONEROOT/$dir ]] && return
- if [[ -h $ZONEROOT/$dir || ! -d $ZONEROOT/$dir ]]; then
- fatal "$e_baddir" "$dir"
- fi
+ safe_dir $dir
}
# Only make a copy if we haven't already done so.