Re: [PATCH] Use org.freedesktop.PolicyKit.AuthenticationAgent for PolicyKit

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

 



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@xxxxxxxxxxxxx>

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@xxxxxxxxxxxxx>
http://cekirdek.pardus.org.tr/~caglar/

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

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/et-mgmt-tools

[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux