diff options
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/fault.c | 1 | ||||
-rw-r--r-- | source4/lib/system.c | 116 |
2 files changed, 1 insertions, 116 deletions
diff --git a/source4/lib/fault.c b/source4/lib/fault.c index ed1e7c4366..ac2d4109fd 100644 --- a/source4/lib/fault.c +++ b/source4/lib/fault.c @@ -19,6 +19,7 @@ */ #include "includes.h" +#include "system/wait.h" static void (*cont_fn)(void *); diff --git a/source4/lib/system.c b/source4/lib/system.c index d50005e8c8..46490bb17e 100644 --- a/source4/lib/system.c +++ b/source4/lib/system.c @@ -335,122 +335,6 @@ void sys_srandom(uint_t seed) #endif } -/************************************************************************** - Returns equivalent to NGROUPS_MAX - using sysconf if needed. -****************************************************************************/ - -int groups_max(void) -{ -#if defined(SYSCONF_SC_NGROUPS_MAX) - int ret = sysconf(_SC_NGROUPS_MAX); - return (ret == -1) ? NGROUPS_MAX : ret; -#else - return NGROUPS_MAX; -#endif -} - -/************************************************************************** - Wrapper for getgroups. Deals with broken (int) case. -****************************************************************************/ - -int sys_getgroups(int setlen, gid_t *gidset) -{ -#if !defined(HAVE_BROKEN_GETGROUPS) - return getgroups(setlen, gidset); -#else - - GID_T gid; - GID_T *group_list; - int i, ngroups; - - if(setlen == 0) { - return getgroups(setlen, &gid); - } - - /* - * Broken case. We need to allocate a - * GID_T array of size setlen. - */ - - if(setlen < 0) { - errno = EINVAL; - return -1; - } - - if (setlen == 0) - setlen = groups_max(); - - if((group_list = (GID_T *)malloc(setlen * sizeof(GID_T))) == NULL) { - DEBUG(0,("sys_getgroups: Malloc fail.\n")); - return -1; - } - - if((ngroups = getgroups(setlen, group_list)) < 0) { - int saved_errno = errno; - SAFE_FREE(group_list); - errno = saved_errno; - return -1; - } - - for(i = 0; i < ngroups; i++) - gidset[i] = (gid_t)group_list[i]; - - SAFE_FREE(group_list); - return ngroups; -#endif /* HAVE_BROKEN_GETGROUPS */ -} - -#ifdef HAVE_SETGROUPS - -/************************************************************************** - Wrapper for setgroups. Deals with broken (int) case. Automatically used - if we have broken getgroups. -****************************************************************************/ - -int sys_setgroups(int setlen, gid_t *gidset) -{ -#if !defined(HAVE_BROKEN_GETGROUPS) - return setgroups(setlen, gidset); -#else - - GID_T *group_list; - int i ; - - if (setlen == 0) - return 0 ; - - if (setlen < 0 || setlen > groups_max()) { - errno = EINVAL; - return -1; - } - - /* - * Broken case. We need to allocate a - * GID_T array of size setlen. - */ - - if((group_list = (GID_T *)malloc(setlen * sizeof(GID_T))) == NULL) { - DEBUG(0,("sys_setgroups: Malloc fail.\n")); - return -1; - } - - for(i = 0; i < setlen; i++) - group_list[i] = (GID_T) gidset[i]; - - if(setgroups(setlen, group_list) != 0) { - int saved_errno = errno; - SAFE_FREE(group_list); - errno = saved_errno; - return -1; - } - - SAFE_FREE(group_list); - return 0 ; -#endif /* HAVE_BROKEN_GETGROUPS */ -} - -#endif /* HAVE_SETGROUPS */ - struct passwd *sys_getpwent(void) { return getpwent(); |