* security.cc: Change some formatting.
* include/cygwin/version.h: Bump API minor version. * cygheap.h (class cygheap_user): Add member groups. * security.h (class cygsidlist): Add members type and maxcount, methods position, addfromgr, alloc_sids and free_sids and operator+= (const PSID psid). Modify contains () to call position () and optimize add () to use maxcount. (class user_groups): Create. Update declarations of verify_token and create_token. * security.cc (cygsidlist::alloc_sids): New. (cygsidlist::free_sids): New. (get_token_group_sidlist): Create from get_group_sidlist. (get_initgroups_sidlist): Create from get_group_sidlist. (get_group_sidlist): Suppress. (get_setgroups_sidlist): Create. (verify_token): Modify arguments. Add setgroups case. (create_token): Modify arguments. Call get_initgroups_sidlist and get_setgroups_sidlist as needed. Set SE_GROUP_LOGON_ID from auth_pos outside of the loop. Rename the various group sid lists consistently. * syscalls.cc (seteuid32): Modify to use cygheap->user.groups. (setegid32): Call cygheap->user.groups.update_pgrp. * grp.cc (setgroups): Create. (setgroups32): Create. * uinfo.cc (internal_getlogin): Initialize and update user.groups.pgsid. * cygwin.din: Add setgroups and setgroups32.
This commit is contained in:
@@ -48,9 +48,12 @@ internal_getlogin (cygheap_user &user)
|
||||
&ptok))
|
||||
system_printf ("OpenProcessToken(): %E\n");
|
||||
else if (!GetTokenInformation (ptok, TokenUser, &tu, sizeof tu, &siz))
|
||||
system_printf ("GetTokenInformation(): %E");
|
||||
system_printf ("GetTokenInformation (TokenUser): %E");
|
||||
else if (!(ret = user.set_sid (tu)))
|
||||
system_printf ("Couldn't retrieve SID from access token!");
|
||||
else if (!GetTokenInformation (ptok, TokenPrimaryGroup,
|
||||
&user.groups.pgsid, sizeof tu, &siz))
|
||||
system_printf ("GetTokenInformation (TokenPrimaryGroup): %E");
|
||||
/* We must set the user name, uid and gid.
|
||||
If we have a SID, try to get the corresponding Cygwin
|
||||
password entry. Set user name which can be different
|
||||
@@ -75,11 +78,14 @@ internal_getlogin (cygheap_user &user)
|
||||
primary group to the group in /etc/passwd. */
|
||||
if (!SetTokenInformation (ptok, TokenOwner, &tu, sizeof tu))
|
||||
debug_printf ("SetTokenInformation(TokenOwner): %E");
|
||||
if (gsid && !SetTokenInformation (ptok, TokenPrimaryGroup,
|
||||
&gsid, sizeof gsid))
|
||||
debug_printf ("SetTokenInformation(TokenPrimaryGroup): %E");
|
||||
if (gsid)
|
||||
{
|
||||
user.groups.pgsid = gsid;
|
||||
if (!SetTokenInformation (ptok, TokenPrimaryGroup,
|
||||
&gsid, sizeof gsid))
|
||||
debug_printf ("SetTokenInformation(TokenPrimaryGroup): %E");
|
||||
}
|
||||
}
|
||||
|
||||
if (ptok != INVALID_HANDLE_VALUE)
|
||||
CloseHandle (ptok);
|
||||
}
|
||||
|
Reference in New Issue
Block a user