Browse Source

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
tags/debian/1.8.0_alpha3
Julian Andres Klode 2 years ago
parent
commit
d57834a36e
8 changed files with 67 additions and 0 deletions
  1. +4
    -0
      apt-pkg/deb/debsystem.cc
  2. +3
    -0
      apt-pkg/deb/dpkgpm.cc
  3. +3
    -0
      apt-pkg/init.cc
  4. +8
    -0
      debian/NEWS
  5. +7
    -0
      doc/apt.conf.5.xml
  6. +4
    -0
      doc/examples/configure-index
  7. +3
    -0
      test/integration/framework
  8. +35
    -0
      test/integration/test-dpkg-path

+ 4
- 0
apt-pkg/deb/debsystem.cc View File

@@ -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);


+ 3
- 0
apt-pkg/deb/dpkgpm.cc View File

@@ -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);


+ 3
- 0
apt-pkg/init.cc View File

@@ -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");


+ 8
- 0
debian/NEWS View File

@@ -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


+ 7
- 0
doc/apt.conf.5.xml View File

@@ -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;.


+ 4
- 0
doc/examples/configure-index View File

@@ -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";};


+ 3
- 0
test/integration/framework View File

@@ -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



+ 35
- 0
test/integration/test-dpkg-path View File

@@ -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

Loading…
Cancel
Save