[et-mgmt-tools] [PATCH] Use org.freedesktop.PolicyKit.AuthenticationAgent for PolicyKit

S.Çağlar Onur caglar at pardus.org.tr
Mon May 5 20:24:40 UTC 2008


05 May 2008 Pts tarihinde, S.Çağlar Onur şunları yazmıştı: 
> 05 May 2008 Pts tarihinde, Daniel P. Berrange şunları yazmıştı: 
> > I'm fine with this in principle, however, it needs to fallback to looking
> > for "org.gnome.PolicyKit"  if "org.freedesktop.PolicyKit.AuthenticationAgent"
> > is not found, because the latter was only introduced in version 0.7 of
> > PolicyKit
> 
> Fair enough :), i'll update the patch with fallback and will re-send...

Following patch introduce usage of "org.freedesktop.PolicyKit.AuthenticationAgent" interface of PolicyKit to permit other PolicyKit Authentication Agents (like PolicyKit-KDE). If virt-manager runs with PolicyKit which not provides that interface, it fallbacks to old one as suggested by Daniel P. Berrange.

Signed-off-by: S.Çağlar Onur <caglar at pardus.org.tr>

diff -r 5142197392f2 src/virtManager/connection.py
--- a/src/virtManager/connection.py	Fri May 02 09:36:36 2008 -0400
+++ b/src/virtManager/connection.py	Mon May 05 23:19:25 2008 +0300
@@ -339,9 +339,17 @@
     def _do_creds_polkit(self, action):
         logging.debug("Doing policykit for %s" % action)
         bus = dbus.SessionBus()
-        obj = bus.get_object("org.gnome.PolicyKit", "/org/gnome/PolicyKit/Manager")
-        pkit = dbus.Interface(obj, "org.gnome.PolicyKit.Manager")
-        pkit.ShowDialog(action, 0)
+
+        try:
+            # First try to use org.freedesktop.PolicyKit.AuthenticationAgent which is introduced with PolicyKit-0.7
+            obj = bus.get_object("org.freedesktop.PolicyKit.AuthenticationAgent", "/")
+            pkit = dbus.Interface(obj, "org.freedesktop.PolicyKit.AuthenticationAgent")
+            pkit.ObtainAuthorization(action, 0, os.getpid())
+        except org.freedesktop.DBus.Error.ServiceUnknown:
+            # If PolicyKit < 0.7, fallback to org.gnome.PolicyKit
+            obj = bus.get_object("org.gnome.PolicyKit", "/org/gnome/PolicyKit/Manager")
+            pkit = dbus.Interface(obj, "org.gnome.PolicyKit.Manager")
+            pkit.ShowDialog(action, 0)
         return 0
 
     def _do_creds_dialog(self, creds):


Cheers
-- 
S.Çağlar Onur <caglar at pardus.org.tr>
http://cekirdek.pardus.org.tr/~caglar/

Linux is like living in a teepee. No Windows, no Gates and an Apache in house!




More information about the et-mgmt-tools mailing list