From 94ef7f994663bcc9cd6553496cd7a46b4182cf91 Mon Sep 17 00:00:00 2001 From: Christian Hofstaedtler Date: Mon, 26 Dec 2011 17:59:26 +0100 Subject: [PATCH] Unconditionally reset resolv.conf in chroot --- etc/grml/fai/config/hooks/instsoft.GRMLBASE | 31 +++------------------- .../fai/config/scripts/GRMLBASE/98-clean-chroot | 22 +++++++-------- 2 files changed, 14 insertions(+), 39 deletions(-) diff --git a/etc/grml/fai/config/hooks/instsoft.GRMLBASE b/etc/grml/fai/config/hooks/instsoft.GRMLBASE index 51a0e77..a3c3d2f 100755 --- a/etc/grml/fai/config/hooks/instsoft.GRMLBASE +++ b/etc/grml/fai/config/hooks/instsoft.GRMLBASE @@ -20,33 +20,10 @@ fi if [ "$FAI_ACTION" = "softupdate" ] ; then echo "Action $FAI_ACTION of FAI (hooks/instsoft.GRMLBASE) via grml-live running" - if [ -r /etc/resolv.conf ] ; then - case "$(chroot $target readlink -f /etc/resolv.conf)" in - /run/*) # resolvconf with /run - mkdir -p $target/run/resolvconf - cat /etc/resolv.conf >> $target/run/resolvconf/resolv.conf - ;; - /lib/*) # resolvconf without /run - # sanity check to avoid "input file is output file", - # see http://bts.grml.org/grml/issue984 - if ! [ -L $target/etc/resolvconf/run/resolv.conf ] ; then - cat /etc/resolv.conf >> $target/etc/resolvconf/run/resolv.conf - else - echo "Error: /etc/resolvconf/run/resolv.conf in chroot should not be a symlink." >&2 - echo " Looks like something is wrong, please fix manually." >&2 - exit 1 - fi - ;; - *) # no resolvconf - if ! [ -L $target/etc/resolv.conf ] ; then - cat /etc/resolv.conf >> $target/etc/resolv.conf - else - echo "Error: /etc/resolv.conf in chroot should not be a symlink (resolvconf not installed)." >&2 - exit 1 - fi - ;; - esac - fi + # /etc/resolv.conf is usually a symlink, pointing out of the chroot. + # Make it a file with known contents. + rm -f "${target}"/etc/resolv.conf + cat /etc/resolv.conf >> "$target"/etc/resolv.conf if [ -r $target/etc/policy-rc.d.conf ] ; then sed -i "s/EXITSTATUS=.*/EXITSTATUS='101'/" $target/etc/policy-rc.d.conf diff --git a/etc/grml/fai/config/scripts/GRMLBASE/98-clean-chroot b/etc/grml/fai/config/scripts/GRMLBASE/98-clean-chroot index 712ef68..d36013c 100755 --- a/etc/grml/fai/config/scripts/GRMLBASE/98-clean-chroot +++ b/etc/grml/fai/config/scripts/GRMLBASE/98-clean-chroot @@ -188,23 +188,21 @@ if ! [ -d $target/etc/resolvconf ] ; then echo "Warning: resolvconf not installed" else echo "Setting up resolvconf" - if [ -L $target/etc/resolvconf/run ] ; then # resolvconf with /run - # /etc/resolvconf/run symlinks to /run/resolvconf - RESOLV_CONF=/run/resolvconf/ - else # no /run present - RESOLV_CONF=/etc/resolvconf/run/ - fi - - rm -rf ${target}/${RESOLV_CONF} - mkdir -p ${target}/${RESOLV_CONF} + if [ ! -L $target/etc/resolvconf/run ] ; then # resolvconf without symlink?! + RESOLV_CONF=/etc/resolvconf/run + rm -rf ${target}/${RESOLV_CONF} + mkdir -p ${target}/${RESOLV_CONF} - touch ${target}/${RESOLV_CONF}/enable-updates - mkdir ${target}/${RESOLV_CONF}/interface + touch ${target}/${RESOLV_CONF}/enable-updates + mkdir ${target}/${RESOLV_CONF}/interface - cat > ${target}/${RESOLV_CONF}/resolv.conf << EOF + cat > ${target}/${RESOLV_CONF}/resolv.conf << EOF # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN EOF + fi + rm -f ${target}/etc/resolv.conf + $ROOTCMD ln -s /etc/resolvconf/run/resolv.conf /etc/resolv.conf fi if ! $ROOTCMD test -x /usr/bin/updatedb ; then -- 2.1.4