]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
virSetUIDGID: Don't leak supplementary groups
authorRichard Weinberger <richard@nod.at>
Tue, 23 Jun 2015 11:48:42 +0000 (13:48 +0200)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 18 Nov 2015 11:41:12 +0000 (11:41 +0000)
The LXC driver uses virSetUIDGID() to become UID/GID 0.
It passes an empty groups list to virSetUIDGID()
to get rid of all supplementary groups from the host side.
But virSetUIDGID() calls setgroups() only if the supplied list
is larger than 0.
This leads to a container root with unrelated supplementary groups.
In most cases this issue is unoticed as libvirtd runs as UID/GID 0
without any supplementary groups.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/util/virutil.c

index cddc78a700c12a4f786a1f6544b92b8ee19c85f5..6f61d6e568c4b3301e4bf780d8aee6b1ea9415d7 100644 (file)
@@ -1103,7 +1103,7 @@ virSetUIDGID(uid_t uid, gid_t gid, gid_t *groups ATTRIBUTE_UNUSED,
     }
 
 # if HAVE_SETGROUPS
-    if (ngroups && setgroups(ngroups, groups) < 0) {
+    if (gid != (gid_t)-1 && setgroups(ngroups, groups) < 0) {
         virReportSystemError(errno, "%s",
                              _("cannot set supplemental groups"));
         return -1;