def has_priv(self, priv, conn=None): """Return if the given user is privileged enough to perform the given operation. This isn't entirely accurate currently, especially on Solaris.""" if priv not in self._privs: raise ValueError('unknown privilege %s' % priv) if priv == self.PRIV_QEMU_SYSTEM: return self._euid == 0 if priv == self.PRIV_CREATE_NETWORK: return (self._euid == 0) or uriutil.is_qemu_system(conn) if platform.system() == 'SunOS': return self._sun_has_priv(priv) # For all others, just assume that prescence of a connection # means we are privileged enough return True
def is_qemu_system(self): return uriutil.is_qemu_system(self.conn, self.get_uri())