X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/b58e2c7c56b1416a343e81f9f80cb1f02c128e25..0dd19915f44df0048d594d527797c62ab6195cc6:/apt-private/private-install.cc diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc index 7bd9a6034..aa28780da 100644 --- a/apt-private/private-install.cc +++ b/apt-private/private-install.cc @@ -521,8 +521,13 @@ bool DoAutomaticRemove(CacheFile &Cache) ioprintf(c1out, P_("%lu package was automatically installed and is no longer required.\n", "%lu packages were automatically installed and are no longer required.\n", autoRemoveCount), autoRemoveCount); std::string autocmd = "apt autoremove"; - if (getenv("SUDO_USER") != NULL) - autocmd = "sudo " + autocmd; + if (getenv("SUDO_USER") != nullptr) + { + auto const envsudocmd = getenv("SUDO_COMMAND"); + auto const envshell = getenv("SHELL"); + if (envsudocmd == nullptr || envshell == nullptr || strcmp(envsudocmd, envshell) != 0) + autocmd = "sudo " + autocmd; + } ioprintf(c1out, P_("Use '%s' to remove it.", "Use '%s' to remove them.", autoRemoveCount), autocmd.c_str()); c1out << std::endl; } @@ -535,15 +540,15 @@ static const unsigned short MOD_INSTALL = 2; bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache, int UpgradeMode) { - std::vector VolatileCmdL; + std::vector VolatileCmdL; return DoCacheManipulationFromCommandLine(CmdL, VolatileCmdL, Cache, UpgradeMode); } -bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, std::vector &VolatileCmdL, CacheFile &Cache, int UpgradeMode) +bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, std::vector &VolatileCmdL, CacheFile &Cache, int UpgradeMode) { std::map verset; return DoCacheManipulationFromCommandLine(CmdL, VolatileCmdL, Cache, verset, UpgradeMode); } -bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, std::vector &VolatileCmdL, CacheFile &Cache, +bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, std::vector &VolatileCmdL, CacheFile &Cache, std::map &verset, int UpgradeMode) { // Enter the special broken fixing mode if the user specified arguments @@ -689,7 +694,7 @@ struct PkgIsExtraInstalled { bool DoInstall(CommandLine &CmdL) { CacheFile Cache; - std::vector VolatileCmdL; + std::vector VolatileCmdL; Cache.GetSourceList()->AddVolatileFiles(CmdL, &VolatileCmdL); // then open the cache