diff options
author | Michael Vogt <michael.vogt@ubuntu.com> | 2009-12-10 16:06:40 +0100 |
---|---|---|
committer | Michael Vogt <michael.vogt@ubuntu.com> | 2009-12-10 16:06:40 +0100 |
commit | e4b16ac68196eab5e58abf715459fe70c199cff3 (patch) | |
tree | 12702a5b543249f7204d476791615d3828bb2a9f /methods | |
parent | f3ceaca7a648f7d93fa88106910151e69f498801 (diff) | |
parent | ac81ae9c07b7f2c3cc5afa76b197086814186557 (diff) |
* merge lp:~mvo/apt/netrc branch, this adds support for a
/etc/apt/auth.conf that can be used to store username/passwords
in a "netrc" style file (with the extension that it supports "/"
in a machine definition). Based on the maemo git branch.
* apt-pkg/deb/dpkgpm.cc:
- add "purge" to list of known actions
Diffstat (limited to 'methods')
-rw-r--r-- | methods/ftp.cc | 5 | ||||
-rw-r--r-- | methods/http.cc | 7 | ||||
-rw-r--r-- | methods/https.cc | 5 |
3 files changed, 13 insertions, 4 deletions
diff --git a/methods/ftp.cc b/methods/ftp.cc index c91600ad5..3e1725823 100644 --- a/methods/ftp.cc +++ b/methods/ftp.cc @@ -19,6 +19,7 @@ #include <apt-pkg/acquire-method.h> #include <apt-pkg/error.h> #include <apt-pkg/hashes.h> +#include <apt-pkg/netrc.h> #include <sys/stat.h> #include <sys/time.h> @@ -982,7 +983,9 @@ bool FtpMethod::Fetch(FetchItem *Itm) FetchResult Res; Res.Filename = Itm->DestFile; Res.IMSHit = false; - + + maybe_add_auth (Get, _config->FindFile("Dir::Etc::netrc")); + // Connect to the server if (Server == 0 || Server->Comp(Get) == false) { diff --git a/methods/http.cc b/methods/http.cc index 461a98406..3b210f6b6 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -29,6 +29,7 @@ #include <apt-pkg/acquire-method.h> #include <apt-pkg/error.h> #include <apt-pkg/hashes.h> +#include <apt-pkg/netrc.h> #include <sys/stat.h> #include <sys/time.h> @@ -42,6 +43,7 @@ #include <map> #include <apti18n.h> + // Internet stuff #include <netdb.h> @@ -49,7 +51,6 @@ #include "connect.h" #include "rfc2553emu.h" #include "http.h" - /*}}}*/ using namespace std; @@ -724,10 +725,12 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out) Req += string("Proxy-Authorization: Basic ") + Base64Encode(Proxy.User + ":" + Proxy.Password) + "\r\n"; + maybe_add_auth (Uri, _config->FindFile("Dir::Etc::netrc")); if (Uri.User.empty() == false || Uri.Password.empty() == false) + { Req += string("Authorization: Basic ") + Base64Encode(Uri.User + ":" + Uri.Password) + "\r\n"; - + } Req += "User-Agent: Debian APT-HTTP/1.3 ("VERSION")\r\n\r\n"; if (Debug == true) diff --git a/methods/https.cc b/methods/https.cc index 47988970b..3717ded7b 100644 --- a/methods/https.cc +++ b/methods/https.cc @@ -14,6 +14,7 @@ #include <apt-pkg/acquire-method.h> #include <apt-pkg/error.h> #include <apt-pkg/hashes.h> +#include <apt-pkg/netrc.h> #include <sys/stat.h> #include <sys/time.h> @@ -126,8 +127,10 @@ bool HttpsMethod::Fetch(FetchItem *Itm) curl_easy_reset(curl); SetupProxy(); + maybe_add_auth (Uri, _config->FindFile("Dir::Etc::netrc")); + // callbacks - curl_easy_setopt(curl, CURLOPT_URL, Itm->Uri.c_str()); + curl_easy_setopt(curl, CURLOPT_URL, static_cast<string>(Uri).c_str()); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); curl_easy_setopt(curl, CURLOPT_WRITEDATA, this); curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback); |