[Yum-devel] [PATCH] allow users to tweak PROXYAUTH settings. BZ 769254

Zdeněk Pavlas zpavlas at redhat.com
Thu Jun 28 11:46:02 UTC 2012


Unfortunately, there's no single works-for-all option,
so let users override it.  Default (basic) works well
for most users, so this probably does not warrant
a proper per-request option.

basic: was the default for years and worked well.
all: enabled ntlm but may break basic (BZ 835869).
basic+ntlm: works around the above bug

The default is to use curl's defaults (basic atm)
Enabling >1 schemes results in small extra overhead
---
 urlgrabber/grabber.py |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/urlgrabber/grabber.py b/urlgrabber/grabber.py
index c46f96f..c2f7647 100644
--- a/urlgrabber/grabber.py
+++ b/urlgrabber/grabber.py
@@ -587,6 +587,14 @@ _log_package_state()
 def _(st):
     return st
 
+# allow users to tweak curl's PROXYAUTH settings
+
+_proxy_auth = 0
+for i in os.environ.get('proxy_auth', '').split():
+    try: _proxy_auth |= getattr(pycurl, 'HTTPAUTH_' + i.upper())
+    except AttributeError:
+        if DEBUG: DEBUG.error('Invalid proxy auth: %s', i)
+
 ########################################################################
 #                 END MODULE INITIALIZATION
 ########################################################################
@@ -1385,7 +1393,8 @@ class PyCurlFileObject(object):
         # proxy
         if opts.proxy is not None:
             self.curl_obj.setopt(pycurl.PROXY, opts.proxy)
-            self.curl_obj.setopt(pycurl.PROXYAUTH, pycurl.HTTPAUTH_ANY)
+            if _proxy_auth:
+                self.curl_obj.setopt(pycurl.PROXYAUTH, _proxy_auth)
 
         if opts.username and opts.password:
             if self.scheme in ('http', 'https'):
-- 
1.7.4.4



More information about the Yum-devel mailing list