* fork.cc (fork): Eliminate superfluous call to getuid().
* security.h: New define `NO_SID'. Remove declarations of functions moved to methods into class cygsid. (class cygsid): Declare new methods `getfromstr', `get_sid', `getfrompw', `getfromgr', `get_rid', `get_uid', `get_gid', `string' and new constructors and operators =, == and !=. Declare new global cygsids `well_known_XXX_sid' substituting the corresponding `get_XXX_sid' functions. Remove declarations of these functions. * sec_helper.cc (well_known_admin_sid): New global variable. (well_known_system_sid): Ditto (well_known_creator_owner_sid): Ditto (well_known_world_sid): Ditto (cygsid::string): New method, substituting `convert_sid_to_string_sid'. (cygsid::get_sid): New method, substituting `get_sid'. (cygsid::getfromstr): New method, substituting `convert_string_sid_to_sid'. (cygsid::getfrompw): New method, substituting `get_pw_sid'. (cygsid::getfromgr): New method, substituting `get_gr_sid'. (cygsid::get_id): New method, substituting `get_id_from_sid'. (get_admin_sid): Eliminated. (get_system_sid): Ditto. (get_creator_owner_sid): Ditto. (get_world_sid): Ditto. * grp.cc: Use new cygsid methods and well known sids throughout. * registry.cc: Ditto. * sec_acl.cc: Ditto. * security.cc: Ditto. * shared.cc: Ditto. * syscalls.cc (seteuid): Ditto. Eliminate redundant conditional. * uinfo.cc (internal_getlogin): Ditto. * spawn.cc (spawn_guts) Revert previous patch.
This commit is contained in:
@ -34,11 +34,10 @@ internal_getlogin (cygheap_user &user)
|
||||
DWORD username_len = UNLEN + 1;
|
||||
struct passwd *pw = NULL;
|
||||
|
||||
if (!user.name ())
|
||||
if (!GetUserName (username, &username_len))
|
||||
user.set_name ("unknown");
|
||||
else
|
||||
user.set_name (username);
|
||||
if (!GetUserName (username, &username_len))
|
||||
user.set_name ("unknown");
|
||||
else
|
||||
user.set_name (username);
|
||||
|
||||
if (os_being_run == winNT)
|
||||
{
|
||||
@ -153,7 +152,7 @@ internal_getlogin (cygheap_user &user)
|
||||
|
||||
/* If we have a SID, try to get the corresponding Cygwin user name
|
||||
which can be different from the Windows user name. */
|
||||
cygsid gsid (NULL);
|
||||
cygsid gsid (NO_SID);
|
||||
if (ret)
|
||||
{
|
||||
cygsid psid;
|
||||
@ -165,13 +164,13 @@ internal_getlogin (cygheap_user &user)
|
||||
setenv ("USERPROFILE", buf, 1);
|
||||
}
|
||||
for (int pidx = 0; (pw = internal_getpwent (pidx)); ++pidx)
|
||||
if (get_pw_sid (psid, pw) && EqualSid (user.sid (), psid))
|
||||
if (psid.getfrompw (pw) && EqualSid (user.sid (), psid))
|
||||
{
|
||||
user.set_name (pw->pw_name);
|
||||
struct group *gr = getgrgid (pw->pw_gid);
|
||||
if (gr)
|
||||
if (!get_gr_sid (gsid.set (), gr))
|
||||
gsid = NULL;
|
||||
if (!gsid.getfromgr (gr))
|
||||
gsid = NO_SID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user