From 806e94dcd8dbdf7bf1909657fd4331cfe17b4ab0 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 10 Dec 2018 16:52:59 +0100 Subject: Set PATH=/usr/sbin:/usr/bin:/sbin:/bin when running dpkg This avoids a lot of problems from local installations of scripting languages and other stuff in /usr/local for which maintainer scripts are not prepared. [v3: Inherit PATH during tests, check overrides work] [v2: Add testing] --- apt-pkg/deb/debsystem.cc | 4 ++++ apt-pkg/deb/dpkgpm.cc | 3 +++ 2 files changed, 7 insertions(+) (limited to 'apt-pkg/deb') 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 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(_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); -- cgit v1.2.3