summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/grp.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2002-11-14 19:19:39 +0000
committerCorinna Vinschen <corinna@vinschen.de>2002-11-14 19:19:39 +0000
commit4ce377c9d46006e1dfa02deba260ee86224517b5 (patch)
tree71ff520ea725606a38ea78b3823aed3c163e9c16 /winsup/cygwin/grp.cc
parent69920bb5bd131f0d334b4eefc47fee7c5fec98a2 (diff)
downloadcygnal-4ce377c9d46006e1dfa02deba260ee86224517b5.tar.gz
cygnal-4ce377c9d46006e1dfa02deba260ee86224517b5.tar.bz2
cygnal-4ce377c9d46006e1dfa02deba260ee86224517b5.zip
* grp.cc (getgroups32): Revert previous patch. Use impersonation
token if process is in impersonated state. * sec_helper.cc (is_grp_member): Rewrite. Call getgroups32 only for current user. Scan passwd and group info otherwise.
Diffstat (limited to 'winsup/cygwin/grp.cc')
-rw-r--r--winsup/cygwin/grp.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc
index 648d5a3da..083b9db75 100644
--- a/winsup/cygwin/grp.cc
+++ b/winsup/cygwin/grp.cc
@@ -341,9 +341,15 @@ getgroups32 (int gidsetsize, __gid32_t *grouplist, __gid32_t gid,
if (group_state <= initializing)
read_etc_group ();
- if (allow_ntsec &&
- strcasematch (username, cygheap->user.name ()) &&
- OpenProcessToken (hMainProc, TOKEN_QUERY, &hToken))
+ if (allow_ntsec)
+ {
+ /* If impersonated, use impersonation token. */
+ if (cygheap->user.issetuid ())
+ hToken = cygheap->user.token;
+ else if (!OpenProcessToken (hMainProc, TOKEN_QUERY, &hToken))
+ hToken = NULL;
+ }
+ if (hToken)
{
if (GetTokenInformation (hToken, TokenGroups, NULL, 0, &size)
|| GetLastError () == ERROR_INSUFFICIENT_BUFFER)
@@ -375,7 +381,8 @@ getgroups32 (int gidsetsize, __gid32_t *grouplist, __gid32_t gid,
}
else
debug_printf ("%d = GetTokenInformation(NULL) %E", size);
- CloseHandle (hToken);
+ if (hToken != cygheap->user.token)
+ CloseHandle (hToken);
if (cnt)
return cnt;
}