>From eedb653448463aff1db947c4e94d63c7609a3c4f Mon Sep 17 00:00:00 2001 From: Markus Duft Date: Thu, 8 Sep 2011 11:18:17 +0200 Subject: [PATCH 1/2] add check for setgroups(), which may be missing on some platforms. this adds the check plus a dummy, non-functional, always-successful replacement function, to keep the original code untouched and simple. Signed-off-by: Markus Duft --- configure.ac | 2 +- src/chroot.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletions(-) diff --git a/configure.ac b/configure.ac index 291b19e..c22f409 100644 --- a/configure.ac +++ b/configure.ac @@ -199,7 +199,7 @@ if test $utils_cv_localtime_cache = yes; then fi # SCO-ODT-3.0 is reported to need -los to link programs using initgroups -AC_CHECK_FUNCS([initgroups]) +AC_CHECK_FUNCS([initgroups setgroups]) if test $ac_cv_func_initgroups = no; then AC_CHECK_LIB([os], [initgroups]) fi diff --git a/src/chroot.c b/src/chroot.c index 95c227b..a9b4b87 100644 --- a/src/chroot.c +++ b/src/chroot.c @@ -52,6 +52,17 @@ static struct option const long_opts[] = {NULL, 0, NULL, 0} }; +#ifndef HAVE_SETGROUPS +/* Some systems (like interix) lack supplemental group support. A dummy, + * always successful replacement is added here to avoid the need to check + * for setgroups availability everywhere, just to support broken platforms. */ +static int setgroups(size_t size, gid_t const *list) +{ + (void)size; (void)list; + return 0; +} +#endif + /* Call setgroups to set the supplementary groups to those listed in GROUPS. GROUPS is a comma separated list of supplementary groups (names or numbers). Parse that list, converting any names to numbers, and call setgroups on the -- 1.7.6.1