X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/0977f81757f42889a9edb761061529041afe0a06..858f91bb796e68b8133574cc85649b9af87a9e8b:/apt-private/private-download.cc?ds=sidebyside diff --git a/apt-private/private-download.cc b/apt-private/private-download.cc index 8cabf14b5..18a9b1fbc 100644 --- a/apt-private/private-download.cc +++ b/apt-private/private-download.cc @@ -49,16 +49,23 @@ bool CheckDropPrivsMustBeDisabled(pkgAcquire &Fetcher) /*{{{*/ for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd() && res == true; ++I) { - int fd = open((*I)->DestFile.c_str(), O_CREAT | O_RDWR, 0600); + if ((*I)->DestFile.empty()) + continue; + // we assume that an existing (partial) file means that we have sufficient rights + if (RealFileExists((*I)->DestFile)) + continue; + int fd = open((*I)->DestFile.c_str(), O_CREAT | O_EXCL | O_RDWR, 0600); if (fd < 0) { res = false; std::string msg; strprintf(msg, _("Can't drop privileges for downloading as file '%s' couldn't be accessed by user '%s'."), (*I)->DestFile.c_str(), SandboxUser.c_str()); - c0out << msg << std::endl; + std::cerr << "W: " << msg << std::endl; _config->Set("APT::Sandbox::User", ""); + break; } + unlink((*I)->DestFile.c_str()); close(fd); } @@ -71,20 +78,23 @@ bool CheckDropPrivsMustBeDisabled(pkgAcquire &Fetcher) /*{{{*/ // CheckAuth - check if each download comes form a trusted source /*{{{*/ bool CheckAuth(pkgAcquire& Fetcher, bool const PromptUser) { - std::string UntrustedList; + std::vector UntrustedList; for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I < Fetcher.ItemsEnd(); ++I) if (!(*I)->IsTrusted()) - UntrustedList += std::string((*I)->ShortDesc()) + " "; + UntrustedList.push_back((*I)->ShortDesc()); - if (UntrustedList == "") + if (UntrustedList.empty()) return true; return AuthPrompt(UntrustedList, PromptUser); } -bool AuthPrompt(std::string const &UntrustedList, bool const PromptUser) +bool AuthPrompt(std::vector const &UntrustedList, bool const PromptUser) { - ShowList(c2out,_("WARNING: The following packages cannot be authenticated!"),UntrustedList,""); + ShowList(c2out,_("WARNING: The following packages cannot be authenticated!"), UntrustedList, + [](std::string const&) { return true; }, + [](std::string const&str) { return str; }, + [](std::string const&) { return ""; }); if (_config->FindB("APT::Get::AllowUnauthenticated",false) == true) { @@ -104,10 +114,12 @@ bool AuthPrompt(std::string const &UntrustedList, bool const PromptUser) return true; } - else if (_config->FindB("APT::Get::Force-Yes",false) == true) + else if (_config->FindB("APT::Get::Force-Yes",false) == true) { + _error->Warning(_("--force-yes is deprecated, use one of the options starting with --allow instead.")); return true; + } - return _error->Error(_("There are problems and -y was used without --force-yes")); + return _error->Error(_("There were unauthenticated packages and -y was used without --allow-unauthenticated")); } /*}}}*/ bool AcquireRun(pkgAcquire &Fetcher, int const PulseInterval, bool * const Failure, bool * const TransientNetworkFailure)/*{{{*/