/* REXX */
/* CLS2REXXed by UMLA01S on 14 Apr 2021 at 12:09:12  */
/*trace r?*/
Signal On NoValue
Call On Error
Signal On Failure
Signal On Syntax
Parse source opsys . exec_name .
 
/*********************************************************************/
/* 04/19/2004 JL Nelson Set up to test finding messages.             */
/* 06/16/2004 JL Nelson Added EXIT code.                             */
/* 06/22/2004 JL Nelson Added check for security system.             */
/* 02/09/2005 JL Nelson Changed constants to variables before        */
/*            rename.                                                */
/* 04/13/2005 JL Nelson Added TEST(MOD) to use input test file.      */
/* 04/27/2005 JL Nelson Added TYPERUN for FSO options.               */
/* 06/08/2005 JL Nelson Pass MAXCC in ZISPFRC variable.              */
/* 06/15/2005 JL Nelson Reset return code to end job step.           */
/* 03/16/2006 JL Nelson Set/test RCode for every ISPEXEC command.    */
/* 03/21/2006 JL Nelson Use NRSTR avoid abend 900 if ampersand in    */
/*            data.                                                  */
/* 05/09/2006 JL Nelson Added WRITE &LASTCC for debugging.           */
/* 07/09/2007 CL Fenton changes made to include ASSET mbr of Dialog  */
/*            data set.  Obtaining CLASS for ASSET mbr.              */
/* 10/22/2015 CL Fenton Changed VMS asset to Asset Definition.       */
/* 04/14/2021 CL Fenton Converted script from CLIST to REXX.         */
/* 04/14/2021 CL Fenton ACP00000 automation for TSS0-OS-000230 to    */
/*            determine which ACP is on the system, STS-026207.      */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*********************************************************************/
CONSLIST = "OFF"                  /* DEFAULT IS OFF                  */
COMLIST  = "OFF"                  /* DEFAULT IS OFF                  */
SYMLIST  = "OFF"                  /* DEFAULT IS OFF                  */
TERMMSGS = "OFF"                  /* DEFAULT IS OFF                  */
TYPERUN  = "FSO"                  /* Run for SRRAUDIT | FSO          */
CACC1000 = "CACC1000"             /* SELECT SECURITY CHECK PGM       */
CATM0409 = "CATM0009"             /* EDIT MACRO TEMP9                */
CATM040A = "CATM000A"             /* EDIT MACRO PDI                  */
CATC1004 = "CATC1004"             /* EXTRACT FACILITY INFORMATION    */
DATADDN  = "DIALOG"               /* Dialog DD name for review       */
FACALLDD = "FACALL"               /* FACILITY ALL OUTPUT             */
ASSET    = "ASSET"                /* Dialog Asset Definition member  */
TEST     = "OFF"                  /* Finding Msgs (OFF|MOD|FINDING)  */
TRACE    = "OFF"                  /* TRACE ACTIONS AND ERRORS        */
esm      = "TSS"                  /* external security manager       */
pgmname = "CATC0004 04/14/21"
 
sysprompt = "OFF"                 /* CONTROL NOPROMPT                */
sysflush = "OFF"                  /* CONTROL NOFLUSH                 */
sysasis = "ON"                    /* CONTROL ASIS - caps off         */
Numeric digits 10                 /* default of 9 not enough         */
maxcc = 0
lminit_dialog_rc    = "0"
lminit_temp9_rc     = "0"
lminit_facall_rc    = "0"
lminit_pdidd_rc     = "0"
lmopen_dialog_rc    = "0"
lmopen_temp9_rc     = "0"
lmmfind_dialog_rc   = "0"
vput_pdidd_rc       = "0"
lmclose_dialog_rc   = "0"
lmclose_temp9_rc    = "0"
view_temp9_rc       = "0"
vget_rc             = "0"
tm09vget            = "0"
tm009rc             = "0"
tm0avget            = "0"
tm00arc             = "0"
extract_catc1004_rc = "0"
lmopen_facall_rc    = "0"
lmopen_pdidd_rc     = "0"
lmclose_facall_rc   = "0"
lmclose_pdidd_rc    = "0"
return_code = 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
 
return_code = 0
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         */
Address ISPEXEC
"CONTROL NONDISPL ENTER"
"CONTROL ERRORS RETURN"
zispfrc = 0
"VPUT (ZISPFRC) SHARED"
 
return_code = 0
"VPUT (CONSLIST COMLIST SYMLIST TERMMSGS TYPERUN TEST CATM040A)",
  "ASIS"
tc04vput = return_code
If return_code <> 0 then do
  Say pgmname "VPUT_RC =" return_code zerrsm
  Say pgmname zerrlm
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
 
/* Determine which security system is running */
return_code = 0
"SELECT CMD("cacc1000 "ACP)"
"VGET (ACPNAME ACPVERS) ASIS"
If acpname <> "TSS" then do
  Say pgmname "Top Secret Job running on the wrong system."
  Say pgmname acpname acpvers
/*return_code = 20
  SIGNAL ERR_EXIT*/
  end
old_resource = "               "
spc = "               "
/*******************************************/
/* INITIALIZE LIBRARY MANAGEMENT           */
/*******************************************/
return_code = 0
"LMINIT DATAID(DATAID) DDNAME("dataddn")"
lminit_dialog_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT_DIALOG_RC =" return_code zerrsm
  Say pgmname zerrlm
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
 
return_code = 0
"LMINIT DATAID(TEMP9) DDNAME(TEMP9)"
lminit_temp9_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT_TEMP9_RC =" return_code zerrsm
  Say pgmname zerrlm
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
 
return_code = 0
"LMINIT DATAID(FACALL) DDNAME("facalldd")"
lminit_facall_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT_FACALL_RC =" return_code zerrsm
  Say pgmname zerrlm
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
 
return_code = 0
"LMINIT DATAID(PDIDD) DDNAME(PDIDD)"
lminit_pdidd_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT_PDIDD_RC =" return_code zerrsm
  Say pgmname zerrlm
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
 
return_code = 0
"LMOPEN DATAID("dataid")"
lmopen_dialog_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMOPEN_DIALOG_RC =" return_code zerrsm
  Say pgmname zerrlm
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
 
If test <> "MOD" then do
  return_code = 0
  "LMOPEN DATAID("temp9") OPTION(OUTPUT)"
  lmopen_temp9_rc = return_code
  If return_code <> 0 then do
    Say pgmname "LMOPEN_TEMP9_RC =" return_code zerrsm
    Say pgmname zerrlm
    return_code = return_code + 16
    SIGNAL ERR_EXIT
    end
 
  x = outtrap("line.")
  cmd = "TSS MODIFY(ST)"
  Address TSO cmd
  Do X = 1 to line.0
    ab = line.x
    return_code = 0
    "LMPUT DATAID("temp9") MODE(INVAR) DATALOC(AB)",
      "DATALEN("length(ab)") NOBSCAN"
    If return_code <> 0 then do
      Say pgmname "LMPUT_TEMP9_RC =" return_code zerrsm
      Say pgmname zerrlm
      end
    end
 
  return_code = 0
  "LMCLOSE DATAID("temp9")"
  lmclose_temp9_rc = return_code
  If return_code > 4 then do
    Say pgmname "LMCLOSE_TEMP9_RC =" return_code zerrsm
    Say pgmname zerrlm
    return_code = return_code + 16
    SIGNAL ERR_EXIT
    end
  end
 
 
BYPASS_TSS:
class = 9
return_code = 0
"LMMFIND DATAID("dataid") MEMBER("asset")"
lmmfind_dialog_rc = return_code
If return_code > 0 then do
  tst = listdsi(dataddn "FILE")
  datadsn = sysdsname
  Say pgmname "The following members are missing from the",
    "Dialog data set" datadsn"."
  Say pgmname"   ASSET    - Member containing Asset Definition",
    "information."
  Say pgmname"     To correct the above enter the Dialog process",
    "and select the following options:"
  Say pgmname"       Option C - Review reports for Findings,",
    "User, access & Dataset rules"
  Say pgmname"       Option F - Asset Definition Process"
  Say pgmname         "Enter the information requested on the",
    "screen.  Enter CREATE to create the"
  Say pgmname         "Asset File and save the information.  Or",
    "enter SAVE to save the information."
  Say
  end
Else do until return_code = 8
  return_code = 0
  "LMGET DATAID("dataid") MODE(INVAR) DATALOC(TRECORD)",
    "MAXLEN(80) DATALEN(LRECL)"
  If return_code = 8 then leave
  If pos("CLASS ",trecord) = 1 then,
    class = substr(trecord,11,1)
  end
 
 
BYPASS_DIALOG:
return_code = 0
"LMCLOSE DATAID("dataid")"
lmclose_dialog_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMCLOSE_DIALOG_RC =" return_code zerrsm
  Say pgmname zerrlm
  end
 
return_code = 0
"LMFREE DATAID("dataid")"
lmfree_dialog_rc = return_code
 
return_code = 0
"VPUT (CLASS PDIDD) ASIS"
vput_pdidd_rc = return_code
If return_code > 4 then do
  Say pgmname "VPUT_PDIDD_RC =" return_code zerrsm
  Say pgmname zerrlm
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
 
return_code = 0
"VIEW DATAID("temp9") MACRO("catm0409")"
view_temp9_rc = return_code
If return_code > 4 then do
  Say pgmname "VIEW_TEMP9_RC =" return_code zerrsm
  Say pgmname zerrlm
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
 
return_code = 0
"VGET (TM09VGET TM009RC TM0AVGET TM00ARC) ASIS"
vget_rc = return_code
 
return_code = 0
"SELECT CMD("catc1004")"
extract_catc1004_rc = return_code
 
return_code = 0
"LMOPEN DATAID("facall")"
lmopen_facall_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMOPEN_FACALL_RC =" return_code zerrsm
  Say pgmname zerrlm
  return_code = return_code + 16
  SIGNAL END_FACALL
  end
 
return_code = 0
"LMOPEN DATAID("pdidd") OPTION(OUTPUT)"
lmopen_pdidd_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMOPEN_PDIDD_RC =" return_code zerrsm
  Say pgmname zerrlm
  return_code = return_code + 16
  SIGNAL END_FACALL
  end
 
sw = "" /* Switch for finding for TSS0385 */
pdimbr = "TSS0385"
 
 
READ_FACALL:
return_code = 0
do until return_code > 0
"LMGET DATAID("facall") MODE(INVAR) DATALOC(TRECORD)",
  "MAXLEN(80) DATALEN(LRECL)"
If return_code = 8 then leave
If pos("FACILITY=",trecord) = 0 then iterate
If pos("FACILITY=",trecord) > 0 &,
   pos("MODE=FAIL",trecord) > 0 then iterate
If sw = " " then do
  ac = "The following FACILITY Control Option(s) MODE sub-option",
    "setting is (are) improperly set:"
  "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") MEMBER("pdimbr")"
  ac = " "
  "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") MEMBER("pdimbr")"
  sw = "X"
  end
ac = "      "substr(trecord,10)
"LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(AC)",
  "DATALEN("length(ac)") MEMBER("pdimbr")"
end
 
 
END_FACALL:
If sw = " " then do
  ac = "Not a Finding"
  "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") MEMBER("pdimbr")"
  end
call add_member
 
If acpname = esm then do
  ac   = ""
  line = acpname "is running on the system."
  end
Else do
  ac   = esm "is not installed and active on the system."
  line = "Found" acpname "running on the system."
  end
call process_pdi "ACP00000#"ac"$"line
 
return_code = 0
"LMCLOSE DATAID("facall")"
lmclose_facall_rc = return_code
 
return_code = 0
"LMCLOSE DATAID("pdidd")"
lmclose_pdidd_rc = return_code
 
return_code = 0
"LMFREE DATAID("temp9")"
lmfree_temp9_rc = return_code
 
return_code = 0
"LMCOMP DATAID("pdidd")"
lmcomp_pdidd_rc = return_code
 
return_code = 0
"LMFREE DATAID("pdidd")"
lmfree_pdidd_rc = return_code
 
return_code = 0
"LMFREE DATAID("facall")"
lmfree_facall_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
If termmsgs = "ON" then do
  Say "==============================================================="
    Say pgmname "LMINIT_DIALOG_RC        "lminit_dialog_rc
    Say pgmname "LMINIT_TEMP9_RC         "lminit_temp9_rc
    Say pgmname "LMINIT_FACALL_RC        "lminit_facall_rc
    Say pgmname "LMINIT_PDIDD_RC         "lminit_pdidd_rc
    Say pgmname "LMOPEN_DIALOG_RC        "lmopen_dialog_rc
    Say pgmname "LMOPEN_TEMP9_RC         "lmopen_temp9_rc
    Say pgmname "LMMFIND_DIALOG_RC       "lmmfind_dialog_rc
    Say pgmname "VPUT_PDIDD_RC           "vput_pdidd_rc
    Say pgmname "LMCLOSE_DIALOG_RC       "lmclose_dialog_rc
    Say pgmname "LMCLOSE_TEMP9_RC        "lmclose_temp9_rc
    Say pgmname "VIEW_TEMP9_RC           "view_temp9_rc
    Say pgmname "VGET_RC                 "vget_rc
    Say pgmname catm0409 "VGET           "tm09vget
    Say pgmname catm0409 "TM009RC        "tm009rc
    Say pgmname catm040a "VGET           "tm0avget
    Say pgmname catm040a "TM00ARC        "tm00arc
    Say pgmname "EXTRACT_CATC1004_RC     "extract_catc1004_rc
    Say pgmname "LMOPEN_FACALL_RC        "lmopen_facall_rc
    Say pgmname "LMOPEN_PDIDD_RC         "lmopen_pdidd_rc
    Say pgmname "LMCLOSE_FACALL_RC       "lmclose_facall_rc
    Say pgmname "LMCLOSE_PDIDD_RC        "lmclose_pdidd_rc
    Say pgmname "LMFREE_DIALOG_RC        "lmfree_dialog_rc
    Say pgmname "LMFREE_TEMP9_RC         "lmfree_temp9_rc
    Say pgmname "LMCOMP_PDIDD_RC         "lmcomp_pdidd_rc
    Say pgmname "LMFREE_PDIDD_RC         "lmfree_pdidd_rc
    Say pgmname "LMFREE_FACALL_RC        "lmfree_facall_rc
  Say "==============================================================="
  end
Exit 0
 
 
/*******************************************/
/*  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':' ERRORTEXT(rc)
  say SOURCELINE(sigl)
  end
if return_code > maxcc then,
  maxcc = return_code
return
 
 
process_pdi:
Address ISPEXEC
parse arg pdimbr "#" findtxt "$" finding
os = "999999"
bl = " "
say PGMNAME 'Processing PDI' pdimbr'.'
if findtxt = "" then do
  ac = "Not a Finding"
  "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(ac)",
    "DATALEN("length(ac)") MEMBER("pdimbr")"
  end
else ,
  "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(findtxt)",
    "DATALEN("length(findtxt)") MEMBER("pdimbr")"
sp = "    "
do until finding = ""
  if finding = "" then leave
  parse value finding with s"{"text"}"finding
  if s <> os then do
    "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(bl)",
      "DATALEN("length(bl)") MEMBER("pdimbr")"
    if s <> '' then do
      ac = '    ' s
      "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(ac)",
        "DATALEN("length(ac)") MEMBER("pdimbr")"
      sp = '         '
      end
    os = s
    end
  if text <> "" then do
    ac = sp text
    "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(ac)",
      "DATALEN("length(ac)") MEMBER("pdimbr")"
    end
  end
 
 
add_member:
return_code = 0
"LMMADD DATAID("pdidd") MEMBER("pdimbr")"
If return_code = 4 then do
  return_code = 0
  "LMMREP DATAID("pdidd") MEMBER("pdimbr")"
  If return_code <> 0 then,
    Say pgmname "LMMREP_PDI_RCODE =" return_code pdimbr zerrsm
  end
Else,
  If return_code <> 0 then,
    Say pgmname "LMMADD_PDI_RCODE =" return_code pdimbr zerrsm
Return
 
 
