Attempt to use krb5-auth-dialog for libvirt auth (if applicable) (Guido Gunther)

This commit is contained in:
Cole Robinson 2009-03-09 16:21:32 -04:00
parent 01de80f203
commit ebe91d6ce2

View File

@ -248,6 +248,18 @@ class vmmConnection(gobject.GObject):
del self.netdevs[name] del self.netdevs[name]
del self.hal_to_netdev[path] del self.hal_to_netdev[path]
def _acquire_tgt(self):
logging.debug("In acquire tgt.")
try:
bus = dbus.SessionBus()
ka = bus.get_object('org.gnome.KrbAuthDialog',
'/org/gnome/KrbAuthDialog')
ret = ka.acquireTgt("", dbus_interface='org.gnome.KrbAuthDialog')
except Exception, e:
logging.info("Cannot acquire tgt" + str(e))
ret = False
return ret
def is_read_only(self): def is_read_only(self):
return self.readOnly return self.readOnly
@ -548,22 +560,40 @@ class vmmConnection(gobject.GObject):
def _open_thread(self): def _open_thread(self):
logging.debug("Background thread is running") logging.debug("Background thread is running")
done = False
while not done:
open_error = self._try_open() open_error = self._try_open()
done = True
if not open_error: if not open_error:
self.state = self.STATE_ACTIVE self.state = self.STATE_ACTIVE
else: else:
self.state = self.STATE_DISCONNECTED self.state = self.STATE_DISCONNECTED
if self.uri.find("+ssh://") > 0:
hint = "\nMaybe you need to install ssh-askpass " + \
"in order to authenticate."
else:
hint = ""
(_type, value, stacktrace) = open_error (_type, value, stacktrace) = open_error
if (type(_type) == type(libvirt.libvirtError) and
value.get_error_code() == libvirt.VIR_ERR_AUTH_FAILED and
"GSSAPI Error" in value.get_error_message() and
"No credentials cache found" in value.get_error_message()):
if self._acquire_tgt():
done = False
continue
# Detailed error message, in English so it can be Googled. # Detailed error message, in English so it can be Googled.
self.connectError = \ self.connectError = (("Unable to open connection to hypervisor"
("Unable to open connection to hypervisor URI '%s':\n" % " URI '%s':\n" % str(self.uri)) +
str(self.uri)) + \ str(_type) + " " + str(value) + "\n" +
str(_type) + " " + str(value) + "\n" + \ traceback.format_exc (stacktrace) + hint)
traceback.format_exc (stacktrace)
logging.error(self.connectError) logging.error(self.connectError)
# We want to kill off this thread asap, so schedule a gobject # We want to kill off this thread asap, so schedule a gobject
# idle even to inform the UI of result # idle even to inform the UI of result
logging.debug("Background open thread complete, scheduling notify") logging.debug("Background open thread complete, scheduling notify")