diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-11-02 04:17:30 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:05:16 -0500 |
commit | 8692564e350db4dfa4a9ef4c4cb014d76b284d3b (patch) | |
tree | 891fbe0b3b55c4b7706bdb6ad8cd85c59cd070e2 /source4/lib | |
parent | 5011f901aa0140ed60a0b58e80ab0f14810ba432 (diff) | |
download | samba-8692564e350db4dfa4a9ef4c4cb014d76b284d3b.tar.gz samba-8692564e350db4dfa4a9ef4c4cb014d76b284d3b.tar.bz2 samba-8692564e350db4dfa4a9ef4c4cb014d76b284d3b.zip |
r3458: more solaris portability fixes, the main one being that we can't use a
structure element called "open" as its a macro on solaris.
(This used to be commit 4e92e15c4e396b1d8cd211192888fea68c2cf0f9)
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(); |