Sfoglia il codice sorgente

Make apt proxy options have the highest priority, unified proxy determining code.

Eugene V. Lyubimkin 17 anni fa
parent
commit
788a8f42c1
6 ha cambiato i file con 73 aggiunte e 45 eliminazioni
  1. 1 1
      configure.in
  2. 6 0
      debian/changelog
  3. 10 5
      doc/apt.conf.5.xml
  4. 19 14
      methods/ftp.cc
  5. 18 13
      methods/http.cc
  6. 19 12
      methods/https.cc

+ 1 - 1
configure.in

@@ -18,7 +18,7 @@ AC_CONFIG_AUX_DIR(buildlib)
 AC_CONFIG_HEADER(include/config.h:buildlib/config.h.in include/apti18n.h:buildlib/apti18n.h.in)
 AC_CONFIG_HEADER(include/config.h:buildlib/config.h.in include/apti18n.h:buildlib/apti18n.h.in)
 
 
 dnl -- SET THIS TO THE RELEASE VERSION --
 dnl -- SET THIS TO THE RELEASE VERSION --
-AC_DEFINE_UNQUOTED(VERSION,"0.7.20~exp3")
+AC_DEFINE_UNQUOTED(VERSION,"0.7.20")
 PACKAGE="apt"
 PACKAGE="apt"
 AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE")
 AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE")
 AC_SUBST(PACKAGE)
 AC_SUBST(PACKAGE)

+ 6 - 0
debian/changelog

@@ -13,6 +13,12 @@ apt (0.7.20) unstable; urgency=low
     - Mentioned 'APT::Periodic' and 'APT::Archives' groups of options.
     - Mentioned 'APT::Periodic' and 'APT::Archives' groups of options.
       (Closes: #438559)
       (Closes: #438559)
     - Mentioned '/* ... */' comments. (Closes: #507601)
     - Mentioned '/* ... */' comments. (Closes: #507601)
+  * methods/{http,https,ftp}, doc/apt.conf.5.xml:
+    - Changed and unified the code that determines which proxy to use. Now
+      'Acquire::{http,ftp}::Proxy[::<host>]' options have the highest priority,
+      and '{http,ftp}_proxy' environment variables are used only if options
+      mentioned above are not specified.
+      (Closes: #445985, #157759, #320184, #365880, #479617)
 
 
   [ Michael Vogt ]
   [ Michael Vogt ]
   * make "apt-get build-dep" installed packages marked automatic
   * make "apt-get build-dep" installed packages marked automatic

+ 10 - 5
doc/apt.conf.5.xml

@@ -202,8 +202,9 @@ DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt";};
      standard form of <literal>http://[[user][:pass]@]host[:port]/</literal>. Per 
      standard form of <literal>http://[[user][:pass]@]host[:port]/</literal>. Per 
      host proxies can also be specified by using the form 
      host proxies can also be specified by using the form 
      <literal>http::Proxy::&lt;host&gt;</literal> with the special keyword <literal>DIRECT</literal> 
      <literal>http::Proxy::&lt;host&gt;</literal> with the special keyword <literal>DIRECT</literal> 
-     meaning to use no proxies. The <envar>http_proxy</envar> environment variable
-     will override all settings.</para>
+	 meaning to use no proxies. If no one of the above settings is specified,
+	 <envar>http_proxy</envar> environment variable
+	 will be used.</para>
 
 
      <para>Three settings are provided for cache control with HTTP/1.1 compliant 
      <para>Three settings are provided for cache control with HTTP/1.1 compliant 
      proxy caches. <literal>No-Cache</literal> tells the proxy to not use its cached 
      proxy caches. <literal>No-Cache</literal> tells the proxy to not use its cached 
@@ -251,9 +252,13 @@ DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt";};
 	 </para></listitem></varlistentry>
 	 </para></listitem></varlistentry>
 
 
      <varlistentry><term>ftp</term>
      <varlistentry><term>ftp</term>
-     <listitem><para>FTP URIs; ftp::Proxy is the default proxy server to use. It is in the 
-     standard form of <literal>ftp://[[user][:pass]@]host[:port]/</literal> and is 
-     overridden by the <envar>ftp_proxy</envar> environment variable. To use a ftp 
+     <listitem><para>FTP URIs; ftp::Proxy is the default ftp proxy to use. It is in the 
+     standard form of <literal>ftp://[[user][:pass]@]host[:port]/</literal>. Per 
+     host proxies can also be specified by using the form 
+     <literal>ftp::Proxy::&lt;host&gt;</literal> with the special keyword <literal>DIRECT</literal> 
+	 meaning to use no proxies. If no one of the above settings is specified,
+	 <envar>ftp_proxy</envar> environment variable
+	 will be used. To use a ftp 
      proxy you will have to set the <literal>ftp::ProxyLogin</literal> script in the 
      proxy you will have to set the <literal>ftp::ProxyLogin</literal> script in the 
      configuration file. This entry specifies the commands to send to tell 
      configuration file. This entry specifies the commands to send to tell 
      the proxy server what to connect to. Please see 
      the proxy server what to connect to. Please see 

+ 19 - 14
methods/ftp.cc

@@ -112,23 +112,28 @@ bool FTPConn::Open(pkgAcqMethod *Owner)
    Close();
    Close();
    
    
    // Determine the proxy setting
    // Determine the proxy setting
-   if (getenv("ftp_proxy") == 0)
+   string SpecificProxy = _config->Find("Acquire::ftp::Proxy::" + ServerName.Host);
+   if (!SpecificProxy.empty())
    {
    {
-      string DefProxy = _config->Find("Acquire::ftp::Proxy");
-      string SpecificProxy = _config->Find("Acquire::ftp::Proxy::" + ServerName.Host);
-      if (SpecificProxy.empty() == false)
-      {
-	 if (SpecificProxy == "DIRECT")
-	    Proxy = "";
-	 else
-	    Proxy = SpecificProxy;
-      }   
-      else
-	 Proxy = DefProxy;
+	   if (SpecificProxy == "DIRECT")
+		   Proxy = "";
+	   else
+		   Proxy = SpecificProxy;
    }
    }
    else
    else
-      Proxy = getenv("ftp_proxy");
-   
+   {
+	   string DefProxy = _config->Find("Acquire::ftp::Proxy");
+	   if (!DefProxy.empty())
+	   {
+		   Proxy = DefProxy;
+	   }
+	   else
+	   {
+		   char* result = getenv("ftp_proxy");
+		   Proxy = result ? result : "";
+	   }
+   }
+
    // Parse no_proxy, a , separated list of domains
    // Parse no_proxy, a , separated list of domains
    if (getenv("no_proxy") != 0)
    if (getenv("no_proxy") != 0)
    {
    {

+ 18 - 13
methods/http.cc

@@ -309,22 +309,27 @@ bool ServerState::Open()
    Persistent = true;
    Persistent = true;
    
    
    // Determine the proxy setting
    // Determine the proxy setting
-   if (getenv("http_proxy") == 0)
+   string SpecificProxy = _config->Find("Acquire::http::Proxy::" + ServerName.Host);
+   if (!SpecificProxy.empty())
    {
    {
-      string DefProxy = _config->Find("Acquire::http::Proxy");
-      string SpecificProxy = _config->Find("Acquire::http::Proxy::" + ServerName.Host);
-      if (SpecificProxy.empty() == false)
-      {
-	 if (SpecificProxy == "DIRECT")
-	    Proxy = "";
-	 else
-	    Proxy = SpecificProxy;
-      }   
-      else
-	 Proxy = DefProxy;
+	   if (SpecificProxy == "DIRECT")
+		   Proxy = "";
+	   else
+		   Proxy = SpecificProxy;
    }
    }
    else
    else
-      Proxy = getenv("http_proxy");
+   {
+	   string DefProxy = _config->Find("Acquire::http::Proxy");
+	   if (!DefProxy.empty())
+	   {
+		   Proxy = DefProxy;
+	   }
+	   else
+	   {
+		   char* result = getenv("http_proxy");
+		   Proxy = result ? result : "";
+	   }
+   }
    
    
    // Parse no_proxy, a , separated list of domains
    // Parse no_proxy, a , separated list of domains
    if (getenv("no_proxy") != 0)
    if (getenv("no_proxy") != 0)

+ 19 - 12
methods/https.cc

@@ -61,19 +61,26 @@ void HttpsMethod::SetupProxy()
    URI ServerName = Queue->Uri;
    URI ServerName = Queue->Uri;
 
 
    // Determine the proxy setting
    // Determine the proxy setting
-   if (getenv("http_proxy") == 0)
+   string SpecificProxy = _config->Find("Acquire::http::Proxy::" + ServerName.Host);
+   if (!SpecificProxy.empty())
    {
    {
-      string DefProxy = _config->Find("Acquire::http::Proxy");
-      string SpecificProxy = _config->Find("Acquire::http::Proxy::" + ServerName.Host);
-      if (SpecificProxy.empty() == false)
-      {
-	 if (SpecificProxy == "DIRECT")
-	    Proxy = "";
-	 else
-	    Proxy = SpecificProxy;
-      }   
-      else
-	 Proxy = DefProxy;
+	   if (SpecificProxy == "DIRECT")
+		   Proxy = "";
+	   else
+		   Proxy = SpecificProxy;
+   }
+   else
+   {
+	   string DefProxy = _config->Find("Acquire::http::Proxy");
+	   if (!DefProxy.empty())
+	   {
+		   Proxy = DefProxy;
+	   }
+	   else
+	   {
+		   char* result = getenv("http_proxy");
+		   Proxy = result ? result : "";
+	   }
    }
    }
    
    
    // Parse no_proxy, a , separated list of domains
    // Parse no_proxy, a , separated list of domains