[comp.sys.apollo] DM logout tool

dbfunk@ICAEN.UIOWA.EDU (David B Funk) (10/21/89)

WRT posting <8910201743.AA00893@civilgate.ce.uiuc.edu>:

> I need a supported way to log out a user from either a program
> or a shell script.
> The reason why I need this is I wish to prevent DM login by a user
> if the home directory does not exist.
> At SR9, I forced a shell script for all DM logins that simply
> did:
> if not existf ^HOME then
>    # code to display messageand wait goes here
>    xdmc lo
> end if
> 
> QUESTION: How can I force a user logged into the console off the
> system?

What you want can be done if it is done correctly. Your problem is that
the simple approach ("xdmc lo" & pad_$dm_cmd(sid,'lo',...) has some
undesireable side effects due to a limitation (feature? ;-) of the
Display Manager. To put it bluntly if you do "xdmc lo" you mess up
the DM. The symptoms are subtle at first but they can get bad.

    Try this experiment. Take a node that is in known good state,
(reboot it if you don't know for sure) and watch carefully what
happens when you log in. First you see the "login:" prompt (sr10;
"Please log in:" for pre-sr10). Type in a login ID & hit return,
the "Password:" prompt appears. Type in the password & hit return,
the prompt dissappears and a few seconds later things happen.
Assuming that you've given it a valid ID & password, an inital
shell appears and ONLY THEN the "Command:" prompt appears in the
DM input window. Hit the "CMD" key, type in "lo" & return. Note that
the "Command:" prompt dissappears for a few seconds before the "login:"
comes back. Log back in and now type in "xdmc lo" in the shell to log
out; you've just messed up the DM and here come the first symptoms.
Log back in again but pay carefull attention to what happens in the
DM input window. Type in the login ID, hit return, and watch closely.
You'll see the "login:" prompt dissappear, the "Command:" prompt
appear for a fraction of a second, and then the "Password:" prompt
appears. Type in the password, hit return, and watch again. The
"Password:" prompt dissappears but now the "Command:" prompt appears
instantly, before any thing else begins to happen.
    Once a "xdmc lo" has been done, the symptoms are there. If the
node is run long enough in this state then other symptoms can occur
like garbage characters & little triangles appearing along with or
in place of the "Command:" prompt. Once this starts, the only cure
is to reboot the node (or reload the DM with an "EX" & "GO").
If you put the "xdmc lo" in a shell script, then you'll have a
read lock left on the file after it is used. If you try to put it
in a program with a pad_$dm_cmd(sid,'lo',..) then you have all kinds
of strange problems with the process hanging.
    So how do you log out from a shell script or program with out
all these problems? The answer is to use the correct incantation.
Don't use "xdmc lo" use instead "xdmc tdm;es 'lo';en". This strange
command sequence sends the cursor to the DM command window, inserts
the text 'lo' there, and then "pushes the return key". The important
thing is that this will let the "xdmc" operation finish before the
DM "sees" the 'lo' command. To deal with the case of the user
hitting the "READ", "EDIT", or "HELP" key and then just walking
away, use "xdmc tdm;en;tl;es 'lo';en". To put this inside a
program use pad_$dm_cmd(sid,'tdm;en;tl;es ''lo'';en',...).
    This will deal with a DM login, I don't yet know how to deal
with 'X' as the "login" environment. Maybe some 'X' guru can help
here. One passing though, if (at sr10) you want to use the sledge
hammer approach, you could kill all the user's processes and then kill
the DM. Init will happily create a new DM if the current one dies.
Of course you may not get things like changed key defs saved or
open edits saved, but the user will be out of there.
    A few final DM goodies: there is an undocumented Word-Wrap
mode for edit pads. Look at page 15 in the Feburary '89 issue
of "The ADUS Ring". Ever wish for an "again" key for DM commands?
Try the "undo" key in the DM "command:" window.

Dave Funk