Bug 558539

Summary: zypper does not respect the environment variable http_proxy, but uses the settings in /etc/sysconfig/proxy
Product: [openSUSE] openSUSE 11.2 Reporter: Richard Bos <richard.bos>
Component: libzyppAssignee: E-mail List <zypp-maintainers>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P4 - Low CC: dmacvicar, dma_k, erico.mendonca, forgotten_xI2C5NvggO, ma, per
Version: Final   
Target Milestone: ---   
Hardware: i586   
OS: openSUSE 11.2   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Bug Depends on: 655483    
Bug Blocks:    

Description Richard Bos 2009-11-25 21:33:43 UTC
User-Agent:       Mozilla/5.0 (compatible; Konqueror/4.2; Linux) KHTML/4.2.3 (like Gecko) SUSE

Coming from a network with proxy to a network without proxy, zypper starts to fail to download files.  Normally it is possible to use the environment variable http_proxy to network access possible again (not only for zypper, but many proxy using applications).  However, zypper does not use this variable, see the for test below:

test 1: http_proxy set and PROXY_ENABLED="yes"
linux-geis:~ # grep -i ^proxy /etc/sysconfig/proxy; echo $http_proxy
PROXY_ENABLED="yes"                                                 
proxy.company.com:8000                                              

linux-geis:~ # zyp ref                                                                                      
Failed to download /content from http://download.opensuse.org/distribution/11.2/repo/non-oss                
Abort, retry, ignore? [a/r/i/?] (a): a                                                                      

This is as expected.


test 2: http_proxy unset and PROXY_ENABLED="yes"
linux-geis:~ # grep -i ^proxy /etc/sysconfig/proxy; echo $http_proxy
PROXY_ENABLED="yes"                                                 

linux-geis:~ # zyp ref                                                                                      
Failed to download /content from http://download.opensuse.org/distribution/11.2/repo/non-oss                
Abort, retry, ignore? [a/r/i/?] (a): a                                                                      

This is unexpected: the variable http_proxy is not honoured.


test 3: http_proxy unset and PROXY_ENABLED="no"
linux-geis:~ # grep -i ^proxy /etc/sysconfig/proxy; echo $http_proxy
PROXY_ENABLED="no"

linux-geis:~ # zyp ref
Repository 'openSUSE 11.2 non-oss' is up to date.
Repository 'openSUSE 11.2 oss' is up to date.

This is unexpected: zypper should not use the values in /etc/sysconfig/proxy
directly.  It should use the environment variable instead.


test 4: http_proxy set and PROXY_ENABLED="no"
linux-geis:~ # grep -i ^proxy /etc/sysconfig/proxy; echo $http_proxy
PROXY_ENABLED="no"
proxy.company.com:8000

linux-geis:~ # zyp ref
Repository 'openSUSE 11.2 non-oss' is up to date.
Repository 'openSUSE 11.2 oss' is up to date.

This should fail: as the environment variable http_proxy is not respected.

It was not until I found the underneath lines in /var/log/zypper.log:
2009-11-25 22:09:32 <1> linux-geis(7415) [zypp++] Sysconfig.cc(read):31 Load '/etc/sysconfig/proxy'
2009-11-25 22:09:32 <1> linux-geis(7415) [zypp] Sysconfig.cc(read):71 done reading '/etc/sysconfig/proxy'
2009-11-25 22:09:32 <1> linux-geis(7415) [zypp++] MediaCurl.cc(attachTo):523 Proxy: -none-

That I understood the variable PROXY_ENABLED had to be altered.



Reproducible: Always

Steps to Reproduce:
See details section above
Actual Results:  
See details section above

Expected Results:  
The environment variable http_proxy should be respected by zypper.
Comment 1 Michael Andres 2009-11-26 17:00:16 UTC
This is related to bug #555066.

We need to figure out why /etc/sysconfig/proxy overrules the environment. I guess this was done to immediately reflect changes done by the YaST proxy configuration. So we'd need a fix for that usecase.
Comment 2 Richard Bos 2009-11-28 16:28:02 UTC
> We need to figure out why /etc/sysconfig/proxy overrules the environment. I
> guess this was done to immediately reflect changes done by the YaST proxy
> configuration. So we'd need a fix for that usecase.

Hmm, that is a good point.  You don't want a user to exit YaST and its related shell, to have him or her re-enter the shell and YaST to have the proxy variable reread.

Zypper should not read /etc/sysconfig/proxy, that is more a task for YaST.

As YaST controls and knows when /etc/sysconfig/proxy is changed, and also knows
when the related proxy variables are changed, YaST should instruct zypper how to deal with the proxy.  This seems possible with aria2c --http-proxy=HOST:PORT argument.

In normal cases YaST and hence Zypper should always use the environment variables, in the (rare ;) ) situation that the user changes the proxy settings, YaST should overwrite the environment settings and instruct aria2c via the --http-proxy=HOST:PORT how to deal with the proxy.  Or perhaps YaST can change the value of the environment variable http_proxy while running?

Hopefully this is can be implemented in YaST?!
Comment 3 Meinhard R 2009-12-18 10:46:31 UTC
I can confirm this bug. This is fatal in a company environent where users are forced to use an authenticating proxy.
After 
1.) changing the repos von 11.1 to 11.2
2.) zypper refresh
3.) zypper install zypper

zypper dup 

will not work anymore:

Failed to download /repodata/repomd.xml from http://download.opensuse.org/repositories/Emulators%3a/Wine/open                                SUSE_11.2/
Abort, retry, ignore? [a/r/i/?] (a):


After reading this and the other bug report I changed the entry

HTTP_PROXY=http://USERNAME:PW@proxy-url:PORT

This is a workaround only.

It worked in openSUSE 11.2.

Please fix asap

Thank you!
Comment 5 Duncan Mac-Vicar 2011-02-07 12:01:52 UTC
In 11.4 we use libproxy (see bug:655483). We wrote a module for libproxy to use /etc/sysconfig/proxy. However libproxy modules do not have order and basically the first module that says "YES" is used. The sysconfig module gets activated if you are running as root, so the behavior will be the same as before.

As in SUSE the variables _come_ from sysconfig this should not be a problem. I don't see a better way to know when sysconfig should not be used. We thought about using the YAST_IS_RUNNING variable but it is not a very clean solution.
Comment 6 Duncan Mac-Vicar 2011-02-07 12:07:20 UTC
In 11.4 we use libproxy (see bug:655483). We wrote a module for libproxy to use /etc/sysconfig/proxy. However libproxy modules do not have order and basically the first module that says "YES" is used. The sysconfig module gets activated if you are running as root, so the behavior will be the same as before.

As in SUSE the variables _come_ from sysconfig this should not be a problem. I don't see a better way to know when sysconfig should not be used. We thought about using the YAST_IS_RUNNING variable but it is not a very clean solution.
Comment 7 Michael Andres 2011-12-01 11:12:10 UTC
fixed in 11.4