PROC 0 -
  NOUSR(OFF)                 /* PRODUCE USER LIST */ -
  CONSLIST(OFF)              /* DEFAULT IS OFF                   */   -
  COMLIST(OFF)               /* DEFAULT IS OFF                   */   -
  SYMLIST(OFF)               /* DEFAULT IS OFF                   */   -
  TERMMSGS(OFF)              /* DEFAULT IS OFF                   */   -
  CACT0008(CACT0008)         /* RESOURCE TABLE                   */   -
  CACM042R(CACM042R)         /* RESOURCE TABLE MACRO             */   -
  CATM0101(CATM0101)         /* PROCESS RESOURCE TABLE           */   -
  CATM0102(CATM0102)         /* PROCESS RESOURCE TABLE           */   -
  CATM0405(CATM0405)         /* DEFAULT MACRO TSSLISTP           */   -
  CACC1000(CACC1000)         /* SECURITY CHECK PROGRAM           */   -
  TRACE(OFF)                 /* TRACE ACTIONS AND ERRORS         */
 
/********************************************************************/
/* THIS CLIST (CATC0102) GENERATES REPORTS FOR SELECTED RESOURCES   */
/* THROUGH THE USE OF TSS COMMANDS, (I.E. TSS WHOHAS COMMANDS).     */
/********************************************************************/
/* 04/21/2008 CL.Fenton Initial script creation to evaluate resources.
/* 03/18/2010 CL.Fenton Added collection analysis for TSS0780.
/* 05/21/2010 CL.Fenton Corrected 912 error in the collection of Audit
/*            record.
/* 06/10/2010 CL.Fenton Corrected test on fld LAUD.
/* 01/30/2013 CL.Fenton Corrected 868 error when processing AUDIT record
/*            entries with "+" in resources, STS-001724.
 
SET PGMNAME = &STR(CATC0102 01/30/13)
 
/* SETUP ERROR ROUTINE */
ERROR DO
  SET RETURN_CODE = &LASTCC
  IF &LASTCC GE 16 THEN +
    WRITE &PGMNAME LASTCC = &LASTCC &ZERRLM
  RETURN
  END
 
ISPEXEC CONTROL NONDISPL ENTER
ISPEXEC CONTROL ERRORS RETURN
 
CONTROL NOFLUSH
/* *************************************** */
/* NO VARIABLES ARE PASSED TO THIS CLIST   */
/* BUT KEYWORDS OF                         */
/* CAN BE PASSED TO LET                    */
/* THIS CLIST BE AWARE OF WHAT  ACCESS     */
/* CONTROL PRODUCT AND EXAMINE VERSION     */
/* YOU ARE                                 */
/* WORKING WITH                            */
/* *************************************** */
/* CONSLIST = CONLIST                      */
/* COMLIST = LIST                          */
/* SYMLIST = SYMLIST                       */
/* TERMMSGS = MESSAGES                     */
/* TRACE TURNS ON MESSAGING                */
/* *************************************** */
 
IF &TRACE = ON THEN                         /* TURN TRACE ON */ -
  DO
    SET CONSLIST = ON
    SET COMLIST = ON
    SET SYMLIST = ON
    SET TERMMSGS = ON
  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 SYSASIS    = ON
 
SET RETURN_CODE = 0                         /* SET RETURN CODE TO 0 */
 
/********************************************************************/
/* MAIN PROCESS LOOP                                                */
/********************************************************************/
 
SET SPC = &STR(          )
SET SPC = &STR(&SPC&SPC&SPC&SPC&SPC&SPC&SPC&SPC)
 
/* Determine which security system is running */
 
ISPEXEC VPUT ( +
  CONSLIST    +
  COMLIST     +
  SYMLIST     +
  TERMMSGS    +
  ) ASIS
 
SET RETURN_CODE = 0
 
ISPEXEC SELECT CMD(&CACC1000 ACP)
 
ISPEXEC VGET ( +
  ACPNAME      +
  ACPVERS      +
  ) ASIS
 
IF &STR(&ACPNAME) NE &STR(TSS) THEN DO
  WRITE &PGMNAME TSS Job running on the wrong system.
  WRITE &PGMNAME &ACPNAME &ACPVERS
  SET RETURN_CODE = 12
  GOTO ERR_EXIT
  END
 
/* *************************************** */
/* INITIALIZE LIBRARY MANAGEMENT           */
/* *************************************** */
 
SET RETURN_CODE = 0                         /* SET RETURN CODE TO 0 */
 
ISPEXEC LMINIT DATAID(CNTL) DDNAME(CNTL)
 
SET LMINIT_CNTL_RC = &RETURN_CODE
IF &RETURN_CODE NE 0 THEN DO
  WRITE &PGMNAME LMINIT_CNTL_RC &RETURN_CODE  &ZERRSM
  GOTO ERR_EXIT
  END
 
ISPEXEC LMINIT DATAID(TEMP6) DDNAME(TEMP6)
 
SET LMINIT_TEMP6_RC = &RETURN_CODE
IF &RETURN_CODE NE 0 THEN DO
  WRITE &PGMNAME LMINIT_TEMP6_RC &RETURN_CODE  &ZERRSM
  GOTO ERR_EXIT
  END
 
ISPEXEC LMINIT DATAID(SENSITVE) DDNAME(SENSITVE)
 
SET LMINIT_SENSITVE_RC = &RETURN_CODE
IF &RETURN_CODE NE 0 THEN DO
  WRITE &PGMNAME LMINIT_SENSITVE_RC &RETURN_CODE  &ZERRSM
  GOTO ERR_EXIT
  END
 
ISPEXEC LMINIT DATAID(TSSLISTP) DDNAME(TSSLISTP)
 
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
 
ISPEXEC LMINIT DATAID(TSSLIST) DDNAME(TSSLIST)
 
SET LMINIT_TSSLIST_RC = &RETURN_CODE
IF &RETURN_CODE NE 0 THEN DO
  WRITE &PGMNAME LMINIT_TSSLIST_RC &RETURN_CODE  &ZERRSM
  SET RETURN_CODE = &RETURN_CODE + 16
  GOTO ERR_EXIT
  END
 
ISPEXEC LMOPEN DATAID(&TSSLIST) OPTION(INPUT)
 
SET LMOPEN_TSSLIST_RC = &RETURN_CODE
IF &RETURN_CODE NE 0 THEN DO
  WRITE &PGMNAME LMOPEN_TSSLIST_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
  GOTO ERR_EXIT
  END
 
SET RETURN_CODE = 0                         /* SET RETURN CODE TO 0 */
 
 
/* *************************************** */
/* GET TABLE VALUES                        */
/* *************************************** */
 
SET RETURN_CODE = 0
 
SET RECTYPE = 1
SET PDINAME =
SET RESNAME =
 
ISPEXEC VPUT ( +
  CNTL         +
  SENSITVE     +
  TSSLISTP     +
  TSSLIST      +
  CATM0405     +
  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      +
  ) ASIS
 
SET &SYSOUTTRAP = 999999999
 
DO X = 1 TO &LENGTH(&NRSTR(&REC1TBL)) BY 18
  SET PDINAME = &SUBSTR(&X:&X+7,&NRSTR(&REC1TBL))    /* PDI ID
  SET RESVAL  = &SUBSTR(&X+9:&X+16,&NRSTR(&REC1TBL)) /* RESOURCE NAME
 
  SET AUDDSNS =
  SET VARON =
 
  SET &SYSLIST = ON
  SET RETURN_CODE = 0
  TSS LIST(AUDIT)
  SET &SYSLIST = OFF
 
  SET A = &SYSOUTLINE  /* OBTAIN LAST LINE FROM CMD RESULTS */
 
  DO LINE = 1 TO &A
    SET DATA = &&SYSOUTLINE&LINE
 
    IF &SUBSTR(1:8,&STR(&DATA)) EQ &RESVAL THEN +
      SET VARON = ON
    ELSE +
      IF &VARON EQ ON AND +
        &SUBSTR(1:8,&STR(&DATA)) EQ &STR(        ) THEN
      ELSE +
        DO
          SET VARON =
          GOTO NEXT_AUDIT
        END
 
    SET AUDDSN = &SUBSTR(14:69,&STR(&DATA&SPC))
    SET Y = &SYSINDEX(&STR( ),&STR(&AUDDSN ))
    IF &Y GT 1 THEN +
      SET AUDDSN = &SUBSTR(1:&Y-1,&STR(&AUDDSN))
    ELSE +
      SET AUDDSN =
/*  SET AUDDSN = &AUDDSN
    SET LAUD = &LENGTH(&STR(&AUDDSN))
    SET Y = 1
    IF &LAUD GT 0 THEN +
    DO UNTIL &Y GT &LAUD
      SET Z = &SYSINDEX(&STR( ),&STR(&AUDDSN ),&Y)
      SET AUDX = &SUBSTR(&Y:&Z-1,&STR(&AUDDSN))
      NEXT_STAR: +
      SET A1 = &SYSINDEX(&STR(* ),&STR(&AUDX  ))
      IF &A1 GT 1 THEN +
        DO
          SET AUDX = &SUBSTR(1:&A1-1,&STR(&AUDX))
          GOTO NEXT_STAR
        END
 
      SET AUDDSNS = &STR(&AUDDSNS)&SUBSTR(1:50,&STR(&AUDX&SPC))
      DO UNTIL &SUBSTR(&Z:&Z,&STR(&AUDDSN X)) NE &STR( )
        SET Z = &Z + 1
      END
      SET Y = &Z
    END
 
    NEXT_AUDIT: +
  END
  ISPEXEC VPUT ( +
    PDINAME      +
    RESVAL       +
    AUDDSNS      +
    ) ASIS
 
  SET RETURN_CODE = 0
 
  /* *************************************** */
  /* CREATE RESOURCE OUTPUT AND CREATE TEMP6 */
  /* *************************************** */
 
  ISPEXEC EDIT DATAID(&TEMP6) MACRO(&CATM0101) MEMBER(&PDINAME)
 
  SET EDIT_TEMP6_RC = &RETURN_CODE
 
  SET RETURN_CODE = 0
 
END
 
SET PDINAME = &STR(TSS0780 )
SET RESVAL  = &STR(MODE    )
SET AUDDSNS =
 
ISPEXEC VPUT ( +
  PDINAME      +
  RESVAL       +
  AUDDSNS      +
  ) ASIS
 
SET RETURN_CODE = 0
 
/* *************************************** */
/* CREATE RESOURCE OUTPUT AND CREATE TEMP6 */
/* *************************************** */
 
ISPEXEC EDIT DATAID(&TEMP6) MACRO(&CATM0102) MEMBER(&PDINAME)
 
SET EDIT_TEMP6_RC = &RETURN_CODE
 
SET RETURN_CODE = 0
 
BYPASS_CACT0008:+
SET RETURN_CODE = 0
 
ISPEXEC LMCOMP DATAID(&TEMP6)
 
SET LMCOMP_TEMP6_RC = &RETURN_CODE
SET RETURN_CODE = 0
 
ISPEXEC LMCLOSE DATAID(&SENSITVE)
 
SET LMCLOSE_SENSITVE_RC = &RETURN_CODE
SET RETURN_CODE = 0
 
ISPEXEC LMCLOSE DATAID(&TSSLIST)
 
SET LMCLOSE_TSSLIST_RC = &RETURN_CODE
SET RETURN_CODE = 0
 
ISPEXEC LMFREE DATAID(&CNTL)
 
SET LMFREE_CNTL_RC = &RETURN_CODE
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(&TSSLISTP)
 
SET LMFREE_TSSLISTP_RC = &RETURN_CODE
SET RETURN_CODE = 0
 
ISPEXEC LMFREE DATAID(&TSSLIST)
 
SET LMFREE_TSSLIST_RC = &RETURN_CODE
SET RETURN_CODE = 0
 
 
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 ( +
  CM2RVGET     +
  CM42RRC      +
  CM01FER      +
  CM01LPER     +
  ) ASIS
 
IF &TERMMSGS = ON THEN +
DO
WRITE ================================================================
WRITE &PGMNAME LMINIT_CNTL_RC             &LMINIT_CNTL_RC
WRITE &PGMNAME LMINIT_TEMP6_RC            &LMINIT_TEMP6_RC
WRITE &PGMNAME LMINIT_SENSITVE_RC         &LMINIT_SENSITVE_RC
WRITE &PGMNAME LMINIT_TSSLISTP_RC         &LMINIT_TSSLISTP_RC
WRITE &PGMNAME LMINIT_TSSLIST_RC          &LMINIT_TSSLIST_RC
WRITE ================================================================
WRITE &PGMNAME LMOPEN_SENSITVE_RC         &LMOPEN_SENSITVE_RC
WRITE &PGMNAME LMOPEN_TSSLIST_RC          &LMOPEN_TSSLIST_RC
WRITE ================================================================
WRITE &PGMNAME VPUT_RC                    &VPUT_RC
WRITE &PGMNAME VIEW_CACT0008_RC           &VIEW_CACT0008_RC
WRITE &PGMNAME &CACM042R VGET              &CM2RVGET
WRITE &PGMNAME &CACM042R RC                &CM42RRC
WRITE &PGMNAME LMCOMP_TEMP6_RC            &LMCOMP_TEMP6_RC
WRITE &PGMNAME LMCLOSE_SENSITVE_RC        &LMCLOSE_SENSITVE_RC
WRITE &PGMNAME LMCLOSE_TSSLIST_RC         &LMCLOSE_TSSLIST_RC
WRITE &PGMNAME LMFREE_CNTL_RC             &LMFREE_CNTL_RC
WRITE &PGMNAME LMFREE_TEMP6_RC            &LMFREE_TEMP6_RC
WRITE &PGMNAME LMFREE_SENSITVE_RC         &LMFREE_SENSITVE_RC
WRITE &PGMNAME LMFREE_TSSLISTP_RC         &LMFREE_TSSLISTP_RC
WRITE &PGMNAME LMFREE_TSSLIST_RC          &LMFREE_TSSLIST_RC
WRITE ================================================================
END
END
