GNOME/Proxy configuration

From openSUSE

FIXME: This needs to be updated for GIO (we no longer really use gnome-vfs at the core of GNOME)

Contents

Proxy configuration in GNOME

GNOME has its own mechanism to store the configuration for proxies. This configuration gets propagated to apps through well-known GConf keys:

Key                                           Type     Remarks
------------------------------------------------------------------------------------
/system/http_proxy/use_http_proxy             bool     used only by gnome-vfs
/system/http_proxy/host                       string   "my-proxy.example.com" without "http://"
/system/http_proxy/port                       int
/system/http_proxy/use_authentication         bool
/system/http_proxy/authentication_user        string
/system/http_proxy/authentication_password    string
/system/http_proxy/ignore_hosts               list-of-string
/system/proxy/mode                            string   THIS IS THE CANONICAL KEY; SEE BELOW
/system/proxy/secure_host                     string   "proxy-for-https.example.com"
/system/proxy/secure_port                     int
/system/proxy/ftp_host                        string   "proxy-for-ftp.example.com"
/system/proxy/ftp_port                        int
/system/proxy/socks_host                      string   "proxy-for-socks.example.com"
/system/proxy/socks_port                      int
/system/proxy/autoconfig_url                  string   "http://proxy-autoconfig.example.com"

The "/system/proxy/mode" key is the canonical one. Gnome-vfs doesn't use it and rather uses an older key, "/system/http_proxy/use_http_proxy", but gnome-control-center and gnome-settings-daemon take care of propagating the value from "mode" to this older key.

In an unpatched GNOME, "/system/proxy/mode" can have these values:

  • "none" - No proxy is used
  • "manual" - The user's configuration values are used (/system/http_proxy/{host,port,etc.})
  • "auto" - The "/system/proxy/autoconfig_url" key is used

Proxy configuration in openSUSE

In openSUSE, however, the most basic place to configure proxies is in YaST. It creates an /etc/sysconfig/proxy file which is just a shell script that sets some environment variables. This script gets sourced from various places to find the configuration, including the user's .profile.

The idea is that GNOME will pick up the values from YaST and use them.

To do this in a way that avoids patching all applications, we make gnome-settings-daemon pick up changes in /etc/sysconfig/proxy and propagate them through the usual GConf keys to GNOME applications. A detailed description follows.

Add an extra GConf key

We add a GConf key called "/system/proxy/use_system_settings" of type string, which can have these values:

  • "only_if_mode_not_set" - This is the default value in the GConf schemas. When the "use_system_setting" key is set to this default value, gnome-settings-daemon only changes the old GConf keys iff the "/system/proxy/mode" key has never been set by the user (i.e. if its value comes straight from the schema defaults). This way we preserve the user's preferences on an upgrade, and use the sysadmin's settings on a new install. As soon as the user changes his preferences in the GUI to "system-values" or "user-values" (described below), the "use-system-setting" key can never go back to its initial value of "only_if_mode_not_set".
  • "system-values" - This makes gnome-settings-daemon overwrite the old GConf keys with the values extracted from /etc/sysconfig/proxy.
  • "user-values" - The user's configuration is used, from the old GConf keys.

So, the possible transitions are these:

     (default)
only_if_mode_not_set ------> system_values <========> user_values

Footnote: ideally we should not have this key at all and just have "/system/proxy/mode" be able to attain a new possible value. However, apps don't expect this, and we want to change them as little as possible.

Rationale: if the user has ever set the "/system/proxy/mode" key, we can assume that his proxy setup is working correctly. Therefore, we don't want to override it with the system's settings. If the user has never changed this key, it means that he is happy whith whatever the sysadmin gave him, so it is safe to pick up the system's values from YaST.

We add an option to the gnome-network-preferences GUI (from the control-center2 package) to show "Use the system's proxy settings". When turned on, this sets the key "/system/proxy/use_system_settings" to "system_values". When turned off, that key gets set to "user-values" and the other options in the GUI get used.

Modify gnome-settings-daemon

Our patched gnome-settings-daemon (also from the control-center2 package) monitors changes in /etc/sysconfig/proxy. When a change happens, it re-reads this file. If the "/system/proxy/use_system_settings" key is set to "system_values", or to "only_if_mode_not_set" and the user has never set "/system/proxy/mode", then the values from YaST get propagated to the normal GConf keys from GNOME so that apps pick up the values automatically.

Recommendations

If a certain application in openSUSE has its own method for proxy configuration, it is recommended that a similar scheme to the above be used to extend it to pick up YaST's configuration. This way the user's settings will be preserved if he has actually set them to something.

Caveats and future work

Not all applications support the same kinds of proxies, or even the same parameters for the same kind of proxy. Firefox seems to have the most featureful support. YaST has very few options. GNOME is somewhere along the middle.

Resources

Our gnome-settings-daemon and gnome-control-center packages have the patches for GNOME; look for *-system-proxy-configuration.diff. These patches are available available in NLD9 SP2, SuSE 9.3, SLED 10, and all versions of openSUSE starting from 10.2.

Our gaim package has a patch called gaim-gconf-proxy-settings.diff. It is available in NLD9 SP2, SuSE 9.3, SuSE 10, and SLED 10. After those, gaim got renamed to pidgin and since then it includes a similar patch in the mainline sources.

Troubleshooting

  • This will only work for programs run under a GNOME session, since it is gnome-settings-daemon who monitors /etc/sysconfig/proxy and mirrors it to the GConf settings.
  • The proxy info from /etc/sysconfig/proxy will only be used if the user has selected "Use the system's proxy configuration" in the gnome-network-preferences capplet.