Re: [pygtk] PolicyKit from Python

2008-07-09 Thread David Zeuthen

(Dunno if you got my other reply, I think Evolution ate it)

On Thu, 2008-02-07 at 16:19 +0100, Murray Cumming wrote:
> Thanks. I figured out a bit more since I sent the email, but I'm still
> having no luck. I blogged about it:
> http://www.murrayc.com/blog/permalink/2008/02/07/gnome-lirc-properties-using-policykit-to-get-sudo-access/

Does this work

 $ dbus-send --session --print-reply \
 --dest=org.freedesktop.PolicyKit.AuthenticationAgent / \
 org.freedesktop.PolicyKit.AuthenticationAgent.ObtainAuthorization \
 string:org.freedesktop.hal.storage.crypto-setup-fixed \
 uint32:0 \
 uint32:$PPID

replacing org.freedesktop.hal.storage.crypto-setup-fixed of course with
what you need. If so it should work from python too. Assuming of course
the application is running unprivileged.

  David


___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] PolicyKit from Python

2008-07-09 Thread David Zeuthen

On Thu, 2008-02-07 at 16:19 +0100, Murray Cumming wrote:
> On Thu, 2008-02-07 at 22:55 +0800, David Zeuthen wrote:
> > On Wed, 2008-02-06 at 13:32 +0100, Murray Cumming wrote:
> > > On Tue, 2008-02-05 at 15:58 +0100, Murray Cumming wrote:
> > > > Does anyone know if there are already PolicyKit (and
> > > > policykit-gnome) python bindings?
> > > 
> > > I discovered that I can probably do this with just the D-Bus API. I made
> > > the attached test case after some googling, but the call to PolicyKit's
> > > ObtainAuthorization() doesn't seem to have any effect. I'd welcome any
> > > advice.
> > > 
> > > I'm on Ubuntu Hardy Heron, where PolicyKit is definitely working, as
> > > seen when I try to use the Services control panel, for instance, which
> > > has an Unlock button.
> > > 
> > > I believe that I need to call ShowDialog() if ObtainAuthorization()
> > > denies authorization, but I want to understand this first part.
> > 
> > The names of interfaces and objects changed a bit since 0.6 to 0.7 to
> > make it desktop agnostic (so in some future if the user is running
> > non-GNOME he will get a native authentication agent etc.); this is what
> > you should use
> > 
> > http://hal.freedesktop.org/docs/PolicyKit/model-authentication-agent.html
> > http://hal.freedesktop.org/docs/PolicyKit-gnome/ref-auth-daemon.html
> > 
> > There is no ShowDialog() any more. Does that clear it up?
> 
> Thanks. I figured out a bit more since I sent the email, but I'm still
> having no luck. I blogged about it:
> http://www.murrayc.com/blog/permalink/2008/02/07/gnome-lirc-properties-using-policykit-to-get-sudo-access/

OK, unfortunately I won't have time to look at this until I'm back from
vacation late next week. But it's worth checking if just dbus-send works

 $ dbus-send --session --print-reply \
 --dest=org.freedesktop.PolicyKit.AuthenticationAgent / \
 org.freedesktop.PolicyKit.AuthenticationAgent.ObtainAuthorization \
 string: \
 uint32:0 \
 uint32:$PPID

where  is something like

 org.freedesktop.hal.storage.crypto-setup-fixed

or whatever comes out of polkit-action. If that works it's probably just
a dbus-python issue...

You asked for a website in your blog entry. What's wrong with

http://hal.freedesktop.org/docs/PolicyKit/
http://hal.freedesktop.org/docs/PolicyKit-gnome/

On a more serious note, yeah, I should move the docs to e.g.
policykit.freedesktop.org or something like that.

   David



___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] PolicyKit from Python

2008-07-09 Thread David Zeuthen

On Wed, 2008-02-06 at 13:32 +0100, Murray Cumming wrote:
> On Tue, 2008-02-05 at 15:58 +0100, Murray Cumming wrote:
> > Does anyone know if there are already PolicyKit (and
> > policykit-gnome) python bindings?
> 
> I discovered that I can probably do this with just the D-Bus API. I made
> the attached test case after some googling, but the call to PolicyKit's
> ObtainAuthorization() doesn't seem to have any effect. I'd welcome any
> advice.
> 
> I'm on Ubuntu Hardy Heron, where PolicyKit is definitely working, as
> seen when I try to use the Services control panel, for instance, which
> has an Unlock button.
> 
> I believe that I need to call ShowDialog() if ObtainAuthorization()
> denies authorization, but I want to understand this first part.

The names of interfaces and objects changed a bit since 0.6 to 0.7 to
make it desktop agnostic (so in some future if the user is running
non-GNOME he will get a native authentication agent etc.); this is what
you should use

http://hal.freedesktop.org/docs/PolicyKit/model-authentication-agent.html
http://hal.freedesktop.org/docs/PolicyKit-gnome/ref-auth-daemon.html

There is no ShowDialog() any more. Does that clear it up?

  David


___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/