lxc_container: Don't call virGetGroupList during exec

Commit 75c1256 states that virGetGroupList must not be called
between fork and exec, then commit ee777e99 promptly violated
that for lxc.

Patch originally posted by Eric Blake <eblake@redhat.com>.
This commit is contained in:
Michal Privoznik 2013-07-17 11:21:09 +02:00
parent cc7329317f
commit 192a86cadf

View File

@ -351,24 +351,18 @@ int lxcContainerWaitForContinue(int control)
*/ */
static int lxcContainerSetID(virDomainDefPtr def) static int lxcContainerSetID(virDomainDefPtr def)
{ {
gid_t *groups;
int ngroups;
/* Only call virSetUIDGID when user namespace is enabled /* Only call virSetUIDGID when user namespace is enabled
* for this container. And user namespace is only enabled * for this container. And user namespace is only enabled
* when nuidmap&ngidmap is not zero */ * when nuidmap&ngidmap is not zero */
VIR_DEBUG("Set UID/GID to 0/0"); VIR_DEBUG("Set UID/GID to 0/0");
if (def->idmap.nuidmap && if (def->idmap.nuidmap &&
((ngroups = virGetGroupList(0, 0, &groups) < 0) || virSetUIDGID(0, 0, NULL, 0) < 0) {
virSetUIDGID(0, 0, groups, ngroups) < 0)) {
virReportSystemError(errno, "%s", virReportSystemError(errno, "%s",
_("setuid or setgid failed")); _("setuid or setgid failed"));
VIR_FREE(groups);
return -1; return -1;
} }
VIR_FREE(groups);
return 0; return 0;
} }