[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#657640: lb_chroot_resolv fails when /etc/resolv.conf is a symlink (resolvconf)



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Package: src:live-build

Hello,

Ubuntu recently switched to using resolvconf by default, this change
showed a small issue in live-build in the way it deals with existing
/etc/resolv.conf, more specifically when it's a symlink.

The current live-build script will do a "test -e" on /etc/resolv.conf
which won't succeed when it's a dangling symlink. It then assumes it
can simply copy the /etc/resolv.conf from the outside into the chroot
but this makes cp fail (can't copy file to dangling symlink).

The attached patch detected that /etc/resolv.conf in the chroot is a
symlink and in such case, moves it aside to .orig but doesn't attempt
to Truncate it (which would obviously fail).

In the remove target, we now check for both -e and -L and restore the
.orig copy of resolv.conf.

- -- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBCgAGBQJPItQeAAoJEMY4l01keS1nv5EP/A+xp5oJc21JyHnKi12upwMc
WzIqVfK/3Eop/4nshOwCpMbt/Y605jaci/81rol0OCSCPgskAJ5a+rWMPxHdGfDp
ZUpHL1a4GCVIbhlv1gW+qVJKGyiu86lt4R6b4vPQf8ILSKB+/+dugJ3FfLOF+BI7
qBQQE6RBFkeJwuQXaFJFNAJQgkNczOHhsv8xnRPwy/xsBzDPDXDzPYMYhI7wNiRn
qcsZbuWxK0IRz6FvucZye7Gm3FBzgwHoIweXhYNWC+9Uk1PoujeAJq/kkweO/k0z
WFdE/65lJ0BiJ73H7nAShOPsYuo14CpbT2Vv1bJMxKvaeUp/qonryQbfAh/LaRZc
MeqiKxY2k/j7RocVJKI221dDfIm6B22cGYMFKkDrN30db7l8uV3fwn7i+iQEZH54
NLcCwp6myDRwiQIDhMfz4+JNYiu0MW7TkQROeBAG97fiD1nXIJA/1Uy5sc2HDezj
n6jqzjuSwfyNAbOW4hMWu8Co/pn8QiDUjbYmwsgzQTHUZFUxUGiTUkxcEwTPAyi2
C1/kPlYeR2kXOGAqY2puYbGEVqdNoxGdigAvnYSyHx6ncK6oQD/BJhBzbGYQ7vtM
wsxKZO09cMnGlKQenfWgCibU451FhHlFZA30D3nfExSglPBGyRs13I08cSiMvjgc
zmtoIbho1jjyYd4WFuKv
=SUm7
-----END PGP SIGNATURE-----
diff -Nrup live-build-3.0~a42/scripts/build/lb_chroot_resolv new/scripts/build/lb_chroot_resolv
--- live-build-3.0~a42/scripts/build/lb_chroot_resolv	2012-01-12 05:37:06.000000000 -0500
+++ new/scripts/build/lb_chroot_resolv	2012-01-27 11:22:54.220719008 -0500
@@ -51,6 +51,10 @@ case "${1}" in
 			# If you want to have a custom resolv.conf, please
 			# overwrite it with normal local_includes mechanism.
 			Truncate chroot/etc/resolv.conf.orig
+		elif [ -L chroot/etc/resolv.conf ]
+		then
+			# Move resolv.conf aside if it's a symlink (likely resolvconf)
+			mv chroot/etc/resolv.conf chroot/etc/resolv.conf.orig
 		fi
 
 		if [ -f /etc/resolv.conf ]
@@ -77,7 +81,7 @@ case "${1}" in
 			# Copying local resolv.conf
 			cp -a config/includes.chroot/etc/resolv.conf chroot/etc/resolv.conf
 			rm -f chroot/etc/resolv.conf.orig
-		elif [ -e chroot/etc/resolv.conf.orig ]
+		elif [ -e chroot/etc/resolv.conf.orig ] || [ -L chroot/etc/resolv.conf.orig ]
 		then
 			# Restoring resolv file or symlink
 			mv chroot/etc/resolv.conf.orig chroot/etc/resolv.conf

Attachment: resolvconf.diff.sig
Description: Binary data


Reply to: