summaryrefslogtreecommitdiff
path: root/methods
diff options
context:
space:
mode:
Diffstat (limited to 'methods')
-rw-r--r--methods/aptmethod.h47
-rw-r--r--methods/cdrom.cc2
-rw-r--r--methods/http.cc4
3 files changed, 41 insertions, 12 deletions
diff --git a/methods/aptmethod.h b/methods/aptmethod.h
index cb5a30e21..f6613ac3b 100644
--- a/methods/aptmethod.h
+++ b/methods/aptmethod.h
@@ -11,6 +11,7 @@
#include <algorithm>
#include <locale>
+#include <memory>
#include <string>
#include <vector>
@@ -471,8 +472,9 @@ protected:
};
class aptAuthConfMethod : public aptMethod
{
- FileFd authconf;
-public:
+ std::vector<std::unique_ptr<FileFd>> authconfs;
+
+ public:
virtual bool Configuration(std::string Message) APT_OVERRIDE
{
if (pkgAcqMethod::Configuration(Message) == false)
@@ -481,14 +483,25 @@ public:
std::string const conf = std::string("Binary::") + Binary;
_config->MoveSubTree(conf.c_str(), NULL);
+ // ignore errors with opening the auth file as it doesn't need to exist
+ _error->PushToStack();
auto const netrc = _config->FindFile("Dir::Etc::netrc");
if (netrc.empty() == false)
{
- // ignore errors with opening the auth file as it doesn't need to exist
- _error->PushToStack();
- authconf.Open(netrc, FileFd::ReadOnly);
- _error->RevertToStack();
+ authconfs.emplace_back(new FileFd());
+ authconfs.back()->Open(netrc, FileFd::ReadOnly);
+ }
+
+ auto const netrcparts = _config->FindDir("Dir::Etc::netrcparts");
+ if (netrcparts.empty() == false)
+ {
+ for (auto const &netrc : GetListOfFilesInDir(netrcparts, "conf", true, true))
+ {
+ authconfs.emplace_back(new FileFd());
+ authconfs.back()->Open(netrc, FileFd::ReadOnly);
+ }
}
+ _error->RevertToStack();
DropPrivsOrDie();
@@ -500,13 +513,25 @@ public:
bool MaybeAddAuthTo(URI &uri)
{
+ bool result = true;
+
if (uri.User.empty() == false || uri.Password.empty() == false)
return true;
- if (authconf.IsOpen() == false)
- return true;
- if (authconf.Seek(0) == false)
- return false;
- return MaybeAddAuth(authconf, uri);
+
+ for (auto &authconf : authconfs)
+ {
+ if (authconf->IsOpen() == false)
+ continue;
+ if (authconf->Seek(0) == false)
+ {
+ result = false;
+ continue;
+ }
+
+ result &= MaybeAddAuth(*authconf, uri);
+ }
+
+ return result;
}
aptAuthConfMethod(std::string &&Binary, char const *const Ver, unsigned long const Flags) APT_NONNULL(3)
diff --git a/methods/cdrom.cc b/methods/cdrom.cc
index d8c032744..77270b09f 100644
--- a/methods/cdrom.cc
+++ b/methods/cdrom.cc
@@ -96,7 +96,7 @@ string CDROMMethod::GetID(string Name)
/*}}}*/
// CDROMMethod::AutoDetectAndMount /*{{{*/
// ---------------------------------------------------------------------
-/* Modifies class varaiable CDROM to the mountpoint */
+/* Modifies class variable CDROM to the mountpoint */
bool CDROMMethod::AutoDetectAndMount(const URI Get, string &NewID)
{
vector<struct CdromDevice> v = UdevCdroms.Scan();
diff --git a/methods/http.cc b/methods/http.cc
index 2e7fca307..d75e9fe84 100644
--- a/methods/http.cc
+++ b/methods/http.cc
@@ -974,6 +974,10 @@ void HttpMethod::SendReq(FetchItem *Itm)
Req << "User-Agent: " << ConfigFind("User-Agent",
"Debian APT-HTTP/1.3 (" PACKAGE_VERSION ")") << "\r\n";
+ auto const referer = ConfigFind("Referer", "");
+ if (referer.empty() == false)
+ Req << "Referer: " << referer << "\r\n";
+
Req << "\r\n";
if (Debug == true)