From fb08c34cf3950f994701a9c98c89670f6346f7ab Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 29 Jul 1998 05:05:36 +0000 Subject: get rid of the runtime test for broken getgroups() and add a compile time test instead. This also allows us to get rid of the igroups element of a couple of structures. (This used to be commit 8b25fe734166b76ceebf8d9543c706ebe0fddc96) --- source3/smbd/password.c | 108 +++++++++++++++--------------------------------- 1 file changed, 33 insertions(+), 75 deletions(-) (limited to 'source3/smbd/password.c') diff --git a/source3/smbd/password.c b/source3/smbd/password.c index aae398dbda..0f8e33940f 100644 --- a/source3/smbd/password.c +++ b/source3/smbd/password.c @@ -137,14 +137,11 @@ void invalidate_vuid(uint16 vuid) /* same number of igroups as groups */ vuser->n_groups = 0; - if (vuser->groups && (vuser->groups != (gid_t *)vuser->igroups)) - free(vuser->groups); + if (vuser->groups) free(vuser->groups); - if (vuser->igroups) free(vuser->igroups); - if (vuser->sids ) free(vuser->sids); + if (vuser->sids) free(vuser->sids); vuser->sids = NULL; - vuser->igroups = NULL; vuser->groups = NULL; } @@ -164,78 +161,41 @@ char *validated_username(uint16 vuid) /**************************************************************************** Setup the groups a user belongs to. ****************************************************************************/ -int setup_groups(char *user, int uid, int gid, int *p_ngroups, - int **p_igroups, gid_t **p_groups) +int setup_groups(char *user, int uid, int gid, int *p_ngroups, GID_T **p_groups) { - if (-1 == initgroups(user,gid)) - { - if (getuid() == 0) - { - DEBUG(0,("Unable to initgroups!\n")); - if (gid < 0 || gid > 16000 || uid < 0 || uid > 16000) - DEBUG(0,("This is probably a problem with the account %s\n",user)); + int i,ngroups; + GID_T *groups; + GID_T grp = 0; + + if (-1 == initgroups(user,gid)) { + if (getuid() == 0) { + DEBUG(0,("Unable to initgroups!\n")); + if (gid < 0 || gid > 16000 || uid < 0 || uid > 16000) { + DEBUG(0,("This is probably a problem with the account %s\n", + user)); + } + } + return -1; } - } - else - { - int i,ngroups; - int *igroups; - gid_t grp = 0; - ngroups = getgroups(0,&grp); - if (ngroups <= 0) - ngroups = 32; - igroups = (int *)malloc(sizeof(int)*ngroups); - for (i=0;i 0) - { - /* does getgroups return ints or gid_t ?? */ - static BOOL groups_use_ints = True; - if (groups_use_ints && - ngroups == 1 && - SVAL(igroups,2) == 0x4242) - groups_use_ints = False; - - for (i=0;groups_use_ints && in_groups = 0; vuser->groups = NULL; - vuser->igroups = NULL; /* Find all the groups this uid is in and store them. Used by become_user() */ setup_groups(unix_name,uid,gid, &vuser->n_groups, - &vuser->igroups, &vuser->groups); DEBUG(3,("uid %d registered to name %s\n",uid,unix_name)); -- cgit