Hi,

Inserting basic http auth headers into baseurl in the repo definition of yum.conf does not actually work as expected. What happens is that when retrieving the metadata, these headers are indeed sent, but once the package sack is downloaded and individual packages requested, these specific package requests do not send any authentication headers out of yumRepo::getPackage() (or perhaps more appropriately yumRepo::_getFile()) and 401's are thus raised.

The http auth headers from the baseurl for the repo surely need to be injected into the rpm download request.

I've included a slightly lazy patch against 3.2.28 which simply injects these upon initial request (if present). pycurl then sends these as necessary. One indeed could trap these 401's and then resend the request with injected headers, but that seems to me to be a lot more traffic.

It might be more efficient to actually add username/password attributes to the YumRepository class than to extract from baseurl each call (and perhaps it should parse all the _url's instead of just the first), but I'm sure someone with any opinion on that can incorporate this patch more appropriately.

Regards,
Alan
--- yum/yumRepo.py.orig 2010-07-21 03:46:55.000000000 +1000
+++ yum/yumRepo.py      2011-09-16 06:46:37.190170838 +1000
@@ -63,6 +63,9 @@
 logger = logging.getLogger("yum.Repos")
 verbose_logger = logging.getLogger("yum.verbose.Repos")
 
+# authentication header detection in baseurl
+auth_headers_re = re.compile('^[a-z]+://(.+):(.+)@')
+
 class YumPackageSack(packageSack.PackageSack):
     """imports/handles package objects from an mdcache dict object"""
     def __init__(self, packageClass):
@@ -753,6 +756,14 @@
         if url:
             (scheme, netloc, path, query, fragid) = urlparse.urlsplit(url)
 
+           # insert authentication headers if present ...
+           authenticated = auth_headers_re.match(self.baseurl[0])
+           if authenticated:
+               username, password = authenticated.groups()
+               url = urlparse.urlunsplit((scheme, '%s:%s@%s' % (username, 
password, netloc), path, query, fragid))
+           else:
+               raise AssertionError, authenticated
+
         if self.mediaid and self.mediafunc:
             discnum = 1
             if url:
_______________________________________________
Yum-devel mailing list
Yum-devel@lists.baseurl.org
http://lists.baseurl.org/mailman/listinfo/yum-devel

Reply via email to