]> 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>
Mon, 22 Jul 2013 16:25:48 +0000 (10:25 -0600)
commitfcdaa3df33975d7c3835fb7e2a97491b816277fd
tree7d8d8d5b29bb459b4086789894ead0372466dc0e
parent3a2d5e7e70eb93be43d244268679bbb1e4ccf795
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)

Conflicts:
bootstrap.conf - not updating gnulib submodule...
configure.ac - ...so checking for getgrouplist by hand...
src/util/virutil.c - ...and copying only the getgrouplist implementation rather than calling the gnulib function
configure.ac
src/libvirt_private.syms
src/util/virutil.c
src/util/virutil.h