summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2018-12-10 17:35:33 +0000
committerJulian Andres Klode <jak@debian.org>2018-12-10 17:35:33 +0000
commitd57834a36e6adebbad28819360a984819995b376 (patch)
tree36a39bad37db8082f26427659817d882a6b0b8d8
parent294b5e77a25d2600e7f3ce12a996d1694b5be817 (diff)
parent806e94dcd8dbdf7bf1909657fd4331cfe17b4ab0 (diff)
Merge branch 'pu/dpkg-path' into 'master'
Set PATH=/usr/sbin:/usr/bin:/sbin:/bin when running dpkg See merge request apt-team/apt!38
-rw-r--r--apt-pkg/deb/debsystem.cc4
-rw-r--r--apt-pkg/deb/dpkgpm.cc3
-rw-r--r--apt-pkg/init.cc3
-rw-r--r--debian/NEWS8
-rw-r--r--doc/apt.conf.5.xml7
-rw-r--r--doc/examples/configure-index4
-rw-r--r--test/integration/framework3
-rwxr-xr-xtest/integration/test-dpkg-path35
8 files changed, 67 insertions, 0 deletions
diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc
index 0a9e98d6d..5df6c58a1 100644
--- a/apt-pkg/deb/debsystem.cc
+++ b/apt-pkg/deb/debsystem.cc
@@ -398,6 +398,10 @@ pid_t debSystem::ExecDpkg(std::vector<std::string> const &sArgs, int * const inp
{
setenv("DPKG_FRONTEND_LOCKED", "true", 1);
}
+
+ if (_config->Find("DPkg::Path", "").empty() == false)
+ setenv("PATH", _config->Find("DPkg::Path", "").c_str(), 1);
+
execvp(Args[0], (char**) &Args[0]);
_error->WarningE("dpkg", "Can't execute dpkg!");
_exit(100);
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 074e52b3f..3c707e220 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -2017,6 +2017,9 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
&& dynamic_cast<debSystem*>(_system)->IsLocked() == true) {
setenv("DPKG_FRONTEND_LOCKED", "true", 1);
}
+ if (_config->Find("DPkg::Path", "").empty() == false)
+ setenv("PATH", _config->Find("DPkg::Path", "").c_str(), 1);
+
execvp(Args[0], (char**) &Args[0]);
cerr << "Could not exec dpkg!" << endl;
_exit(100);
diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc
index d98affe06..a619368ec 100644
--- a/apt-pkg/init.cc
+++ b/apt-pkg/init.cc
@@ -209,6 +209,9 @@ bool pkgInitConfig(Configuration &Cnf)
Cnf.CndSet("Acquire::Changelogs::URI::Origin::Ubuntu", "https://changelogs.ubuntu.com/changelogs/pool/@CHANGEPATH@/changelog");
Cnf.CndSet("Acquire::Changelogs::AlwaysOnline::Origin::Ubuntu", true);
+
+ Cnf.CndSet("DPkg::Path", "/usr/sbin:/usr/bin:/sbin:/bin");
+
// Read an alternate config file
_error->PushToStack();
const char *Cfg = getenv("APT_CONFIG");
diff --git a/debian/NEWS b/debian/NEWS
index 95c2d27fd..95725b261 100644
--- a/debian/NEWS
+++ b/debian/NEWS
@@ -1,3 +1,11 @@
+apt (1.8.0~alpha3) UNRELEASED; urgency=medium
+
+ The PATH for running dpkg is now configured by the option DPkg::Path,
+ and defaults to "/usr/sbin:/usr/bin:/sbin/:bin". Previous behavior of
+ not changing PATH may be restored by setting the option to an empty string.
+
+ -- Julian Andres Klode <jak@debian.org> Mon, 10 Dec 2018 16:51:36 +0100
+
apt (1.6~rc1) unstable; urgency=medium
Seccomp sandboxing has been turned off by default for now. If it works
diff --git a/doc/apt.conf.5.xml b/doc/apt.conf.5.xml
index 64a26bc4a..ffbcba5a4 100644
--- a/doc/apt.conf.5.xml
+++ b/doc/apt.conf.5.xml
@@ -776,6 +776,13 @@ APT::Compressor::rev {
using the list notation and each list item is passed as a single argument
to &dpkg;.</para></listitem>
</varlistentry>
+
+ <varlistentry><term><option>Path</option></term>
+ <listitem><para>This is a string that defines the <envar>PATH</envar>
+ environment variable used when running dpkg. It may be set to any
+ valid value of that environment variable; or the empty string, in
+ which case the variable is not changed.</para></listitem>
+ </varlistentry>
<varlistentry><term><option>Pre-Invoke</option></term><term><option>Post-Invoke</option></term>
<listitem><para>This is a list of shell commands to run before/after invoking &dpkg;.
diff --git a/doc/examples/configure-index b/doc/examples/configure-index
index 3dd6e0afc..743e676de 100644
--- a/doc/examples/configure-index
+++ b/doc/examples/configure-index
@@ -462,6 +462,10 @@ DPkg
// Probably don't want to use force-downgrade..
Options {"--force-overwrite";"--force-downgrade";}
+ // Defaults to /usr/sbin:/usr/bin:/sbin:/bin, might be set to empty
+ // string to inherit from environment
+ Path "<STRING>";
+
// Auto re-mounting of a readonly /usr
Pre-Invoke {"mount -o remount,rw /usr";};
Post-Invoke {"mount -o remount,ro /usr";};
diff --git a/test/integration/framework b/test/integration/framework
index 8ec2e80cf..e7b82c273 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -482,6 +482,9 @@ EOF
unset GREP_OPTIONS POSIXLY_CORRECT
unset http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy
+ # Make dpkg inherit testing path
+ echo 'DPkg::Path "";\n' >> aptconfig.conf
+
# Make gcov shut up
export GCOV_ERROR_FILE=/dev/null
diff --git a/test/integration/test-dpkg-path b/test/integration/test-dpkg-path
new file mode 100755
index 000000000..b17b59421
--- /dev/null
+++ b/test/integration/test-dpkg-path
@@ -0,0 +1,35 @@
+#!/bin/sh
+set -e
+
+TESTDIR="$(readlink -f "$(dirname "$0")")"
+. "$TESTDIR/framework"
+
+setupenvironment
+configarchitecture 'native'
+configdpkgnoopchroot
+
+# create a bunch of test pkgs
+createtestpkg() {
+ setupsimplenativepackage "testpkg-$1" 'native' '1.0' 'unstable'
+ BUILDDIR="incoming/testpkg-$1-1.0"
+ echo '#!/bin/sh
+echo PATH=$PATH' > "${BUILDDIR}/debian/preinst"
+ buildpackage "$BUILDDIR" 'unstable' 'main' 'native'
+ rm -rf "$BUILDDIR"
+}
+
+createtestpkg 'one'
+createtestpkg 'two'
+
+setupaptarchive
+
+
+# Inherit from environment
+testsuccess aptget install testpkg-one -y -o DPkg::Path=""
+cp rootdir/tmp/testsuccess.output apt.log
+testsuccess grep "PATH=$PATH" apt.log
+
+# Set a custom value
+testsuccess aptget install testpkg-two -y -o DPkg::Path="foobar:$PATH"
+cp rootdir/tmp/testsuccess.output apt.log
+testsuccess grep "PATH=foobar:$PATH" apt.log