diff options
author | Michael Vogt <michael.vogt@ubuntu.com> | 2013-04-30 10:44:16 +0200 |
---|---|---|
committer | Michael Vogt <michael.vogt@ubuntu.com> | 2013-04-30 10:44:16 +0200 |
commit | 3599bca5211077f5456a40adb5cec1bcbee8c3ae (patch) | |
tree | 221627b7ef4e3d6d294fbaaab425f2400734bd93 /methods | |
parent | 6029901a2cf49aac035590960d84572b56f28933 (diff) | |
parent | b5595da902e62af7c295f1603ae5b43ba4cef281 (diff) |
merged from the debian-sid branch
Diffstat (limited to 'methods')
-rw-r--r-- | methods/connect.cc | 11 | ||||
-rw-r--r-- | methods/gpgv.cc | 15 | ||||
-rw-r--r-- | methods/http.cc | 6 | ||||
-rw-r--r-- | methods/http.h | 2 | ||||
-rw-r--r-- | methods/https.cc | 4 | ||||
-rw-r--r-- | methods/https.h | 5 | ||||
-rw-r--r-- | methods/rfc2553emu.cc | 2 |
7 files changed, 26 insertions, 19 deletions
diff --git a/methods/connect.cc b/methods/connect.cc index 9a092a43c..fc7a72ee9 100644 --- a/methods/connect.cc +++ b/methods/connect.cc @@ -17,6 +17,7 @@ #include <apt-pkg/fileutl.h> #include <apt-pkg/strutl.h> #include <apt-pkg/acquire-method.h> +#include <apt-pkg/configuration.h> #include <stdio.h> #include <errno.h> @@ -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()); @@ -197,6 +205,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->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)); } diff --git a/methods/gpgv.cc b/methods/gpgv.cc index 25ba0d063..3f814b9f0 100644 --- a/methods/gpgv.cc +++ b/methods/gpgv.cc @@ -6,6 +6,7 @@ #include <apt-pkg/fileutl.h> #include <apt-pkg/indexcopy.h> #include <apt-pkg/configuration.h> +#include <apt-pkg/gpgv.h> #include <utime.h> #include <stdio.h> @@ -70,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 = SigVerify::RunGPGV(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"); diff --git a/methods/http.cc b/methods/http.cc index acf25a42a..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 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 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/ 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 <apt-pkg/strutl.h> 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); } |