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

David H. Brierley dave at galaxia.Newport.RI.US
Sun Mar 18 05:53:33 AEST 1990


Here is a problem I am currently attempting to solve.  I am hoping that
someone on the net might be able to come up with some kind of inspired
solution for it, or at least point me in the right direction.

I am working on a replacement for the window manager and the status
manager.  This program will include all the features of the 3.51 wmgr and
smgr programs, with the exception of cron functions, and will also include
some of the features of the "hotkey" program that I released a while ago
and some features of the replacement wmgr program that was posted.  One of
the features of the replacement wmgr that I have included is the ability to
create multiple login windows on the console.  The "hotkey" capability
allows each user to define a command that is to be run when one of the
shifted function keys is pressed.

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.
-- 
David H. Brierley
Home: dave at galaxia.Newport.RI.US   {rayssd,xanth,lazlo,mirror,att}!galaxia!dave
Work: dhb at rayssd.ray.com           {sun,uunet,gatech,necntc,ukma}!rayssd!dhb



More information about the Comp.sys.att mailing list