On Wed, Jul 09, 2014 at 12:00:26PM +0000, Thorsten Glaser wrote:
> gregor herrmann dixit:
> 
> >That doesn't match my understanding and experience. AFAIK, there is
> >no internet access (available|allowed) but connections to localhost
> >are fine.

Yes. There are many packages in the archive relying on this.

> Hm, maybe something like, enabling lo0 in the chroot before
> running the build itself – could that work?
> 
> Not really…
> 
> /var/cache/pbuilder/base.cow-squeeze/{,usr/}*bin/{ifconfig,ip} do not
> exist. Are there any other tools that could be used for this? (squeeze
> being the first version with “unshare -n”, AFAICT.)

I don't see why you need to do it in the chroot? See the attached
patch.  It's only lightly tested but seems to work. It needs a
(linux-only?) dependency on iproute2, of course (unless you prefer
ifconfig instead).

> In case of doubt, just build those packages with USENETWORK=yes…
> at least for now.

I really think this needs to be fixed.
-- 
Niko Tyni   [email protected]
>From e8013b24697b8190a2afbd47bed627ddff7882fc Mon Sep 17 00:00:00 2001
From: Niko Tyni <[email protected]>
Date: Fri, 11 Jul 2014 08:41:46 +0300
Subject: [PATCH] Enable the loopback device even when USE_NETWORK=no

Many packages in the Debian archive rely on the loopback device
for their test suites.
---
 Makefile                 | 1 +
 pbuilder-buildpackage    | 7 ++++---
 pbuilder-unshare-wrapper | 4 ++++
 3 files changed, 9 insertions(+), 3 deletions(-)
 create mode 100755 pbuilder-unshare-wrapper

diff --git a/Makefile b/Makefile
index 299498b..170f78d 100644
--- a/Makefile
+++ b/Makefile
@@ -58,6 +58,7 @@ PKGLIB_SCRIPTS += \
 	pbuilder-satisfydepends-gdebi \
 	pbuilder-selftest \
 	pbuilder-uml-checkparams \
+	pbuilder-unshare-wrapper \
 	pbuilder-updatebuildenv \
 	pdebuild-checkparams \
 	pdebuild-internal \
diff --git a/pbuilder-buildpackage b/pbuilder-buildpackage
index 2158cbe..01162ec 100755
--- a/pbuilder-buildpackage
+++ b/pbuilder-buildpackage
@@ -48,6 +48,7 @@ else
     SUTOUSER=" env LOGNAME=$BUILDUSERNAME /bin/sh"
 fi
 
+UNSHARE=
 case $USENETWORK in
 yes)
 	if [ "$DEB_BUILD_ARCH_OS" = "linux" ]; then
@@ -56,9 +57,9 @@ yes)
 	fi
 	;;
 *)
-	if $CHROOTEXEC /usr/bin/unshare -n true; then
+	if /usr/bin/unshare -n true && /usr/lib/pbuilder/pbuilder-unshare-wrapper true; then
 		USENETWORK=no
-		SUTOUSER="/usr/bin/unshare -n -- $SUTOUSER"
+		UNSHARE="/usr/bin/unshare -n -- /usr/lib/pbuilder/pbuilder-unshare-wrapper"
 		log "I: pbuilder: network access will be disabled during build"
 	else
 		USENETWORK=yes
@@ -154,7 +155,7 @@ DPKG_COMMANDLINE="env PATH=\"$PATH\" dpkg-buildpackage -us -uc ${DEBEMAIL:+\"-e$
     fi
     DPKG_COMMANDLINE="cd tmp/buildd/*/ && $DPKG_COMMANDLINE"
     log "I: Running $DPKG_COMMANDLINE"
-    echo "$DPKG_COMMANDLINE" | $CHROOTEXEC $SUTOUSER
+    echo "$DPKG_COMMANDLINE" | $UNSHARE $CHROOTEXEC $SUTOUSER
 ) &
 BUILD_PID=$!
 if [ -n "${TIMEOUT_TIME}" ]; then
diff --git a/pbuilder-unshare-wrapper b/pbuilder-unshare-wrapper
new file mode 100755
index 0000000..144926b
--- /dev/null
+++ b/pbuilder-unshare-wrapper
@@ -0,0 +1,4 @@
+#!/bin/sh
+set -e
+ip link set lo up
+exec "$@"
-- 
2.0.1

Reply via email to