Package: pbuilder
Version: 0.230.4
Followup-For: Bug #865637
Dear Maintainer,
I'm using
pdebuild --use-pdebuild-internal
which today failed for CUPS: It evaulates $USER for its test case, which
is still set to 'root' despite using 'su pbuser'. 'cupsd' then failes to
start as it refuses to run as user 'root':
$ ps axfuww
> pbuser 9225 | \_ /bin/bash /usr/bin/pdebuild --use-pdebuild-internal
> --buildresult /var/build/temp/tmp.BwTBJbBy00/result --debbuildopts -F -sa --
> --basetgz /var/buildsystem2/pbuilder/errata4.4-1.tgz --buildplace
> /var/build/temp/tmp.BwTBJbBy00/pbuilder/ --architecture i386
> pbuser 9247 | \_ /bin/bash /usr/bin/pdebuild --use-pdebuild-internal
> --buildresult /var/build/temp/tmp.BwTBJbBy00/result --debbuildopts -F -sa --
> --basetgz /var/buildsystem2/pbuilder/errata4.4-1.tgz --buildplace
> /var/build/temp/tmp.BwTBJbBy00/pbuilder/ --architecture i386
> pbuser 9249 | | \_ tee
> ../cups_2.2.1-8+deb9u4A~4.4.1.201909091134_i386.build
> root 9252 | \_ sudo pbuilder --execute --bindmounts
> /var/build/temp/tmp.BwTBJbBy00 --basetgz
> /var/buildsystem2/pbuilder/errata4.4-1.tgz --buildplace
> /var/build/temp/tmp.BwTBJbBy00/pbuilder/ --architecture i386 --
> /usr/lib/pbuilder/pdebuild-internal /var/build/temp/tmp.BwTBJbBy00/cups-2.2.1
> --debbuildopts --debbuildopts -F -sa --uid 2113 --gid 5001
> --pbuildersatisfydepends /usr/lib/pbuilder/pbuilder-satisfydepends
> root 9254 | \_ /bin/bash /usr/sbin/pbuilder --execute
> --bindmounts /var/build/temp/tmp.BwTBJbBy00 --basetgz
> /var/buildsystem2/pbuilder/errata4.4-1.tgz --buildplace
> /var/build/temp/tmp.BwTBJbBy00/pbuilder/ --architecture i386 --
> /usr/lib/pbuilder/pdebuild-internal /var/build/temp/tmp.BwTBJbBy00/cups-2.2.1
> --debbuildopts --debbuildopts -F -sa --uid 2113 --gid 5001
> --pbuildersatisfydepends /usr/lib/pbuilder/pbuilder-satisfydepends
> root 9323 | \_ /bin/bash /runscript
> /var/build/temp/tmp.BwTBJbBy00/cups-2.2.1 --debbuildopts --debbuildopts -F
> -sa --uid 2113 --gid 5001 --pbuildersatisfydepends
> /usr/lib/pbuilder/pbuilder-satisfydepends
> root 12141 | \_ su -p pbuser
> pbuser 12142 | \_ bash
> pbuser 12143 | \_ /usr/bin/perl
> /usr/bin/dpkg-buildpackage -rfakeroot -us -uc -F -sa
> pbuser 12567 | \_ /usr/bin/make -f
> debian/rules build
> pbuser 12624 | \_ /usr/bin/perl
> /usr/bin/dh build --with systemd
> pbuser 22812 | \_ /usr/bin/make -f
> debian/rules override_dh_auto_test
> pbuser 22830 | \_ /bin/sh -c
> CUPS_TESTBASE=/tmp/cups.IIYDf2 make check
> pbuser 22831 | \_ make check
> pbuser 23659 | \_ /bin/sh
> -c cd test; ./run-stp-tests.sh 1 0 n n
> pbuser 23660 | \_
> /bin/sh ./run-stp-tests.sh 1 0 n n
> pbuser 5840 | \_
> sleep 10
> pbuser 9219 \_ tee -i -a
> /var/buildsystem2/logs/errata4.4-1/cups_2.2.1-8+deb9u4A~4.4.1.201909091134.log
$ xargs -0 -n1 -a /proc/12142/environ echo | grep -e USER -e LOGNAME -e HOME -e
PATH
> USERNAME=root
> USER=root
> HOME=/var/build/temp/tmp.BwTBJbBy00
> SUDO_USER=build
> LOGNAME=root
> PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
/usr/lib/pbuilder/pdebuild-internal:
> 130 CMD="env PATH=$PATH dpkg-buildpackage -rfakeroot -us -uc $DEBBUILDOPTS"
> 135 su -p pbuser;ยท
It was changed by git:4d6220c0d2e3abdcf247838168591e9d5e4a078b
> author dancer <dancer> Mon Jun 5 11:39:03 2006 +0000
>
> su -p for pdebuild-internal, to allow options passing through environment.
pbuilder should really provide a clean environment or at least provide
sane defaults for the environment variables listed in <man:su(1)>:
- HOME (done)
- PATH (done)
- USER (missing)
- LOGNAME (missing)
- SHELL (missing)
and also
- XDG_CONFIG_HOME
- TMPDIR (breaks every 'mktemp' when combined with 'pam_tmpdir.so')
- ...
See attached patch.
-- System Information:
Debian Release: 10.1
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 4.19.0-5-amd64 (SMP w/4 CPU cores)
Kernel taint flags: TAINT_WARN
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8),
LANGUAGE=de:en_US (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages pbuilder depends on:
ii debconf [debconf-2.0] 1.5.71
ii debootstrap 1.0.114
ii dpkg-dev 1.19.7
Versions of packages pbuilder recommends:
ii devscripts 2.19.5+deb10u1
ii eatmydata 105-7
ii fakeroot 1.23-1
ii iproute2 4.20.0-2
ii sudo 1.8.27-1
Versions of packages pbuilder suggests:
pn cowdancer <none>
pn gdebi-core <none>
-- debconf information excluded
>From 8b1d237f8df78fb371e02951231257cb519c5dbe Mon Sep 17 00:00:00 2001
Message-Id:
<8b1d237f8df78fb371e02951231257cb519c5dbe.1568030448.git.h...@univention.de>
From: Philipp Hahn <[email protected]>
Date: Mon, 9 Sep 2019 13:29:33 +0200
Subject: [PATCH] Clean pbuilder environment
To: Debian pbuilder maintenance team <[email protected]>
Initialize at least the following environment variables when using `su
-p` to provide a sane environment:
- HOME
- PATH
- USER
- LOGNAME
- SHELL
Also setup shell for user `pbuser`.
As use `eval` inside the chroot environment shell instead of piping in
the command on STDIN.
<https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=865637>
---
pdebuild-internal | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/pdebuild-internal b/pdebuild-internal
index b6bd601..3e99990 100644
--- a/pdebuild-internal
+++ b/pdebuild-internal
@@ -33,9 +33,6 @@ set -e
# passwd is needed as well because of useradd and groupadd calls.
apt-get install -q -y "${APTGETOPT[@]}" pbuilder passwd
-# I'm not going to have the same LOGNAME as outside, I'm root.
-export LOGNAME=root
-
cd "$1"
shift;
@@ -119,7 +116,7 @@ fi
# TODO: what about id -G output? if other groups than the designated
# is used, we're stuffed.
groupadd -g "${BUILDRESULTGID}" -o pbgroup
-useradd -g pbgroup -u "${BUILDRESULTUID}" -d "${HOME}" -o pbuser
+useradd -g pbgroup -u "${BUILDRESULTUID}" -d "${HOME}" -s "${SHELL}" -o pbuser
executehooks "A"
@@ -127,13 +124,12 @@ executehooks "A"
# $DEBBUILDOPTS is expanded here, but split inside the su, to ensure the
# options are de-quoted (and de-escaped) like pbuilder-buildpackage.
export DEBBUILDOPTS
-CMD="env PATH=$PATH dpkg-buildpackage -rfakeroot -us -uc $DEBBUILDOPTS"
+CMD="eval env 'PATH=$PATH' 'USER=pbuser' 'LOGNAME=pbuser' 'SHELL=$SHELL'
'HOME=$HOME' dpkg-buildpackage -rfakeroot -us -uc $DEBBUILDOPTS"
echo "I: Running $CMD"
# This command should be ran with current directory as bind-mounted
# package source directory
-if echo "$CMD" | \
- su -p pbuser;
- then
+if su -c "$CMD" -p pbuser
+then
# build was successful
:
else
--
2.20.1