~ubuntu-branches/ubuntu/precise/virtinst/precise-updates

« back to all changes in this revision

Viewing changes to virtinst/User.py

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-11 11:47:53 UTC
  • mfrom: (1.6.6 sid)
  • Revision ID: package-import@ubuntu.com-20120211114753-sq9f3xayrma8px2h
Tags: 0.600.1-1ubuntu1
* Merge from debian unstable. Remaining changes:
  - debian/patches/9003-fix-path-to-hvmloader-in-testsuite.patch: adjust
    testsuite for 0001-fix-path-to-hvmloader.patch and
    0002-Fix-path-to-pygrub.patch.
  - debian/patches/9004_ubuntu_fix_tree_support.patch: Fix tree detection
    for all ISO/HTTP source, to not longer fail with cobbler/koan.
  - debian/patches/9005_ubuntu_precise.patch: Add Ubuntu precise as a
    supported distro.
  - debian/{control,rules,pyversions}: Build using dh_python2, use
    debhelper v8 instead of cdbs; for some reason the package build an
    empty binary package when using dh_python2.
  - debian/control: added acl package to depends.
  - debian/control: added libvirt-bin to recommends

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
        if priv == self.PRIV_CREATE_NETWORK:
55
55
            return (self._euid == 0) or _util.is_qemu_system(conn)
56
56
 
57
 
        if platform.system() != 'SunOS':
58
 
            is_xen = not conn or conn.lower()[0:3] == 'xen'
59
 
            if priv in [ self.PRIV_CLONE, self.PRIV_CREATE_DOMAIN ]:
60
 
                if is_xen:
61
 
                    return self._euid == 0
62
 
                return True
63
 
 
64
 
            return self._euid == 0
65
 
 
 
57
        if platform.system() == 'SunOS':
 
58
            return self._sun_has_priv(priv)
 
59
 
 
60
        # For all others, just assume that prescence of a connection
 
61
        # means we are privileged enough
 
62
        return True
 
63
 
 
64
    def _sun_has_priv(self, priv):
66
65
        # Not easy to work out!
67
66
        if self._euid != User.current().euid:
68
67
            return self._euid == 0
69
68
 
70
69
        import ucred
71
70
        cred = ucred.get(os.getpid())
72
 
        if priv in [ self.PRIV_CLONE, self.PRIV_CREATE_DOMAIN, self.PRIV_CREATE_NETWORK ]:
 
71
        if priv in [ self.PRIV_CLONE,
 
72
                     self.PRIV_CREATE_DOMAIN,
 
73
                     self.PRIV_CREATE_NETWORK ]:
73
74
            return cred.has_priv('Effective', 'virt_manage')
74
75
        if priv == self.PRIV_NFS_MOUNT:
75
76
            return (cred.has_priv('Effective', 'sys_mount') and