Xref: utzoo unix-pc.general:5034 comp.sys.att:9034 Path: utzoo!attcan!uunet!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!uflorida!haven!aplcen!jhunix!andy From: andy@jhunix.HCF.JHU.EDU (Andy S Poling) Newsgroups: unix-pc.general,comp.sys.att Subject: Re: Who is "logged in" when you are running multiple login windows? Summary: who was in last non-root active window... Keywords: unixpc, 3b1, multiple windows, login Message-ID: <4518@jhunix.HCF.JHU.EDU> Date: 19 Mar 90 08:06:37 GMT References: <871@galaxia.Newport.RI.US> Reply-To: andy@jhunix.UUCP (Andy S Poling) Followup-To: unix-pc.general Organization: The Johns Hopkins University - HCF Lines: 46 In article <871@galaxia.Newport.RI.US> dave@galaxia.Newport.RI.US (David H. Brierley) writes: [...] >The problem I am having is that if there is more than one user logged in on >the console, which one is the "currently active user". When one of the >shifted function keys is pressed I want the program to do a setuid() to the >currently active user before running the command since otherwise all the >commands would run as root. I also need to know who the current user is in >case the user asks to read his mail. My first thought was to scan through >the utmp file to see who is logged in and then look at each of the window >devices to see which one was accessed most recently and therefore determine >which user most recently typed something on the keyboard. This seemed to >work ok until my wife logged in and started up the UA, at which point it >stopped working. It seems that the UA doesn't bother to change the >ownership of the window devices, in fact it cannot change the owner because >it is not running as root. As soon as my wife allocated a window which was >previously owned by me, my program began insisting that I was the currently >active user instead of my wife. > >If anyone has any ideas on how to solve this problem it would be greatly >appreciated. Ahhh. I ran into this problem when I too replaced smgr and wmgr with my own home-brew manager. In my setup, I implemented faster UA-type widowed menus and I needed to know who was mousing my manager (out of multiple concurrent windows). Since everything is in one program in my case, I simply kept track of the last non-root window that was active (since I made it active, I know). When the menu functions are moused, I use that stored uid. This, effectively, does the same thing as checking utmp, then tty ownership. I don't run the UA anymore so I don't know if my scheme works any better with it. However (and this is a reasonably big however :-) since my manager also logs people in, it routinely (every 2 secs) checks whether any closed windows are improprly represented in utmp and changes the utmp entries for those windows to reflect a logout. I think this would make that troublesome UA window "invisible" since utmp would show it as "logged out". I consider this proper behavior on the part of my software - to act otherwise would throw security out the window. The real problem is that the UA was intended for a single user environment. -Andy -- Andy Poling Internet: andy@gollum.hcf.jhu.edu Network Services Group Bitnet: ANDY@JHUVMS Homewood Academic Computing Voice: (301)338-8096 Johns Hopkins University UUCP: mimsy!aplcen!jhunix!gollum!andy