diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2001-04-20 18:30:22 +0400 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2001-04-20 18:30:22 +0400 |
commit | bfbc1aecdca4f960234d3eb9e524b22fe6573f02 (patch) | |
tree | c75cdd4c49cae985d16d84e38c5369f6d3678c5d /winsup/cygwin/grp.cc | |
parent | c0d1968a18c75ffb160c840c474b9b1e095cd541 (diff) |
* grp.cc (getgroups): Change so that SIDs get compared instead
of strings to SIDs.
Diffstat (limited to 'winsup/cygwin/grp.cc')
-rw-r--r-- | winsup/cygwin/grp.cc | 14 |
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; |