Bug 2255 - regression: issue2179 fix broke http auth in some cases
Summary: regression: issue2179 fix broke http auth in some cases
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: unspecified
Hardware: All All
: urgent bug
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-25 13:14 UTC by Wagner Bruna
Modified: 2012-05-13 05:03 UTC (History)
4 users (show)

See Also:
Python Version: ---


Attachments
(34 bytes, application/octet-stream)
2010-06-25 13:14 UTC, Wagner Bruna
Details
(34 bytes, application/octet-stream)
2010-06-25 19:31 UTC, kiilerix
Details
(34 bytes, application/x-download)
2010-06-26 10:07 UTC, Wagner Bruna
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wagner Bruna 2010-06-25 13:14 UTC
The bug seems to be triggered by lots of http requests on a pull/incoming
operation, so it's a bit hard to create a minimal test case; I'm attaching a
full bundle of the repo reconstructed with debugdag + debugbuilddag.

To reproduce:

- serve that repo behind http authentication;
- clone it at revision 364;
- run 'hg incoming'.

Bisect points to:

http://hg.intevation.org/mercurial/crew/rev/a1e575b48563
Comment 1 kiilerix 2010-06-25 19:31 UTC
Reproduced on https://bitbucket.org/wbruna/test-http-auth

The problem is that the HTTPDigestAuthHandler instance is reused for several
requests in the discover phase, so we have to reset the retry counter at
some time. The hack in a1e575b48563 didn't consider that.

The attached patch works for me, but wbruna has some problems - perhaps
related to proxy or something else ...
Comment 2 Wagner Bruna 2010-06-26 08:25 UTC
Unfortunately, that bitbucket repository needs to be private, so I need to
whitelist all users. But I created a public test server with the same
configuration (Apache, mod_wsgi, basic auth) as the real repository:

hg clone -r clonehere http://test:test@hgtest.imescos.net/test-http-auth
cd test-http-auth
hg incoming -l 10
Comment 3 Wagner Bruna 2010-06-26 08:35 UTC
issue2255fix.diff works for me with Debian stable python version (2.5.2),
but still fails with the python version currently in testing (2.6.5). We
noticed the packaged version differs a bit from upstream; I'll test with a
local installation.
Comment 4 Wagner Bruna 2010-06-26 09:43 UTC
kiilerix, does

import urllib2;hasattr(urllib2.AbstractBasicAuthHandler(),'retried')

returns True for your Python 2.6.5 install? (the version from Debian does;
apparently most (including the 2.6.5 Python souce tarball) don't...).
Comment 5 Wagner Bruna 2010-06-26 10:07 UTC
The attached patch issue2255fix-basicauth.diff, on top of issue2255fix.diff,
works for me, for both 2.5.2 and 2.6.5.
Comment 6 Wagner Bruna 2010-07-29 18:51 UTC
This was also reported on Debian:

http://bugs.debian.org/586907

But I'm not sure if my patch is appropriate as is, it looks too much
dependant on specific urllib behavior.
Comment 7 kiilerix 2010-07-30 06:01 UTC
wbruna, do you agree that issue2299 is a duplicate of this? (I didn't have a
clear memory of this issue and couldn't find it when I looked for it...)

And for the record: The answer to the question in msg12910 is False for
Fedora 13. The bogus retry handling in AbstractBasicAuthHandler has only
been backported in Debian & co.
Comment 8 Wagner Bruna 2010-08-01 06:39 UTC
Yes, issue2299 looks the same to me.
Comment 9 Wagner Bruna 2010-08-11 10:21 UTC
To summarize:

The first patch was applied for 1.6
(http://selenic.com/repo/hg/rev/2ec346160783), and solves this issue for
http digest authentication;

If

import urllib2;hasattr(urllib2.AbstractBasicAuthHandler(),'retried')

returns True (Python 2.6.5 + some 2.6.6 changes, as distributed by some
Linux distros), a fix like proposed on issue2255fix-basicauth.diff is still
needed for http basic (non-digest) authentication.
Comment 10 HG Bot 2010-08-13 18:00 UTC
Fixed by http://hg.intevation.org/mercurial/crew/rev/6c51a5056020
Wagner Bruna <wbruna@softwareexpress.com.br>
http basic auth: reset redirect counter on new requests (issue2255)
Comment 11 Bugzilla 2012-05-12 09:10 UTC

--- Bug imported by bugzilla@serpentine.com 2012-05-12 09:10 EDT  ---

This bug was previously known as _bug_ 2255 at http://mercurial.selenic.com/bts/issue2255
Imported an attachment (id=1418)
Imported an attachment (id=1419)
Imported an attachment (id=1420)