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]

setuid on Win95 and etc_changed, passwd & group.


Hello Corinna,

The following patches affect many files but they are simple.
They can wait for 1.3.20.

1) On Win95/98/ME, seteuid and setegid now change the uid/gid.
   Related to that are simplifications in spawn.cc and dcrt0.cc 
   and plugging a handle leak in uinfo.cc (5 first files).
2) passwd and group: various cleanup, plus fixing the following
   scenario that came to light while investigating etc_changed
   (but it doesn't cause any BSOD):
   t0: process starts, reads passwd and group
   t1: user updates /etc/group
   t2: program calls getpwuid. etc_changed returns TRUE. Timestamp
       of passwd file is old, no update. OK.
   t3: program calls getgrgid. etc_changed returns FALSE. 
       /etc/group is not updated. Bug.

During testing I noticed another issue. If etc_changed is initialized
in a parent and /etc/passwd is changed between the moments where a 
child is forked and where etc_changed is first called in the child, 
etc_changed unexpectedly returns false in the child (WinME).
Not sure how to fix that, short of always rereading the files in 
the child (when/if actually accessed). That would be an OK solution if
we hadn't just copied the data from the parent. Would it be possible
to store passwd and group in some other heap (from Windows?) that
doesn't get copied? If that was done, then the etc_changed handle
could be opened as needed instead of being inherited.

Incidentally while looking at cygheap.cc I noticed that the 
+ sizeof (_cmalloc_entry) on line 221 duplicates the one on line
234. I didn't change it in this patch as it is not related to the rest, 
but I have run with an abbreviated line 221 for a day.


2003/01/15  Pierre Humblet  <pierre.humblet@ieee.org>

	* syscalls.cc (seteuid32): On Win95 get the pw entry. If it exists
	update the euid and call cygheap->user.set_name. Remove special handling 
	of ILLEGAL_UID.
	(setgid32): Add a debug_printf. On Win95, always set the egid. 
	Remove special handling of ILLEGAL_GID. Do not compare gid and gr_gid.
	* child_info.h (class cygheap_exec_info): Remove uid.
	* spawn.cc (spawn_guts): Do not set ciresrv.moreinfo->uid.
	* dcrto.cc ( ): Always call uinfo_init.
	* uinfo.cc (uinfo_init): Reorganize and close handle if needed.
	(cygheap_user::ontherange): Do not call internal_getpwnam if pw is NULL.
	* cygheap.h (struct init_cygheap): Define type etc_changed_bits.
	Add etc_changed_flags member, and add argument to etc_changed. 
	* cygheap.cc (init_cygheap::etc_changed): Add argument. Use it in 
	conjunction with etc_changed_flags.
	* pwdgroup.h (class pwdgrp_check): Add member me, initialize it in 
	constructor. Add third argument to declaration of internal_getgroups.
	(pwdgrp_check::isinitializing): Add argument to etc_changed.
	(pwdgrp_check::isuninitialized): Add call to initialize etc_changed.	
	* passwd.cc: Add argument to declaration of passwd_state.
	(grab_int): replace almost_null by "".
	(read_etc_passwd): On NT, add a line for uid = -1. Use same default uid
	for Win95 and NT. Call cygheap_user::ontherange to initialize HOME. 
	* grp.cc (read_etc_group): On NT, add a line for gid = -1. Change name
	"unknown" to "mkgroup". 
	(internal_getgrgid): Do not return default in nontsec case.
	(internal_getgroups): Add argument srchsid and look for it in groups
	if not NULL.

Attachment: ntsec.diff
Description: Text document


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