PROC 0                                                                -
  CONSLIST(OFF)              /* DEFAULT IS OFF                     */ -
  COMLIST(OFF)               /* DEFAULT IS OFF                     */ -
  SYMLIST(OFF)               /* DEFAULT IS OFF                     */ -
  TERMMSGS(ON)               /* DEFAULT IS OFF                     */ -
  TYPERUN(FSO)               /* Run for SRRAUDIT | FSO             */ -
  CACC1000(CACC1000)         /* SELECT SECURITY CHECK PGM          */ -
  CACM0422(CACM0422)         /* SELECT EDIT macro AUACCESS(*)      */ -
  CACM042R(CACM042R)         /* RESOURCE TABLE MACRO               */ -
  CACT0008(CACT0008)         /* RESOURCE TABLE                     */ -
  CATM0120(CATM0120)         /* SELECT EDIT macro TEMP6(mbr)       */ -
  CATM0405(CATM0405)         /* DEFAULT MACRO TSSLISTP             */ -
  AUACCESSDD(AUACCESS)       /* Default DDNAME - Work file         */ -
  CNTLDD(CNTL)               /* Default DDNAME - Security table    */ -
  DIALOGDD(DIALOG)           /* Default DDNAME - Authorized users  */ -
  PDIDD(PDIDD)               /* Default DDNAME - PDI data set      */ -
  SENSITVEDD(SENSITVE)       /* Default DDNAME - Sensitive rpts    */ -
  TEMP6DD(TEMP6)             /* Default DDNAME - TEMP records      */ -
  TSSLISTPDD(TSSLISTP)       /* Default DDNAME - TSSLISTP records  */ -
  TRACE(OFF)                 /* TRACE ACTIONS AND ERRORS           */
 
/********************************************************************/
/* THIS CLIST (CATC0120) GENERATES PDI FINDINGS FOR SELECTED        */
/* RESOURCES FROM INFORMATION COLLECTED IN PREVIOUS STEPS.          */
/********************************************************************/
/* 03/31/2008 CL Fenton Script created to generate PDIs for Resources.
/* 09/03/2008 CL Fenton Corrected error with PDI name < 8 char.
/* 03/18/2010 CL Fenton Added analysis for TSS0780.
/* 06/05/2012 CL Fenton Chgs to allow use of AUACCESS for authorized
/*            users list to prevent the possible "IKJ56548I INSUFFICIENT
/*            STORAGE FOR CLIST TO CONTINUE" message from occurring when
/*            a DIALOG user group contains an excessive number of user,
/*            CSD-AR003400969.
/* 08/10/2020 CL Fenton Corrected problem with a variable, AUACCCNT,
/*            not being initialized to zero for other processes,
/*            STS-023991 and STS-024840.
 
SET PGMNAME = &STR(CATC0120 08/10/20)
 
SET SYSPROMPT = OFF                 /* CONTROL NOPROMPT          */
SET SYSFLUSH  = OFF                 /* CONTROL NOFLUSH           */
SET SYSASIS   = ON                  /* CONTROL ASIS - caps off   */
 
/* ERROR ROUTINE */
ERROR DO
  SET RETURN_CODE = &LASTCC          /* SAVE LAST ERROR CODE */
  IF &LASTCC GT 16 THEN +
    WRITE &PGMNAME LASTCC = &LASTCC &ZERRLM
  RETURN
  END
 
SET RETURN_CODE = 0
 
IF &NRSTR(&TRACE) EQ ON THEN DO     /* TURN messages on          */
  SET TERMMSGS = ON                 /* CONTROL MSG               */
  SET COMLIST  = ON                 /* CONTROL LIST              */
  SET CONSLIST = ON                 /* CONTROL CONLIST           */
  SET SYMLIST  = ON                 /* CONTROL SYMLIST           */
  END
 
SET SYSSYMLIST = &SYMLIST           /* CONTROL SYMLIST/NOSYMLIST */
SET SYSCONLIST = &CONSLIST          /* CONTROL CONLIST/NOCONLIST */
SET SYSLIST    = &COMLIST           /* CONTROL LIST/NOLIST       */
SET SYSMSG     = &TERMMSGS          /* CONTROL MSG/NOMSG         */
 
SET ZISPFRC = 0
ISPEXEC VPUT (ZISPFRC) SHARED
 
SET RETURN_CODE = 0
 
ISPEXEC VPUT ( +
  CONSLIST     +
  COMLIST      +
  SYMLIST      +
  TERMMSGS     +
  CACT0008     +
  CACM042R     +
  CACM0422     +
  CATM0405     +
  TYPERUN      +
  ) ASIS
 
SET TC20VPUT = &RETURN_CODE
IF &RETURN_CODE NE 0 THEN DO
  WRITE &PGMNAME VPUT RC = &RETURN_CODE  &ZERRSM
  SET RETURN_CODE = &RETURN_CODE + 16
  GOTO ERR_EXIT
  END
 
/* Determine which security system is running */
 
SET RETURN_CODE = 0
 
ISPEXEC SELECT CMD(&CACC1000 ACP)
 
ISPEXEC VGET ( +
  ACPNAME      +
  ACPVERS      +
  ) ASIS
 
IF &SUBSTR(1:3,&NRSTR(&ACPNAME   )) NE TSS THEN DO
  WRITE &PGMNAME Top Secret Job running on the wrong system.
  WRITE &PGMNAME &ACPNAME &ACPVERS
  SET RETURN_CODE = 20
  GOTO ERR_EXIT
  END
 
/* *************************************** */
/* INITIALIZE LIBRARY MANAGEMENT           */
/* *************************************** */
 
SET LP = &STR((
SET RP = )
 
SET RETURN_CODE = 0
ISPEXEC LMINIT DATAID(AUACCESS) DDNAME(&AUACCESSDD) ENQ(EXCLU)
SET LMINIT_AUACCESS_RC = &RETURN_CODE
IF &RETURN_CODE NE 0 THEN DO
  WRITE &PGMNAME LMINIT_AUACCESS_RC = &RETURN_CODE  &ZERRSM
  SET RETURN_CODE = &RETURN_CODE + 16
  GOTO ERR_EXIT
  END
 
ISPEXEC LMINIT DATAID(CNTL) DDNAME(&CNTLDD)
SET LMINIT_CNTL_RC = &RETURN_CODE
IF &RETURN_CODE NE 0 THEN DO
  WRITE &PGMNAME LMINIT_CNTL_RC &RETURN_CODE  &ZERRSM
  SET RETURN_CODE = &RETURN_CODE + 16
  GOTO ERR_EXIT
  END
 
ISPEXEC LMINIT DATAID(DIALOG) DDNAME(&DIALOGDD)
SET LMINIT_DIALOG_RC = &RETURN_CODE
IF &RETURN_CODE NE 0 THEN DO
  WRITE &PGMNAME LMINIT_DIALOG_RC = &RETURN_CODE  &ZERRSM
  SET RETURN_CODE = &RETURN_CODE + 16
  GOTO ERR_EXIT
  END
 
ISPEXEC LMINIT DATAID(PDIDD) DDNAME(&PDIDD)
SET LMINIT_PDIDD_RC = &RETURN_CODE
IF &RETURN_CODE NE 0 THEN DO
  WRITE &PGMNAME LMINIT_PDIDD_RC &RETURN_CODE  &ZERRSM
  SET RETURN_CODE = &RETURN_CODE + 16
  GOTO ERR_EXIT
  END
 
ISPEXEC LMINIT DATAID(SENSITVE) DDNAME(&SENSITVEDD)
SET LMINIT_SENSITVE_RC = &RETURN_CODE
IF &RETURN_CODE NE 0 THEN DO
  WRITE &PGMNAME LMINIT_SENSITVE_RC &RETURN_CODE &ZERRSM
  SET RETURN_CODE = &RETURN_CODE + 16
  GOTO ERR_EXIT
  END
 
ISPEXEC LMINIT DATAID(TEMP6) DDNAME(&TEMP6DD)
SET LMINIT_TEMP6_RC = &RETURN_CODE
IF &RETURN_CODE NE 0 THEN DO
  WRITE &PGMNAME LMINIT_TEMP6_RC &RETURN_CODE     &ZERRSM
  SET RETURN_CODE = &RETURN_CODE + 16
  GOTO ERR_EXIT
  END
 
ISPEXEC LMINIT DATAID(TSSLISTP) DDNAME(&TSSLISTPDD)
SET LMINIT_TSSLISTP_RC = &RETURN_CODE
IF &RETURN_CODE NE 0 THEN DO
  WRITE &PGMNAME LMINIT_TSSLISTP_RC &RETURN_CODE  &ZERRSM
  SET RETURN_CODE = &RETURN_CODE + 16
  GOTO ERR_EXIT
  END
 
LISTDSI &SENSITVEDD FILE
 
SET LISTDSI_FILE_RCODE   = &RETURN_CODE
SET LISTDSI_FILE_REASON = &SYSREASON
IF &SYSREASON EQ 0 THEN DO
  SET ODSNAME  = &SYSDSNAME
  SET LISTDSI_FILE_MSGLVL2 = &NRSTR(&SYSMSGLVL2)
  END
ELSE DO
  WRITE &PGMNAME LISTDSI failed for SENSITVE &SYSREASON
  WRITE &PGMNAME &NRSTR(&SYSMSGLVL1)
  WRITE &PGMNAME &NRSTR(&SYSMSGLVL2)
  END
 
SET RETURN_CODE = 0
 
LISTDSI &TEMP6DD FILE
 
SET LISTDSI_FILE_RCODE   = &RETURN_CODE
SET LISTDSI_FILE_REASON = &SYSREASON
IF &SYSREASON EQ 0 THEN DO
  SET TDSNAME  = &SYSDSNAME
  SET LISTDSI_FILE_MSGLVL2 = &NRSTR(&SYSMSGLVL2)
  END
ELSE DO
  WRITE &PGMNAME LISTDSI failed for TEMP6 &SYSREASON
  WRITE &PGMNAME &NRSTR(&SYSMSGLVL1)
  WRITE &PGMNAME &NRSTR(&SYSMSGLVL2)
  END
 
/* *************************************** */
/* OPEN DATASETS                           */
/* *************************************** */
 
SET RETURN_CODE = 0
 
ISPEXEC LMOPEN DATAID(&AUACCESS) OPTION(INPUT)
SET LMOPEN_AUACCESS_RC = &RETURN_CODE
IF &RETURN_CODE NE 0 THEN DO
  WRITE &PGMNAME LMOPEN_AUACCESS_RC &RETURN_CODE  &ZERRSM
  GOTO ERR_EXIT
  END
 
ISPEXEC LMOPEN DATAID(&CNTL) OPTION(INPUT)
SET LMOPEN_CNTL_RC = &RETURN_CODE
IF &RETURN_CODE NE 0 THEN DO
  WRITE &PGMNAME LMOPEN_CNTL_RC &RETURN_CODE  &ZERRSM
  GOTO ERR_EXIT
  END
 
ISPEXEC LMOPEN DATAID(&DIALOG) OPTION(INPUT)
SET LMOPEN_DIALOG_RC = &RETURN_CODE
IF &RETURN_CODE NE 0 THEN DO
  WRITE &PGMNAME LMOPEN_DIALOG_RC &RETURN_CODE  &ZERRSM
  GOTO ERR_EXIT
  END
 
ISPEXEC LMOPEN DATAID(&PDIDD) OPTION(OUTPUT)
SET LMOPEN_PDIDD_RC = &RETURN_CODE
IF &RETURN_CODE NE 0 THEN DO
  WRITE &PGMNAME LMOPEN_PDIDD_RC &RETURN_CODE  &ZERRSM
  SET RETURN_CODE = &RETURN_CODE + 16
  GOTO ERR_EXIT
  END
 
ISPEXEC LMOPEN DATAID(&SENSITVE) OPTION(OUTPUT)
SET LMOPEN_SENSITVE_RC = &RETURN_CODE
IF &RETURN_CODE NE 0 THEN DO
  WRITE &PGMNAME LMOPEN_SENSITVE_RC &RETURN_CODE &ZERRSM
  SET RETURN_CODE = &RETURN_CODE + 16
  GOTO ERR_EXIT
  END
 
 
/* *************************************** */
/* GET TABLE VALUES                        */
/* *************************************** */
 
SET RETURN_CODE = 0
 
SET RECTYPE = 1
SET PDINAME =
SET RESNAME =
SET AUACCCNT = 0
 
ISPEXEC VPUT ( +
  CNTL         +
  DIALOG       +
  AUACCESS     +
  AUACCCNT     +
  PDIDD        +
  SENSITVE     +
  TSSLISTP     +
  ODSNAME      +
  RECTYPE      +
  PDINAME      +
  RESNAME      +
  ) ASIS
 
SET VPUT_RC = &RETURN_CODE
 
SET RETURN_CODE = 0
 
ISPEXEC VIEW DATAID(&CNTL) MEMBER(&CACT0008) MACRO(&CACM042R)
 
SET VIEW_CACT0008_RC = &RETURN_CODE
IF &VIEW_CACT0008_RC GT 4 THEN DO
  WRITE &PGMNAME VIEW CNTL &CACT0008  RC = &VIEW_CACT0008_RC
  SET RETURN_CODE = &RETURN_CODE + 16
  GOTO BYPASS_CACT0008
  END
 
ISPEXEC VGET ( +
  REC1TBL      +
  RESOURCE     +
  ) ASIS
 
 
/* *************************************** */
/* EDIT TSS  REPORTS                       */
/* *************************************** */
 
DO X = 1 TO &LENGTH(&NRSTR(&REC1TBL)) BY 18
  SET PDINAME = &SUBSTR(&X:&X+7,&NRSTR(&REC1TBL))    /* PDI ID
  SET PDINAME = &PDINAME
  SET RESVAL  = &SUBSTR(&X+9:&X+16,&NRSTR(&REC1TBL)) /* RESOURCE NAME
 
  SET RETURN_CODE = 0
 
  SET LOCATE = &SYSDSN('&TDSNAME(&PDINAME)')
 
  IF &NRSTR(&LOCATE) EQ OK THEN GOTO CHECK_SENSMBR
 
  WRITE &PGMNAME SYSDSN ITER RC = 8 &TDSNAME(&PDINAME) +
    &LOCATE
 
  GOTO DO_CNT_END
 
 
CHECK_SENSMBR: +
  SET RETURN_CODE = 0
  IF &NRSTR(&PDINAME) EQ &STR( ) THEN GOTO DO_CNT_END
 
  /* *************************************** */
  /* PUT VARS IN POOL                        */
  /* *************************************** */
 
  SET RECTYPE = 2
  SET RESNAME =
 
  ISPEXEC VPUT ( +
    RECTYPE      +
    PDINAME      +
    RESNAME      +
    RESVAL       +
    ) ASIS
 
  SET RETURN_CODE = 0
 
  ISPEXEC VIEW DATAID(&CNTL) MEMBER(&CACT0008) MACRO(&CACM042R)
  SET RETURN_CODE = 0
 
  ISPEXEC EDIT DATAID(&TEMP6) MACRO(&CATM0120) MEMBER(&PDINAME)
 
  IF &RETURN_CODE GT 4 THEN +
    WRITE &PGMNAME EDIT TEMP6 RC = &RETURN_CODE     &PDINAME  &ZERRSM
 
DO_CNT_END: END
 
SET REC2TBL = &STR(         DORMANT           IMPL           WARN )
SET PDINAME = &STR(TSS0780)
SET RESVAL  = &STR(MODE    )
ISPEXEC VPUT ( +
  REC2TBL      +
  PDINAME      +
  RESNAME      +
  RESVAL       +
  ) ASIS
 
SET RETURN_CODE = 0
 
ISPEXEC EDIT DATAID(&TEMP6) MACRO(&CATM0120) MEMBER(&PDINAME)
 
IF &RETURN_CODE GT 4 THEN +
  WRITE &PGMNAME EDIT TEMP6 RC = &RETURN_CODE     &PDINAME  &ZERRSM
 
 
/* *************************************** */
/* CLOSE OUTPUT                            */
/* *************************************** */
 
CLOSEUP: +
SET RETURN_CODE = 0
 
ISPEXEC LMCLOSE DATAID(&AUACCESS)
SET LMCLOSE_AUACCESS_RC = &RETURN_CODE
SET RETURN_CODE = 0
 
ISPEXEC LMCLOSE DATAID(&CNTL)
SET LMCLOSE_CNTL_RC = &RETURN_CODE
SET RETURN_CODE = 0
 
ISPEXEC LMCLOSE DATAID(&DIALOG)
SET LMCLOSE_DIALOG_RC = &RETURN_CODE
SET RETURN_CODE = 0
 
ISPEXEC LMCLOSE DATAID(&PDIDD)
SET LMCLOSE_PDIDD_RC = &RETURN_CODE
SET RETURN_CODE = 0
 
ISPEXEC LMCLOSE DATAID(&SENSITVE)
SET LMCLOSE_SENSITVE_RC = &RETURN_CODE
SET RETURN_CODE = 0
 
ISPEXEC LMCOMP DATAID(&PDIDD)
SET LMCOMP_PDIDD_RC = &RETURN_CODE
SET RETURN_CODE = 0
 
ISPEXEC LMCOMP DATAID(&TEMP6)
SET LMCOMP_TEMP6_RC = &RETURN_CODE
SET RETURN_CODE = 0
 
/* *************************************** */
/* FREE FILES                              */
/* *************************************** */
 
SET RETURN_CODE = 0
 
ISPEXEC LMFREE DATAID(&TEMP6)
 
SET LMFREE_TEMP6_RC = &RETURN_CODE
SET RETURN_CODE = 0
 
ISPEXEC LMFREE DATAID(&SENSITVE)
 
SET LMFREE_SENSITVE_RC = &RETURN_CODE
SET RETURN_CODE = 0
 
ISPEXEC LMFREE DATAID(&PDIDD)
 
SET LMFREE_PDIDD_RC = &RETURN_CODE
SET RETURN_CODE = 0
 
ISPEXEC LMFREE DATAID(&CNTL)
 
SET LMFREE_CNTL_RC = &RETURN_CODE
SET RETURN_CODE = 0
 
/* *************************************** */
/* ERROR EXIT                              */
/* *************************************** */
 
ERR_EXIT: +
IF &MAXCC GE 16 OR +
   &RETURN_CODE GT 0 THEN DO
  ISPEXEC VGET (ZISPFRC) SHARED
  IF &MAXCC GT &ZISPFRC THEN +
    SET ZISPFRC = &MAXCC
  ELSE +
    SET ZISPFRC = &RETURN_CODE
  ISPEXEC VPUT (ZISPFRC) SHARED
  WRITE &PGMNAME ZISPFRC = &ZISPFRC
  END
 
ISPEXEC VGET ( +
  TM20VGET     +
  TM420RC      +
  TM21VGET     +
  TM421RC      +
  CM2VVGET     +
  CM2VVPUT     +
  CM42VRC      +
  ) ASIS
 
IF &NRSTR(&TERMMSGS) EQ ON THEN DO
WRITE ===============================================================
WRITE &PGMNAME LMINIT_AUACCESS_RC       &LMINIT_AUACCESS_RC
WRITE &PGMNAME LMINIT_CNTL_RC           &LMINIT_CNTL_RC
WRITE &PGMNAME LMINIT_DIALOG_RC         &LMINIT_DIALOG_RC
WRITE &PGMNAME LMINIT_PDIDD_RC          &LMINIT_PDIDD_RC
WRITE &PGMNAME LMINIT_SENSITVE_RC       &LMINIT_SENSITVE_RC
WRITE &PGMNAME LMINIT_TEMP6_RC          &LMINIT_TEMP6_RC
WRITE &PGMNAME LMINIT_TSSLISTP_RC       &LMINIT_TSSLISTP_RC
WRITE ===============================================================
WRITE &PGMNAME LMOPEN_AUACCESS_RC       &LMOPEN_AUACCESS_RC
WRITE &PGMNAME LMOPEN_CNTL_RC           &LMOPEN_CNTL_RC
WRITE &PGMNAME LMOPEN_DIALOG_RC         &LMOPEN_DIALOG_RC
WRITE &PGMNAME LMOPEN_PDIDD_RC          &LMOPEN_PDIDD_RC
WRITE &PGMNAME LMOPEN_SENSITVE_RC       &LMOPEN_SENSITVE_RC
WRITE ===============================================================
WRITE &PGMNAME VIEW_CACT0008_RC         &VIEW_CACT0008_RC
WRITE &PGMNAME &CATM0120 VGET            &TM20VGET
WRITE &PGMNAME &CATM0120 TM420RC         &TM420RC
WRITE ===============================================================
WRITE &PGMNAME LMCLOSE_AUACCESS_RC      &LMCLOSE_AUACCESS_RC
WRITE &PGMNAME LMCLOSE_CNTL_RC          &LMCLOSE_CNTL_RC
WRITE &PGMNAME LMCLOSE_DIALOG_RC        &LMCLOSE_DIALOG_RC
WRITE &PGMNAME LMCLOSE_PDIDD_RC         &LMCLOSE_PDIDD_RC
WRITE &PGMNAME LMCLOSE_SENSITVE_RC      &LMCLOSE_SENSITVE_RC
WRITE ===============================================================
WRITE &PGMNAME LMCOMP_PDIDD_RC          &LMCOMP_PDIDD_RC
WRITE &PGMNAME LMCOMP_TEMP6_RC          &LMCOMP_TEMP6_RC
WRITE ===============================================================
WRITE &PGMNAME LMFREE_AUACCESS_RC       &LMFREE_AUACCESS_RC
WRITE &PGMNAME LMFREE_CNTL_RC           &LMFREE_CNTL_RC
WRITE &PGMNAME LMFREE_DIALOG_RC         &LMFREE_DIALOG_RC
WRITE &PGMNAME LMFREE_PDIDD_RC          &LMFREE_PDIDD_RC
WRITE &PGMNAME LMFREE_SENSITVE_RC       &LMFREE_SENSITVE_RC
WRITE &PGMNAME LMFREE_TEMP6_RC          &LMFREE_TEMP6_RC
WRITE &PGMNAME LMFREE_TSSLISTP_RC       &LMFREE_TSSLISTP_RC
WRITE ===============================================================
END
 
EXIT CODE(0)
