! ----- SEARCH_SYSUAF.FUN ----- ! ! ----- FUNCTION TO SEE IF A USERNAME ALREADY EXISTS ON ANY NODE ----- ! ! ----- Search all cluster-wide nodes for matching account. ! ----- Return SEARCH_SYSUAF=TRUE if matching account on local node, ! ----- else return SEARCH_SYSUAF=FALSE. ! ----- Return OTHER_NODE=TRUE if matching account on any non-duplicate ! ----- remote node, else return OTHER_NODE=FALSE. ! ! ---------- PASSED: ---------- ! ! ----- USER_NAME is username to search for ----- ! ! ----- ACTION_INDEX = USER_ACTIONS() array index of desired menu option ! ! ----- DEBUG_MODE = TRUE if Debug mode is enabled ! ! ---------- RETURNED: ---------- ! ! ----- COPY_USER_FILE_DATA = If adding a new user: ! ----- Contains the SYSUAF record from ! ----- the remote node which has an ! ----- existing SYSUAF record for this ! ----- username ! ! ----- COPY_USER_FILE_INDEX = If adding a new user: ! ----- Contains the actual I/O channel ! ----- of the remote node which has an ! ----- existing SYSUAF record for this ! ----- username ! ! ----- INVALID_DIVISION = TRUE if a non-privileged person ! ----- running NUSER is not authorized to ! ----- modify the user that is being ! ----- displayed (based upon the process's ! ----- held identifiers) ! ! ----- NODE_COUNTER = Number of nodes that user is on ! ! ----- NODE_LIST = List of nodes that user is on ! ! ----- OTHER_NODE is TRUE if any username is found on a ! ----- non-local non-duplicate node ! ! ----- SAVE_HELD_IDENTS_CTR = If adding a new user: ! ----- Contains the count of saved held ! ----- identifiers for the username ! ----- which has an existing SYSUAF ! ----- record on a remote node ! ! ----- SAVE_HELD_IDENTS_STR() = If adding a new user: ! ----- Contains the list of saved held ! ----- identifiers for the username ! ----- which has an existing SYSUAF ! ----- record on a remote node ! ! ----- SEARCH_SYSUAF returns TRUE if any username is found on ! ----- the local node ! ! ----- VALID_ENTRY = TRUE if the user's division is valid, ! ----- based upon the privilege of the ! ----- person running NUSER or that ! ----- process's held identifiers (from the ! ----- LOOKUP_DISPLAY_USER_INFO function) ! ! ----- Last Change 03/02/94 by Brian Lomasky ----- ! FUNCTION WORD SEARCH_SYSUAF(STRING NODE_LIST, WORD VALID_ENTRY) %INCLUDE "NUSER.INC" ! ----- MAX NUMBER OF USERNAMES ----- ! ----- (MUST MATCH VALUE IN GET_FIRST_LAST.FUN) ----- DECLARE WORD CONSTANT MAX_USERNAMES = 40% DECLARE STRING DEFAULT_NODE ! NULL STRING TO ACCESS DEFAULT DECLARE WORD DUPL_NODE ! TRUE IF FOUND ON ANY DUPL NODE DECLARE STRING DUPL_NODE_LIST ! LIST OF DUPLICATE NODES DECLARE WORD FOUND_OTHER_NODE ! TRUE IF FOUND ON OTHER NODE DECLARE LONG HELD_IDENT_INDEX ! HELD IDENTIFIER ARRAY INDEX DECLARE WORD I_O_CHNL_SYSUAF ! SYSUAF I/O CHANNEL TO ACCESS DECLARE WORD NODE_INDEX ! LIST OF NODES TO COPY USER DECLARE WORD SYSUAF_CHNL ! SYSUAF.DAT I/O CHANNEL TO USE DECLARE WORD SYSUAF_RECORD_FOUND! TRUE IF SYSUAF RECORD FOUND DECLARE WORD TEMP ! TEMPORARY WORD VARIABLE DECLARE STRING TEMP_STRING ! TEMPORARY STRING DECLARE LONG TEMP_USER ! TEMPORARY USERNAME COUNTER EXTERNAL WORD FUNCTION CALC_DUPL_NODES( & STRING) ! RETURN LIST OF DUPL NODES EXTERNAL WORD FUNCTION LOOKUP_DISPLAY_USER_INFO( & WORD, WORD) ! LOOKUP AND DISPLAY USER INFO ! ----- LIST OF POSSIBLE USERNAMES ----- ! ----- (MUST MATCH DEFINITION IN GET_FIRST_LAST.FUN) ----- MAP (SEASUAF) STRING THE_USERS(MAX_USERNAMES) = 12% ! ----- LOCAL FUNCTION THAT RETURNS TRUE IF USER NAME ----- ! ----- ALREADY FOUND ----- DEF WORD ALREADY_FOUND_USER ! ----- ASSUME USER ALREADY FOUND ----- ALREADY_FOUND_USER = TRUE TEMP_USER = 0% WHILE TEMP_USER < THE_USERS_COUNTER TEMP_USER = TEMP_USER + 1% EXIT DEF IF THE_USERS(TEMP_USER) = USER_NAME NEXT ! ----- INCREMENT COUNT OF POSSIBLE USERNAMES ----- THE_USERS_COUNTER = THE_USERS_COUNTER + 1% THE_USERS(THE_USERS_COUNTER) = USER_NAME ! ----- RETURN NEW USER STATUS ----- ALREADY_FOUND_USER = FALSE END DEF ! ----- LOCAL FUNCTION TO ALLOW PRIVILEGED USERS TO ----- ! ----- REMOVE THE LINK BETWEEN TWO DUPLICATE NODES ----- ! ----- (RETURNS TRUE IF "YES" OR "B") ----- DEF WORD TREAT_AS_NON_DUPLICATE ! ----- ASSUME "NO"/CONTROL-Z RESPONSE ----- TREAT_AS_NON_DUPLICATE = FALSE EXIT DEF IF NOT PRIVILEGED WHILE TRUE TEMP = TRUE WHEN ERROR IN PRINT PRINT "This account also" + & " exists on the" + & " following node(s): " & + DUPL_NODE_LIST PRINT "which are usually" + & " processed as" + & " duplicate nodes" PRINT "(i.e. whatever happens" & + " to one node's UAF" & + " also happens to" + & " the other node's UAF)." PRINT PRINT "Do you want to" + & " perform operations" + & " only to the account" & + " on the LOCAL node?" LINPUT #98%, & "Enter Y or N : ";& TEMP_STRING USE TEMP = FALSE CONTINUE END WHEN ! ----- EXIT IF CONTROL/Z ----- EXIT DEF IF NOT TEMP ! ----- DISCARD ANY GARBAGE CHARS ----- TEMP_STRING = EDIT$(TEMP_STRING, 38%) TEMP_STRING = "N" IF TEMP_STRING = "" EXIT DEF IF TEMP_STRING = "N" IF TEMP_STRING = "Y" THEN ! ----- RETURN "Y" RESPONSE ----- TREAT_AS_NON_DUPLICATE = TRUE EXIT DEF END IF PRINT PRINT "Error - You must enter the" + & " letter Y or N" + & TRM$(PLEASE_TRY_AGAIN) PRINT NEXT END DEF ! ----- CALCULATE LIST OF DUPLICATE NODES ----- DEFAULT_NODE = "" ! NULL STRING TO ACCESS DEFAULT EXIT FUNCTION IF CALC_DUPL_NODES(DEFAULT_NODE) DUPL_NODE_LIST = "" ! INIT LIST OF DUPLICATE NODES NODE_LIST = "" ! INIT LIST OF NODES USER IS ON SEARCH_SYSUAF = FALSE ! ASSUME NOT ON LOCAL NODE OTHER_NODE = FALSE ! ASSUME NOT FOUND ON OTHER NODE FOUND_OTHER_NODE = FALSE ! ASSUME NOT FOUND ON OTHER NODE DUPL_NODE = FALSE ! ASSUME NOT ON A DUPLICATE NODE INVALID_DIVISION = FALSE ! ASSUME USER IN ALLOWED DIV I_O_CHNL_SYSUAF = 0% ! ----- FOR EACH OPEN SYSUAF FILE: ----- WHILE I_O_CHNL_SYSUAF < SYSUAF_COUNTER I_O_CHNL_SYSUAF = I_O_CHNL_SYSUAF + 1% ! ----- SKIP IF SYSUAF UNAVAILABLE ----- ITERATE IF TRM$(SYSUAF_SPECS(I_O_CHNL_SYSUAF)) = "" IF DEBUG_MODE THEN PRINT "DEBUG> Search SYSUAF #" + & NUM1$(I_O_CHNL_SYSUAF) + " for "& + TRM$(USER_NAME) END IF ! ----- CALCULATE THE REAL I/O CHANNEL ----- SYSUAF_CHNL = I_O_CHNL_SYSUAF + 49% SYSUAF_RECORD_FOUND = TRUE WHEN ERROR IN GET #SYSUAF_CHNL, KEY #0% EQ & USER_NAME, REGARDLESS USE IF ERR = BUCKET_LOCKED THEN SLEEP 1% RETRY END IF IF ERR = REC_NOT_FOUND THEN SYSUAF_RECORD_FOUND = FALSE CONTINUE END IF EXIT HANDLER END WHEN IF NOT SYSUAF_RECORD_FOUND THEN IF DEBUG_MODE THEN PRINT "DEBUG>No match for " + & TRM$(USER_NAME) END IF ITERATE END IF UNLOCK #SYSUAF_CHNL ! ----- ACCUMULATE FOR GRANT/DENY PROMPT ----- NODE_COUNTER = NODE_COUNTER + 1% NODE_LIST = NODE_LIST + TRM$(SYSUAF_NODES( & I_O_CHNL_SYSUAF)) + "," IF DEBUG_MODE THEN PRINT "DEBUG> SEARCH_SYSUAF: Found" + & " user on I_O_CHNL_SYSUAF=" + & NUM1$(I_O_CHNL_SYSUAF) + & ", Node=" + & TRM$(SYSUAF_NODES(I_O_CHNL_SYSUAF)) END IF ! ----- IF SEARCHING THE LOCAL NODE'S SYSUAF: ----- IF I_O_CHNL_SYSUAF = 1% THEN ! ----- SET FLAG FOR EXISTING USERNAME ON ----- ! ----- THE LOCAL NODE ----- SEARCH_SYSUAF = TRUE ! ----- DONE IF ADDING USER ----- EXIT FUNCTION IF & USER_ACTIONS(ACTION_INDEX) = "A" ELSE PRINT IF NOT FOUND_OTHER_NODE ! ----- SET FLAG IF EXISTING USERNAME ON ----- ! ----- A NON-LOCAL NODE ----- FOUND_OTHER_NODE = TRUE ! ----- SET LOCAL FLAG IF EXISTING ----- ! ----- USERNAME ON A NON-LOCAL ----- ! ----- NON-DUPLICATE NODE ----- ! ----- FOR EACH DUPLICATE NODE TO BE ----- ! ----- ACCESSED: ----- NODE_INDEX = 0% WHILE NODE_INDEX < NODES_IN_MEMORY NODE_INDEX = NODE_INDEX + 1% ! ----- SET FLAG IF DUPLICATE ----- ! ----- NODE FOUND ----- IF NODE_LISTS(NODE_INDEX) = & TRM$(SYSUAF_NODES( & I_O_CHNL_SYSUAF)) THEN ! ----- SET FLAG SINCE ----- ! ----- THIS NODE IS A ----- ! ----- DUPLICATE NODE ----- DUPL_NODE = TRUE IF DUPL_NODE_LIST = "" THEN DUPL_NODE_LIST =& TRM$( & SYSUAF_NODES( & I_O_CHNL_SYSUAF& )) ELSE DUPL_NODE_LIST =& DUPL_NODE_LIST & + TRM$( & SYSUAF_NODES( & I_O_CHNL_SYSUAF& )) + ", " END IF END IF NEXT IF USER_ACTIONS(ACTION_INDEX) = "A" THEN TEMP_USER = ALREADY_FOUND_USER PRINT PRINT "Note: This username" & + " already exists on" & + " node " + & TRM$(SYSUAF_NODES( & I_O_CHNL_SYSUAF)) + BEL ! ----- LOOKUP AND DISPLAY USER ----- ! ----- INFO ----- IF LOOKUP_DISPLAY_USER_INFO( & I_O_CHNL_SYSUAF, VALID_ENTRY) THEN INVALID_DIVISION = TRUE END IF ! ----- (See previous reference to ----- ! ----- see what the ! ----- LOOKUP_DISPLAY_USER_INFO ----- ! ----- function returns) ----- ! ----- STORE THE REAL SYSUAF I/O ----- ! ----- CHANNEL OF THE NODE TO ----- ! ----- COPY THIS USERNAME FROM ----- IF COPY_USER_FILE_INDEX = 0% THEN COPY_USER_FILE_INDEX = & SYSUAF_CHNL ! ----- STORE SYSUAF DATA ----- ! ----- TO BE COPIED ----- COPY_USER_FILE_DATA = UAF_REC ! ----- STORE HELD ----- ! ----- IDENTIFIER DATA TO ----- ! ----- BE COPIED BY THE ----- ! ----- COPY_THIS_USER_ACCOUNT ! ----- FUNCTION ----- HELD_IDENT_INDEX = 0% SAVE_HELD_IDENTS_CTR = & HELD_IDENTS_CTR WHILE HELD_IDENT_INDEX & < HELD_IDENTS_CTR HELD_IDENT_INDEX& = HELD_IDENT_INDEX & + 1% SAVE_HELD_IDENTS_STR( & HELD_IDENT_INDEX) & = HELD_IDENTS_STR(& HELD_IDENT_INDEX) NEXT END IF ELSE PRINT "Note: This username" & + " also has an" + & " account on node " + & TRM$(SYSUAF_NODES( & I_O_CHNL_SYSUAF)) END IF END IF NEXT ! ----- SEE IF WE FOUND THIS ACCOUNT ON ANY NON-LOCAL NODE ----- IF FOUND_OTHER_NODE THEN ! ----- SEE IF WE FOUND THIS ACCOUNT ON ANY ----- ! ----- DUPLICATE NODE(S) ----- IF DUPL_NODE THEN ! ----- SEE IF THIS SHOULD BE HANDLED AS ----- ! ----- AN ACCOUNT ON A NON-LOCAL ----- ! ----- NON-DUPLICATE NODE ----- OTHER_NODE = TREAT_AS_NON_DUPLICATE ELSE ! ----- USERNAME IS ON A NON-DUPLICATE ----- ! ----- NODE ----- OTHER_NODE = TRUE END IF END IF END FUNCTION