From bfbc1aecdca4f960234d3eb9e524b22fe6573f02 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Fri, 20 Apr 2001 14:30:22 +0000 Subject: [PATCH] * grp.cc (getgroups): Change so that SIDs get compared instead of strings to SIDs. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/grp.cc | 14 ++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 5b5f04853..7fdb1f96e 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +Fri Apr 20 16:29:00 2001 Corinna Vinschen + + * grp.cc (getgroups): Change so that SIDs get compared instead + of strings to SIDs. + Fri Apr 20 14:50:00 2001 Corinna Vinschen * Makefile.in: Add object files `sec_helper.cc' and `sec_acl.cc'. 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;