]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Use -1 as unpriviledged uid/gid
authorChristophe Fergeau <cfergeau@redhat.com>
Sat, 2 Mar 2013 14:19:47 +0000 (15:19 +0100)
committerChristophe Fergeau <cfergeau@redhat.com>
Mon, 4 Mar 2013 07:50:09 +0000 (08:50 +0100)
Commit f506a4c1 changed virSetUIDGID() to be a noop
when uid/gid are -1, while it used to be a noop when
they are <= 0.

The changes in this commit broke creating new VMs in GNOME Boxes
as qemuDomainCheckDiskPresence gets called during domain creation/startup,
which in turn calls virFileAccessibleAs which fails after calling
virSetUIDGID(0, 0) (Boxes uses session libvirtd). virSetUIDGID is called with
(0, 0) as these are the default user/group values in virQEMUDriverConfig
for session libvirtd.

This commit changes virQEMUDriverConfigNew to use -1 as the unpriviledged
uid/gid. I've also looked at the various places where cfg->user is used,
and they all seem to handle -1 correctly.

src/qemu/qemu_conf.c

index f3b09cf954d307f34ae442a5d0a7a873c679fc18..3ef3499bbd9fb210a7d7b0f505f7d069b9fabced 100644 (file)
@@ -129,8 +129,8 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged)
         if (virGetGroupID(QEMU_GROUP, &cfg->group) < 0)
             goto error;
     } else {
-        cfg->user = 0;
-        cfg->group = 0;
+        cfg->user = (uid_t)-1;
+        cfg->group = (gid_t)-1;
     }
     cfg->dynamicOwnership = privileged;