Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/grp.cc')
-rw-r--r--winsup/cygwin/grp.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc
index 2b1b5986d..9b068f7c9 100644
--- a/winsup/cygwin/grp.cc
+++ b/winsup/cygwin/grp.cc
@@ -274,24 +274,26 @@ getgroups (int gidsetsize, gid_t *grouplist, gid_t gid, const char *username)
GetTokenInformation (hToken, TokenGroups, buf, 4096, &size))
{
TOKEN_GROUPS *groups = (TOKEN_GROUPS *) buf;
- char ssid[256];
+ char ssid[MAX_SID_LEN];
+ PSID sid = (PSID) ssid;
for (DWORD pg = 0; pg < groups->GroupCount; ++pg)
{
- convert_sid_to_string_sid (groups->Groups[pg].Sid, ssid);
- for (int gg = 0; gg < curr_lines; ++gg)
+ struct group *gr;
+ while ((gr = getgrent ()) != NULL)
{
- if (group_buf[gg].gr_passwd &&
- !strcmp (group_buf[gg].gr_passwd, ssid))
+ if (get_gr_sid (sid, gr) &&
+ EqualSid (sid, groups->Groups[pg].Sid))
{
if (cnt < gidsetsize)
- grouplist[cnt] = group_buf[gg].gr_gid;
+ grouplist[cnt] = gr->gr_gid;
++cnt;
if (gidsetsize && cnt > gidsetsize)
goto error;
break;
}
}
+ endgrent ();
}
CloseHandle (hToken);
return cnt;