layers and utmp

mouse at mcgill-vision.UUCP mouse at mcgill-vision.UUCP
Wed Feb 4 18:24:25 AEST 1987


In article <5563 at brl-smoke.ARPA>, gwyn at brl-smoke.ARPA (Doug Gwyn ) writes:
> In article <11967 at sun.uucp> guy%gorodish at Sun.COM (Guy Harris) writes:
>> This is a depressingly common source of grief in UNIX.  The Sun
>> window system puts entries in "utmp" every time it opens up a
>> terminal emulation window,
What's annoying is that it doesn't always get rid of them.

> I should note that there is a lot of 4.3BSD user-mode code that does
> NOT follow the advice contained in the UNIX Reference Manual about
> the proper way to determine user names.

> Read GETLOGIN(3) in the Manual ([...]) then follow the recommended
> procedure in order to determine a login name to associate with the
> process.

Except that *that* procedure still has bugs in the presence of multiple
codes with the same uid.  What I would recommend is

	username = getenv("USER")
	if the USER variable exists
		if the user exists and its UID matches getuid(), or if
		  getuid() is zero (superuser),
			use that name
	call getlogin(), if it succeeds then use the value
	use getpwuid(getuid())

The BSD networking programs rlogin/rsh/rcp all suffered from this (we
are running them with the above algorithm); so does suntools (all
windows show up as belonging to the first user in /etc/passwd with the
real uid - we can't fix this one, no source code).  Most annoying to
get mail, for example, claiming to be from the wrong user.

Comments recommending changing UIDs of the codes to make the uid space
1-to-1 will be ignored unless accompanied by fixes to all code (and
there's a lot, both kernel and user) that assumes that uid=0 iff
super-user.

					der Mouse

USA: {ihnp4,decvax,akgua,utzoo,etc}!utcsri!mcgill-vision!mouse
     think!mosart!mcgill-vision!mouse
Europe: mcvax!decvax!utcsri!mcgill-vision!mouse
ARPAnet: think!mosart!mcgill-vision!mouse at harvard.harvard.edu



More information about the Comp.unix.questions mailing list