From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX"  7-JUL-1989 18:19
To:	MRGATE::"ARISIA::EVERHART"
Subj:	LOGINOUT_HACK part 2 of 2

Received: From KL.SRI.COM ([0.0.0.0]) by CRVAX.SRI.COM with TCP; Fri,  7 JUL 89 14:29:32 PDT
Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Fri, 7 Jul 89 14:22:53 PDT
Received: by ucbvax.Berkeley.EDU (5.61/1.37)
	id AA09919; Fri, 7 Jul 89 14:12:58 -0700
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 7 Jul 89 19:00:29 GMT
From: gkn@mcnc.org  (Gerard K. Newman)
Organization: North Carolina Supercomputing Center
Subject: LOGINOUT_HACK part 2 of 2
Message-Id: <4835@alvin.mcnc.org>
References: <1463@ndmath.UUCP>, <4804@alvin.mcnc.org>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

+-+-+-+ Beginning of part 2 +-+-+-+
X; the user  types `094Z then we'll  exit.  Otherwise we take what gets
X; typed  and fire it  off to the gateway,  who  will grab  onto our
X; terminal and do its thing.
X;
X; Inputs:
X;
X;`009None.
X;
X; Outputs:
X;
X;`009As described above.
X;
X;-
X
XCTSS_LOGIN:`009`009`009`009;Grab a CTSS login line
X
X; Get a channel to our SYS$INPUT.
X
X`009$ASSIGN_S DEVNAM=SYS$INPUT,-`009;Get a channel
X`009`009CHAN=TT_CHAN`009`009; to our terminal
X
X; Get an out-of-band AST for `094\.
X
X`009MOVAL`009OOB_MASK,R1`009`009;Address the OOB mask
X`009$QIOW_S`009CHAN=TT_CHAN,-`009`009;Get an out-of-band AST
X`009`009FUNC=#IO$_SETMODE!IO$M_OUTBAND!IO$M_TT_ABORT,- ;(abort the read)
X`009`009P1=OOB_AST,-`009`009;AST here
X`009`009P2=R1`009`009`009;Here's the OOB mask
X
X; Translate SDSC$CTSS_HERALD and if there is one then dump it out onto
X; the terminal.
X
X`009$TRNLNM_S LOGNAM=HERALD,-`009;Translate this logical name
X`009`009TABNAM=LNM$PROCESS,-`009;Translate from this table
X`009`009ITMLST=LNM_LIST`009`009;Get this stuff.
X`009MOVL`009HERALD_LENG,R1`009`009;Anything to say?
X`009BEQL`00910$`009`009`009;If EQL no.
X`009$QIOW_S`009CHAN=TT_CHAN,-`009`009;Else say it.
X`009`009FUNC=#IO$_WRITELBLK,-`009;Write
X`009`009P1=HERALD_BUFF,-`009; this
X`009`009P2=R1,-`009`009`009;  message
X`009`009P4=#`094x01020000`009`009;(carriage control)
X
V; Start building the message we'll send to the gateway.  Stuff in the physica
Xl
X; device name as a counted string.
X
X10$:`009MOVAB`009MBX_BUFF,R3`009`009;Address our mailbox message buffer
X`009MOVL`009R3,R6`009`009`009;Twice.
X`009MOVB`009DEV_LENG,(R3)+`009`009;Stuff the device name length
X`009MOVC3`009DEV_LENG,DEVICE,(R3)`009;Copy the device name
X
X; Next, prompt the user and collect a CTSS login line.  Exit if:
X;
X;`009- we time out.
X;`009- the user types `094Z
X
X20$:`009MOVAB`009PROMPT,R1`009`009;Address our prompt
X`009MOVZBL`009(R1)+,R0`009`009;Get the length
X`009$QIOW_S`009CHAN=TT_CHAN,-`009`009;Read
X`009`009FUNC=#IO$_READPROMPT,-`009; with prompt
X`009`009IOSB=IOSB,-`009`009;I/O status here
X`009`009P1=1(R3),-`009`009;Buffer here
X`009`009P2=#128,-`009`009;Up to this much stuff
X`009`009P3=LGI_PWD_TMO,-`009;Timeout after this long
X`009`009P5=R1,P6=R0`009`009;Prompt address & length
X`009BLBC`009R0,30$`009`009`009;Eh?
X`009MOVZWL`009IOSB,R0`009`009`009;Check here, too
X`009CMPL`009#SS$_CONTROLY,R0`009;Did OOB_AST hit?
X`009BEQL`00940$`009`009`009;If EQL yes
X`009CMPL`009#SS$_CONTROLC,R0`009;Check both ways
X`009BEQL`00940$`009`009`009;If EQL yes
X
X30$:`009BLBC`009R0,ERROR_EXIT`009`009;If LBC then error
X
X; Check for a `094Z terminator.
X
X`009CMPB`009#`094x1A,IOSB+4`009`009;`094Z?
X`009BEQL`009ERROR_EXIT`009`009;Yep, lose now.
X
X; Copy the user's input into the mailbox message buffer.
X
X`009MOVZBL`009IOSB+2,R0`009`009;Any input?
X`009BEQL`00920$`009`009`009;If EQL no, ask again
X`009MOVB`009R0,(R3)+`009`009;Stash the length
X`009ADDL`009R0,R3`009`009`009;Compute the
X`009SUBL`009R6,R3`009`009`009; final length
X
V; Fire the message off to the CTSS gateway.  Once the gateway has set things
X up
X; for this connection it will just $DELPRC us ...
X
V`009$SCHDWK_S DAYTIM=DELTA_30`009;Schedule a wakeup in 30 seconds just in cas
Xe
X`009$QIO_S`009CHAN=MBX_CHAN,-`009`009;Fire the
X`009`009FUNC=#IO$_WRITELBLK,-`009; message off
X`009`009P1=(R6),P2=R3`009`009;  to the gateway
X`009$HIBER_S`009`009`009;Hibernate
X
X; If we get here the gateway didn't respond.  Argh.
X
X`009MOVZWL`009#SS$_TIMEOUT,R0`009`009;Die with
X`009BRB`009ERROR_EXIT`009`009; a timeout
X
X; Here to crank the real loginout.
X
X40$:`009RSB`009`009`009`009;Just crank the real loginout.
X
X; Non-functional OOB_AST routine.
X
XOOB_AST: .Word`0090`009`009`009;World's shortest AST routine
X
X`009RET`009`009`009`009;That's easy
X
X`009.Page
X`009.Subtitle`009ERROR_EXIT`009- Error exit
X
X;+
X;
X; ----- ERROR_EXIT:  Error exit
X;
X;
X; This routine is called to display an error message on SYS$OUTPUT
X; and then exit.
X;
X; Inputs:
X;
X;`009R0`009- Error code
X;
X; Outputs:
X;
X;`009Error text displayed and program exits with status.
X;
X;-
X
XERROR_EXIT:`009`009`009`009;Error exit
X
X`009BSBW`009LOSE_SYSPRV`009`009;Lose SYSPRV if necessary
X`009BISL3`009#STS$M_INHIB_MSG,R0,R2`009;Save the error code
X`009BBS`009#STS$V_INHIB_MSG,R0,10$`009;Inhibit message?
X`009BLBS`009R0,10$`009`009`009;Error?
X`009$GETMSG_S MSGID=R0,-`009`009;Get the error message text
X`009`009MSGLEN=OUT_DESC,-`009;Return the length here
X`009`009BUFADR=OUT_DESC,-`009;Here's the output buffer
X`009`009FLAGS=#1`009`009;Text only
X`009PUSHAQ`009OUT_DESC`009`009;Stack the descriptor address
X`009CALLS`009#1,G`094LIB$PUT_OUTPUT`009;Display same
X
X10$:`009$EXIT_S`009R2`009`009`009;Exit with status
X
X`009.Page
X`009.Subtitle`009LOSE_SYSPRV`009- Lose SYSPRV if we don't deserve it
X
X;+
X;
X; ----- LOSE_SYSPRV:  Lose SYSPRV if we don't deserve it
X;
X;
X; This routine will lose SYSPRV if we don't deserve to have it (not in
X; our process privilege mask and we don't have a system UIC).
X;
X; Inputs:
X;
X;`009UIC_GROUP`009- Our UIC group
X;`009MAXSYSGROUP`009- The maximum system UIC group
X;`009PROCPRIV`009- Our process default privilege mask
X;
X; Outputs:
X;
X;`009SYSPRV disabled unless we deserve it.
X;
X;-
X
XLOSE_SYSPRV:`009`009`009`009   ;Lose SYSPRV if we don't deserve it
X
X`009BBS`009#PRV$V_SYSPRV,PROCPRIV,10$ ;Branch if we have it
X`009CMPL`009UIC_GROUP,MAXSYSGROUP`009   ;Do we have a system UIC?
X`009BLEQ`00910$`009`009`009   ;If LEQ yes
X`009$SETPRV_S ENBFLG=#0,PRVADR=SYSPRV  ;Lose SYSPRV otherwise
X
X10$:`009RSB`009`009`009`009   ;Done
X
X`009`009
X
X`009.End`009START
$ GOSUB UNPACK_FILE

$ FILE_IS = "LOGINOUT_HACK.COM"
$ CHECKSUM_IS = 1629381672
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X$ Macro/Cross/List LOGINOUT_HACK
X$ Link/NoTrace LOGINOUT_HACK+LOGINOUT_HACK/Options
$ GOSUB UNPACK_FILE

$ FILE_IS = "LOGINOUT_HACK.OPT"
$ CHECKSUM_IS = 1750685460
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
XBase`009= 262144`009`009!512*512
$ GOSUB UNPACK_FILE

$ FILE_IS = "LOGINOUT_HACK.README"
$ CHECKSUM_IS = 493112948
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X
V`009Copy SYS$COMMON:[SYSEXE]LOGINOUT.EXE to SYS$COMMON:[SYSEXE]DEC_LOGINOUT.E
XXE
X
X`009Copy LOGINOUT_HACK.EXE to SYS$SPECIFIC:[SYSEXE]LOGINOUT.EXE
X
X`009Install it with CMKRNL, SYSNAM, SYSPRV, LOG_IO, ALTPRI and TMPMBX
X`009privileges (/OPEN/HEADER/SHARED won't hurt, either).
X
X`009BE SURE that DEC_LOGINOUT.EXE is installed the same way.
X
X`009If DEC's LOGINOUT grows much it will be necessary to change the
X`009second longword of MAP_RANGE and the linker options file to a
X`009larger number (right now it's set up for 512 pages).
X
$ GOSUB UNPACK_FILE
$ EXIT
-+-+-+-+-+ End of part 2 +-+-+-+-+-

