4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-21 16:26:12 +08:00

* grp.cc (initgroups32): Run get_server_groups under original token.

* syscalls.cc (seteuid32): Slightly reorganize code creating a token.
This commit is contained in:
Corinna Vinschen 2006-08-31 15:57:56 +00:00
parent c9f1f4b438
commit 55283468e6
3 changed files with 18 additions and 12 deletions

View File

@ -1,3 +1,8 @@
2006-08-31 Corinna Vinschen <corinna@vinschen.de>
* grp.cc (initgroups32): Run get_server_groups under original token.
* syscalls.cc (seteuid32): Slightly reorganize code creating a token.
2006-08-27 Christopher Faylor <cgf@timesys.com> 2006-08-27 Christopher Faylor <cgf@timesys.com>
* child_info.h (child_info_spawn::~child_info_spawn): Don't close * child_info.h (child_info_spawn::~child_info_spawn): Don't close

View File

@ -471,6 +471,7 @@ initgroups32 (const char *name, __gid32_t gid)
if (wincap.has_security ()) if (wincap.has_security ())
{ {
ret = -1; ret = -1;
cygheap->user.deimpersonate ();
struct passwd *pw = internal_getpwnam (name); struct passwd *pw = internal_getpwnam (name);
struct __group32 *gr = internal_getgrgid (gid); struct __group32 *gr = internal_getgrgid (gid);
cygsid usersid, grpsid; cygsid usersid, grpsid;
@ -492,6 +493,8 @@ initgroups32 (const char *name, __gid32_t gid)
ret = 0; ret = 0;
out: out:
if (wincap.has_security ())
cygheap->user.reimpersonate ();
syscall_printf ( "%d = initgroups (%s, %u)", ret, name, gid); syscall_printf ( "%d = initgroups (%s, %u)", ret, name, gid);
return ret; return ret;
} }

View File

@ -2205,27 +2205,25 @@ seteuid32 (__uid32_t uid)
if (new_token == INVALID_HANDLE_VALUE) if (new_token == INVALID_HANDLE_VALUE)
{ {
new_token = subauth (pw_new); new_token = subauth (pw_new);
if (new_token == INVALID_HANDLE_VALUE) debug_printf ("subauth %s, try create_token.",
new_token == INVALID_HANDLE_VALUE ? "failed" : "succeeded");
HANDLE new_token2 = create_token (usersid, groups, pw_new, new_token);
if (new_token2 == INVALID_HANDLE_VALUE)
{ {
debug_printf ("subauthentication failed, try create token.");
new_token = create_token (usersid, groups, pw_new, NULL);
if (new_token == INVALID_HANDLE_VALUE) if (new_token == INVALID_HANDLE_VALUE)
{ {
debug_printf ("create_token failed, bail out of here");
cygheap->user.reimpersonate (); cygheap->user.reimpersonate ();
return -1; return -1;
} }
debug_printf ("create_token failed, use original subauth token");
} }
else else
{ {
debug_printf ("subauthentication succeeded, try create token."); debug_printf ("create_token succeeded");
HANDLE new_token2 = create_token (usersid, groups, pw_new, new_token); if (new_token != INVALID_HANDLE_VALUE)
if (new_token2 == INVALID_HANDLE_VALUE) CloseHandle (new_token);
debug_printf ("create token failed, use original token"); new_token = new_token2;
else
{
CloseHandle (new_token);
new_token = new_token2;
}
} }
/* Keep at most one internal token */ /* Keep at most one internal token */
if (cygheap->user.internal_token != NO_IMPERSONATION) if (cygheap->user.internal_token != NO_IMPERSONATION)