/* REXX */
/* CLS2REXXed by UMLA01S on 10 Nov 2025 at 20:37:14  */
/*trace ?r*/
Signal On NoValue
Call On Error
Signal On Failure
Signal On Syntax
Parse source opsys . exec_name .
 
/*********************************************************************/
/* This REXX (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.      */
/* 11/10/2025 CL Fenton Converted script from CLIST to REXX.         */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*********************************************************************/
pgmname = "CATC0102 11/10/25"
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        */
sysflush = "OFF"                  /* CONTROL NOFLUSH                 */
lminit_cntl_rc       = "N/A"
lminit_temp6_rc      = "N/A"
lminit_sensitve_rc   = "N/A"
lminit_tsslistp_rc   = "N/A"
lminit_tsslist_rc    = "N/A"
lmopen_sensitve_rc   = "N/A"
lmopen_tsslist_rc    = "N/A"
vput_rc              = "N/A"
view_cact0008_rc     = "N/A"
cm2rvget             = "N/A"
cm42rrc              = "N/A"
lmcomp_temp6_rc      = "N/A"
lmclose_sensitve_rc  = "N/A"
lmclose_tsslist_rc   = "N/A"
lmfree_cntl_rc       = "N/A"
lmfree_temp6_rc      = "N/A"
lmfree_sensitve_rc   = "N/A"
lmfree_tsslistp_rc   = "N/A"
lmfree_tsslist_rc    = "N/A"
Numeric digits 10                 /* default of 9 not enough         */
maxcc = 0
 
Arg OPTION
do until OPTION = ""
  parse var OPTION key"("val")" OPTION
  val = strip(val,"b","'")
  val = strip(val,"b",'"')
  optcmd = key '= "'val'"'
  interpret optcmd
  end
 
If trace = "ON" then do            /* TURN messages on          */
  termmsgs = "ON"                  /* CONTROL MSG               */
  comlist = "ON"                   /* CONTROL LIST              */
  conslist = "ON"                  /* CONTROL CONLIST           */
  symlist = "ON"                   /* CONTROL SYMLIST           */
  end
 
If CONSLIST = "ON" | COMLIST = "ON" | SYMLIST = "ON" | TRACE = "ON",
  then Trace ?r
 
syssymlist = symlist           /* CONTROL SYMLIST/NOSYMLIST */
sysconlist = conslist          /* CONTROL CONLIST/NOCONLIST */
syslist    = comlist           /* CONTROL LIST/NOLIST       */
sysmsg     = termmsgs          /* CONTROL MSG/NOMSG         */
sysasis    = "ON"
Address ISPEXEC
"CONTROL NONDISPL ENTER"
"CONTROL ERRORS RETURN"
 
/***********************************************/
/* CONSLIST = CONLIST                          */
/* COMLIST  = LIST                             */
/* SYMLIST = SYMLIST                           */
/* TERMMSGS = MESSAGES                         */
/* TRACE TURNS ON MESSAGING                    */
/***********************************************/
return_code = 0                         /* SET RETURN CODE TO 0 */
/********************************************************************/
/* MAIN PROCESS LOOP                                                */
/********************************************************************/
"VPUT (CONSLIST COMLIST SYMLIST TERMMSGS) ASIS"
 
return_code = 0
/* Determine which security system is running */
"SELECT CMD("cacc1000 "ACP)"
"VGET (ACPNAME ACPVERS) ASIS"
If acpname <> "TSS" then do
  Say pgmname "TSS Job running on the wrong system."
  Say pgmname acpname acpvers
  return_code = 12
  SIGNAL ERR_EXIT
  End
 
/*******************************************/
/* INITIALIZE LIBRARY MANAGEMENT           */
/*******************************************/
return_code = 0
"LMINIT DATAID(CNTL) DDNAME(CNTL)"
lminit_cntl_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT_CNTL_RC" return_code zerrsm
  SIGNAL ERR_EXIT
  End
 
"LMINIT DATAID(TEMP6) DDNAME(TEMP6)"
lminit_temp6_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT_TEMP6_RC" return_code zerrsm
  SIGNAL ERR_EXIT
  End
 
"LMINIT DATAID(SENSITVE) DDNAME(SENSITVE)"
lminit_sensitve_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT_SENSITVE_RC" return_code zerrsm
  SIGNAL ERR_EXIT
  End
 
"LMINIT DATAID(TSSLISTP) DDNAME(TSSLISTP)"
lminit_tsslistp_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT_TSSLISTP_RC" return_code zerrsm
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  End
 
"LMINIT DATAID(TSSLIST) DDNAME(TSSLIST)"
lminit_tsslist_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT_TSSLIST_RC" return_code zerrsm
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  End
 
"LMOPEN DATAID("tsslist") OPTION(INPUT)"
lmopen_tsslist_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMOPEN_TSSLIST_RC" return_code zerrsm
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  End
 
"LMOPEN DATAID("sensitve") OPTION(OUTPUT)"
lmopen_sensitve_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMOPEN_SENSITVE_RC" return_code zerrsm
  SIGNAL ERR_EXIT
  End
 
/*******************************************/
/* GET TABLE VALUES                        */
/*******************************************/
 
return_code = 0
rectype = 1
pdiname = ""
resname = ""
"VPUT (CNTL SENSITVE TSSLISTP TSSLIST CATM0405 RECTYPE PDINAME",
  "RESNAME) ASIS"
vput_rc = return_code
 
return_code = 0
"VIEW DATAID("cntl") MEMBER("cact0008") MACRO("cacm042r")"
view_cact0008_rc = return_code
If view_cact0008_rc > 4 then do
  Say pgmname "VIEW CNTL" cact0008 "RC =" view_cact0008_rc
  return_code = return_code + 16
  SIGNAL ERR_EXIT
/*SIGNAL BYPASS_CACT0008*/
  End
 
x = outtrap("out.")
return_code = 0
Address TSO "TSS LIST(AUDIT)"
return_code = 0
 
"VGET (REC1TBL) ASIS"
 
Do X = 1 to length(rec1tbl) by 18
  parse var rec1tbl . =(x) pdiname resval .
  auddsns = ""
  varon = ""
  Do LINE = 1 to out.0
    data = out.line
/*  say "RESVAL:"resval "Audit Res:"left(data,8) "VARON:"varon*/
    If left(data,8) <> resval &,
       varon = "" then iterate
    If left(data,8) = resval then,
      varon = "ON"
    Else,
      If varon = "ON" &,
         (left(data,8) <> resval |,
          left(data,8) = " ") then do
        varon = ""
        leave line
        End
 
    auddsn = strip(substr(data,14),"T")
    If auddsn <> "*ALL*" then,
      auddsn = strip(auddsn,"T","*")
    auddsns = auddsns""left(auddsn,50)
    End
 
  "VPUT (PDINAME RESVAL AUDDSNS) ASIS"
 
  return_code = 0
  /*******************************************/
  /* CREATE RESOURCE OUTPUT AND CREATE TEMP6 */
  /*******************************************/
  "EDIT DATAID("temp6") MACRO("catm0101") MEMBER("pdiname")"
 
  edit_temp6_rc = return_code
  return_code = 0
  End
 
pdiname = "TSS0780"
resval = "MODE"
auddsns = ""
"VPUT (PDINAME RESVAL AUDDSNS) ASIS"
return_code = 0
/*******************************************/
/* CREATE RESOURCE OUTPUT AND CREATE TEMP6 */
/*******************************************/
 
"EDIT DATAID("temp6") MACRO("catm0102") MEMBER("pdiname")"
edit_temp6_rc = return_code
 
 
 
BYPASS_CACT0008:
return_code = 0
"LMCOMP DATAID("temp6")"
lmcomp_temp6_rc = return_code
 
return_code = 0
"LMCLOSE DATAID("sensitve")"
lmclose_sensitve_rc = return_code
 
return_code = 0
"LMCLOSE DATAID("tsslist")"
lmclose_tsslist_rc = return_code
 
return_code = 0
"LMFREE DATAID("cntl")"
lmfree_cntl_rc = return_code
 
return_code = 0
"LMFREE DATAID("temp6")"
lmfree_temp6_rc = return_code
 
return_code = 0
"LMFREE DATAID("sensitve")"
lmfree_sensitve_rc = return_code
 
return_code = 0
"LMFREE DATAID("tsslistp")"
lmfree_tsslistp_rc = return_code
 
return_code = 0
"LMFREE DATAID("tsslist")"
lmfree_tsslist_rc = return_code
 
return_code = 0
 
 
ERR_EXIT:
If maxcc >= 16 | return_code > 0 then do
  "VGET (ZISPFRC) SHARED"
  If maxcc > zispfrc then,
    zispfrc = maxcc
  Else,
    zispfrc = return_code
  "VPUT (ZISPFRC) SHARED"
  Say pgmname "ZISPFRC =" zispfrc
  End
 
"VGET (CM2RVGET CM42RRC CM01FER CM01LPER) ASIS"
If termmsgs = "ON" then do
  Say "==============================================================="
  Say pgmname "LMINIT_CNTL_RC                    "lminit_cntl_rc
  Say pgmname "LMINIT_TEMP6_RC                   "lminit_temp6_rc
  Say pgmname "LMINIT_SENSITVE_RC                "lminit_sensitve_rc
  Say pgmname "LMINIT_TSSLISTP_RC                "lminit_tsslistp_rc
  Say pgmname "LMINIT_TSSLIST_RC                 "lminit_tsslist_rc
  Say "==============================================================="
  Say pgmname "LMOPEN_SENSITVE_RC                "lmopen_sensitve_rc
  Say pgmname "LMOPEN_TSSLIST_RC                 "lmopen_tsslist_rc
  Say "==============================================================="
  Say pgmname "VPUT_RC                           "vput_rc
  Say pgmname "VIEW_CACT0008_RC                  "view_cact0008_rc
  Say pgmname cacm042r "VGET                     "cm2rvget
  Say pgmname cacm042r "RC                       "cm42rrc
  Say pgmname "LMCOMP_TEMP6_RC                   "lmcomp_temp6_rc
  Say pgmname "LMCLOSE_SENSITVE_RC               "lmclose_sensitve_rc
  Say pgmname "LMCLOSE_TSSLIST_RC                "lmclose_tsslist_rc
  Say pgmname "LMFREE_CNTL_RC                    "lmfree_cntl_rc
  Say pgmname "LMFREE_TEMP6_RC                   "lmfree_temp6_rc
  Say pgmname "LMFREE_SENSITVE_RC                "lmfree_sensitve_rc
  Say pgmname "LMFREE_TSSLISTP_RC                "lmfree_tsslistp_rc
  Say pgmname "LMFREE_TSSLIST_RC                 "lmfree_tsslist_rc
  Say "==============================================================="
  End
Exit
 
 
/*******************************************/
/*  SYSCALL SUBROUTINES                    */
/*******************************************/
 
 
NoValue:
Failure:
Syntax:
say pgmname 'REXX error' rc 'in line' sigl':' strip(ERRORTEXT(rc))
say SOURCELINE(sigl)
SIGNAL ERR_EXIT
 
 
Error:
return_code = RC
if RC > 4 & RC <> 8 then do
  say pgmname "LASTCC =" RC strip(zerrlm)
  say pgmname 'REXX error' rc 'in line' sigl':' strip(ERRORTEXT(rc))
  say SOURCELINE(sigl)
  end
if return_code > maxcc then,
  maxcc = return_code
return
 
 
