Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!mit-eddie!genrad!decvax!decwrl!pyramid!prls!philabs!micomvax!musocs!mcgill-vision!mouse From: mouse@mcgill-vision.UUCP Newsgroups: comp.unix.questions Subject: Re: layers and utmp Message-ID: <631@mcgill-vision.UUCP> Date: Wed, 4-Feb-87 03:24:25 EST Article-I.D.: mcgill-v.631 Posted: Wed Feb 4 03:24:25 1987 Date-Received: Sat, 7-Feb-87 11:03:05 EST References: <11967@sun.uucp> <5563@brl-smoke.ARPA> Organization: McGill University, Montreal Lines: 43 In article <5563@brl-smoke.ARPA>, gwyn@brl-smoke.ARPA (Doug Gwyn ) writes: > In article <11967@sun.uucp> guy%gorodish@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@harvard.harvard.edu