/* REXX */
/* CLS2REXXed by UMLA01S on 5 Aug 2019 at 18:59:25  */
/*trace r?*/
Signal On NoValue
Call On Error
Signal On Failure
Signal On Syntax
Parse source opsys . exec_name .
 
/*********************************************************************/
/* 04/15/2004 JL Nelson Set up to test finding messages              */
/* 06/18/2004 JL Nelson Added EXIT code                              */
/* 06/22/2004 JL Nelson Added code to check security system          */
/* 02/23/2005 JL Nelson Changed constants to variables before        */
/*            rename.                                                */
/* 04/18/2005 JL Nelson Added TEST(MOD) to use input test file       */
/* 06/09/2005 JL Nelson Pass MAXCC in ZISPFRC variable               */
/* 06/15/2005 JL Nelson Reset return code to end job step            */
/* 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.       */
/* 08/05/2019 CL Fenton Converted script from CLIST to REXX.         */
/* 04/07/2021 CL Fenton ACP00000 automation for RACF-OS-000040 to    */
/*            determine which ACP is on the system, STS-026207.      */
/* 01/29/2026 CL Fenton Changes made in output messages.             */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*********************************************************************/
pgmname = "CARC0005 01/29/26"
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       */
CARM0409 = "CARM0009"             /* SELECT EDIT macro TEMP9         */
CARM040A = "CARM000A"             /* SELECT EDIT macro PDI           */
DATADDN  = "DIALOG"               /* Dialog DD name for review       */
ASSET    = "ASSET"                /* Dialog Asset Definition member  */
TEST     = "OFF"                  /* Finding Msgs (OFF|MOD|FINDING)  */
TRACE    = "OFF"                  /* TRACE ACTIONS AND ERRORS        */
esm      = "RACF"                 /* external security manager       */
lminit_dialog_rc  = "N/A"
lminit_temp9_rc   = "N/A"
lminit_pdidd_rc   = "N/A"
lmopen_pdidd_rc   = "N/A"
lmclose_pdidd_rc  = "N/A"
lmopen_dialog_rc  = "N/A"
lmopen_temp9_rc   = "N/A"
lmmfind_dialog_rc = "N/A"
lmclose_dialog_rc = "N/A"
lmclose_temp9_rc  = "N/A"
rc05vput          = "N/A"
view_temp9_rc     = "N/A"
rm09vget          = "N/A"
rm009rc           = "N/A"
rm0avget          = "N/A"
rm00arc           = "N/A"
lmfree_dialog_rc  = "N/A"
lmfree_temp9_rc   = "N/A"
lmcomp_pdidd_rc   = "N/A"
lmfree_pdidd_rc   = "N/A"
 
sysprompt = "OFF"                 /* CONTROL NOPROMPT                */
sysflush = "OFF"                  /* CONTROL NOFLUSH                 */
sysasis = "ON"                    /* CONTROL ASIS - caps off         */
Numeric digits 10                 /* default of 9 not enough         */
maxcc = 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 (SYMLIST CONSLIST COMLIST TERMMSGS CARM040A TYPERUN TEST)",
   "ASIS"
rc05vput = return_code
If return_code <> 0 then do
  Say pgmname "VPUT_RC =" return_code zerrsm
  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 <> "RACF" then do
  Say pgmname "RACF Job running on the wrong system"
  Say pgmname acpname acpvers
  return_code = 20
  SIGNAL ERR_EXIT
  end
old_resource = "               "
uidstr = "UID("
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(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("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 ERR_EXIT
  end
 
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("pdidd")"
lmclose_pdidd_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMCLOSE_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 = "SETROPTS LIST"
  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_SETROPTS:
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("carm0409")"
view_temp9_rc = return_code
"VGET (RM009RC) ASIS"
If view_temp9_rc > 4 then do
  Say pgmname "VIEW_TEMP9_RC =" rm009rc zerrsm
  Say pgmname zerrlm
  end
 
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
 
 
/*******************************************/
/* ERROR EXIT                              */
/*******************************************/
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 (RM09VGET RM009RC RM0AVGET RM00ARC) ASIS"
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_PDIDD_RC                   "lminit_pdidd_rc
  Say pgmname "LMOPEN_DIALOG_RC                  "lmopen_dialog_rc
  Say pgmname "LMOPEN_PDIDD_RC                   "lmopen_pdidd_rc
  Say pgmname "LMOPEN_TEMP9_RC                   "lmopen_temp9_rc
  Say pgmname "LMMFIND_DIALOG_RC                 "lmmfind_dialog_rc
  Say pgmname "LMCLOSE_DIALOG_RC                 "lmclose_dialog_rc
  Say pgmname "LMCLOSE_PDIDD_RC                  "lmclose_pdidd_rc
  Say pgmname "LMCLOSE_TEMP9_RC                  "lmclose_temp9_rc
  Say pgmname "VPUT                              "rc05vput
  Say pgmname "VIEW_TEMP9_RC                     "view_temp9_rc
  Say pgmname carm0409 "VGET                     "rm09vget
  Say pgmname carm0409 "RM009RC                  "rm009rc
  Say pgmname carm040a "VGET                     "rm0avget
  Say pgmname carm040a "RM00ARC                  "rm00arc
  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 "==============================================================="
  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 pdi "#" findtxt "$" finding
os = "999999"
bl = " "
Say PGMNAME "Processing PDI" pdi"."
if findtxt = "" then do
  ac = "Not a Finding"
  "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(ac)",
    "DATALEN("length(ac)") MEMBER("pdi")"
  end
else ,
  "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(findtxt)",
    "DATALEN("length(findtxt)") MEMBER("pdi")"
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("pdi")"
    if s <> '' then do
      ac = '    ' s
      "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(ac)",
        "DATALEN("length(ac)") MEMBER("pdi")"
      sp = '         '
      end
    os = s
    end
  if text <> "" then do
    ac = sp text
    "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(ac)",
      "DATALEN("length(ac)") MEMBER("pdi")"
    end
  end
 
 
replace:
"LMMADD DATAID("pdidd") MEMBER("pdi")"
if return_code = 4 then do
  "LMMREP DATAID("pdidd") MEMBER("pdi")"
  if return_code <> 0 then,
    Say PGMNAME "LMMREP_PDIDD =" return_code pdi zerrsm
  end
return
 
 
