From 67bb8835c76e3efc43de55493971fe2402c0d709 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 12 Mar 1998 02:43:46 +0000 Subject: [PATCH] move setup_groups() into password.c so that swat can link without including server.o --- source/smbd/password.c | 86 ++++++++++++++++++++++++++++++++++++++++++ source/smbd/server.c | 83 ---------------------------------------- 2 files changed, 86 insertions(+), 83 deletions(-) diff --git a/source/smbd/password.c b/source/smbd/password.c index b422dda36c5..212d931e877 100644 --- a/source/smbd/password.c +++ b/source/smbd/password.c @@ -147,6 +147,92 @@ char *validated_username(uint16 vuid) return(vuser->name); } + +/**************************************************************************** +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 **p_attrs) +{ + 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)); + } + } + else + { + int i,ngroups; + int *igroups; + int *attrs; + gid_t grp = 0; + ngroups = getgroups(0,&grp); + if (ngroups <= 0) + ngroups = 32; + igroups = (int *)malloc(sizeof(int)*ngroups); + attrs = (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 && i 16000 || uid < 0 || uid > 16000) - DEBUG(0,("This is probably a problem with the account %s\n",user)); - } - } - else - { - int i,ngroups; - int *igroups; - int *attrs; - gid_t grp = 0; - ngroups = getgroups(0,&grp); - if (ngroups <= 0) - ngroups = 32; - igroups = (int *)malloc(sizeof(int)*ngroups); - attrs = (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 && i