We are running an AS/400 in S/36E at security level 20. Securing our system had become a necessity and going to level 30 seemed like a big step for our small shop. When we discovered that procedures could not be secured because they are not objects, we decided to create our own security.
The first step was to change each user profile to LMTCPB(*YES). None of our user menus give them access to system menus so they are limited to what we give them.
We then created a physical file named USERAUTH to hold the procedure name and the user authorized to use it. The key to the file is procedure and user name. See the DDS in 1a. Each user that needs access to the procedure will have to be entered. We created a DFU program to modify the file and a CL program to start the DFU.
We then created a physical file named USERAUTH to hold the procedure name and the user authorized to use it. The key to the file is procedure and user name. See the DDS in Figure 1a. Each user that needs access to the procedure will have to be entered. We created a DFU program to modify the file and a CL program to start the DFU.
In each procedure called by a user menu, we execute a procedure named CHECKUSR at line 1, which is listed in 1b. CHECKUSR puts the procedure and user name in the LDA , then calls an RPG program named CHECKUSR, shown in 1c. The RPG program uses the procedure and user name as the key to the file USERAUTH. If that record does not exist, the user is not authorized to use the procedure and the LDA values are blanked out. The RPG program ends and the procedure CHECKUSR checks the LDA for blanks. When blanks are found, a message is sent to QSYSOPR, the job log is printed, the user is informed and the procedure is canceled.
In each procedure called by a user menu, we execute a procedure named CHECKUSR at line 1, which is listed in Figure 1b. CHECKUSR puts the procedure and user name in the LDA , then calls an RPG program named CHECKUSR, shown in Figure 1c. The RPG program uses the procedure and user name as the key to the file USERAUTH. If that record does not exist, the user is not authorized to use the procedure and the LDA values are blanked out. The RPG program ends and the procedure CHECKUSR checks the LDA for blanks. When blanks are found, a message is sent to QSYSOPR, the job log is printed, the user is informed and the procedure is canceled.
This procedure assumes that if a user is authorized to the menu option, the user is also authorized to any files that are used by that option.
- Brad Hooley
Editor's Note: This technique can be used on a S/36 very easily by simply building the USERAUTH file as indexed with a key length of 20 and starting on position 1. The procedure needs a LOAD/RUN OCL pair instead of the CALL statement; the SNDMSG command must be changed to MSG (leaving the first parameter blank), and the OCL statement that executes the DSPJOBLOG command can be removed altogether. Finally, the RPG program should have an F-spec with "F" on column 19, record length 20, key length 20, key location 1, followed by the I-specs necessary to describe the record (two fields only), and the KLIST/KFLD can be changed to MOVEL/MOVE to move the components of the key into field KEY.
TechTalk: Securing Procedures in S/36E
Figure 1A Physical file USERAUTH
A UNIQUE A R USER01 TEXT('USERS/PROCEDURES') A PROC 8A TEXT('PROCEDURE NAME') A USER 10A TEXT('USER NAME') A K PROC A K USER
TechTalk: Securing Procedures in S/36E
Figure 1B Procedure CHECKUSR
Figure 1b: Procedure CHECKUSR * PROCEDURE: CHECKUSR // LOCAL OFFSET-1,BLANK-18,DATA-'?PROC?' // LOCAL OFFSET-9,DATA-'?USER?' * // CALL CHECKUSR * // IFF '?L'1,18'?'= GOTO OK // SNDMSG MSG('?USER? TRIED TO ACCESS PROCEDURE ?PROC?. + UNAUTHORIZED!!!') TOUSR(QSYSOPR) // DSPJOBLOG OUTPUT(*PRINT) // PAUSE 'YOU ARE NOT AUTHORIZED TO USE THIS PROCEDURE!!!' // CANCEL // TAG OK
TechTalk: Securing Procedures in S/36E
Figure 1C RPG program CHECKUSR
FUSERAUTHIF E K DISK I UDS I 1 8 PROC I 11 18 USER C KEY KLIST C KFLD PROC C KFLD USER C KEY CHAINUSERAUTH 99 C 99 MOVE *BLANKS PROC C 99 MOVE *BLANKS USER C SETON LR
LATEST COMMENTS
MC Press Online