Firefox ignores GNOME 3 proxy settings

Bug #875266 reported by Nobuto Murata
90
This bug affects 18 people
Affects Status Importance Assigned to Milestone
Mozilla Firefox
Fix Released
Medium
firefox (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

Firefox ignores GNOME3 proxy settings.
This is regression from Natty+GNOME 2.

How to reproduce:
 1. set proxy in gnome-control-center
 2. set 'Use system proxy settings' in Firefox settings (default)
 3. open web pages

Expected:
 4. pages are shown using proxy

Happened instead:
 4. pages are not shown behind proxy

WORKAROUND:
 use 'manual proxy configuration' in Firefox settings

ProblemType: Bug
DistroRelease: Ubuntu 11.10
Package: firefox 7.0.1+build1+nobinonly-0ubuntu2
ProcVersionSignature: Ubuntu 3.0.0-12.20-generic-pae 3.0.4
Uname: Linux 3.0.0-12-generic-pae i686
AddonCompatCheckDisabled: False
AlsaVersion: Advanced Linux Sound Architecture Driver Version 1.0.24.
AplayDevices:
 **** List of PLAYBACK Hardware Devices ****
 card 0: Intel [HDA Intel], device 0: ALC269 Analog [ALC269 Analog]
   Subdevices: 1/1
   Subdevice #0: subdevice #0
ApportVersion: 1.23-0ubuntu3
Architecture: i386
ArecordDevices:
 **** List of CAPTURE Hardware Devices ****
 card 0: Intel [HDA Intel], device 0: ALC269 Analog [ALC269 Analog]
   Subdevices: 1/1
   Subdevice #0: subdevice #0
AudioDevicesInUse:
 USER PID ACCESS COMMAND
 /dev/snd/controlC0: nobuto 1667 F.... pulseaudio
BuildID: 20111008085056
CRDA: Error: [Errno 2] そのようなファイルやディレクトリはありません
Card0.Amixer.info:
 Card hw:0 'Intel'/'HDA Intel at 0xf0a00000 irq 45'
   Mixer name : 'Realtek ALC269'
   Components : 'HDA:10ec0269,10cf0000,00100004 HDA:11c11040,10cf14a5,00100200'
   Controls : 17
   Simple ctrls : 11
Channel: release
CheckboxSubmission: 1d84ca1b2de43c2199974f7b8a6ca9cb
CheckboxSystem: 0657dd966bc74d2b22e7c94051aa55af
Date: Sun Oct 16 04:41:44 2011
EcryptfsInUse: Yes
ForcedLayersAccel: False
IfupdownConfig:
 auto lo
 iface lo inet loopback
InstallationMedia: Ubuntu 11.10 "Oneiric Ocelot" - Beta i386 (20111007)
IpRoute:
 default via 192.168.11.1 dev wlan0 proto static
 169.254.0.0/16 dev wlan0 scope link metric 1000
 192.168.11.0/24 dev wlan0 proto kernel scope link src 192.168.11.52 metric 2
Profiles:
 Profile0 (Default) - LastVersion=7.0.1/20111008085056
 Profile1 - LastVersion=7.0.1/20111008085056
 Profile2 - LastVersion=6.0.2/20110905174115 (Out of date)
 Profile3 - LastVersion=6.0/20110812234425 (Out of date)
 Profile4 - LastVersion=5.0/20110622232052 (Out of date)
RunningIncompatibleAddons: False
SourcePackage: firefox
UpgradeStatus: No upgrade log present (probably fresh install)
dmi.bios.date: 03/30/2009
dmi.bios.vendor: FUJITSU // Phoenix Technologies Ltd.
dmi.bios.version: Version 1.22
dmi.board.name: FJNB1E6
dmi.board.vendor: FUJITSU
dmi.chassis.type: 10
dmi.chassis.vendor: FUJITSU
dmi.modalias: dmi:bvnFUJITSU//PhoenixTechnologiesLtd.:bvrVersion1.22:bd03/30/2009:svnFUJITSU:pnFMVMGD75P:pvr:rvnFUJITSU:rnFJNB1E6:rvr:cvnFUJITSU:ct10:cvr:
dmi.product.name: FMVMGD75P
dmi.sys.vendor: FUJITSU

Revision history for this message
In , Jhorak (jhorak) wrote :

Gnome 3 uses GSettings for proxy configuration now. Firefox does not get proxy settings set by gnome-control-center when option 'Use system proxy settings' in Connection settings is set.

Revision history for this message
In , Jhorak (jhorak) wrote :

Created attachment 556542
gsettings proxy patch v 1

Initial patch, not sure who to set as reviewer, feel free to reassign.

Revision history for this message
In , Karlt (karlt) wrote :

Is this setting fetched during start-up?

I'm worried about using GSettings during start-up. (Bug 611953 comment 37)
Using GSettings during a delayed request after the browser is visible would be acceptable, I hope.

A stack track at the first invocation of this code may tell the story.

Revision history for this message
Nobuto Murata (nobuto) wrote :
Changed in firefox:
importance: Unknown → Medium
status: Unknown → In Progress
Changed in firefox (Ubuntu):
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
ThierryM (thierry-munoz) wrote :

Hi,
I confirm the proxy settings aren't applied for Firefox and Thunderbird. But there are applied for Chromium.

Revision history for this message
CuteChaps (sh-senthilkumar) wrote :

Firefox/pidgin/thunderbird doesn't pick the proxy settings from system proxy settings.

Revision history for this message
CuteChaps (sh-senthilkumar) wrote :

It was working fine on 11.04, multiple users are affected so please help us with a fix or workaround at the earliest.

Revision history for this message
In , Jhorak (jhorak) wrote :

Created attachment 567719
backtrace first run

Attaching backtrace of first run (when previous version of Firefox was executed last time).

Revision history for this message
In , Jhorak (jhorak) wrote :

Created attachment 567720
backtrace next run

Revision history for this message
In , Jhorak (jhorak) wrote :

Created attachment 567725
DumpJSStack

By checking js stacktrace getting proxy settings for this kind of URI makes sense. I can't imagine how to avoid it during startup.

Revision history for this message
In , Karlt (karlt) wrote :

Thank you. I'm OK with checking settings during startup if it's only for the whatsnew page when there is a new version.

Looks like starting the proxy service is lazy intentionally:
http://hg.mozilla.org/mozilla-central/annotate/767693e248aa/netwerk/base/src/nsIOService.cpp#l653

I'll look further into your patch, thanks.

Revision history for this message
In , Karlt (karlt) wrote :

Comment on attachment 556542
gsettings proxy patch v 1

I looked at the GSettingsService changes.

There is a new symbol that needs to be added to the GSETTINGS_FUNCTIONS at the
top of the file for dynamic lookup, and some other things to touch up there so
that this compiles against old versions of GIO.

>+#include "nsISupports.h"
> #include "nsCOMPtr.h"
>+#include "nsIMutableArray.h"

I expect nsISupports.h does not need to be listed explicitly because
nsIMutableArray.h or nsISupportsPrimitives.h will pull it in.

>+ const gchar ** gs_strings = g_variant_get_strv(value, NULL);
>+ g_variant_unref(value);

gs_strings doesn't own the strings, only the list of pointers.
What owns the strings after value is released?

>+ if (!gs_strings) {
>+ // empty array
>+ return NS_OK;
>+ }

aResult needs to be set if returning NS_OK.

>+ nsCOMPtr<nsIMutableArray> items(do_CreateInstance(NS_ARRAY_CONTRACTID));
>+ if (!items)
>+ return NS_ERROR_OUT_OF_MEMORY;

Leaks gs_strings.

Probably tidiest to move this construction to before other allocations.

>+ nsCOMPtr<nsISupportsString> obj(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));

Would it make sense to instead use nsISupportsCString?
That would be more consistent with the AUTF8Strings returned by getString and
used in parameters, and it is probably the format more useful to the caller in
this case.

Think about whether using NS_NewAdoptingUTF8StringEnumerator instead of
nsIMutableArray would simplify things:
http://hg.mozilla.org/mozilla-central/annotate/84117219ded0/xpcom/ds/nsStringEnumerator.h#l90

Revision history for this message
In , Jhorak (jhorak) wrote :

(In reply to Karl Tomlinson (:karlt) from comment #7)
> Think about whether using NS_NewAdoptingUTF8StringEnumerator instead of
> nsIMutableArray would simplify things:
> http://hg.mozilla.org/mozilla-central/annotate/84117219ded0/xpcom/ds/
> nsStringEnumerator.h#l90

Isn't NewAdoptingUTF8StringEnumerator available only for internal API? I'm having problem with compilation when file including nsStringEnumerator.h (it seems to include nsString.h which needs to have MOZILLA_INTERNAL_API defined and I don't see MOZILLA_INTERNAL_API in Makefile or in compilation output - in toolkit/system/gnome directory).

Revision history for this message
In , Karlt (karlt) wrote :

(In reply to jhorak from comment #8)
> Isn't NewAdoptingUTF8StringEnumerator available only for internal API?

Looks like you are right, based on bug 466622 comment 16 and 17.

Revision history for this message
In , Jhorak (jhorak) wrote :

Created attachment 577534
gsettings proxy patch v2

Thanks for reviewing. Attaching patch which should respect mentioned issues.

>There is a new symbol that needs to be added to the GSETTINGS_FUNCTIONS at the
>top of the file for dynamic lookup, and some other things to touch up there so
>that this compiles against old versions of GIO.
Could you be more specific (the other things)?

Please have a look.

Revision history for this message
In , Karlt (karlt) wrote :
Download full text (3.7 KiB)

Comment on attachment 577534
gsettings proxy patch v2

> FUNC(g_variant_get_string, const char *, (GVariant* value, gsize* length)) \
> FUNC(g_variant_is_of_type, gboolean, (GVariant* value, const GVariantType* type)) \
> FUNC(g_variant_new_int32, GVariant *, (gint32 value)) \
> FUNC(g_variant_new_boolean, GVariant *, (gboolean value)) \
> FUNC(g_variant_new_string, GVariant *, (const char* string)) \
>+ FUNC(g_variant_get_strv, GVariant *, (gsize* length)) \

These were roughly in an order.
Can you insert get_strv after get_string, please?

(In reply to jhorak from comment #10)
> Could you be more specific (the other things)?

Check the #define statements before and after GSETTIINGS_FUNCTIONS as any new
symbols need to be added here.

A #define is needed for g_variant_get_strv and G_VARIANT_TYPE_STRING_ARRAY.

>+ if (mGConf && IsProxyMode("auto")) {
>+ return mGConf->GetString(NS_LITERAL_CSTRING("/system/proxy/autoconfig_url"),
>+ aResult);
> }

>+ if (mGSettings) {
>+ // Check if mode is auto

I assume GSettings should override GConf settings.
Otherwise I assume those who upgrade to GNOME 3 will still be using their old
GConf settings, but the configuration utility will change the GSettings
values.

>+ nsCString proxyMode;
>+ nsCOMPtr<nsIGSettingsCollection> proxy_settings;
>+ mGSettings->GetCollectionForSchema(NS_LITERAL_CSTRING("org.gnome.system.proxy"),
>+ getter_AddRefs(proxy_settings));
>+ if (proxy_settings) {
>+ nsresult rv = proxy_settings->GetString(NS_LITERAL_CSTRING("mode"), proxyMode);

Move the proxyMode declaration to within the "if (proxy_setttings)" block
where it is used.

>+ return proxy_settings->GetString(NS_LITERAL_CSTRING("autoconfig-url"),
>+ aResult);

Alignment.

>+ PRInt32 port;
>+ rv = proxy_settings->GetInt(NS_LITERAL_CSTRING("port"), &port);
>+ NS_ENSURE_SUCCESS(rv, rv);
>+
>+ SetProxyResult(aType, host, port, aResult);
>+ return NS_OK;

Need to return NS_ERROR_FAILURE when the port is 0.

       'Each of the 4 proxy types is enabled if its "host" key is
        non-empty and its "port" key is non-0.'

http://git.gnome.org/browse/gsettings-desktop-schemas/tree/schemas/org.gnome.system.proxy.gschema.xml.in.in

>+ // Check if proxy is enabled, flag is only in schema org.gnome.system.proxy.http,
>+ // there is no separate flag for each schema.
>+ nsresult rv = mGSettings->GetCollectionForSchema(NS_LITERAL_CSTRING("org.gnome.system.proxy.http"),
>+ getter_AddRefs(proxy_settings));
>+ NS_ENSURE_SUCCESS(rv, rv);
>+ rv = proxy_settings->GetBoolean(NS_LITERAL_CSTRING("enabled"), &masterProxySwitch);
>+ NS_ENSURE_SUCCESS(rv, rv);

"enabled" is described as "Unused", so don't use this key.

>+ bool useHttpProxyForAll = false;
>+ // This setting sometimes doesn't exist, don't bail on failure
>+ proxy_settings->GetBoolean(NS_LITERAL_CSTRING("use-same-proxy"), &useHttpProxyForAll);
>+
>+ if (!useHttpProxyForAll) {
>+ rv = SetProxyResultFromGSettings("org.gnome.system.proxy.socks", "SOCKS", a...

Read more...

Revision history for this message
In , Karlt (karlt) wrote :

Comment on attachment 577534
gsettings proxy patch v2

>+ obj->SetData(nsCString(*p_gs_strings));

nsDependentCString is more conventional here.

>-static bool GConfIgnoreHost(const nsACString& aIgnore,
>- const nsACString& aHost)
>+static PRBool HostIgnoredByProxy(const nsACString& aIgnore,
>+ const nsACString& aHost)

We now use bool/true/false.

>+ nsDependentCSubstring aIgnoreStripped(start, slash);

The a- prefix on variables is used for parameters (arguments).
As this is not a parameter, so call it "ignoreStripped".

(In reply to Karl Tomlinson (:karlt) from comment #11)
> >+ if (mGConf && IsProxyMode("auto")) {
> >+ return mGConf->GetString(NS_LITERAL_CSTRING("/system/proxy/autoconfig_url"),
> >+ aResult);
> > }
>
> >+ if (mGSettings) {
> >+ // Check if mode is auto
>
> I assume GSettings should override GConf settings.
> Otherwise I assume those who upgrade to GNOME 3 will still be using their old
> GConf settings, but the configuration utility will change the GSettings
> values.

The existance of GSettings does not imply that gsettings-desktop-schemas is
installed, but, if there is an org.gnome.system.proxy schema, and mode is not
auto, then best to respect the desktop-schemas settings by not falling back to
GConf here.

>+ if (mGSettings)
>+ return GetProxyFromGSettings(scheme, host, port, aResult);
>+ else
>+ return GetProxyFromGConf(scheme, host, port, aResult);

Also here, best to fall back to GConf if org.gnome.system.proxy does not
exist.

Revision history for this message
In , Jhorak (jhorak) wrote :

Created attachment 578249
gsettings proxy patch v3

Attaching next version. Mentioned issues should be resolved. Also changed UUID of nsIGSettingsService due to its change.

Revision history for this message
In , Karlt (karlt) wrote :

Comment on attachment 578249
gsettings proxy patch v3

>+ nsCOMPtr<nsIGSettingsCollection> proxy_settings;
>+
>+ // Check if proxy is enabled, flag is only in schema org.gnome.system.proxy.http,
>+ // there is no separate flag for each schema.
>+ nsresult rv = mGSettings->GetCollectionForSchema(NS_LITERAL_CSTRING("org.gnome.system.proxy.http"),
>+ getter_AddRefs(proxy_settings));
>+ NS_ENSURE_SUCCESS(rv, rv);
>+
>+ rv = mGSettings->GetCollectionForSchema(NS_LITERAL_CSTRING("org.gnome.system.proxy"),
>+ getter_AddRefs(proxy_settings));

The "org.gnome.system.proxy.http" schema is now not needed here.

>- if (!mGConf)
>+ if (!mGConf || !mGSettings)
> return GetProxyFromEnvironment(scheme, host, port, aResult);

This isn't what we want. This will use the environment unless GSettings and
GConf are available. Best to treat this as a fallback after the GSettings and
GConf code.

>+ /* Check for org.gnome.syste.proxy schema */
>+ nsCOMPtr<nsIGSettingsCollection> proxy_settings;
>+ mGSettings->GetCollectionForSchema(NS_LITERAL_CSTRING("org.gnome.system.proxy"),
>+ getter_AddRefs(proxy_settings));
>+ /* If schema is found let GSettings determine the right proxy, otherwise fallback to gconf. */
>+ if (proxy_settings)
>+ return GetProxyFromGSettings(scheme, host, port, aResult);

GetCollectionForSchema is an expensive operation, so I don't want the
"org.gnome.system.proxy" schema fetched both here and in GetProxyFromGSettings.

I think it should be fine to fall back to GConf and/or environment variables
when GetProxyFromGSettings returns a failure code.

Revision history for this message
In , Jhorak (jhorak) wrote :

Created attachment 578520
gsettings proxy patch v4

- Removed forgotten org.gnome.system.proxy.http
- GetProxyFromEnvironment moved to the end as the last method to use to determine proxy
- Part for checking org.gnome.syste.proxy schema removed.

Revision history for this message
In , Karlt (karlt) wrote :

Comment on attachment 578520
gsettings proxy patch v4

>+ items->AppendElement(obj, PR_FALSE);

Can you update PR_FALSE with false, please?

Revision history for this message
In , Jhorak (jhorak) wrote :

Created attachment 579030
gsettings proxy patch v5

Thanks for review, attaching patch with replaced PR_FALSE.

Revision history for this message
In , Dao-g (dao-g) wrote :
Revision history for this message
In , Matt Brubeck (mbrubeck) wrote :
Changed in firefox:
status: In Progress → Fix Released
Revision history for this message
CuteChaps (sh-senthilkumar) wrote :

How to apply the fix

Changed in firefox (Ubuntu):
status: Triaged → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :
Download full text (4.1 KiB)

This bug was fixed in the package firefox - 11.0~b1+build1-0ubuntu1

---------------
firefox (11.0~b1+build1-0ubuntu1) precise; urgency=low

  * New upstream release from the beta channel (FIREFOX_11_0b1_BUILD1)
    - Fix LP: #875266 - Firefox ignores GNOME3 proxy settings
    - Fix LP: #857153 - Needs to get accessibility settings from GSettings

  * Update globalmenu-extension to 2.0.3
  * Ensure that the crash reporter is disabled if rebuilt by Ubuntu
    derivatives, as there will be no crash symbols for those
    - update debian/rules
  * Only add "Ubuntu" to the UA string when being built for Ubuntu
    - update debian/rules
  * Drop obsolete Debian menu file
    - remove debian/firefox.menu.in
    - don't create a 32x32 xpm icon in debian/rules
    - drop the imagemagick build-depend in debian/control
  * Temporarily disable ipdl tests due to build failures. These aren't
    enabled upstream, anyway
    - update debian/config/mozconfig.in
  * Always set the update channel - not setting it at build-time on release
    builds breaks the extensions.checkCompatibility pref. The only things
    using it at runtime are nsBlocklistService, Test Pilot (beta + aurora)
    and the about dialog (where the channel is hidden anyway)
    - update debian/rules
    - update debian/firefox.install.in
  * Don't declare an extra DEB_ENABLE_THUMB2 variable, as it's only used
    for the mozconfig. Just do the "if DEB_HOST_ARCH == armel" check
    directly there instead
    - update debian/rules
    - update debian/config/mozconfig.in
  * Fix LP: #898883 - IPC xpcshell tests hang the buildd's. Give all
    xpcshell tests an X display, as plugin-container won't work without one
    - update debian/build/testsuite.mk
  * Turn on all IPC xpcshell tests again
    - update debian/build/testsute.mk
  * Drop the default-apps xml file from lucid and maverick - there is
    already one provided by gnome-control-center, which means that ours
    is only relevant for nightly builds. It's not worth the extra
    complexity for this
    - remove debian/firefox.xml.in
    - update debian/firefox-gnome-support.install.in
    - update debian/rules
  * Ship Test Pilot as a distribution addon, like upstream. This means
    that the addon manager can update it. It does also mean that it will
    remain installed in users profiles if they try the beta or aurora
    builds, but the Feedback button is disabled on release builds
    - update debian/firefox.install.in
    - fixes LP: #913357
  * Drop patches fixed upstream
    - remove debian/patches/fix-build-failure-without-yarr-jit.patch
    - remove debian/patches/fix-cursor-handling.patch
    - update debian/patches/series
  * Keep the firefox-kde-support suggest on releases older than precise
    for now
    - update debian/rules
  * Ensure that we suggest kmozillahelper on lucid
    - update debian/rules
  * Ensure that we replace kubuntu-firefox-installer on lucid
    - update debian/rules
  * Don't build with --disable-gconf on precise and newer. There won't be
    a hard runtime requirement on this from Firefox 12 anyway, and this
    keeps us closer to the upstream configuration
    - update debian/config/mozconfig.in
...

Read more...

Changed in firefox (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
In , Theodore Lee (sharp-shiny) wrote :

Does this fix cover setting a SOCKS proxy? The 2012-02-21 Nightly still doesn't seem to pick up SOCKS proxy settings from GNOME 3.

Revision history for this message
In , Karlt (karlt) wrote :

We'll need bug 713802 to get support in nightlies.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.