Re: Network Manager and Gnome Proxy Settings



I've done exactly this, though it required quite a bit more magic.  You
can't run from just any user session.  It has to be a user session that
knows whatever environment is necessary to connect to an existing gconf
daemon.  Otherwise the effects will not be persistent.

The only way I was able to get it to work was to add:

xml:readonly:$(HOME)/.nm/gconf

To my users $HOME/.gconf.path.mandatory

Then create a proxy configuration file as a gconftool dump:

gconftool --dump /system/proxy > ~/.nm/system.proxy.xml
gconftool --dump /system/http_proxy > ~/.nm/system.http_proxy.xml

Then when the network comes up set the properties in $HOME/.nm/gconf
without a running gconfd with gconftool --direct:

gconftool --direct --config-source=xml:readwrite:$HOME/.nm/gconf --load=
$HOME/.nm/system.proxy.xml /system/proxy
gconftool --direct --config-source=xml:readwrite:$HOME/.nm/gconf --load=
$HOME/.nm/system.http_proxy.xml /system/http_proxy
#this part forces all running gconfd-2's to reload read-only data.
killall -q -HUP gconfd-2

Setting .gconf.path.mandatory this way cases $HOME/.nm/gconf to take
priority over the normal read-write gconf database.  This also has the
effect of making everything in /system/proxy and /system/http_proxy
read-only, effectively breaking gnome-network-settings.  I combine this
with a per-location set of network manager scripts (using the network
manager uuid), to set my proxy based on location.

A similar facility could be used to set mandatory system wide settings.


On Sat, 2010-09-18 at 16:51 +0000, Darren Hart wrote:
> I'm looking to write some scripts to automate proxy settings after
> connecting to my company vpn. I think my questions are best directed
> to network-manager and gnome-network-properties (gnome-control-center)
> developers. I didn't see an appropriate list for the latter on
> mail.gnome.org (networkmanager isn't listed there either for some
> reason). If someone can suggest an appropriate list for
> gnome-network-properties, I would appreciate it.
> 
> What I would like to do is set the various proxy host/port values via
> gconf on vpn-up and vpn-down events. I've written a script to detect
> these events and placed it in /etc/NetworkManager/dispatcher.d/. In
> this script I try to use gconftool to set the /system/http_proxy/host
> and other such values. When I run this script from my user session, it
> works as expected, when running from the nm dispatcher, it doesn't
> seem to change the values. It runs as root there, so I even tried it
> with "su myuser -c " without success. I have confirmed that the script
> is running and that it correctly identifies the vpn-up and vpn-down
> events via some print statements to the syslog.
> 
> I would also like it to be able to do the equivalent of "Apply
> System-Wide..." from the gnome-network-properties dialog. I tried
> telling gconftool to use the /etc/gconf/gconf.xml.defaults config, but
> that did change those values either.
> 
> Lastly, I haven't been able to determine where the ALL_PROXY and
> NO_PROXY env vars get set, as they are not written to
> /etc/environment.
> 
> Is there a way to run a post-vpn script that has the appropriate
> "scope" to modify the necessary gconf settings to update both the user
> proxies as well as the system-wide proxies?
> 
> Thanks,
> 
> --
> Darren Hart
> _______________________________________________
> networkmanager-list mailing list
> networkmanager-list gnome org
> http://mail.gnome.org/mailman/listinfo/networkmanager-list

-- 
Daniel Rogers
mobile: 510-379-8302
home:   925-429-5109
office: 415-979-3740




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]