d .TITLE FOR System Users Camelian Utility (Permanent Form) .SBTTL Documentation ,;++ ; ; TITLE: FOR.MAR X; ; FACILITY: System users change to someone else utility. ; ; ABSTRACT: ; This program allows a user who has the proper UIC to change L; some of his process context information to that of virtually ; any other user known to the system via SYS$SYSTEM:SYSUAF.DAT. ; Additionally, this program leaves a trail which the account x; billing software can use to determine it's use. ; @; ENVIRONMENT: ; Runs as an image in the context of a process. May signal ; any known SS$_ or RMS$_ return status. l; ; AUTHOR: Ralph Weber CREATION DATE: 11-FEB-1980 4; ; MODIFIED BY: ; ` ;--- d;+++ ; ,; FUNCTIONAL DESCRIPTION: ; After determining that use of FOR is legal for the current UIC, ; this image determines the USERNAME to which portions of the X; process context are to be switched. If no USERNAME was given ; on the command line which invoked this image a USERNAME is ; prompted for. Then the system authorization file, ; SYS$SYSTEM:SYSUAF.DAT is searched for the specified USERNAME. ; If the USERNAME is found the following elements of the L; software process context are atered based on the contents of ; the SYSUAF entry found: ; PCB$L_UIC is set equal to UAF$L_UIC. x; CTL$T_USERNAME is set equal to UAF$T_USERNAME with a three ; character FOR_ID appended for accounting purposes. @; CTL$T_ACCOUNT is set equal to UAF$T_ACCOUNT. ; The device shown in UAF$T_DEFDEV is assigned to SYS$DISK. ; The RMS default directory is set from UAF$T_DEFDIR. l; An attempt is made to have the process name changed to ; CTL$T_USERNAME. If this fails because of SS$_DUPLNAM the 4; process name is left unchanged. ; ; If the USERNAME is not found or if the UIC associated with ` ; USERNAME can also run FOR, no changes are made and the image ; exits with an error status. ( ; ; ; CALLING SEQUENCE: T ; ; $FOR:=$DRA0:[CYCEXE]FOR  ; $FOR Username ; ; H ; INPUT PARAMETERS: ; ; Username is a USERNAME listed in SYS$SYSTEM:SYSUAF.DAT. t; If successful the process UIC, USERNAME, ; ACCOUNT, Default Device, Default Directory, and <; Process Name will be altered based on those ; belonging to Username. ; h; ; OUTPUT PARAMETERS: None. 0; ; ; IMPLICIT INPUTS: \; ; PCB$L_UIC is the current UIC for this process. It is $; used to determine if running FOR is legal. ; ; SYS$SYSTEM:SYSUAF.DAT is the current system authorization file. P; It is used to determine the new values for ; process context parameters altered by FOR. ; This file is not altered! |; ; D; IMPLICIT OUTPUTS: ; ; PCB$L_UIC changed to UAF$L_UIC. p; ; CTL$T_USERNAME changed to UAF$T_USERNAME concantenated with 8; a three character FOR_ID (see table below). ; ; CTL$T_ACCOUNT changed to UAF$T_ACCOUNT. d; ; SYS$DISK changed to UAF$T_DEFDEV. ,; ; Default Directory changed to UAF$T_DEFDIR. ; X; Process Name An attempt is made to make process name ; conform with CTL$T_USERNAME. If SS$_DUPLNAM is ; returned process name is left unchanged. ; ; L; SIDE EFFECTS: ; ; This image requires CMKRNL, CMEXEC, PHY_IO, and SYSNAM x; privileges. ; @; This image will not change to a USERNAME which also has the ; privilege to run this image. Thus it may only be executed once  ; per login/out and all accounting data will be accurate. l ; ; 4!; COMPLETION STATUS: !; !; SS$_NORMAL if successful. `"; SS$_NOPRIV if UIC does not allow use of FOR or "; if attempt made to change to a UIC which also (#; may run FOR. #; SS$_BADPARAM if bad USERNAME detected. #; RMS$_EOF if USERNAME not found in SYS$SYSTEM:SYSUAF.DAT. T$; SS$_???? or RMS$_??? if other abnormal condition encountered. $; %; %; TABLE DESCRIBING FOR_ID %; H&; FOR_ID User of FOR causing FOR_ID &; Nnn UIC [20,nn] 0, -  FAC=GET, FOP=SQO 8 SYSUAF_RAB:  $RAB FAB=SYSUAF_FAB, MBF=3, RAC=SEQ - d ROP=RAH, UBF=UAF_RECORD, USZ=UAF$K_LENGTH  ,UAF_RECORD:  .BLKB UAF$K_LENGTH  XUAF_ERROR_TEXT:  .ASCID /Error reading SYSUAF.DAT/   ; USERNAME Buffer and Work Space L NEW_USERNAME:  .BLKB 9 xFOR_ID: .BLKB 3  @ ; Character Descriptors for Various Change-it System Calls  l .ALIGN LONG 4!NEW_DEVICE: ! .LONG 0, UAF_RECORD+UAF$T_DEFDEV+1 ! `"SYS$DISK_NAME: " .ASCID /SYS$DISK/ (# # .ALIGN LONG # T$NEW_DIRECTORY: $ .LONG 0, UAF_RECORD+UAF$T_DEFDIR+1 % %NEW_PRC_NAME: % .LONG 12, NEW_USERNAME d .SBTTL Setup ;+++ ,; SETUP: ; Check for current UIC allowed to use FOR, ; LOW_GROUP_LIMIT < CURRENT_GROUP < HI_GROUP_LIMIT and X; LOW_MEMB_LIMIT < CURRENT_MEMB < HI_MEMB_LIMIT. ; Use CLI callback to obtain command line with desired new ; USERNAME. ; If USERNAME not present, prompt for USERNAME. ; Open SYS$SYSTEM:SYSUAF.DAT and look for USERNAME. L; If any errors regarding SYSUAF occur, exit giving message ; and RMS exit status. ; Close SYS$SYSTEM:SYSUAF.DAT. x; ;--- @   .PSECT FOR_CODE, PIC,USR,CON,REL,LCL,SHR,EXE,RD,NOWRT,LONG l  4; FOR Program Entry Point FOR_START:  .WORD ^M ` ( GET_CUR_UIC: $GETJPI_S ITMLST=JPI_GET_UIC ;Get current UIC information. BLBS R0, TEST_FOR_VALID T $EXIT_S R0  TEST_FOR_VALID: CMPW CURRENT_GROUP, - ;Current group must be between #LOW_GROUP_LIMIT ;LOW_GROUP_LIMIT and H BLEQ FOR_NOT_VALID ;HI_GROUP_LIMIT; otherwise use CMPW CURRENT_GROUP, - ;of FOR is not valid.  #HI_GROUP_LIMIT t BGEQ FOR_NOT_VALID  CMPW CURRENT_MEMB, - ;Current member must be between < #LOW_MEMB_LIMIT ;LOW_MEMB_LIMIT and  BLEQ FOR_NOT_VALID ;HI_MEMB_LIMIT; otherwise use  CMPW CURRENT_MEMB, - ;of FOR is not valid. h #HI_MEMB_LIMIT  BLSS FOR_VALID 0 FOR_NOT_VALID:  $EXIT_S #SS$_NOPRIV \  $FOR_VALID: GET_NEW_USERNAM:  PUSHAB GET_COMMAND ;Use CLI callback to get P CALLS #1, G^SYS$CLI ;invoking command parameter(s).  MOVQ GET_COMMAND+CLI$Q_RQDESC, - ;Move resultant string  R6 ;descriptor in R6 & R7. | MOVC5 R6, (R7), #^A/ /, - ;Move desired new USERNAME to  #12, NEW_USERNAME ;local working buffer. D SKPC #^A/ /, #3, FOR_ID ;If desired USERNAME exceeds  BEQL 10$ ;nine characters, it must be  $EXIT_S #SS$_BADPARAM ;bad. p10$:  8CHECK_NO_NAME:  SKPC #^A/ /, #9, NEW_USERNAME ;If no USERNAME is present,  BNEQ 10$ ;we must prompt for one. d PUSHAQ USRNM_PMT_DESC  PUSHAQ USRNM_BUF_DESC , CALLS #2, LIB$GET_COMMAND  BLBS R0, 10$  $EXIT_S R0 X10$:  OPEN_SYSUAF:  MOVAB UAF_RECORD, R6 ;Setup pointer to UAF input.  $OPEN FAB=SYSUAF_FAB ;Open SYS$SYSTEM:SYSUAF.DAT and L BLBC R0, SYSUAF_ERROR ;prepair to process the file.  $CONNECT RAB=SYSUAF_RAB  BLBS R0, SYSUAF_LOOP x SYSUAF_ERROR: @ MOVL R0, R2 ;For any error on SYSUAF, give  $CLOSE FAB=SYSUAF_FAB ;a message stating that SYSUAF  PUSHAQ UAF_ERROR_TEXT ;produced the error and exit l CALLS #1, LIB$PUT_OUTPUT ;with error status as return $EXIT_S R2 ;status. 4! ! !SYSUAF_LOOP: `" " $GET RAB=SYSUAF_RAB ;Read a UAF record. (# BLBC R0, SYSUAF_ERROR # # CMPC3 #12, NEW_USERNAME, - ;Compare desired USERNAME T$ UAF$T_USERNAME(R6) ;with UAF USERNAME and when $ BNEQ SYSUAF_LOOP ;they don't match try again. % % %FOUND_USERNAME: H& $CLOSE FAB=SYSUAF_FAB ;Close SYS$SYSTEM:SYSUAF.DAT. d .SBTTL Action ;+++ ,; ; ACTION: ; If new UIC could run FOR, attempt to switch is invalid. X; Build proper FOR_ID in new USERNAME. ; In KERNEL mode set: ; PCB$L_UIC, CTL$T_USERNAME, & CTL$T_ACCOUNT. ; Use SYS$CRELOG to replace SYS$DISK contents. ; Use SYS$SETDIR to replace default directory. L; Use SYS$SETPRM to attempt to change process name. ;---  xTEST_DEST_UIC:  CMPW UAF$W_GRP(R6), - ;Destination UIC cannot be @ #LOW_GROUP_LIMIT ;able to run FOR.  BLEQ DEST_VALID  CMPW UAF$W_GRP(R6), - l #HI_GROUP_LIMIT  BGEQ DEST_VALID 410$: CMPW UAF$W_MEM(R6), -  #LOW_MEMB_LIMIT  BLEQ DEST_VALID ` CMPW UAF$W_MEM(R6), - #HI_MEMB_LIMIT ( BGEQ DEST_VALID DEST_NOT_VALID: T $EXIT_S #SS$_NOPRIV  DEST_VALID: H BUILD_FOR_ID: ASSUME LOW_GROUP_LIMIT EQ <^O16>  ASSUME HI_GROUP_LIMIT EQ <^O21> t 20$: CMPW CURRENT_GROUP, #^O20 ;The first char. in FOR_ID is: < BNEQ 17$  MOVB #^A/N/, FOR_ID ;N for current group = 20.  BRB 100$ h17$: CMPW CURRENT_GROUP, #^O17  BNEQ 16$ 0 MOVB #^A/P/, FOR_ID ;P for current group = 17. 16$: 100$: \  ASSUME LOW_MEMB_LIMIT GE 0 $ ASSUME HI_MEMB_LIMIT LE <^O77>  EXTZV #3, #3, CURRENT_MEMB, R0 ;The second and third  ADDB2 #^A/0/, R0 ;characters of the FOR_ID are P MOVB R0, FOR_ID+1 ;the current member number.  EXTZV #0, #3, CURRENT_MEMB, R0 ;For this we must translate  ADDB2 #^A/0/, R0 ;binary to ASCII. | MOVB R0, FOR_ID+2  D KERNEL_ACTION:  $CMKRNL_S ROUTIN=KRNL_ROUTINE p BRB GENERAL_ACTION  8KRNL_ROUTINE:  .WORD ^M  MOVAB UAF_RECORD, R6 ;Restore UAF record pointer. d  MOVL G^SCH$GL_CURPCB, R2 ;Get pointer to our PCB. , MOVL UAF$L_UIC(R6), - ;Move new UIC into  PCB$L_UIC(R2) ;Process Control Block.  X MOVC3 #12, NEW_USERNAME, - ;Move new USERNAME (w/ FOR_ID)  G^CTL$T_USERNAME ;into P1 space.   MOVC3 #8, UAF$T_ACCOUNT(R6), - ;Move new ACCOUNT into  G^CTL$T_ACCOUNT ;P1 space. L  CVTBW UAF$T_DEFDEV(R6), - ;Complete descriptor for  NEW_DEVICE ;new SYS$DISK device. x $CRELOG_S LOGNAM=SYS$DISK_NAME, - ;Use SYS$CRELOG service to  EQLNAM=NEW_DEVICE, - ;change SYS$DISK name. @ TBLFLG=#LOG$C_PROCESS, -  ACMODE=#PSL$C_EXEC  l ;Let $CRELOG return status be ;return status of KERNAL 4! ;routine. ! ! RET ;That's all in KERNEL mode. `" " (#GENERAL_ACTION: # # CMPL R0, #SS$_SUPERSEDE ;Expect an old name replaced T$ BEQL 10$ ;return status. $ BLBS R0, 10$ % $EXIT_S R0 % %10$: CVTBW UAF$T_DEFDIR(R6), - ;Complete descriptor for H& NEW_DIRECTORY ;new default directory. & PUSHL #0 ' PUSHL #0 t' PUSHAQ NEW_DIRECTORY ;Use system routine to set ' CALLS #3, G^SYS$SETDDIR ;new default directory. <( BLBS R0, 20$ ( $EXIT_S R0 ) h)20$: $SETPRN_S PRCNAM=NEW_PRC_NAME ;Attempt to change process ) CMPL R0, #SS$_DUPLNAM ;name. But ignore failure 0* BNEQ 22$ ;because of SS$_DUPLNAM. * MOVZWL #SS$_NORMAL, R0 *22$: $EXIT_S R0 \+ + $, .END FOR_START