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