diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2008-07-09 11:58:38 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2008-07-09 11:58:38 +0000 |
commit | 5558de95e59c62d23d70f64fb7dc510f4f77477f (patch) | |
tree | 426aec61c3437439f898c6800b3db29f6f4ba509 /winsup/cygwin/grp.cc | |
parent | 8f7208243ed7ac12a297eef5cdb2f3250c2185e7 (diff) | |
download | cygnal-5558de95e59c62d23d70f64fb7dc510f4f77477f.tar.gz cygnal-5558de95e59c62d23d70f64fb7dc510f4f77477f.tar.bz2 cygnal-5558de95e59c62d23d70f64fb7dc510f4f77477f.zip |
* autoload.cc (DsGetDcNameW): Replace DsGetDcNameA.
* dcrt0.cc (child_info_spawn::handle_spawn): Drop artificial
supplementary group list from calling setgroups in parent.
* grp.cc (internal_getgroups): Drop 9x-only code. Reformat.
* sec_auth.cc (get_logon_server): Do everything in WCHAR only.
(get_user_groups): Ditto. Use wlogonserver in LookupAccountNameW
calls, too.
(is_group_member): Get logon server as first argument and use in call
to NetLocalGroupGetMembers.
(get_user_local_groups): Get logon server as first argument and use in
calls to NetLocalGroupEnum and LookupAccountNameW. Revamp to work
more correctly in domain environments.
(get_server_groups): Accommodate aforementioned changed function calls.
* security.h (get_logon_server): Change prototype accordingly.
* uinfo.cc (cygheap_user::env_logsrv): Accommodate changed
get_logon_server call.
Diffstat (limited to 'winsup/cygwin/grp.cc')
-rw-r--r-- | winsup/cygwin/grp.cc | 88 |
1 files changed, 30 insertions, 58 deletions
diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc index 37a0fcd73..f38888e1b 100644 --- a/winsup/cygwin/grp.cc +++ b/winsup/cygwin/grp.cc @@ -331,8 +331,6 @@ internal_getgroups (int gidsetsize, __gid32_t *grouplist, cygpsid * srchsid) DWORD size; int cnt = 0; struct __group32 *gr; - __gid32_t gid; - const char *username; if (!srchsid && cygheap->user.groups.issetgroups ()) { @@ -340,8 +338,8 @@ internal_getgroups (int gidsetsize, __gid32_t *grouplist, cygpsid * srchsid) for (int gidx = 0; (gr = internal_getgrent (gidx)); ++gidx) if (sid.getfromgr (gr)) for (int pg = 0; pg < cygheap->user.groups.sgsids.count (); ++pg) - if (sid == cygheap->user.groups.sgsids.sids[pg] && - sid != well_known_world_sid) + if (sid == cygheap->user.groups.sgsids.sids[pg] + && sid != well_known_world_sid) { if (cnt < gidsetsize) grouplist[cnt] = gr->gr_gid; @@ -360,67 +358,41 @@ internal_getgroups (int gidsetsize, __gid32_t *grouplist, cygpsid * srchsid) else hToken = hProcToken; - if (hToken) + if (GetTokenInformation (hToken, TokenGroups, NULL, 0, &size) + || GetLastError () == ERROR_INSUFFICIENT_BUFFER) { - if (GetTokenInformation (hToken, TokenGroups, NULL, 0, &size) - || GetLastError () == ERROR_INSUFFICIENT_BUFFER) + PTOKEN_GROUPS groups = (PTOKEN_GROUPS) alloca (size); + + if (GetTokenInformation (hToken, TokenGroups, groups, size, &size)) { - PTOKEN_GROUPS groups = (PTOKEN_GROUPS) alloca (size); + cygsid sid; - if (GetTokenInformation (hToken, TokenGroups, groups, size, &size)) + if (srchsid) { - cygsid sid; - - if (srchsid) - { - for (DWORD pg = 0; pg < groups->GroupCount; ++pg) - if ((cnt = (*srchsid == groups->Groups[pg].Sid))) - break; - } - else - for (int gidx = 0; (gr = internal_getgrent (gidx)); ++gidx) - if (sid.getfromgr (gr)) - for (DWORD pg = 0; pg < groups->GroupCount; ++pg) - if (sid == groups->Groups[pg].Sid - && (groups->Groups[pg].Attributes - & (SE_GROUP_ENABLED | SE_GROUP_INTEGRITY_ENABLED)) - && sid != well_known_world_sid) - { - if (cnt < gidsetsize) - grouplist[cnt] = gr->gr_gid; - ++cnt; - if (gidsetsize && cnt > gidsetsize) - goto error; - break; - } + for (DWORD pg = 0; pg < groups->GroupCount; ++pg) + if ((cnt = (*srchsid == groups->Groups[pg].Sid))) + break; } + else + for (int gidx = 0; (gr = internal_getgrent (gidx)); ++gidx) + if (sid.getfromgr (gr)) + for (DWORD pg = 0; pg < groups->GroupCount; ++pg) + if (sid == groups->Groups[pg].Sid + && (groups->Groups[pg].Attributes + & (SE_GROUP_ENABLED | SE_GROUP_INTEGRITY_ENABLED)) + && sid != well_known_world_sid) + { + if (cnt < gidsetsize) + grouplist[cnt] = gr->gr_gid; + ++cnt; + if (gidsetsize && cnt > gidsetsize) + goto error; + break; + } } - else - debug_printf ("%d = GetTokenInformation(NULL) %E", size); - return cnt; } - - gid = myself->gid; - username = cygheap->user.name (); - for (int gidx = 0; (gr = internal_getgrent (gidx)); ++gidx) - if (gid == gr->gr_gid) - { - if (cnt < gidsetsize) - grouplist[cnt] = gr->gr_gid; - ++cnt; - if (gidsetsize && cnt > gidsetsize) - goto error; - } - else if (gr->gr_mem) - for (int gi = 0; gr->gr_mem[gi]; ++gi) - if (strcasematch (username, gr->gr_mem[gi])) - { - if (cnt < gidsetsize) - grouplist[cnt] = gr->gr_gid; - ++cnt; - if (gidsetsize && cnt > gidsetsize) - goto error; - } + else + debug_printf ("%d = GetTokenInformation(NULL) %E", size); return cnt; error: |