Cygwin: fork: fix child process permissions, take 2

VirtualQueryEx, called by fixup_mmaps_after_fork, requires
PROCESS_QUERY_INFORMATION permissions per MSDN.  However, testing
shows that PROCESS_QUERY_LIMITED_INFORMATION is sufficient when
running the same code on Windows 8.1 or Windows 10.  Fix the code
to give the forked child always PROCESS_QUERY_INFORMATION perms
on Windows Vista/7 and respective server releases.

Revert now unneeded patch to check_token_membership as well.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen
2019-01-30 12:18:03 +01:00
parent a52396bd07
commit ef8ce3077f
3 changed files with 8 additions and 17 deletions

View File

@@ -118,13 +118,16 @@ cygheap_user::init ()
This needs careful checking should we use check_token_membership in other
circumstances. */
bool
check_token_membership (HANDLE tok, PSID sid)
check_token_membership (PSID sid)
{
NTSTATUS status;
ULONG size;
tmp_pathbuf tp;
PTOKEN_GROUPS groups = (PTOKEN_GROUPS) tp.w_get ();
/* If impersonated, use impersonation token. */
HANDLE tok = cygheap->user.issetuid () ? cygheap->user.primary_token ()
: hProcToken;
status = NtQueryInformationToken (tok, TokenGroups, groups, 2 * NT_MAX_PATH,
&size);
if (!NT_SUCCESS (status))
@@ -139,15 +142,6 @@ check_token_membership (HANDLE tok, PSID sid)
return false;
}
bool
check_token_membership (PSID sid)
{
/* If impersonated, use impersonation token. */
HANDLE tok = cygheap->user.issetuid () ? cygheap->user.primary_token ()
: hProcToken;
return check_token_membership (tok, sid);
}
static void
internal_getlogin (cygheap_user &user)
{