summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/proxy.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2016-06-20 13:49:31 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2016-06-20 13:49:31 +0200
commit9515ed7bcdb32c7985ca83d309beda7155d02136 (patch)
treeb511a7fdc1f8ebd1efade89b5c362111c62d77ad /apt-pkg/contrib/proxy.cc
parentcad1877559f3e1703c3fea4d081978e1b4bb4a0e (diff)
implement and document DIRECT for auto-detect-proxy
There is a subtile difference between an empty setting and "DIRECT" in the configuration as the later overrides the generic settings while the earlier does not. Also, non-zero exitcodes should really be reported as an error rather than silently discarded.
Diffstat (limited to 'apt-pkg/contrib/proxy.cc')
-rw-r--r--apt-pkg/contrib/proxy.cc19
1 files changed, 13 insertions, 6 deletions
diff --git a/apt-pkg/contrib/proxy.cc b/apt-pkg/contrib/proxy.cc
index 84d802dcb..4529cf230 100644
--- a/apt-pkg/contrib/proxy.cc
+++ b/apt-pkg/contrib/proxy.cc
@@ -51,19 +51,26 @@ bool AutoDetectProxy(URI &URL)
if(Popen(&Args[0], PipeFd, Child, FileFd::ReadOnly) == false)
return _error->Error("ProxyAutoDetect command '%s' failed!", AutoDetectProxyCmd.c_str());
char buf[512];
- if (PipeFd.ReadLine(buf, sizeof(buf)) == nullptr)
- return true;
+ bool const goodread = PipeFd.ReadLine(buf, sizeof(buf)) != nullptr;
PipeFd.Close();
- ExecWait(Child, "ProxyAutoDetect", true);
+ if (ExecWait(Child, "ProxyAutoDetect") == false)
+ return false;
+ // no output means the detector has no idea which proxy to use
+ // and apt will use the generic proxy settings
+ if (goodread == false)
+ return true;
auto const cleanedbuf = _strstrip(buf);
-
+ // We warn about this as the implementor probably meant to use DIRECT instead
if (cleanedbuf[0] == '\0')
- return _error->Warning("ProxyAutoDetect returned no data");
+ {
+ _error->Warning("ProxyAutoDetect command returned an empty line");
+ return true;
+ }
if (Debug)
std::clog << "auto detect command returned: '" << cleanedbuf << "'" << std::endl;
- if (strstr(cleanedbuf, URL.Access.c_str()) == cleanedbuf)
+ if (strstr(cleanedbuf, URL.Access.c_str()) == cleanedbuf || strcmp(cleanedbuf, "DIRECT") == 0)
_config->Set("Acquire::"+URL.Access+"::proxy::"+URL.Host, cleanedbuf);
return true;