]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/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>
Thu, 11 Jul 2013 21:25:53 +0000 (15:25 -0600)
commit75c125641ac73473ba4b0542524d67a184769c8e
tree6561e5e2203df6ee505b9f049160ed1ac3a8a4a4
parentc1983ba4e3902308054e961fcae75cece73ef4ba
util: add virGetGroupList

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>
bootstrap.conf
src/libvirt_private.syms
src/util/virutil.c
src/util/virutil.h