summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Marineau <marineam@gentoo.org>2008-12-02 03:38:10 +0000
committerMichael Marineau <marineam@gentoo.org>2008-12-02 03:38:10 +0000
commit0221874f0ba925700d9a782e4c78d5827a3fe20f (patch)
tree63784e4344278d34340869b65ed03b32319b5e33 /app-emulation/virt-manager/files
parentStable for HPPA too. (diff)
downloadgentoo-2-0221874f0ba925700d9a782e4c78d5827a3fe20f.tar.gz
gentoo-2-0221874f0ba925700d9a782e4c78d5827a3fe20f.tar.bz2
gentoo-2-0221874f0ba925700d9a782e4c78d5827a3fe20f.zip
Allow user access without policykit
(Portage version: 2.1.4.5)
Diffstat (limited to 'app-emulation/virt-manager/files')
-rw-r--r--app-emulation/virt-manager/files/virt-manager-0.6.0-read-only-fallback.patch77
1 files changed, 77 insertions, 0 deletions
diff --git a/app-emulation/virt-manager/files/virt-manager-0.6.0-read-only-fallback.patch b/app-emulation/virt-manager/files/virt-manager-0.6.0-read-only-fallback.patch
new file mode 100644
index 000000000000..f270810dd27a
--- /dev/null
+++ b/app-emulation/virt-manager/files/virt-manager-0.6.0-read-only-fallback.patch
@@ -0,0 +1,77 @@
+--- virt-manager-0.6.0/src/virtManager/connection.py.orig 2008-09-10 15:37:12.000000000 -0400
++++ virt-manager-0.6.0/src/virtManager/connection.py 2008-12-01 22:33:34.000000000 -0500
+@@ -38,11 +38,6 @@
+ from virtManager.netdev import vmmNetDevice
+ from virtManager.storagepool import vmmStoragePool
+
+-LIBVIRT_POLICY_FILES = [
+- "/usr/share/PolicyKit/policy/libvirtd.policy",
+- "/usr/share/PolicyKit/policy/org.libvirt.unix.policy"
+-]
+-
+ def get_local_hostname():
+ try:
+ (host, aliases, ipaddrs) = gethostbyaddr(gethostname())
+@@ -139,15 +134,6 @@
+ self.uri = "xen:///"
+
+ self.readOnly = readOnly
+- if not self.is_remote() and os.getuid() != 0 and self.uri != "qemu:///session":
+- hasPolkit = False
+- for f in LIBVIRT_POLICY_FILES:
+- if os.path.exists(f):
+- hasPolkit = True
+-
+- if not hasPolkit:
+- self.readOnly = True
+-
+ self.state = self.STATE_DISCONNECTED
+ self.vmm = None
+ self.storage_capable = None
+@@ -464,8 +450,7 @@
+ logging.error(self.connectError)
+ return -1
+
+- def _open_thread(self):
+- logging.debug("Background thread is running")
++ def _try_open(self):
+ try:
+ flags = 0
+ if self.readOnly:
+@@ -478,12 +463,34 @@
+ libvirt.VIR_CRED_EXTERNAL],
+ self._do_creds,
+ None], flags)
++ except:
++ exc_info = sys.exc_info()
++
++ # If the previous attempt was read/write try to fall back
++ # on read-only connection, otherwise report the error.
++ if not self.readOnly:
++ try:
++ self.vmm = libvirt.openReadOnly(self.uri)
++ self.readOnly = True
++ logging.info("Read/write connection failed to %s,"
++ "falling back on read-only." % self.uri)
++ return
++ except:
++ pass
++
++ return exc_info
+
++ def _open_thread(self):
++ logging.debug("Background thread is running")
++
++ open_error = self._try_open()
++
++ if not open_error:
+ self.state = self.STATE_ACTIVE
+- except:
++ else:
+ self.state = self.STATE_DISCONNECTED
+
+- (type, value, stacktrace) = sys.exc_info ()
++ (type, value, stacktrace) = open_error
+ # Detailed error message, in English so it can be Googled.
+ self.connectError = \
+ ("Unable to open connection to hypervisor URI '%s':\n" %