You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

97 lines
2.5 KiB

  1. // Include Files /*{{{*/
  2. #include <config.h>
  3. #include <apt-pkg/acquire.h>
  4. #include <apt-pkg/acquire-item.h>
  5. #include <apt-pkg/configuration.h>
  6. #include <apt-pkg/error.h>
  7. #include <apt-pkg/strutl.h>
  8. #include "private-output.h"
  9. #include <locale.h>
  10. #include <fstream>
  11. #include <string>
  12. #include <vector>
  13. #include <apti18n.h>
  14. /*}}}*/
  15. // CheckAuth - check if each download comes form a trusted source /*{{{*/
  16. bool CheckAuth(pkgAcquire& Fetcher, bool const PromptUser)
  17. {
  18. std::string UntrustedList;
  19. for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I < Fetcher.ItemsEnd(); ++I)
  20. if (!(*I)->IsTrusted())
  21. UntrustedList += std::string((*I)->ShortDesc()) + " ";
  22. if (UntrustedList == "")
  23. return true;
  24. ShowList(c2out,_("WARNING: The following packages cannot be authenticated!"),UntrustedList,"");
  25. if (_config->FindB("APT::Get::AllowUnauthenticated",false) == true)
  26. {
  27. c2out << _("Authentication warning overridden.\n");
  28. return true;
  29. }
  30. if (PromptUser == false)
  31. return _error->Error(_("Some packages could not be authenticated"));
  32. if (_config->FindI("quiet",0) < 2
  33. && _config->FindB("APT::Get::Assume-Yes",false) == false)
  34. {
  35. c2out << _("Install these packages without verification?") << std::flush;
  36. if (!YnPrompt(false))
  37. return _error->Error(_("Some packages could not be authenticated"));
  38. return true;
  39. }
  40. else if (_config->FindB("APT::Get::Force-Yes",false) == true)
  41. return true;
  42. return _error->Error(_("There are problems and -y was used without --force-yes"));
  43. }
  44. /*}}}*/
  45. bool AcquireRun(pkgAcquire &Fetcher, int const PulseInterval, bool * const Failure, bool * const TransientNetworkFailure)/*{{{*/
  46. {
  47. pkgAcquire::RunResult res;
  48. if(PulseInterval > 0)
  49. res = Fetcher.Run(PulseInterval);
  50. else
  51. res = Fetcher.Run();
  52. if (res == pkgAcquire::Failed)
  53. return false;
  54. for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin();
  55. I != Fetcher.ItemsEnd(); ++I)
  56. {
  57. if ((*I)->Status == pkgAcquire::Item::StatDone &&
  58. (*I)->Complete == true)
  59. continue;
  60. if (TransientNetworkFailure != NULL && (*I)->Status == pkgAcquire::Item::StatIdle)
  61. {
  62. *TransientNetworkFailure = true;
  63. continue;
  64. }
  65. ::URI uri((*I)->DescURI());
  66. uri.User.clear();
  67. uri.Password.clear();
  68. std::string descUri = std::string(uri);
  69. _error->Error(_("Failed to fetch %s %s\n"), descUri.c_str(),
  70. (*I)->ErrorText.c_str());
  71. if (Failure != NULL)
  72. *Failure = true;
  73. }
  74. return true;
  75. }
  76. /*}}}*/