From 9a771b2961695d00d4bc4a47deae7e6113b2cd01 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Fri, 14 Jun 2002 18:01:21 +0000 Subject: * cygheap.cc (cygheap_user::set_logsrv): Remove. (cygheap_user::set_domain): Ditto. * cygheap.h (cygheap_user::set_logsrv): Remove declaration. (cygheap_user::set_domain): Ditto. (cygheap_user::env_domain): Declare new method. (cygheap_user::env_name): Ditto. * environ.cc (spenvs): Add two environment variables. * spawn.cc (spawn_guts): Call build_env after RevertToSelf. Always set ciresrv.mount_h. (cygheap_user::ontherange): Recalculate homedrive/homepath if they are empty. Use env_logsrv to get logon server. (cygheap_user::env_logsrv): Calculate server name here rather than relying on it having been previously calculated. (cygheap_user::env_domain): Ditto for domain name. (cygheap-user::env_name): New method. * syscalls.cc (seteuid32): Do not get or set the environment. Do not call LookupAccountSid nor internal_getlogin. Set cygheap->user name and sid from the passwd entry. * uinfo.cc (uinfo_init): Only call internal_getlogin when starting from a non Cygwin process and use the values returned in user. (internal_getlogin): Simplify to case where starting from a non Cygwin process. Store return values in user and return void. Do not set the Windows default environment. * dcrt0.cc (dll_crt0_1): Call uinfo_init only when needed. Do not set myself->uid nor reset user.sid. * spawn.cc (spawn_guts): Get the sid from cygheap->user. Always RevertToSelf(). Don't set uid in impersonated case. * cygheap.cc (cygheap_user::set_sid): Do not set orig_sig. (cygheap_user::set_orig_sid): New. * cygheap.h: Declare cygheap_user::set_sid. * winsup.h: Add argument to uinfo_init(). --- winsup/cygwin/cygheap.cc | 54 +++++++++++++++--------------------------------- 1 file changed, 17 insertions(+), 37 deletions(-) (limited to 'winsup/cygwin/cygheap.cc') diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc index 723fde2ff..8f76b5b85 100644 --- a/winsup/cygwin/cygheap.cc +++ b/winsup/cygwin/cygheap.cc @@ -445,54 +445,34 @@ cygheap_user::set_name (const char *new_name) pname = cstrdup (new_name ? new_name : ""); homedrive = NULL; homepath = NULL; -} - -void -cygheap_user::set_logsrv (const char *new_logsrv) -{ if (plogsrv) - cfree (plogsrv - 2); - if (!new_logsrv || !*new_logsrv) - plogsrv = NULL; - else - { - plogsrv = (char *) cmalloc (HEAP_STR, strlen (new_logsrv) + 3) + 2; - strcpy (plogsrv, new_logsrv); - } -} - -void -cygheap_user::set_domain (const char *new_domain) -{ + cfree (plogsrv); if (pdomain) cfree (pdomain); - pdomain = (new_domain && *new_domain) ? cstrdup (new_domain) : NULL; + plogsrv = pdomain = NULL; } BOOL cygheap_user::set_sid (PSID new_sid) { - if (!new_sid) + if (new_sid) { + if (!psid) + psid = cmalloc (HEAP_STR, MAX_SID_LEN); if (psid) - cfree (psid); - if (orig_psid) - cfree (orig_psid); - psid = NULL; - orig_psid = NULL; - return TRUE; + return CopySid (MAX_SID_LEN, psid, new_sid); } - else + return FALSE; +} + +BOOL +cygheap_user::set_orig_sid () +{ + if (psid) { - if (!psid) - { - if (!orig_psid) - { - orig_psid = cmalloc (HEAP_STR, MAX_SID_LEN); - CopySid (MAX_SID_LEN, orig_psid, new_sid); - } - psid = cmalloc (HEAP_STR, MAX_SID_LEN); - } - return CopySid (MAX_SID_LEN, psid, new_sid); + if (!orig_psid) orig_psid = cmalloc (HEAP_STR, MAX_SID_LEN); + if (orig_psid) + return CopySid (MAX_SID_LEN, orig_psid, psid); } + return FALSE; } -- cgit v1.2.3