summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McDonald <danmcd@joyent.com>2021-03-01 13:46:26 -0500
committerGitHub <noreply@github.com>2021-03-01 13:46:26 -0500
commit6e328f367d9cab0f5edb03286642f5533dc2c362 (patch)
treebac6675af36d9eb1ca4324f5f3f7a9705511043f
parent49713c9ca119fd2f1e7a7182fd90921297aa978a (diff)
downloadillumos-joyent-6e328f367d9cab0f5edb03286642f5533dc2c362.tar.gz
OS-7754 Ubuntu 18.04 in lx needs different resolver configuration
Co-authored-by: Michael Zeller <mike@mikezeller.net> Reviewed by: Dan McDonald <danmcd@joyent.com> Reviewed by: Mike Zeller <mike.zeller@joyent.com> Approved by: Brian Bennett <brian.bennett@joyent.com>
-rw-r--r--usr/src/lib/brand/lx/zone/lx_boot.ksh9
-rw-r--r--usr/src/lib/brand/lx/zone/lx_boot_zone_busybox.ksh34
-rw-r--r--usr/src/lib/brand/lx/zone/lx_boot_zone_debian.ksh33
-rw-r--r--usr/src/lib/brand/lx/zone/lx_boot_zone_redhat.ksh32
-rw-r--r--usr/src/lib/brand/lx/zone/lx_boot_zone_suse.ksh2
-rw-r--r--usr/src/lib/brand/lx/zone/lx_boot_zone_ubuntu.ksh51
6 files changed, 100 insertions, 61 deletions
diff --git a/usr/src/lib/brand/lx/zone/lx_boot.ksh b/usr/src/lib/brand/lx/zone/lx_boot.ksh
index 7361e45b52..e2eb523a3d 100644
--- a/usr/src/lib/brand/lx/zone/lx_boot.ksh
+++ b/usr/src/lib/brand/lx/zone/lx_boot.ksh
@@ -22,6 +22,7 @@
#
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright 2017 ASS-Einrichtungssysteme GmbH, Inc.
+# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
# Copyright 2020 Joyent, Inc.
#
# lx boot script.
@@ -90,6 +91,14 @@ fi
[[ -z $distro ]] && fatal "Unsupported distribution!"
#
+# Retrieve an attribute from the zone configuration
+#
+zone_attr() {
+ zonecfg -z "$ZONENAME" info attr "name=$1" \
+ | nawk '$1 == "value:" {print $2}'
+}
+
+#
# Perform distro-specific customization.
#
. $(dirname $0)/lx_boot_zone_${distro}
diff --git a/usr/src/lib/brand/lx/zone/lx_boot_zone_busybox.ksh b/usr/src/lib/brand/lx/zone/lx_boot_zone_busybox.ksh
index 1ad83902bc..702ac782a1 100644
--- a/usr/src/lib/brand/lx/zone/lx_boot_zone_busybox.ksh
+++ b/usr/src/lib/brand/lx/zone/lx_boot_zone_busybox.ksh
@@ -36,11 +36,16 @@ depend() {
keyword nojail noprefix novserver
}
start() {
+EOF
+# Only alter resolv.conf if we're getting info from zonecfg(1M).
+zonecfg -z $ZONENAME info attr name=resolvers | grep -q resolvers
+if [[ $? == 0 ]]; then
+ cat > $tmpfile <<EOF
if [ ! -e /etc/resolv.conf ]; then
echo "# AUTOMATIC ZONE CONFIG" > /etc/resolv.conf
EOF
-zonecfg -z $ZONENAME info attr name=resolvers |
-awk '
+ zonecfg -z $ZONENAME info attr name=resolvers |
+ awk '
{
if ($1 == "value:") {
nres = split($2, resolvers, ",")
@@ -52,9 +57,9 @@ awk '
"/etc/resolv.conf")
}
}
-' >> $tmpfile
-zonecfg -z $ZONENAME info attr name=dns-domain |
-awk '
+ ' >> $tmpfile
+ zonecfg -z $ZONENAME info attr name=dns-domain |
+ awk '
{
if ($1 == "value:") {
dom = $2
@@ -63,14 +68,23 @@ awk '
END {
printf(" echo \"search %s\" >> %s\n", dom, "/etc/resolv.conf")
}
-' >> $tmpfile
-cat >> $tmpfile <<EOF
+ ' >> $tmpfile
+ cat >> $tmpfile <<EOF
fi
return 0
-}
-stop() {
+ }
+EOF
+else
+ cat >> $tmpfile <<EOF
return 0
-}
+ }
+EOF
+fi
+
+cat >> $tmpfile <<EOF
+ stop() {
+ return 0
+ }
EOF
fnm=$ZONEROOT/etc/init.d/networking
if [[ -f $fnm || -h $fnm ]]; then
diff --git a/usr/src/lib/brand/lx/zone/lx_boot_zone_debian.ksh b/usr/src/lib/brand/lx/zone/lx_boot_zone_debian.ksh
index 35ae59c19c..86b5bffbe5 100644
--- a/usr/src/lib/brand/lx/zone/lx_boot_zone_debian.ksh
+++ b/usr/src/lib/brand/lx/zone/lx_boot_zone_debian.ksh
@@ -36,29 +36,32 @@ safe_dir /etc/rc6.d
safe_dir /etc/rcS.d
safe_opt_dir /etc/selinux
-# Populate resolve.conf setup files
-zonecfg -z $ZONENAME info attr name=resolvers | awk '
-BEGIN {
+# Populate resolv.conf setup files IF we have resolvers information.
+zonecfg -z $ZONENAME info attr name=resolvers | grep -q resolvers
+if [[ $? == 0 ]]; then
+ zonecfg -z $ZONENAME info attr name=resolvers | awk '
+ BEGIN {
print("# AUTOMATIC ZONE CONFIG")
-}
-$1 == "value:" {
+ }
+ $1 == "value:" {
nres = split($2, resolvers, ",");
for (i = 1; i <= nres; i++) {
print("nameserver", resolvers[i]);
}
-}
-' > $tmpfile
-zonecfg -z $ZONENAME info attr name=dns-domain | awk '
-$1 == "value:" {
+ }
+ ' > $tmpfile
+ zonecfg -z $ZONENAME info attr name=dns-domain | awk '
+ $1 == "value:" {
dom = $2
-}
-END {
+ }
+ END {
print("search", dom);
-}
-' >> $tmpfile
-fnm=$ZONEROOT/etc/resolv.conf
-if [[ -f $fnm || -h $fnm ]]; then
+ }
+ ' >> $tmpfile
+ fnm=$ZONEROOT/etc/resolv.conf
+ if [[ -f $fnm || -h $fnm ]]; then
mv -f $tmpfile $fnm
+ fi
fi
# Override network configuration
diff --git a/usr/src/lib/brand/lx/zone/lx_boot_zone_redhat.ksh b/usr/src/lib/brand/lx/zone/lx_boot_zone_redhat.ksh
index 566b401c18..1d70ed56cf 100644
--- a/usr/src/lib/brand/lx/zone/lx_boot_zone_redhat.ksh
+++ b/usr/src/lib/brand/lx/zone/lx_boot_zone_redhat.ksh
@@ -12,7 +12,7 @@
#
# Copyright 2015 Joyent, Inc.
-# Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved.
+# Copyright 2016 OmniTI Computer Consulting, Inc. All rights reserved.
#
#
@@ -57,14 +57,20 @@ case "\$1" in
start)
[ "\$EUID" != "0" ] && exit 4
+EOF
+
+# Alter resolv.conf if we're pulling resolver information from zonecfg(1M).
+zonecfg -z $ZONENAME info attr name=resolvers | grep -q resolvers
+if [[ $? == 0 ]]; then
+ cat >> $tmpfile <<EOF
if [ ! -e /etc/resolv.conf ]; then
if [ -h /etc/resolv.conf ]; then
rm -f /etc/resolv.conf
fi
echo "# AUTOMATIC ZONE CONFIG" > /etc/resolv.conf
EOF
-zonecfg -z $ZONENAME info attr name=resolvers |
-awk '
+ zonecfg -z $ZONENAME info attr name=resolvers |
+ awk '
{
if ($1 == "value:") {
nres = split($2, resolvers, ",")
@@ -76,9 +82,9 @@ awk '
"/etc/resolv.conf")
}
}
-' >> $tmpfile
-zonecfg -z $ZONENAME info attr name=dns-domain |
-awk '
+ ' >> $tmpfile
+ zonecfg -z $ZONENAME info attr name=dns-domain |
+ awk '
{
if ($1 == "value:") {
dom = $2
@@ -87,9 +93,13 @@ awk '
END {
printf(" echo \"search %s\" >> %s\n", dom, "/etc/resolv.conf")
}
-' >> $tmpfile
-cat >> $tmpfile <<EOF
+ ' >> $tmpfile
+ cat >> $tmpfile <<EOF
fi
+EOF
+fi
+
+cat >> $tmpfile <<EOF
touch /var/lock/subsys/network
rc=0
;;
@@ -172,7 +182,7 @@ if ! egrep -s "NETWORKING=yes" $fnm; then
cat > $fnm <<- EOF
NETWORKING=yes
HOSTNAME=$cfghnm
- EOF
+EOF
fi
fi
@@ -282,7 +292,7 @@ if [[ ! -f $ZONEROOT/etc/init/tty.override ]]; then
respawn
instance console
exec /sbin/mingetty console
- EOF
+EOF
fi
if [[ ! -f $ZONEROOT/etc/init/start-ttys.override ]]; then
@@ -296,7 +306,7 @@ if [[ ! -f $ZONEROOT/etc/init/start-ttys.override ]]; then
script
initctl start tty
end script
- EOF
+EOF
fi
#
diff --git a/usr/src/lib/brand/lx/zone/lx_boot_zone_suse.ksh b/usr/src/lib/brand/lx/zone/lx_boot_zone_suse.ksh
index dd8b4e3721..b8e3b69b21 100644
--- a/usr/src/lib/brand/lx/zone/lx_boot_zone_suse.ksh
+++ b/usr/src/lib/brand/lx/zone/lx_boot_zone_suse.ksh
@@ -43,7 +43,7 @@ safe_opt_dir /etc/systemd/system/network-online.target.wants
safe_dir /etc/YaST2
safe_opt_dir /etc/selinux
-# Populate resolve.conf setup files
+# Populate resolv.conf setup files
zonecfg -z $ZONENAME info attr name=resolvers | awk '
BEGIN {
print("# AUTOMATIC ZONE CONFIG")
diff --git a/usr/src/lib/brand/lx/zone/lx_boot_zone_ubuntu.ksh b/usr/src/lib/brand/lx/zone/lx_boot_zone_ubuntu.ksh
index 27d047e4ca..97629094fd 100644
--- a/usr/src/lib/brand/lx/zone/lx_boot_zone_ubuntu.ksh
+++ b/usr/src/lib/brand/lx/zone/lx_boot_zone_ubuntu.ksh
@@ -12,6 +12,7 @@
#
# Copyright 2016 Joyent, Inc.
+# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
#
#
@@ -28,30 +29,32 @@ safe_dir /etc/resolvconf/resolv.conf.d
safe_dir /etc/network
safe_dir /etc/network/interfaces.d
safe_dir /etc/network/interfaces.d/smartos
-
-# Populate resolve.conf setup files
-zonecfg -z $ZONENAME info attr name=resolvers | awk '
-BEGIN {
- print("# AUTOMATIC ZONE CONFIG")
-}
-$1 == "value:" {
- nres = split($2, resolvers, ",");
- for (i = 1; i <= nres; i++) {
- print("nameserver", resolvers[i]);
- }
-}
-' > $tmpfile
-zonecfg -z $ZONENAME info attr name=dns-domain | awk '
-$1 == "value:" {
- dom = $2
-}
-END {
- print("search", dom);
-}
-' >> $tmpfile
-fnm=$ZONEROOT/etc/resolvconf/resolv.conf.d/tail
-if [[ -f $fnm || -h $fnm || ! -e $fnm ]]; then
- mv -f $tmpfile $fnm
+safe_dir /etc/systemd
+
+# Populate resolv.conf setup files IFF we have resolvers information.
+resolvers=`zone_attr resolvers`
+if [[ $? == 0 ]]; then
+
+ echo "# AUTOMATIC ZONE CONFIG" > $tmpfile
+ _IFS=$IFS; IFS=,; for r in $resolvers; do
+ echo "nameserver $r"
+ done >> $tmpfile
+ IFS=$_IFS
+ domain=`zone_attr dns-domain`
+ [[ $? == 0 ]] && echo "search $domain" >> $tmpfile
+
+ if [ -f $ZONEROOT/etc/systemd/resolved.conf ]; then
+ cf=$ZONEROOT/etc/systemd/resolved.conf
+ sed -i -E '/^(DNS|Domains) *=/d' $cf
+ echo "DNS=$resolvers" >> $cf
+ [[ -n "$domain" ]] && echo "Domains=$domain" >> $cf
+ mv -f $tmpfile $ZONEROOT/etc/resolv.conf
+ else
+ fnm=$ZONEROOT/etc/resolvconf/resolv.conf.d/tail
+ if [[ -f $fnm || -h $fnm || ! -e $fnm ]]; then
+ mv -f $tmpfile $fnm
+ fi
+ fi
fi
# Override network configuration