Force connection to readonly if non-root and local HV uri and no policykit (Saori Fukuta)

This commit is contained in:
Daniel P. Berrange 2008-02-23 15:38:32 -05:00
parent 22b78bc1c1
commit 31f800f4ae
1 changed files with 7 additions and 1 deletions

View File

@ -36,6 +36,8 @@ from virtManager.domain import vmmDomain
from virtManager.network import vmmNetwork
from virtManager.netdev import vmmNetDevice
LIBVIRT_POLICY_FILE = "/usr/share/PolicyKit/policy/libvirtd.policy"
def get_local_hostname():
try:
(host, aliases, ipaddrs) = gethostbyaddr(gethostname())
@ -113,7 +115,6 @@ class vmmConnection(gobject.GObject):
def __init__(self, config, uri, readOnly = None):
self.__gobject_init__()
self.config = config
self.readOnly = readOnly
self.connectThread = None
self.connectError = None
@ -121,6 +122,11 @@ class vmmConnection(gobject.GObject):
if self.uri is None or self.uri.lower() == "xen":
self.uri = "xen:///"
self.readOnly = readOnly
if not self.is_remote() and os.getuid() != 0 and self.uri != "qemu:///session":
if not os.path.exists(LIBVIRT_POLICY_FILE):
self.readOnly = True
self.state = self.STATE_DISCONNECTED
self.vmm = None