Bug 769254 - YUM does not supports proxies with NTLM
Summary: YUM does not supports proxies with NTLM
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: python-urlgrabber
Version: 17
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Fedora Packaging Toolset Team
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-12-20 11:39 UTC by Mikhail
Modified: 2014-01-21 23:20 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-08-09 22:52:17 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
authconfig-gtk (46.48 KB, image/png)
2011-12-21 09:28 UTC, Mikhail
no flags Details
Use ANYAUTH curl option for proxy authentication (967 bytes, patch)
2012-02-16 12:54 UTC, Nelson Benitez
no flags Details | Diff
Log of curl failing to use --proxy-basic (2.49 KB, text/plain)
2012-06-27 09:24 UTC, Andrea
no flags Details
proxy config automatic (27.64 KB, image/png)
2012-07-23 08:56 UTC, Mikhail
no flags Details
proxy config manual (32.23 KB, image/png)
2012-07-23 08:56 UTC, Mikhail
no flags Details

Description Mikhail 2011-12-20 11:39:14 UTC
Description of problem:
YUM does not supports proxies with NTLM

My Fedora 16 Workstation joined to Windows domain. I can't install/update any package because yum couldn't support NTLM and can't work via ISA proxy.

Comment 1 Mikhail 2011-12-21 09:28:31 UTC
Created attachment 549002 [details]
authconfig-gtk

Comment 2 Nelson Benitez 2012-02-15 17:18:40 UTC
I have same problem, I had a fedora 16 at work which was configured to use my employer's http proxy (a squid one) to access internet, that was fine and I could install packages.. until the company decided to enforce authentication (NTLM) on the proxy, now I can't use yum to install or update software.

Yum uses curl to download packages, and I can use curl to go through proxy with these flags:

curl --proxy-ntlm --proxy-user user:pass www.somedomain.org/somefile


So it's only a matter of Yum being able to pass those flags to curl, what about new yum.conf 'auth_type' option that will pass --proxy-ntlm if set to 'ntlm' ?


Also you can use --proxy-anyauth like:

curl --proxy-anyauth --proxy-user user:pass www.somedomain.org/somefile

and so don't need the yum.conf option I mentioned before.


Hope you can fix this bug as is blocking people using fedora from corporate networks.

Comment 3 Zdeněk Pavlas 2012-02-16 08:59:57 UTC
Hi Nelson, thanks for the report.  Nice to hear that curl in F16 actually works over NTLM proxies, because docs at http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTHTTPAUTH state that it works only with OpenSSL, but Fedora ships NSS instead.

I don't have access to any NTLM proxy.  Could you add this line to /usr/lib/python2.7/site-packages/urlgrabber/grabber.py and report if it works?  Thanks!

--- a/urlgrabber/grabber.py
+++ b/urlgrabber/grabber.py
@@ -1289,6 +1289,7 @@ class PyCurlFileObject(object):
                     else:
                         if proxy == '_none_': proxy = ""
                         self.curl_obj.setopt(pycurl.PROXY, proxy)
+                        self.curl_obj.setopt(pycurl.PROXYAUTH, pycurl.HTTPAUTH_ANY)
             
         if opts.username and opts.password:
             if self.scheme in ('http', 'https'):

Comment 4 Nelson Benitez 2012-02-16 12:54:49 UTC
Created attachment 562486 [details]
Use ANYAUTH curl option for proxy authentication

Hi Zdenek, I already did a patch that is working fine for me, I was about to post it here just when you submit it your comment.. so I'm attaching it here,  the patch is same as yours but only adds the ANYAUTH option when the proxy var contains '@' which means it has user:pass data. Use wherever approach you like.

I couldn't use git to make the patch because git has same NTLM problem.. but the patch is from current master downloaded from gitweb.

Thanks!

PD: Btw, yay! for script languages like python that make me fix this without having to recompile/repackage..

Comment 5 Nelson Benitez 2012-02-16 13:01:20 UTC
Btw the page you linked stated it supported NSS:
"You need to build libcurl with either OpenSSL or NSS support for this option to work, or build libcurl on Windows."

Comment 6 Zdeněk Pavlas 2012-02-16 13:26:37 UTC
Yep, I told Kamil Dudka and he fixed it 30 minutes ago :)

I've proposed this upstream fix: http://lists.baseurl.org/pipermail/yum-devel/2012-February/009089.html

I don't think PROXYAUTH=HTTP_ANY must be conditional.  curl parses the proxy string, and if there's no user/pass, I'm quite sure it will ignore PROXYAUTH anyway.

Comment 7 Fedora Admin XMLRPC Client 2012-04-27 15:26:25 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 8 Nelson Benitez 2012-06-01 08:40:29 UTC
Zdenek, I've tested fedora 17 at work with a NTLM proxy and your patch is not working..

Comment 9 Zdeněk Pavlas 2012-06-01 09:30:39 UTC
Yep, checked python-urlgrabber-3.9.1-11.fc17, and the patch was not there.  Could you try latest rawhide build? (python-urlgrabber-3.9.1-14.fc18 atm) It should work in f17, too.

Comment 10 Nelson Benitez 2012-06-01 11:55:22 UTC
I've just tested python-urlgrabber-3.9.1-14.fc18 and is working fine.. but it's a pity it didn't got into fedora 17.

Comment 11 Fedora Update System 2012-06-08 14:28:52 UTC
python-urlgrabber-3.9.1-12.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/python-urlgrabber-3.9.1-12.fc17

Comment 12 Fedora Update System 2012-06-15 07:25:55 UTC
python-urlgrabber-3.9.1-13.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/python-urlgrabber-3.9.1-13.fc17

Comment 14 Mikhail 2012-06-22 03:53:29 UTC
Fedora 17
$ rpm -q python-urlgrabber
python-urlgrabber-3.9.1-13.fc17.noarch

Comment 15 Fedora Update System 2012-06-26 00:43:06 UTC
python-urlgrabber-3.9.1-13.fc17 has been pushed to the Fedora 17 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 16 Andrea 2012-06-26 20:30:31 UTC
I've got a similar problem and the recent update of python-urlgrabber to version 13 in Fedora 17 has broken my yum update.

I have it in a VirtualBox behind a corporate proxy.

Basically I get

Error: Cannot retrieve metalink for repository: fedora. Please verify its path and try again

I've then downgraded python-urlgrabber to version 11 and it works again.
Just to be clear, with version 11 I had NO problems, ver 13 caused my issue.

With a similar setup wget works and reaches behind the firewall.

Trying to look at the network traffic, it seems that yum sends the first request without including the authentication token.
While wget sends something.
I will add the log tomorrow.

In yum.conf I have

proxy=http://xxx.xxx.xxx:0000
proxy_username=xxxxxx
proxy_password=xxxxxx

I've tried with 2 Windows accounts, one with domain
FM\xxxxxx
and one without
xxxxxx

which both used to work.

Comment 17 Zdeněk Pavlas 2012-06-27 07:35:20 UTC
> yum sends the first request without including the authentication token.

Yes, that's expected.  When PROXYAUTH=BASIC (default in r11), curl sends
"Proxy-Authorization: Basic dXNlcjpwd2Q=".  With PROXYAUTH=NTLM, curl sends
"Proxy-Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=" instead.

In r13 we set PROXYAUTH=ANY (to enable both basic and ntlm), and curl sends no such headers.  The proxy should return 407 Proxy Authentication Required, and set the Proxy-Authenticate header.  Curl then retries the request with correct Proxy-Authorization header..

It would be great if you could check the proxy's response.  Maybe the proxy is broken, or there's a bug in curl.  If necessary, I'd add proxy_auth=basic/ntlm/any option to yum.conf to work this around.

Comment 18 Andrea 2012-06-27 08:28:59 UTC
yum request sent in version 11

CONNECT mirrors.fedoraproject.org:443 HTTP/1.1
Host: mirrors.fedoraproject.org:443
Proxy-Authorization: Basic xnxmnbzxvmbxcvmbxcmbvxmcbvxmcbvxmcvn
User-Agent: urlgrabber/3.9.1 yum/3.4.3
Proxy-Connection: Keep-Alive

in version 13

CONNECT mirrors.fedoraproject.org:443 HTTP/1.1
Host: mirrors.fedoraproject.org:443
User-Agent: urlgrabber/3.9.1 yum/3.4.3
Proxy-Connection: Keep-Alive

and proxy answers

HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  )
Via: 1.1 GBAS-00328
Proxy-Authenticate: Negotiate
Proxy-Authenticate: Kerberos
Proxy-Authenticate: NTLM
Proxy-Authenticate: Basic realm="gbas-00328.EMEA.ABNAMRO-NET.COM"
Connection: close
Proxy-Connection: close
Pragma: no-cache
Cache-Control: no-cache
Content-Type: text/html
Content-Length: 724   

then yum sends again the same thing and the proxy answers the same.

Comment 19 Andrea 2012-06-27 08:50:02 UTC
curl works for both --proxy-basic and --proxy-ntlm
(i've checked, the traffic is different, ntlm is a 2 way conversation).

and for --proxy-basic is as expected.

but --proxy-any does not.

Again it sends twice the same header like above.

I guess the option proxy_auth in yum.conf would be greatly appreciated.

Comment 20 Andrea 2012-06-27 09:24:31 UTC
Created attachment 594731 [details]
Log of curl failing to use --proxy-basic

This is the output of

curl -v -o index.html --proxy-any www.bbc.co.uk 2> /tmp/curl.txt

with the variable http_proxy set properly.

It seems that curl tries something with kerberos

* gss_init_sec_context() failed: : Credentials cache file '/tmp/krb5cc_1000' not found

Still it would be good to be able to overwrite curl's proxy decision.

Comment 21 Zdeněk Pavlas 2012-06-28 07:25:14 UTC
Ok, confirmed this is a bug in curl, incorrectly handling kerberos failures.  You can probably work this around in 3 ways:

a) initialize your Kerberos account locally (obtain and cache Kerberos tickets)

b) patch urlgrabber.py

-            self.curl_obj.setopt(pycurl.PROXYAUTH, pycurl.HTTPAUTH_ANY)
+            self.curl_obj.setopt(pycurl.PROXYAUTH, pycurl.HTTPAUTH_ANY-pycurl.HTTPAUTH_GSSNEGOTIATE)

This disables Kerberos, but NTLM and Basic should still be used, if necessary.

c) remove that line completely (revert to urlgrabber r11 behavior), so only the (default) Basic auth is used.

Comment 22 Andrea 2012-06-28 09:41:22 UTC
Thanks.

I'd rather not initialise kerberos, all other applications (wget, firefox, ubuntu) are happy with the basic proxy.

Just to understand

Are you or anybody else:

1) going to report / fix curl?
2) Releasing a new patched python-urlgrabber?
3) Adding the flag you mentioned to yum?

Regards

Comment 23 Zdeněk Pavlas 2012-06-28 09:53:18 UTC
1) Yes, filled Bug 835869.
2) I'm going to disable GSSNEGOTIATE in next release (solution b).
3) Not sure.  Don't think it's necessary ATM.

Comment 24 Andrea 2012-06-28 10:08:08 UTC
Solution 2) is good enough for me.
Tried and it works.

Comment 25 Fedora Update System 2012-07-20 12:23:44 UTC
python-urlgrabber-3.9.1-14.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/python-urlgrabber-3.9.1-14.fc17

Comment 26 Fedora Update System 2012-07-21 02:57:16 UTC
Package python-urlgrabber-3.9.1-14.fc17:
* should fix your issue,
* was pushed to the Fedora 17 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing python-urlgrabber-3.9.1-14.fc17'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-10943/python-urlgrabber-3.9.1-14.fc17
then log in and leave karma (feedback).

Comment 27 Andrea 2012-07-23 08:35:55 UTC
Good, works for me.

Thanks

Comment 28 Mikhail 2012-07-23 08:55:47 UTC
now also work for me, but I prefer config proxy in one place  via "System Settings/Network/Network proxy" please see attached screenshot. Of course if password is not set, prompt input password in yum console.

Comment 29 Mikhail 2012-07-23 08:56:23 UTC
Created attachment 599714 [details]
proxy config automatic

Comment 30 Mikhail 2012-07-23 08:56:56 UTC
Created attachment 599716 [details]
proxy config manual

Comment 31 Fedora Update System 2012-08-09 22:52:17 UTC
python-urlgrabber-3.9.1-14.fc17 has been pushed to the Fedora 17 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.