This is the mail archive of the cygwin-patches@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Reorganizing internal_getlogin()


/* I just found the mail of Chris from last nite (spend a day
   on the road) but as all of the following was ready and tested, 
   I am sending it anyway. Pick what you want. */

As explained previously, the main purpose of the patches 
is to increase performances of servers that fork() and 
setuid() but do not exec(). In particular, the number of
accesses to logonservers (either directly, or through 
LookupAccountSid ) is greatly reduced. The performance
of programs that setuid() and exec() is improved as well, 
e.g. by not reading the passwd file in the child.

In addition the code (mostly uinfo.cc and seteuid) is greatly 
streamlined (IMHO). The changes are pretty self explanatory,
except perhaps the following.
dll_crt0_1() passes a flag to uinfo_init() to indicate if the
parent is a Cygwin process. The previous method (ppid != 1) 
is not reliable and causes the following bug: when a cygwin 
process with ppid == 1 exec()'s after setgid(), the new gid 
gets lost.
Another minor bug is fixed: LOGONSERVER is always set correctly.

Pierre

2002-06-12  Pierre Humblet <pierre.humblet@ieee.org>

	* 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): Add an argument. 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, with an 
	argument. Do not set myself->uid nor reset user.sid.
	* environ.cc (addWinDefEnv): New.
	(inWinDefEnv): New.
	(writeWinDefEnv): New.
	* environ.h: Declare inWinDefEnv() and addWinDefEnv(), and 
	define WINDEFENVC.
	* spawn.cc (spawn_guts): Call functions above to set
	traditional Windows environment variables when copying the
	environment to the cygheap, before CreateProcessAsUser().
	Get the sid from cygheap->user. Always RevertToSelf().
	* cygheap.cc (cygheap_user::set_sid): Do not set orig_sig.
	(cygheap_user::set_sid): New.
	* cygheap.h: Declare cygheap_user::set_sid.
	* winsup.h: Add argument to uinfo_init().

Attachment: spawn.cc.diff
Description: Text document

Attachment: cygheap.h.diff
Description: Text document

Attachment: dcrt0.cc.diff
Description: Text document

Attachment: environ.cc.diff
Description: Text document

Attachment: environ.h.diff
Description: Text document

Attachment: cygheap.cc.diff
Description: Text document

Attachment: syscalls.cc.diff
Description: Text document

Attachment: winsup.h.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]