Re: Accessing NetworkManager from a daemon

On 29/08/14 18:20, Stuart Longland wrote:
On 29/08/14 01:34, Dan Williams wrote:
Polkit is about access control though, and if you don't care about that,
you can tell Polkit to allow all your accesses.  But the problem you're
having is that you don't even get that far, because NM is checking if
you have a session first.  Can you check if you have ConsoleKit or
systemd session tracking enabled?  If you get a hit for this, you have
systemd enabled

Indeed, I run your command and get:
stuartl sjl-lxc-debian:~$ ldd /usr/sbin/NetworkManager | grep systemd-login => /lib/i386-linux-gnu/ (0xf7387000)

Okay, so I've now tried a different approach.  Rather than trying to
bend Polkit/ConsoleKit/NetworkManager to my will in talking directly to
www-data, I've done something that's perhaps a little kludgy, but then
again, perhaps not.

I've written a DBus service which is launched from the Django
script.  It listens for requests from www-data to update connections and
acts on them.

So when I create a connection, the web application writes to the
database, then sends a DBus message to the agent telling it what ID it
just created.  The agent picks this up, generates the configuration dict
and feeds NetworkManager with it.

That's where it's "kludgy".  The flip side is that if the configuration
changes, I can pick up on the signals NetworkManager emits to update the
Django model.  I haven't done this as yet, but seeing as I've got the
potential there I might as well.

The DBus service runs as 'root', and is launched by dbus-activation so
there's no issues with talking to NetworkManager, and I'm now able to
add and delete network connections from the web UI.

If people on the list here are interested in such a module for Django to
control NetworkManager, let me know and I'll see what I can organise.

Stuart Longland
Systems Engineer
     _ ___
\  /|_) |                           T: +61 7 3535 9619
 \/ | \ |     38b Douglas Street    F: +61 7 3535 9699
   SYSTEMS    Milton QLD 4064

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