; Valerie Caro COINS Research Computer Facility ; UNIVERSITY OF MASSACHUSETTS/ AMHERST, MA 01003 .title uafsub - Subroutines for SYSUAF access ;+++++ ; MODULE DESCRIPTION ; ; This module contains subroutines for accessing SYSUAF the ; system authorization file. ; ;+++++ .library 'sys$library:lib' $rmsdef $rabdef $fabdef $uafdef $prvdef $syidef .psect uafsub_rms,rd,wrt,noexe,long .sbttl SYSUAF RMS Static Data uaffab:: $fab fnm=,- fac=,- shr=,- org=IDX uafrab:: $rab fab=uaffab,- ubf=uafbuf,- usz=uaf$c_length,- kbf=uafkey,- ksz=uafkey_size ; READ/WRITE BUFFER SPACE uafbuf:: .blkb uaf$c_length uafkey_size=12 uafkey:: .blkb uafkey_size uafopen:: .long 0 ;initialized flag for UAF ; IDENTIFIER SPACE holder: ;username of person running GQM .long 0 holder_name: .address 0 id_holder: .blkl 1 ; id format of username .long 0 grpid_name: ; identifier name .ascid /GRPMGR/ grpmgr_id: .blkl 1 ; id format of GRPMGR sysid_name: ; identifier name .ascid /SYSMGR/ sysmgr_id: .blkl 1 ; id format of SYSMGR context: .long 0 ; context for $find_held held: .blkl 1 ; id returned by $find_held node_number: ; which node are we on? .long 0 maxgrp: ; sysgen param to indicate .long 0 ; system uic syi_item_list: .word 4 ; length .word syi$_node_number ; item code .long node_number,0 ; buffer .word 4 ; length .word syi$_maxsysgroup ; sysgen param : max group uic ; - for system uic. .long maxgrp,0 ; buffer .long 0 ; terminator .sbttl uaf_open ;+++++ ; FUNCTION ; ; This routine opens SYS$SYSTEM:SYSUAF.DAT using RMS. ; ;+++ ; INPUT PARAMETERS ; ; none. ; ;+++ ; OUTPUT PARAMETERS ; ; none. ; ;+++++ .psect uafsub_cod,rd,nowrt,exe .entry uaf_open,^M<> $open fab=uaffab ;open it blbs r0,10$ ;skip if ok ret ;return with error 10$: $connect rab=uafrab ;connect it blbs r0,20$ ;skip if ok ret ;return with error 20$: movl #1,uafopen ;set initialized flag movl #1,r0 ;set ok return ret .sbttl uaf_close - close the uafdata file ;+++++ ; FUNCTION ; ; Close the uaf file and set the flag to indicate closed. ; ;+++ ; IMPLICIT INPUTS ; ; RMS DATABASE ; uafOPEN flag ; ;+++ ; OUTPUT PARAMETERS ; ; none. ;+++++ .entry uaf_close,^M<> $close fab=uaffab blbs r0,10$ ret ;back if error 10$: clrl uafopen ;clear open flag movl #1,r0 ;set ok ret .sbttl uaf_get_by_user ;+++++ ; FUNCTION ; ; This routine fetches a record from the USER AUTHORIZATION FILE ; using the USERNAME field as a key. ; ;+++ ; INPUT PARAMETERS ; ; uaf_get_key address of descriptor for USERNAME ; ;+++ ; OUTPUT PARAMETERS ; ; The buffer at: UAFBUF is filled with the record. ; ;+++ ; STATUS ; ; RMS status is returned in R0. ; ;+++++ uaf_get_key =4 .entry uaf_get_by_user,^M blbs uafopen,10$ ;skip if file open calls #0,uaf_open ;otherwise open the uaf blbs r0,10$ ret 10$: $rab_store rab=uafrab,- krf=#0,- ksz=#uafkey_size,- rac=KEY ;set access mode movq @uaf_get_key(ap),r0 ;fetch key descriptor movc5 r0,(r1),#32,#uafkey_size,uafkey ;move with zero fill $get rab=uafrab ;fetch the record ret ;return with status .sbttl uaf_get_by_uic ;+++++ ; FUNCTION ; ; This routine fetches a record from the USER AUTHORIZATION FILE ; by UIC number. ; ;+++ ; INPUT PARAMETERS ; ; uaf_get_uic addr of UIC ; ;+++ ; OUTPUT PARAMETERS ; ; The record is returned to UAFBUF. ; ;+++++ uaf_get_uic =4 .entry uaf_get_by_uic,^M blbs uafopen,10$ ;skip if file open calls #0,uaf_open ;open if not blbs r0,10$ ret ;return with status if err 10$: $rab_store rab=uafrab,- krf=#1,- ksz=#4,- rac=KEY ;set access mode ; Setup Key and get record movc5 #4,@uaf_get_uic(ap),#0,#uafkey_size,uafkey $get rab=uafrab ;get the record ret .sbttl uaf_get_first_uic ;+++++ ; FUNCTION ; ; This routine gets the first record EQUAL TO or GREATER THAN the ; UIC that is passed. ; ;+++ ; INPUT PARAMETERS ; ; uic user's UIC code ; ;+++ ; OUTPUT PARAMETERS ; ; user user's username ; uic user's UIC (modify) ; acct user's account ; ;+++++ get_1st_user =4 get_1st_uic =8 get_1st_acct =12 .entry uaf_get_first_uic,^M blbs uafopen,10$ ;open file if not open calls #0,uaf_open blbs r0,10$ ret ; Setup options and key 10$: $rab_store rab=uafrab,- krf=#1,- ksz=#4,- rop=KGE,- ;GE is ok rac=KEY ;use INDEXED movc5 #4,@get_1st_uic(ap),#0,#uafkey_size,uafkey ; Get the record into our buffer $get rab=uafrab blbs r0,20$ ret ; Call copy routine to return info 20$: pushl get_1st_acct(ap) pushl get_1st_uic(ap) pushl get_1st_user(ap) calls #4,copy_uaf_info ret .sbttl uaf_get_next_uic ;+++++ ; FUNCTION ; ; This routine sequentially accesses the SYSUAF on the UIC key. ; ;+++ ; INPUT PARAMETERS ; ; none. ; ;+++ ; OUTPUT PARAMETERS ; ; username user's name ; uic user's uic ; account user's account ; ;+++++ next_uic_user =4 next_uic_uic =8 next_uic_acct =12 .entry uaf_get_next_uic,^M<> blbs uafopen,10$ calls #0,uaf_open blbs r0,10$ ret 10$: $rab_store rab=uafrab,- krf=#1,- ksz=#4,- rac=SEQ ;set sequential on UIC $get rab=uafrab ;get the record blbs r0,20$ ret ; Call copy routine to return data 20$: pushl next_uic_acct(ap) pushl next_uic_uic(ap) pushl next_uic_user(ap) calls #4,copy_uaf_info ret .sbttl uaf_get_next_user ;+++++ ; FUNCTION ; ; This routine gets the next record from SYSUAF by USERNAME. ; ;+++ ; INPUT PARAMETERS ; ; none. ; ;+++ ; OUTPUT PARAMETERS ; ; username user's name ; uic user's uic ; account user's account ; ;+++++ next_user_user =4 next_user_uic =8 next_user_acct =12 .entry uaf_get_next_user,^M<> blbs uafopen,10$ calls #0,uaf_open blbs r0,10$ ret 10$: $rab_store rab=uafrab,- krf=#0,- ksz=#uafkey_size,- rac=SEQ $get rab=uafrab blbs r0,20$ ret ; Copy data to passed parameters 20$: pushl next_user_acct(ap) pushl next_user_uic(ap) pushl next_user_user(ap) calls #4,copy_uaf_info ret .sbttl get_user_info ;+++++ ; FUNCTION ; ; This routine searches the UAF file for a given username and returns ; 1) username ; 2) uic ; 4) account name ; ;+++ ; INPUT PARAMETERS ; ; user username (1-12) character string ; ;+++ ; OUTPUT PARAMETERS ; ; user username of user ; uic uic of user ; acct account of user ; ;+++++ get_user_user =4 get_user_uic =8 get_user_acct =12 .entry get_user_info,^M<> pushl get_user_user(ap) calls #1,uaf_get_by_user ;get the record blbs r0,10$ ;skip if ok ret ;return an error 10$: pushl get_user_acct(ap) pushl get_user_uic(ap) pushl get_user_user(ap) calls #4,copy_uaf_info ret .sbttl get_uic_info ;+++++ ; FUNCTION ; ; This routine accesses the SYSUAF file for a particular UIC and returns ; 1) username ; 2) UIC ; 4) account name ; ;+++ ; INPUT PARAMETERS ; ; get_uic_uic UIC to use as key ; ;+++ ; OUTPUT PARAMETERS ; ; user username of user ; uic uic of user ; acct account of user ; ; ;+++++ get_uic_user =4 get_uic_uic =8 get_uic_acct =12 .entry get_uic_info,^M<> pushl get_uic_uic(ap) calls #1,uaf_get_by_uic ;get record blbs r0,10$ ;skip if ok ret ;return an error 10$: pushl get_uic_acct(ap) pushl get_uic_uic(ap) pushl get_uic_user(ap) calls #4,copy_uaf_info ret .sbttl copy_uaf_info ;+++++ ; FUNCTION ; ; This routine returns : ; 1) username ; 2) uic ; 4) account ; ; from the current SYSUAF record. ; ;+++ ; INPUT PARAMETERS ; ; none. ; ;+++ ; OUTPUT PARAMETERS ; ; user username of user ; uic uic of user ; acct account of user ; ;+++++ copy_user =4 copy_uic =8 copy_acct =12 .entry copy_uaf_info,^M moval uafbuf,r11 ;setup addr of record buffer ; return UIC movl uaf$l_uic(r11),@copy_uic(ap) ; return username movq @copy_user(ap),r7 ;get desc for username movc5 #12,uaf$t_username(r11),#32,r7,(r8) ; return account movq @copy_acct(ap),r7 ;get desc for account movc5 #8,uaf$t_account(r11),#32,r7,(r8) movl #1,r0 ;set ok ret .sbttl uaf_get_auth ;+++++ ; FUNCTION ; ; This routine derives the normal UAF information together with ; authorization information used by DQUOTA. The authorization information ; is : ; 1) whether the user is a GROUP MANAGER ; 2) whether the user is the SYSTEM MANAGER ; ; The first of these is determined by checking the IDENTIFIER GRPMGR ; in the Rights database. The second is activated if the default UIC is ; a system UIC. ; ;+++ ; INPUT PARAMETERS ; ; user username of user to check ; ;+++ ; OUTPUT PARAMETERS ; ; uic uic of user's account ; acct account name of user ; grpprv whether user is GROUP MANAGER ; sysprv whether user is SYSTEM MANAGER ; ;+++++ get_auth_user =4 get_auth_uic =8 get_auth_acct =12 get_auth_grpprv =16 get_auth_sysprv =20 .entry uaf_get_auth,^M .enable lsb ; Use get_user_info for all but privilege information pushl get_auth_acct(ap) pushl get_auth_uic(ap) pushl get_auth_user(ap) calls #4,get_user_info blbs r0,10$ ret 10$: clrl @get_auth_sysprv(ap) ; Now search for GRPMGR and SYSMGR identifier 20$: clrl @get_auth_grpprv(ap) movq @get_auth_user(ap),holder ;get username descriptor $ASCTOID_S name=holder, id=id_holder ;translate to id format blbc r0, 22$ ;error? $ASCTOID_S name=GRPID_NAME, id=grpmgr_id ; translate group mgr id blbc r0, 22$ ;error? $ASCTOID_S name=SYSID_NAME, id=sysmgr_id ;translate system mgr id blbc r0, 22$ ;error? brw 23$ 22$: brw 30$ ;;;; initialize exit flag 23$: movl #SS$_NOPRIV,r8 ;exit with error ;;;; SEARCH LIST OF IDENTIFIERS HELD FOR GRPMGR 25$: $FIND_HELD_S holder=id_holder, id=held, contxt=context blbc r0, abort ;no more id's in list? cmpl sysmgr_id, held ;is this system mgr id? beql 28$ ;no. get next id. cmpl grpmgr_id, held ;is this group mgr id? bneq 25$ ;no. get next id. movl #1,@get_auth_grpprv(ap) ;set GROUP MANAGER movl #1,r8 ;clear exit flag brb 25$ 28$: movl #1,@get_auth_sysprv(ap) ;set SYSTEM MANAGER movl #1,r8 ;clear exit flag abort: movl r8,r0 30$: ret .disable lsb .end