diff options
| -rwxr-xr-x | main.py | 23 | ||||
| -rwxr-xr-x | repo | 9 |
2 files changed, 26 insertions, 6 deletions
| @@ -295,6 +295,24 @@ class _BasicAuthHandler(urllib2.HTTPBasicAuthHandler): | |||
| 295 | self.retried = 0 | 295 | self.retried = 0 |
| 296 | raise | 296 | raise |
| 297 | 297 | ||
| 298 | class _DigestAuthHandler(urllib2.HTTPDigestAuthHandler): | ||
| 299 | def http_error_auth_reqed(self, auth_header, host, req, headers): | ||
| 300 | try: | ||
| 301 | old_add_header = req.add_header | ||
| 302 | def _add_header(name, val): | ||
| 303 | val = val.replace('\n', '') | ||
| 304 | old_add_header(name, val) | ||
| 305 | req.add_header = _add_header | ||
| 306 | return urllib2.AbstractDigestAuthHandler.http_error_auth_reqed( | ||
| 307 | self, auth_header, host, req, headers) | ||
| 308 | except: | ||
| 309 | reset = getattr(self, 'reset_retry_count', None) | ||
| 310 | if reset is not None: | ||
| 311 | reset() | ||
| 312 | elif getattr(self, 'retried', None): | ||
| 313 | self.retried = 0 | ||
| 314 | raise | ||
| 315 | |||
| 298 | def init_http(): | 316 | def init_http(): |
| 299 | handlers = [_UserAgentHandler()] | 317 | handlers = [_UserAgentHandler()] |
| 300 | 318 | ||
| @@ -303,13 +321,14 @@ def init_http(): | |||
| 303 | n = netrc.netrc() | 321 | n = netrc.netrc() |
| 304 | for host in n.hosts: | 322 | for host in n.hosts: |
| 305 | p = n.hosts[host] | 323 | p = n.hosts[host] |
| 306 | mgr.add_password(None, 'http://%s/' % host, p[0], p[2]) | 324 | mgr.add_password(p[1], 'http://%s/' % host, p[0], p[2]) |
| 307 | mgr.add_password(None, 'https://%s/' % host, p[0], p[2]) | 325 | mgr.add_password(p[1], 'https://%s/' % host, p[0], p[2]) |
| 308 | except netrc.NetrcParseError: | 326 | except netrc.NetrcParseError: |
| 309 | pass | 327 | pass |
| 310 | except IOError: | 328 | except IOError: |
| 311 | pass | 329 | pass |
| 312 | handlers.append(_BasicAuthHandler(mgr)) | 330 | handlers.append(_BasicAuthHandler(mgr)) |
| 331 | handlers.append(_DigestAuthHandler(mgr)) | ||
| 313 | 332 | ||
| 314 | if 'http_proxy' in os.environ: | 333 | if 'http_proxy' in os.environ: |
| 315 | url = os.environ['http_proxy'] | 334 | url = os.environ['http_proxy'] |
| @@ -28,7 +28,7 @@ if __name__ == '__main__': | |||
| 28 | del magic | 28 | del magic |
| 29 | 29 | ||
| 30 | # increment this whenever we make important changes to this script | 30 | # increment this whenever we make important changes to this script |
| 31 | VERSION = (1, 13) | 31 | VERSION = (1, 14) |
| 32 | 32 | ||
| 33 | # increment this if the MAINTAINER_KEYS block is modified | 33 | # increment this if the MAINTAINER_KEYS block is modified |
| 34 | KEYRING_VERSION = (1,0) | 34 | KEYRING_VERSION = (1,0) |
| @@ -154,7 +154,7 @@ def _Init(args): | |||
| 154 | """Installs repo by cloning it over the network. | 154 | """Installs repo by cloning it over the network. |
| 155 | """ | 155 | """ |
| 156 | opt, args = init_optparse.parse_args(args) | 156 | opt, args = init_optparse.parse_args(args) |
| 157 | if args or not opt.manifest_url: | 157 | if args: |
| 158 | init_optparse.print_usage() | 158 | init_optparse.print_usage() |
| 159 | sys.exit(1) | 159 | sys.exit(1) |
| 160 | 160 | ||
| @@ -311,11 +311,12 @@ def _InitHttp(): | |||
| 311 | n = netrc.netrc() | 311 | n = netrc.netrc() |
| 312 | for host in n.hosts: | 312 | for host in n.hosts: |
| 313 | p = n.hosts[host] | 313 | p = n.hosts[host] |
| 314 | mgr.add_password(None, 'http://%s/' % host, p[0], p[2]) | 314 | mgr.add_password(p[1], 'http://%s/' % host, p[0], p[2]) |
| 315 | mgr.add_password(None, 'https://%s/' % host, p[0], p[2]) | 315 | mgr.add_password(p[1], 'https://%s/' % host, p[0], p[2]) |
| 316 | except: | 316 | except: |
| 317 | pass | 317 | pass |
| 318 | handlers.append(urllib2.HTTPBasicAuthHandler(mgr)) | 318 | handlers.append(urllib2.HTTPBasicAuthHandler(mgr)) |
| 319 | handlers.append(urllib2.HTTPDigestAuthHandler(mgr)) | ||
| 319 | 320 | ||
| 320 | if 'http_proxy' in os.environ: | 321 | if 'http_proxy' in os.environ: |
| 321 | url = os.environ['http_proxy'] | 322 | url = os.environ['http_proxy'] |
