PolkitAgentTextListener from a Python script

Colin Walters walters at verbum.org
Sun Aug 31 07:40:26 PDT 2014


On Fri, Aug 29, 2014, at 07:42 AM, Stuart Longland wrote:
> Hi all,
> On 28/08/14 11:20, Stuart Longland wrote:
> > My research into this has suggested I need to make use of the
> > PolkitAgentTextListener:
> > http://www.freedesktop.org/software/polkit/docs/0.105/PolkitAgentTextListener.html
> > 
> > How do I access this object via DBus?
> 
> Still tinkering with this.  I note the documentation makes reference to
> pkttyagent, which I've attempted to launch via Python's pty and
> subprocess modules.  No such luck it seems, as it *demands* a tty, and I
> haven't yet been able to fool it.

Ultimately pkttyagent just uses the DBus APIs to register as an agent,
which you can do directly from python too, via pygobject's bindings to
GDBus for example.

However, I suspect that even if you succeed in registering an agent, you
will be at least partially foiled by the fact there's no session
registered, that's what the error message here is saying:

> org.freedesktop.NetworkManager.Settings.PermissionDenied: No session found for uid 33 (unknown)

I'd take a look at:

http://cockpit-project.org/

It's written in C, but is also a web interface that performs system
control by DBus.  Notably, you log into it via username/password, and it
creates a PAM (and thus systemd) session.


More information about the polkit-devel mailing list