.title uafjnl - Update one or more uaf's.  .ident /1.0/ ; ; Title: ; Uafjnl - Update user authorization file and capture uaf commands. ; ; Version: ; 1.0 ; ; Facility: ; System Manager Tool. ; ; Abstract: ; This program accepts commands for the authorization program. The ; commands are passed via a mailbox to a subprocess that is execut- ; ing AUTHORIZE, and written to a journal file. The purpose of the ; journal file is to apply the authorize commands to the uaf on the ; remote node. ; ; Environment: ; Should only be executed from system manager account. ; ; Author: ; Mark Oakley, 25-Jun-1983, Battelle Columbus Labs ; ; Modified: ;   .sbttl data section  .psect data,rd,wrt,noexe,long,shr,pic  $accdef ; Symbols for process termination message. ! $dibdef ; Symbols for $GETDEV system service. " $dvidef ; Symbols for $GETDVI system service. # $ssdef ; Termination symbols. $ %; &; Macro to handle return codes. '; ( .macro on_err there,?here ) blbs r0,here * brw there +here: .endm on_err ,; -; Data structures for mailbox. .; / 0read_mbx_efn = 5 1 2write_mbx_efn = 6 3 4read_mbx_chan: 5 .blkw 1 6 7write_mbx_chan: 8 .blkw 1 9 :read_mbx_iosb: ; .blkq 1 < =write_mbx_iosb: > .blkq 1 ? @read_mbx_lognam: A .ascid /UAF_READ_MBX/ B Cwrite_mbx_lognam: D .ascid /UAF_WRITE_MBX/ E Fmbx_info: G .blkb dib$k_length H Imbx_info_desc: J .long dib$k_length K .address mbx_info L Mmbx_info_len: N .blkw 1 O P .align long Q; R; Data structures for journal file. S; T Ujou_file_fab: V $fab dnm=<.jou>,- W fac=put,- X fnm=,- Y fop=sqo,- Z org=seq,- [ rat=cr,- \ rfm=var ] ^jou_file_rab: _ $rab fab=jou_file_fab,- ` rbf=command_buf a bcommand_buf_desc: c .long command_buf_siz d .address command_buf e fcommand_buf: g .blkb 132 hcommand_buf_siz = . - command_buf i jcommand_len: k .blkl 1 l; m; Data structures for subprocess output. n; ooutput_buf_desc: p .long output_buf_siz q .address output_buf r soutput_buf: t .blkb 255 uoutput_buf_siz = . - output_buf vorig_output_buf_siz = . - output_buf w xoutput_len: y .blkl 1 z {output_received: | .blkb 1 } ~; ; Data structures for subprocess. ; subprocess_pid: .blkl 1 subprocess_name: .ascid /UAF_SUBPROC/ image_name: .ascid /SYS$SYSTEM:LOGINOUT.EXE/ subproc_done: ; Flag to tell us subprocess has completed .blkb 1 ; an output operation. subproc_term: ; Flag to tell us subprocess has terminated. .blkb 1 term_mbx_itmlst: ; Need to have the mailbox unit number .word term_mbx_unit_len ; when creating the subprocess. .word dvi$_unit .address term_mbx_unit .address 0 .long 0 term_mbx_chan: .blkw 1 term_mbx_unit: .blkw 1 .blkw 1 ; Dummy space for $GETDVI call. term_mbx_unit_len = . - term_mbx_unit term_mbx_iosb: .blkq 1 term_mbx_lognam: .ascid /UAF_TERM_MBX/ term_mbx_msg: .blkb acc$k_termlen ; ; Miscellaneous data structures. ; no_print: ; Tells whether or not to print output from .blkb 1 ; the subprocess. little_e: .ascii /e/ capital_e: .ascii /E/ prompt_desc: ; Standard prompt. .ascid /UAF> / cont_prompt_desc: ; Continuation prompt. .ascid /_/ cont_flag: ; Tells us if the continuation prompt .blkb 1 ; should be used on long commands. minus: ; Use this to check continuation. .ascii /-/ end_of_input: .blkb 1 ; ; Commands to start AUTHORIZE and terminate subprocess. ; assign_comm: .ascid /$ ASSIGN SYS$SYSTEM:SYSUAF.DAT SYSUAF/ run_comm: .ascid /$ RUN SYS$SYSTEM:AUTHORIZE/ exit_comm: .ascid #$ LOGOUT/BRIEF# .sbttl main program .psect code,rd,nowrt,exe,long,pic,shr .entry uafjnl,^m jsb setup_jou_file ; Open journal file for output. on_err exit jsb get_mbx ; Routine to create necessary mailboxes. on_err exit jsb get_subproc ; Routine to create subprocess. on_err exit jsb start_auth ; Start executing AUTHORIZE. on_err exit next_command: jsb get_command ; Prompt user for a command. on_err exit 10$: jsb save_command ; Save command in journal file. on_err exit pushl command_len ; Have the subprocess execute the pushal command_buf ; the command. calls #2,send_command on_err exit jsb check_subproc_done ; Declare AST routine for subprocess on_err exit ; output completion. jsb check_output ; Did the subprocess send us any on_err exit ; output? blbs end_of_input,break_out ; Was a ^Z or exit command previously brb next_command ; No, get another command. break_out: ; Yes, terminate subprocess. jsb clean_up ; Housekeeping. exit: ret .sbttl setup_jou_file, get_mbx routines ; ; Open journal file. ; setup_jou_file:   $create fab=jou_file_fab  on_err setup_exit   $connect -  rab=jou_file_rab  on_err setup_exit  setup_exit:  rsb    ; ; Create mailboxes for the subprocess to read from, ; write to, and write subprocess termination message. ; get_mbx:  $crembx_s - ; Subprocess reads from this mailbox.  chan=read_mbx_chan,-  maxmsg=#255,- ; Commands are less than 132 char.  promsk=#^xf000,- ; No world access.  lognam=read_mbx_lognam  on_err mbx_exit   $crembx_s - ; Subprocess writes to this mailbox.  chan=write_mbx_chan,-  maxmsg=#255,- ; Assume no output lines > 255 char.  promsk=#^xf000,- ; No world access.  lognam=write_mbx_lognam  on_err mbx_exit ! " $crembx_s - ; Subprocess sends termination message # chan=term_mbx_chan,- ; to this mailbox. $ maxmsg=#255,- ; Should be more than enough. % promsk=#^xf000,- ; No world access. & lognam=term_mbx_lognam ' on_err mbx_exit ( )mbx_exit: * rsb + , .sbttl get_subproc, subproc_term_rtn routines -; .; Create subprocess to execute AUTHORIZE. /; 0get_subproc: 1 2 $getdvi_s - ; Get unit number of 3 chan=term_mbx_chan,- ; termination mailbox. 4 itmlst=term_mbx_itmlst 5 on_err subproc_exit 6 7 $creprc_s - 8 pidadr=subprocess_pid,- 9 image=image_name,- : input=read_mbx_lognam,- ; output=write_mbx_lognam,- < error=write_mbx_lognam,- = prcnam=subprocess_name,- > baspri=#6,- ? mbxunt=term_mbx_unit @ on_err subproc_exit A B $qio_s chan=term_mbx_chan,- ; Cause AST delivery upon C func=#io$_readvblk,- ; subprocess completion. D astadr=subproc_term_rtn,- E iosb=term_mbx_iosb,- F p1=term_mbx_msg,- G p2=#acc$k_termlen H on_err subproc_exit I Jsubproc_exit: K rsb L M N; O; This routine is invoked when the subprocess terminates. P; Q R .entry subproc_term_rtn,^m<> S T movb #1,subproc_term ; Remember that we terminated. U $wake_s ; Make sure we don't fall asleep V ; waiting for output that will W ; never come. X Y ret Z [ .sbttl start_auth \; ]; Start up AUTHORIZE. ^; _start_auth: ` a movb #1,no_print ; Don't print any subprocess output. b c movzwl assign_comm,-(sp) ; Push length. d moval assign_comm,r2 ; Address of descriptor. e pushal @4(r2) ; Push location of string. f calls #2, send_command ; Send ASSIGN command. g on_err start_auth_exit h i jsb check_subproc_done j on_err start_auth_exit k l jsb check_output m on_err start_auth_exit n o movzwl run_comm,-(sp) ; Push length. p moval run_comm,r2 ; Address of descriptor. q pushal @4(r2) ; Push location of string. r calls #2, send_command ; Send RUN command. s on_err start_auth_exit t u jsb check_subproc_done v on_err start_auth_exit w x jsb check_output y on_err start_auth_exit z { clrb no_print ; Ok to print subprocess output. | }start_auth_exit: ~ rsb   .sbttl get_command routine ; ; Prompt the user for a command. ; get_command:  $cancel_s - ; Get rid of any extra set mode  chan=write_mbx_chan ; attention qio's on this mailbox.  on_err get_exit   pushal command_len  blbc cont_flag,10$ ; Use the continuation prompt?  pushal cont_prompt_desc ; Yes.  clrb cont_flag  brb 20$ 10$:  pushal prompt_desc ; No. 20$:  pushal command_buf_desc  calls #3,g^lib$get_input  ; ; Check for end of input. ;  cmpl #rms$_eof,r0 ; Was a ^Z entered?  bneq 40$   movb capital_e,command_buf ; A ^Z was entered, send the  movl #1,command_len ; subprocess an exit command.  movl #ss$_normal,r0 ; Make sure we don't abort.  40$:  on_err get_exit ; Now check for error.   movzbl command_buf,r1 ; We're at the end if a small "e"  cmpb r1,little_e ; was first character entered.  bneq 60$  movb #1,end_of_input ; Remember we hit end of input.  60$:  cmpb r1,capital_e ; We're at the end if a capital "e"  bneq 80$ ; was first character entered.  movb #1,end_of_input ; Remember we hit end of input.  80$:  moval command_buf,r1 ; Pick up last character in  addl2 command_len,r1 ; command line.  movb -(r1),r2  cmpb minus,r2 ; Is it a continuation character?  bneq 90$  movb #1,cont_flag ; Yes, set the continuation flag.  90$: get_exit:  rsb   .sbttl save_command, send_command routines ; ; Write command to journal file. ; save_command:   movw command_len,- ; Set the length of the command.  jou_file_rab+rab$w_rsz   $put rab=jou_file_rab  on_err save_exit  save_exit:  rsb      ; ; Send a command to the subprocess. ;  .entry send_command,^m<>   $qio_s efn=#read_mbx_efn,-  chan=read_mbx_chan,-  func=#io$_writevblk,-  iosb=read_mbx_iosb,-  p1=@4(ap),-  p2=8(ap)  on_err send_exit   pushal read_mbx_iosb ; Wait for subprocess to  pushl #read_mbx_efn ; read command.  calls #2,wait_io_done  on_err send_exit   movzwl read_mbx_iosb,r0  on_err send_exit  send_exit:  ret   .sbttl check_subproc_done subproc_done_rtn routines ; ; This routine causes an AST routine to be executed if the ; subprocess requests any input (that is, completes). ; check_subproc_done:   clrb subproc_done  $qio_s chan=read_mbx_chan,-  func=#io$_setmode!io$m_readattn,-  p1=subproc_done_rtn  on_err check_subproc_done_exit  check_subproc_done_exit:  rsb      .sbttl subproc_done_rtn routine ; ; Routine to indicate subprocess is done with current command. ;  .entry subproc_done_rtn,^m<>  movb #1,subproc_done  blbs output_received,20$ ; Wake us up if no output was  $wake_s ; received.  20$:  ret   .sbttl check_output ; ; Check for any output. Stop checking when subprocess is done ; sending output. ; check_output:  read_loop:  clrb output_received  $qio_s chan=write_mbx_chan,- ; Get set to receive  func=#io$_setmode!io$m_wrtattn,- ; any output.  p1=get_output  on_err check_output_exit   $hiber_s ; Sleep until we get output, subprocess  ; tries to read another command, or  ; subprocess terminates.   blbs output_received,40$ ; Did output completion wake  ; us up?   $getdev_s - ; No, either subprocess wants  devnam=write_mbx_lognam,- ; another command, or sub-  prilen=mbx_info_len,- ; process terminated - see if  pribuf=mbx_info_desc ; there are any messages left  on_err check_output_exit ; in the mailbox.   tstw mbx_info+8  bgtr 30$  brw check_output_exit  30$: ! calls #0,get_output ; There was a message left, " on_err check_output_exit ; go get it. # $40$: % blbs no_print,50$ ; Should we write the output? & pushal output_buf_desc ; Yes. ' calls #1,g^lib$put_output ( on_err check_output_exit ) *50$: + movl #orig_output_buf_siz,- ; Restore actual length of , output_buf_desc ; the buffer. - . blbs subproc_done,60$ ; Is the subprocess done? / brw read_loop ; No, check for more output. 0 160$: 2 3check_output_exit: 4 rsb 5 6 .sbttl get_output routine 7; 8; This routine gets the contents of the mailbox that the 9; subprocess writes to. :; ; .entry get_output,^m<> < = $qio_s efn=#write_mbx_efn,- ; Read the mailbox. > chan=write_mbx_chan,- ? func=#io$_readvblk!io$m_now,- @ iosb=write_mbx_iosb,- A p1=output_buf,- B p2=#output_buf_siz C on_err get_output_exit D E movl write_mbx_iosb+2,- ; Put the actual length of the F output_buf_desc ; output into the descriptor. G H movb #1,output_received I blbs subproc_done,20$ ; Wakeup if we are still J $wake_s ; sleeping (that is, if the K on_err get_output_exit ; subprocess has not awaken L ; us). M20$: N Oget_output_exit: P ret Q R .sbttl wait_io_done routine S; T; This routine waits on an i/o operation to complete. U; V .entry wait_io_done,^m<> W X10$: Y movzwl @8(ap),r0 ; Is I/O done? Z bneq 20$ ; Yes, branch. [ $clref_s - \ efn=4(ap) ; Clear the event flag. ] movzwl @8(ap),r0 ; Did the I/O just complete? ^ bneq 20$ ; Yes, branch. _ $waitfr_s - ` efn=4(ap) ; Wait for completion. a brb 10$ ; On completion, try again. b c20$: d ret e f; g; This routine terminates the processes and performs miscellaneous h; housekeeping chores. i; jclean_up: k l movb #1,no_print ; Don't print logout info. m movzwl exit_comm,-(sp) ; Push length. n moval exit_comm,r2 ; Address of descriptor. o pushal @4(r2) ; Push location of string. p calls #2,send_command ; Send EXIT command. q on_err clean_up_exit r s jsb check_subproc_done ; Declare AST routine for subprocess t on_err clean_up_exit ; output completion. u v jsb check_output ; Did the subprocess send us any w on_err clean_up_exit ; output? x y movl #ss$_normal,r0 z {clean_up_exit: | rsb } ~   .end uafjnl