From cc41811512ba00f70738b70f0448c9172b71daf2 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 9 Jan 2013 11:00:13 +0100 Subject: * methods/https.cc: - reuse connection in https, thanks to Thomas Bushnell, BSG for the patch. LP: #1087543, Closes: #695359 --- methods/https.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'methods') diff --git a/methods/https.cc b/methods/https.cc index c1a49ba60..11d4ba8aa 100644 --- a/methods/https.cc +++ b/methods/https.cc @@ -124,7 +124,6 @@ bool HttpsMethod::Fetch(FetchItem *Itm) curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback); curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, this); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, false); - curl_easy_setopt(curl, CURLOPT_FAILONERROR, true); curl_easy_setopt(curl, CURLOPT_FILETIME, true); // SSL parameters are set by default to the common (non mirror-specific) value @@ -240,6 +239,7 @@ bool HttpsMethod::Fetch(FetchItem *Itm) curl_easy_setopt(curl, CURLOPT_VERBOSE, true); // error handling + curl_errorstr[0] = '\0'; curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_errorstr); // If we ask for uncompressed files servers might respond with content- @@ -288,7 +288,7 @@ bool HttpsMethod::Fetch(FetchItem *Itm) File->Close(); // cleanup - if(success != 0) + if(success != 0 || (curl_responsecode != 200 && curl_responsecode != 304)) { _error->Error("%s", curl_errorstr); // unlink, no need keep 401/404 page content in partial/ -- cgit v1.2.3 From 45a9cc46a143cc2864bba910cff2d9dfc1172dec Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 9 Jan 2013 14:47:35 +0100 Subject: add missing curl_easy_cleanup() --- methods/https.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'methods') diff --git a/methods/https.h b/methods/https.h index b1961a870..293e288e0 100644 --- a/methods/https.h +++ b/methods/https.h @@ -41,6 +41,11 @@ class HttpsMethod : public pkgAcqMethod File = 0; curl = curl_easy_init(); }; + + ~HttpsMethod() + { + curl_easy_cleanup(curl); + }; }; #include -- cgit v1.2.3 From 72663b44179f4c6f3ec2e4ec25d8df3c4590b222 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 11 Jan 2013 09:51:00 +0100 Subject: * methods/http.cc: - quote spaces in filenames to ensure as the http method is also (potentially) used for non deb,dsc content that may contain spaces, thanks to Daniel Hartwig and Thomas Bushnell (LP: #1086997) --- methods/http.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'methods') diff --git a/methods/http.cc b/methods/http.cc index acf25a42a..b7e766004 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -686,7 +686,7 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out) and we expect the proxy to do this */ if (Proxy.empty() == true || Proxy.Host.empty()) sprintf(Buf,"GET %s HTTP/1.1\r\nHost: %s\r\nConnection: keep-alive\r\n", - QuoteString(Uri.Path,"~").c_str(),ProperHost.c_str()); + QuoteString(Uri.Path,"~ ").c_str(),ProperHost.c_str()); else { /* Generate a cache control header if necessary. We place a max -- cgit v1.2.3 From 1d12857c083b436fb88710cd8e87267ece7af8a9 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 24 Jan 2013 18:52:25 +0100 Subject: quote plus in filenames to work around a bug in the S3 server (LP: #1003633) --- methods/http.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'methods') diff --git a/methods/http.cc b/methods/http.cc index b7e766004..fddf8a78e 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -685,8 +685,12 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out) pass it on, HTTP/1.1 says the connection should default to keep alive and we expect the proxy to do this */ if (Proxy.empty() == true || Proxy.Host.empty()) + { + // see LP bugs #1003633 and #1086997. The "+" is encoded as a workaround + // for a amazon S3 bug sprintf(Buf,"GET %s HTTP/1.1\r\nHost: %s\r\nConnection: keep-alive\r\n", - QuoteString(Uri.Path,"~ ").c_str(),ProperHost.c_str()); + QuoteString(Uri.Path,"+~ ").c_str(),ProperHost.c_str()); + } else { /* Generate a cache control header if necessary. We place a max -- cgit v1.2.3 From 69c2ecbdc937e3c73fe67d3c9bce12a80d3ec7ec Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 10 Mar 2013 12:24:13 +0100 Subject: various simple changes to fix cppcheck warnings --- methods/rfc2553emu.cc | 2 -- 1 file changed, 2 deletions(-) (limited to 'methods') diff --git a/methods/rfc2553emu.cc b/methods/rfc2553emu.cc index f00e85889..372882769 100644 --- a/methods/rfc2553emu.cc +++ b/methods/rfc2553emu.cc @@ -154,11 +154,9 @@ int getaddrinfo(const char *nodename, const char *servname, /* */ void freeaddrinfo(struct addrinfo *ai) { - struct addrinfo *Tmp; while (ai != 0) { free(ai->ai_addr); - Tmp = ai; ai = ai->ai_next; free(ai); } -- cgit v1.2.3 From 2f5b615169aef2d9c74bb337af229dee2dce595e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 15 Mar 2013 14:17:01 +0100 Subject: * apt-pkg/indexcopy.cc: - rename RunGPGV to ExecGPGV and move it to apt-pkg/contrib/gpgv.cc --- methods/gpgv.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'methods') diff --git a/methods/gpgv.cc b/methods/gpgv.cc index 25ba0d063..98381b845 100644 --- a/methods/gpgv.cc +++ b/methods/gpgv.cc @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -72,7 +73,7 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile, else if (pid == 0) { _error->PushToStack(); - bool const success = SigVerify::RunGPGV(outfile, file, 3, fd); + bool const success = ExecGPGV(outfile, file, 3, fd); if (success == false) { string errmsg; -- cgit v1.2.3 From 99ed26d32226f0dffe5a37fb78c5588f9d9ecfd5 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 15 Mar 2013 14:29:46 +0100 Subject: * apt-pkg/contrib/gpgv.cc: - ExecGPGV is a method which should never return, so mark it as such and fix the inconsistency of returning in error cases --- methods/gpgv.cc | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'methods') diff --git a/methods/gpgv.cc b/methods/gpgv.cc index 98381b845..3f814b9f0 100644 --- a/methods/gpgv.cc +++ b/methods/gpgv.cc @@ -71,19 +71,7 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile, if (pid < 0) return string("Couldn't spawn new process") + strerror(errno); else if (pid == 0) - { - _error->PushToStack(); - bool const success = ExecGPGV(outfile, file, 3, fd); - if (success == false) - { - string errmsg; - _error->PopMessage(errmsg); - _error->RevertToStack(); - return errmsg; - } - _error->RevertToStack(); - exit(111); - } + ExecGPGV(outfile, file, 3, fd); close(fd[1]); FILE *pipein = fdopen(fd[0], "r"); -- cgit v1.2.3 From 945d2a8aeecf844137843265e72d7991f77c3353 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 21 Mar 2013 16:18:58 +0100 Subject: merge patch from Colin to fix error message from getaddrinfo() (#703603) --- methods/connect.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'methods') diff --git a/methods/connect.cc b/methods/connect.cc index 9a092a43c..3573d3cbf 100644 --- a/methods/connect.cc +++ b/methods/connect.cc @@ -197,6 +197,9 @@ bool Connect(std::string Host,int Port,const char *Service,int DefPort,int &Fd, return _error->Error(_("Temporary failure resolving '%s'"), Host.c_str()); } + if (Res == EAI_SYSTEM) + return _error->Error(_("System error resolving '%s:%s' (%s)"), + Host.c_str(),ServStr,strerror(errno)); return _error->Error(_("Something wicked happened resolving '%s:%s' (%i - %s)"), Host.c_str(),ServStr,Res,gai_strerror(Res)); } -- cgit v1.2.3 From 45d02095cbd425c741b69810f91bc2282bf9230b Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 22 Mar 2013 21:46:53 +0100 Subject: add new config options "Acquire::ForceIPv4" and "Acquire::ForceIPv6" to allow focing one or the other (closes: #611891) --- methods/connect.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'methods') diff --git a/methods/connect.cc b/methods/connect.cc index 3573d3cbf..35f4723ce 100644 --- a/methods/connect.cc +++ b/methods/connect.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -167,6 +168,13 @@ bool Connect(std::string Host,int Port,const char *Service,int DefPort,int &Fd, Hints.ai_flags = AI_ADDRCONFIG; Hints.ai_protocol = 0; + if(_config->FindB("Acquire::ForceIPv4", false) == true) + Hints.ai_family = AF_INET; + else if(_config->FindB("Acquire::ForceIPv6", false) == true) + Hints.ai_family = AF_INET6; + else + Hints.ai_family = AF_UNSPEC; + // if we couldn't resolve the host before, we don't try now if(bad_addr.find(Host) != bad_addr.end()) return _error->Error(_("Could not resolve '%s'"),Host.c_str()); -- cgit v1.2.3 From 5cf466f44ef3eeefbdabc95e1b369bad8889f899 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 25 Mar 2013 09:03:48 +0100 Subject: * methods/connect.cc: - use Errno() instead of strerror(), thanks to David Kalnischk --- methods/connect.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'methods') diff --git a/methods/connect.cc b/methods/connect.cc index 35f4723ce..fc7a72ee9 100644 --- a/methods/connect.cc +++ b/methods/connect.cc @@ -206,8 +206,8 @@ bool Connect(std::string Host,int Port,const char *Service,int DefPort,int &Fd, Host.c_str()); } if (Res == EAI_SYSTEM) - return _error->Error(_("System error resolving '%s:%s' (%s)"), - Host.c_str(),ServStr,strerror(errno)); + return _error->Errno("getaddrinfo", _("System error resolving '%s:%s'"), + Host.c_str(),ServStr); return _error->Error(_("Something wicked happened resolving '%s:%s' (%i - %s)"), Host.c_str(),ServStr,Res,gai_strerror(Res)); } -- cgit v1.2.3 From b5595da902e62af7c295f1603ae5b43ba4cef281 Mon Sep 17 00:00:00 2001 From: "bubulle@debian.org" <> Date: Wed, 10 Apr 2013 11:28:11 +0200 Subject: Fix English spelling error in a message ('A error'). Unfuzzy translations. Closes: #705087 --- methods/http.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'methods') diff --git a/methods/http.h b/methods/http.h index 7a3ccda54..7446119cd 100644 --- a/methods/http.h +++ b/methods/http.h @@ -158,7 +158,7 @@ class HttpMethod : public pkgAcqMethod ERROR_UNRECOVERABLE, /** \brief The server reported a error with a error content page */ ERROR_WITH_CONTENT_PAGE, - /** \brief A error on the client side */ + /** \brief An error on the client side */ ERROR_NOT_FROM_SERVER, /** \brief A redirect or retry request */ TRY_AGAIN_OR_REDIRECT -- cgit v1.2.3