[packagekit] PolicyKit dbus interfacing

Martin Pitt martin.pitt at ubuntu.com
Wed Aug 6 22:42:57 PDT 2008

Hi Aidan,

Aidan Skinner [2008-08-06 23:05 +0100]:
>         policykit =
> self.bus.get_object('org.freedesktop.PolicyKit.AuthenticationAgent',
> '/',
> 'org.gnome.PolicyKit.AuthorizationManager.SingleInstance')

Two potential traps here:

 * Are you sure that self.bus points to the session bus? If it's the
   same than used for packagekit itself, it's wrong, since PackageKit
   uses the system bus. Try s/self.bus/dbus.SessionBus().

 * I haven't seen that AuthorizationManager.SingleInstance object in
   recent PolicyKit versions at least. Starting with 0.7, the object
   name is "org.freedesktop.PolicyKit.AuthenticationAgent". If you are
   still using a very old PolicyKit version, that might be different,
   of course.

I am using this code in jockey without any problems with polkit >= 0.7:

       pk_auth = dbus.Interface(dbus.SessionBus().get_object(
           'org.freedesktop.PolicyKit.AuthenticationAgent', '/', False),
       # TODO: provide xid
       res = pk_auth.ObtainAuthorization(privilege_name, dbus.UInt32(0),
           dbus.UInt32(os.getpid()), timeout=300)

>         if(policykit == None):
>            print("Error: Could not get PolicyKit D-Bus Interface\n")
>         granted =
> policykit.ObtainAuthorization("org.freedesktop.packagekit.update-system", (dbus.UInt32)(tid), (dbus.UInt32)(os.getpid()))

What is tid here? The method expects a window XID here, not a
packagekit transaction ID.


Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.freedesktop.org/archives/packagekit/attachments/20080807/6fd862eb/attachment-0004.pgp>

More information about the PackageKit mailing list