From 592b78001c381f9cca6f20d8d1d47696bb98c0d1 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 16 Oct 2009 15:36:28 +0200 Subject: port netrc support from maemon --- methods/http.cc | 7 +++++-- methods/https.cc | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'methods') diff --git a/methods/http.cc b/methods/http.cc index 1eba0f279..6bfe80baf 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -42,6 +43,7 @@ #include #include + // Internet stuff #include @@ -49,7 +51,6 @@ #include "connect.h" #include "rfc2553emu.h" #include "http.h" - /*}}}*/ using namespace std; @@ -725,9 +726,11 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out) Base64Encode(Proxy.User + ":" + Proxy.Password) + "\r\n"; if (Uri.User.empty() == false || Uri.Password.empty() == false) + { + maybe_add_auth (Uri, _config->FindFile("Dir::Etc::netrc")); 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 37d93e308..a86c78029 100644 --- a/methods/https.cc +++ b/methods/https.cc @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -126,6 +127,8 @@ 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_WRITEFUNCTION, write_data); -- cgit v1.2.3 From 1de1f70383ea2d44147ccaceff280fd70faf4c81 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 16 Oct 2009 15:42:05 +0200 Subject: add maybe_add_auth for ftp as well --- methods/ftp.cc | 4 +++- methods/http.cc | 2 +- methods/https.cc | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'methods') diff --git a/methods/ftp.cc b/methods/ftp.cc index c91600ad5..eb398666f 100644 --- a/methods/ftp.cc +++ b/methods/ftp.cc @@ -982,7 +982,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 6bfe80baf..50478b44c 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -725,9 +725,9 @@ 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) { - maybe_add_auth (Uri, _config->FindFile("Dir::Etc::netrc")); Req += string("Authorization: Basic ") + Base64Encode(Uri.User + ":" + Uri.Password) + "\r\n"; } diff --git a/methods/https.cc b/methods/https.cc index a86c78029..075d655b7 100644 --- a/methods/https.cc +++ b/methods/https.cc @@ -127,7 +127,7 @@ bool HttpsMethod::Fetch(FetchItem *Itm) curl_easy_reset(curl); SetupProxy(); - maybe_add_auth (Uri, _config->FindFile("Dir::ETc::netrc")); + maybe_add_auth (Uri, _config->FindFile("Dir::Etc::netrc")); // callbacks curl_easy_setopt(curl, CURLOPT_URL, Itm->Uri.c_str()); -- cgit v1.2.3 From f1c081b6ad0c5925e9668fd159f1ac6d8ab672bc Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 16 Oct 2009 16:04:41 +0200 Subject: add ftp support, basic debugging --- methods/ftp.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'methods') diff --git a/methods/ftp.cc b/methods/ftp.cc index eb398666f..3e1725823 100644 --- a/methods/ftp.cc +++ b/methods/ftp.cc @@ -19,6 +19,7 @@ #include #include #include +#include #include #include -- cgit v1.2.3 From 01fc89305c7b5fc52d719c6898a9fdf03abf3ce6 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 4 Dec 2009 10:22:56 +0100 Subject: * apt-pkg/contrib/netrc.cc: - check for hostname and then host+path - better debug output * methods/https.cc: - fix bug in netrc integration --- methods/https.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'methods') diff --git a/methods/https.cc b/methods/https.cc index 075d655b7..585e13848 100644 --- a/methods/https.cc +++ b/methods/https.cc @@ -130,7 +130,7 @@ bool HttpsMethod::Fetch(FetchItem *Itm) 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(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); -- cgit v1.2.3