making network manager update proxies



Greetings,

The scripts I mention are available at
http://www.phasevelocity.org/~daniel/nm-scripts.tgz

Updating my proxies and being able to restart my ssh tunnels when the
network changes is one of the last pieces I needed to really make
NetworkManager useful.

I've come up with a somewhat reliable architecture for doing so.

I've written two NetworkManager dispatch scripts.

The first is by-location, and the second is by-user.  I've also
developed a procedure of reliable changing gconf2 defaults so that my
gnome proxies properly switch.

First by-location attempts to execute either:

/etc/NetworkManager/locations.d/by-uuid/$CONNECTION_UUID
or
/etc/NetworkManager/locations.d/default
depending on if $CONNECTION_UUID is set or not.  These scripts are
called as root.

by-user does a similar procedure for calling
$HOME/.nm/by-uuid/$CONNECTION_UUID or $HOME/.nm/default depending on
whether or not $CONNECTION_UUID is set.  These scripts are run as the
logged in user, and are only executed if that user is logged in.

Those dispatch scripts are enough to conveniently configure per-location
and per-user commands.

The second half, getting gconf to behave was in two parts.  First I
edited $HOME/.gconf.path.mandatory and added the line xml:readonly:
$(HOME)/.nm/gconf

This causes gconf to read out per-user mandatory overrides (that
override the read-write database) from $(HOME)/.nm/gconf

I then used

$ gconftool --dump /system/proxy > $(HOME)/.nm/settings/proxy.default.xml
$ gconftool --dump /system/http_proxy > $(HOME)/.nm/settings/http_proxy.default.xml

To create two default proxy settings files that can be loaded with gconftool --load

I then added the lines to my by-uuid user script:

gconftool --direct --config-source=xml:readwrite:$HOME/.nm/gconf --load=$HOME/.nm/settings/proxy.default.xml /system/proxy
gconftool --direct --config-source=xml:readwrite:$HOME/.nm/gconf --load=$HOME/.nm/settings/http_proxy.default.xml /system/http_proxy
#HUP causes a re-read of read-only settings
killall -q -HUP gconfd-2

This successfully switches proxies in gconf2.

These scripts solve my problems wonderfully.  However they have a host
of issues for general use, though I do believe they are close to a good,
general solution.

First, this setup will break gnome-network-properties.  Unfortunately I
couldn't find a good way to twiddle gconf settings without having access
to various gnome-session environment variables.  Fortunately, I don't
have to use it anymore, so it's a non-issue for me  A person who
understands gconf better than I could either write a command line tool
to edit gnome-network-properties correctly, which I could call from the
per user scripts, or could rewrite gnome-network-properties to edit the
networkmanager gconf dir.

Second, there is no way to call down on a per-location basis.  So the
default script is always called for down.  This is because down doesn't
set CONNECTION_UUID.

Third, the per-user stuff should probably call default always, and also
the per-location script if it exists.

Fourth, this isn't a flexible configuration architecture.  There could
be some work to make the by-uuid scripts more reusable.

Fifth, this doesn't safely fork off the per-user scripts as it should.
This means any user could probably hang NetworkManager indefinitely by
calling sleep(1000) in a loop.  This puts more burden on the user to
properly avoid reexecing or cleaning up during a set of rapid network
changes.

Anyways, this does present a workable solution to how to make gconf work
with NetworkManager.

-- 
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]