]> git.ipfire.org Git - thirdparty/libvirt.git/commit
util: add virGetGroupList
authorEric Blake <eblake@redhat.com>
Tue, 21 May 2013 23:47:48 +0000 (17:47 -0600)
committerEric Blake <eblake@redhat.com>
Fri, 19 Jul 2013 22:36:42 +0000 (16:36 -0600)
commitc3c8689e7fe5c29583eda508955ae92bca24b895
tree6889b3db9b0ebe3e1faf061e229a14433eb57bd7
parenteae6310649d7c06bcc53faf6f0237e62ea3e876a
util: add virGetGroupList

https://bugzilla.redhat.com/show_bug.cgi?id=964358

Since neither getpwuid_r() nor initgroups() are safe to call in
between fork and exec (they obtain a mutex, but if some other
thread in the parent also held the mutex at the time of the fork,
the child will deadlock), we have to split out the functionality
that is unsafe.  At least glibc's initgroups() uses getgrouplist
under the hood, so the ideal split is to expose getgrouplist for
use before a fork.  Gnulib already gives us a nice wrapper via
mgetgroups; we wrap it once more to look up by uid instead of name.

* bootstrap.conf (gnulib_modules): Add mgetgroups.
* src/util/virutil.h (virGetGroupList): New declaration.
* src/util/virutil.c (virGetGroupList): New function.
* src/libvirt_private.syms (virutil.h): Export it.

Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 75c125641ac73473ba4b0542524d67a184769c8e)
bootstrap.conf
src/libvirt_private.syms
src/util/virutil.c
src/util/virutil.h