* security.cc (get_supplementary_group_sidlist): New function.

(get_group_sidlist): Call get_supplementary_group_sidlist() to
	retrieve list of supplementary groups SIDs from /etc/group and
	add them to the user's group list.
This commit is contained in:
Corinna Vinschen 2001-11-03 21:19:50 +00:00
parent ed14f73cc2
commit f41d24a14d
2 changed files with 38 additions and 0 deletions

View File

@ -1,3 +1,10 @@
2001-11-03 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_supplementary_group_sidlist): New function.
(get_group_sidlist): Call get_supplementary_group_sidlist() to
retrieve list of supplementary groups SIDs from /etc/group and
add them to the user's group list.
2001-11-03 Christopher Faylor <cgf@redhat.com> 2001-11-03 Christopher Faylor <cgf@redhat.com>
* fhandler.cc (fhandler_base::read): Return just read ahead characters * fhandler.cc (fhandler_base::read): Return just read ahead characters

View File

@ -448,6 +448,30 @@ get_user_primary_group (WCHAR *wlogonserver, const char *user,
return retval; return retval;
} }
static int
get_supplementary_group_sidlist (const char *username, cygsidlist &grp_list)
{
struct group *gr;
int cnt = 0;
for (int gidx = 0; (gr = internal_getgrent (gidx)); ++gidx)
{
if (gr->gr_mem)
for (int gi = 0; gr->gr_mem[gi]; ++gi)
if (strcasematch (username, gr->gr_mem[gi]))
{
if (gr->gr_passwd && *gr->gr_passwd)
{
cygsid sid (gr->gr_passwd);
if ((PSID)sid && grp_list.add (sid))
++cnt;
}
break;
}
}
return cnt;
}
static BOOL static BOOL
get_group_sidlist (const char *logonserver, cygsidlist &grp_list, get_group_sidlist (const char *logonserver, cygsidlist &grp_list,
cygsid &usersid, cygsid &pgrpsid, cygsid &usersid, cygsid &pgrpsid,
@ -459,6 +483,7 @@ get_group_sidlist (const char *logonserver, cygsidlist &grp_list,
DWORD ulen = INTERNET_MAX_HOST_NAME_LENGTH + 1; DWORD ulen = INTERNET_MAX_HOST_NAME_LENGTH + 1;
DWORD dlen = INTERNET_MAX_HOST_NAME_LENGTH + 1; DWORD dlen = INTERNET_MAX_HOST_NAME_LENGTH + 1;
SID_NAME_USE use; SID_NAME_USE use;
cygsidlist sup_list;
auth_pos = -1; auth_pos = -1;
sys_mbstowcs (wserver, logonserver, INTERNET_MAX_HOST_NAME_LENGTH + 1); sys_mbstowcs (wserver, logonserver, INTERNET_MAX_HOST_NAME_LENGTH + 1);
@ -514,6 +539,12 @@ get_group_sidlist (const char *logonserver, cygsidlist &grp_list,
return FALSE; return FALSE;
if (!grp_list.contains (pgrpsid)) if (!grp_list.contains (pgrpsid))
grp_list += pgrpsid; grp_list += pgrpsid;
if (get_supplementary_group_sidlist (user, sup_list))
{
for (int i = 0; i < sup_list.count; ++i)
if (!grp_list.contains (sup_list.sids[i]))
grp_list += sup_list.sids[i];
}
return TRUE; return TRUE;
} }