Who is "logged in" when you are running multiple login windows?

Andy S Poling andy at jhunix.HCF.JHU.EDU
Mon Mar 19 18:06:37 AEST 1990


In article <871 at galaxia.Newport.RI.US> dave at 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 at gollum.hcf.jhu.edu
Network Services Group                   Bitnet: ANDY at JHUVMS
Homewood Academic Computing              Voice: (301)338-8096    
Johns Hopkins University                 UUCP: mimsy!aplcen!jhunix!gollum!andy



More information about the Comp.sys.att mailing list