[linux-elitists] Per-user network up and down scripts

Don Marti dmarti@zgp.org
Fri Dec 5 08:48:40 PST 2008

begin Greg KH quotation of Fri, Dec 05, 2008 at 07:19:49AM -0800:
> On Fri, Dec 05, 2008 at 03:27:19AM -0500, Ruben Safir wrote:
> > It is doing a hell of a lot less now.  I hate DBUS and HAL
> Then go back to a 5 year old distro and see how well it works for
> dynamic devices and proper multi-user permissions on those devices.

The good news is that if you have the right to
install a script in /etc, you don't have to learn
D-Bus to solve the problem of running something when
an interface comes up or down.  NetworkManager makes
sure that the appropriate up and down scripts get
run at the right times, so all you have to do is drop
your script in the right place.  For example, if you
have an ssh tunnel that you want up when the network
is, you can put a script in /etc/network/if-up.d to
bring it up, and /etc/network/if-post-down.d to tear
it down.

script for /etc/network/if-up.d:

script for /etc/network/if-post-down.d:

(If things get flaky, just use your existing
NetworkManager panel thingy to bounce the network,
and you bounce your tunnel too.)

So, not a problem, except for stuff you want to
run as a user.  If the user is already running the
application that needs to take action when the network
changes, no big deal -- just make the application
listen for a D-Bus message.

For actions that aren't associated with long-running
apps, we just need a script under /etc/network that
will run per-user scripts for users who are members
of the "netdev" group.

Is there a way to list all members of a group that
will work whether the group is in /etc/group or on
LDAP or some other directory server?

Don Marti                                        +1 510-814-0932
http://zgp.org/~dmarti/                          +1 510-332-1587 mobile
See you at OpenSource World: August 10-13, 2009 in San Francisco

More information about the linux-elitists mailing list