/* REXX */
/* CLS2REXXed by UMLA01S on 10 Dec 2020 at 16:27:36  */
/*Trace r?*/
Signal On NoValue
Call On Error
Signal On Failure
Signal On Syntax
Parse source opsys . exec_name .
Address ISREDIT
 
"MACRO"               /* CAAM0006 EDIT MACRO */
/*********************************************************************/
/* 04/19/2004 JL Nelson Added parameter to test error cond.          */
/* 12/20/2005 C Stern Added CAAM0007 to VGET.                        */
/* 12/20/2005 C Stern Added ACF0250 to TABLE.                        */
/* 12/22/2005 C Stern Added ACF0280 to TABLE.                        */
/* 01/17/2006 C Stern Added ACF0330 to TABLE.                        */
/* 03/24/2006 C Stern Added error handling.                          */
/* 06/06/2006 C Stern Updated ERROR ROUTINE.                         */
/* 10/30/2006 C Stern Added ZUSSA053 per CF/FSO.                     */
/* 12/22/2006 CL Fenton Correct issue with ACF0290 not having        */
/*            correct finding details.                               */
/* 12/22/2006 CL Fenton Removed CLASMAP and INFODIR for              */
/*            ZUSSA050.                                              */
/* 12/22/2006 CL Fenton ACF0550 removed.                             */
/* 07/11/2007 CL Fenton Removed requirement for UNCLASS systems.     */
/*            Streamlined script process.                            */
/* 02/28/2009 CL Fenton changes made removing compress and delete    */
/*            for PDI dataset.                                       */
/* 07/16/2009 CL Fenton changes made to clean up analysis.           */
/* 03/06/2013 CL Fenton split ACF0370 into checking for the CAT I    */
/*            and ACF0375 a CAT II for the remaining GSO OPTS,       */
/*            STS-000812.  ADD ACF0400 to evaluate GSO PWPHRASE      */
/*            option settings, CSD-AR003262504.                      */
/* 01/27/2016 CL Fenton Added ACF0395 to evaluate value of           */
/*            PSWDENCT.  Evaluation of encryption requirements,      */
/*            STS-013213.  Changes for ONEPWALG for release 16.0     */
/*            present for future release.                            */
/* 12/10/2020 CL Fenton Removed TERMPRO variable.                    */
/* 12/10/2020 CL Fenton Converted script from CLIST to REXX.         */
/* 06/17/2021 CL Fenton Chgs to remove ACF0260, ACF0410, ACF0490,    */
/*            ACF0520, ZUSSA050, and ZUSSA053, STS-026845.           */
/* 11/26/2021 CL Fenton Added entries to TABLE for PSWD vuls         */
/*            ACF2-ES-000430, ACF2-ES-000590, ACF2-ES-000820,        */
/*            ACF2-ES-000840, ACF2-ES-000860, ACF2-ES-000870,        */
/*            ACF2-ES-000890, ACF2-ES-000900, ACF2-ES-000850,        */
/*            ACF2-ES-000910, and ACF2-ES-000990, STS-027409,        */
/*            STS-027410, STS-027411, STS-027412, STS-027413,        */
/*            STS-027414, STS-027415, STS-027416, STS-027417,        */
/*            STS-027418, and STS-027419.                            */
/* 08/16/2023 CL Fenton Added entries to TABLE for SAFDEF vul        */
/*            ACF2-SM-000040 for ZSMSA006, SCTASK0045234.            */
/* 03/05/2024 CL Fenton Changes made to correct issues of "not       */
/*            defined" findings were GSO entry exist,                */
/*            SCTASK0102148.                                         */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*********************************************************************/
pgmname = "CAAM0006 03/05/24"
Address ISPEXEC "CONTROL NONDISPL ENTER"
Address ISPEXEC "CONTROL ERRORS RETURN"
 
/*******************************************/
/* This EDIT MACRO provides the finding    */
/* details for ACF2 control options.       */
/*******************************************/
/*CONTROL LIST CONLIST SYMLIST MSG*/
table = "APPLDEF ACF0250 AUTOERAS ACF0270 BACKUP ACF0280 EXITS",
        "ACF0310 LINKLST ACF0330 NJE ACF0360 OPTS ACF0370 OPTS",
        "ACF0375 PPGM ACF0380 PSWD ACF039A PSWD ACF039B PSWD ACF039C",
        "PSWD ACF039D PSWD ACF039E PSWD ACF039F PSWD ACF039G PSWD",
        "ACF039H PSWD ACF039I PSWD ACF039J PSWD ACF039K PSWD ACF0395",
        "PWPHRASE ACF0400 RESVOLS ACF0420 RULEOPTS ACF0430 SECVOLS",
        "ACF0480 TSOCRT ACF0510 TSOTWX ACF0530 TSO2741 ACF0540",
        "SAFDEF ZSMSA006"
 
return_code = 0
maxcc       = 0
zerrlm      = ""
zerrsm      = ""
/*******************************************/
/* VARIABLES ARE PASSED TO THIS MACRO      */
/* CONSLIST                                */
/* COMLIST                                 */
/* SYMLIST                                 */
/* TERMMSGS                                */
/*******************************************/
Address ISPEXEC "VGET (CONSLIST COMLIST SYMLIST TERMMSGS TEST",
  "PDIDD PDIDSN CAAM0007) ASIS"
am06vge = return_code
If return_code <> 0 then do
  Say pgmname "VGET RC =" return_code zerrsm
  Say pgmname "CONSLIST/"conslist "COMLIST/"comlist
  Say pgmname "SYMLIST/"symlist "TERMMSGS/"termmsgs "TEST/"test
  Say pgmname "PDIDD/"pdidd "PDIDSN/"pdidsn "CAAM0007/"caam0007
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
 
If CONSLIST = "ON" | COMLIST = "ON" | SYMLIST = "ON" ,
  then Trace ?r
 
return_code = 0
findrc = 0
 
/*******************************************/
/* Turn on messages                        */
/*******************************************/
syssymlist = symlist                    /* CONTROL SYMLIST/NOSYMLIST */
sysconlist = conslist                   /* CONTROL CONLIST/NOCONLIST */
syslist = comlist                       /* CONTROL LIST/NOLIST       */
sysmsg = termmsgs                       /* CONTROL MSG/NOMSG         */
sysprompt = "OFF"                       /* CONTROL NOPROMPT          */
sysasis = "ON"                          /* CONTROL ASIS - caps off   */
 
/*******************************************/
/* MAIN PROCESS                            */
/*******************************************/
"NULLS ON ALL"
"(LASTLINE) = LINENUM .ZLAST"
"CURSOR = 1 0"
optdel = "X"
Address ISPEXEC "VPUT (OPTDEL) ASIS"
chk = ""
Address ISPEXEC "LMOPEN DATAID("pdidd") OPTION(OUTPUT)"
 
 
ACF0290_CHECK:
pdinum = "ACF0290"
do until return > 0
  return_code = 0
  "FIND ' / BLPPGM'"
  If test = "FINDING" then,
    return_code = 8
 
  If return_code > 0 then do
    If chk = " " then do
      ac = "Not a Finding"
      ab = "BLPPGM will not be specified."
      Address ISPEXEC "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(AC)",
        "DATALEN("length(ac)") MEMBER("pdinum")"
      Address ISPEXEC "LMPUT DATAID("pdidd") MODE(INVAR) DATALOC(AB)",
        "DATALEN("length(ab)") MEMBER("pdinum")"
      end
    return_code = 0
    Call add_member
    chk = ""
    Address ISPEXEC "LMCLOSE DATAID("pdidd")"
    return_code = 0
    optline = ""
    leave
    end
  If chk = " " then do
    chk = "X"
    ac = "The following GSO record value(s) is (are) set improperly:"
    Address ISPEXEC "LMPUT DATAID("pdidd") MODE(INVAR)",
      "DATALOC(AC) DATALEN("length(ac)") MEMBER("pdinum")"
    ac = "     "
    Address ISPEXEC "LMPUT DATAID("pdidd") MODE(INVAR)",
      "DATALOC(AC) DATALEN("length(ac)") MEMBER("pdinum")"
    end
  "(ROW,COL) = CURSOR"
  "(DATA) = LINE" row
  opt = word(data,1) word(data,2) word(data,3)
  ac = "     "opt
  Address ISPEXEC "LMPUT DATAID("pdidd") MODE(INVAR)",
    "DATALOC(AC) DATALEN("length(ac)") MEMBER("pdinum")"
  If row < lastline then,
    row = row + 1
  Else,
    row = lastline
  Do I = row to lastline until data = " "
    "(DATA) = LINE" i
    opt = substr(strip(data,"T"),23)
    ac = "          "opt
    Address ISPEXEC "LMPUT DATAID("pdidd") MODE(INVAR)",
      "DATALOC(AC) DATALEN("length(ac)") MEMBER("pdinum")"
    end
  end
 
 
ACF0480_CHECK:
/*!*/SIGNAL ACF0500_CHECK
pdinum = "ACF0480"
do until return > 0
  return_code = 0
  "FIND ' / SECVOLS'"
  If test = "FINDING" then, /* test error conditions */
    return_code = 8
  findrc = return_code
  If return_code > 0 then do
    If chk = " " then do
      opt = "SECVOLS"
      optline = "VOLMASK()@"
      end
    return_code = 0
    Address ISPEXEC "VPUT (CHK FINDRC OPT OPTLINE) ASIS"
    Address ISPEXEC "EDIT DATAID("pdidd") MACRO("caam0007")",
      "MEMBER("pdinum")"
    return_code = 0
    chk = ""
    optline = ""
    optdel = "X"
    Address ISPEXEC "VPUT (OPTDEL) ASIS"
    end
  chk = "X"
  call Process_GSO_record
  end
 
 
ACF0500_CHECK:
return_code = 0
pdinum = "ACF0500"
"FIND ' / TSO '"
If test = "FINDING" then,
  return_code = 8
/*  ACCOUNT(1) BYPASS(#) CHAR(BS) CMDLIST() NOFSRETAIN        */
/*  LINE(ATTN) LOGONCK PERFORM(0) PROC(IKJACCNT) NOQLOGON     */
/*  REGION(SITE DEFINED) SUBCLSS() SUBHOLD() SUBMSG() TIME(0) */
/*  TSOSOUT(A) UNIT(SYSDA) WAITIME(60) OR LESS                */
If return_code = 0 then do
  call Process_GSO_record
  return_code = 0
  end
Else,
  opt = "TSO"
findrc = return_code
Address ISPEXEC "VPUT (CHK FINDRC OPT OPTLINE) ASIS"
Address ISPEXEC "EDIT DATAID("pdidd") MACRO("caam0007") MEMBER("pdinum")"
chk = "X"
optline = ""
optdel = "X"
Address ISPEXEC "VPUT (OPTDEL) ASIS"
return_code = 0
 
 
ALLOTHER_CHECK:
do x = 1 to words(table) by 2
  "CURSOR = 1 0"
  find_rc = 0
  opta = word(table,x)
  pdinum = word(table,x+1)
  If pdinum = "ZSMSA006" then do
    call Process_ZSMSA006
    end
  Else do
    chk = ""
    Do until find_rc > 0
      return_code = 0
      "FIND ' /" opta"'"
      If test = "FINDING" then,
        return_code = 8
      find_rc = return_code
      If return_code = 0 then do
        call Process_GSO_record
        If optline = " " & chk <> " " then do
          chk = ""
          optline = "NOT"
          end
        return_code = 0
        end
      Else,
        opt = opta
      call Edit_PDI
      end
    optdel = "X"
    Address ISPEXEC "VPUT (OPTDEL) ASIS"
    end
  end
Address ISPEXEC "VPUT  (AM06VGE) ASIS"
 
 
END_EXIT:
return_code = 0
/*******************************************/
/* ERROR EXIT                              */
/*******************************************/
 
 
ERR_EXIT:
If maxcc >= 16 | return_code > 0 then do
  Address ISPEXEC "VGET (ZISPFRC) SHARED"
  If maxcc > zispfrc then,
    zispfrc = maxcc
  Else,
    zispfrc = return_code
  Address ISPEXEC "VPUT (ZISPFRC) SHARED"
  Say pgmname "ZISPFRC =" zispfrc
  end
"END"
Exit
 
 
/*******************************************/
/*  SYSCALL SUBROUTINES                    */
/*******************************************/
ADD_MEMBER:
return_code = 0
Address ISPEXEC "LMMADD DATAID("pdidd") MEMBER("pdinum")"
If return_code = 4 then do
  return_code = 0
  Address ISPEXEC "LMMREP DATAID("pdidd") MEMBER("pdinum")"
  If return_code <> 0 then,
    Say pgmname "LMMREP_PDI_RC =" return_code pdinum zerrsm
    end
Else do
  If return_code <> 0 then,
    Say pgmname "LMMADD_PDI_RC =" return_code pdinum zerrsm
  end
Return
 
 
Process_ZSMSA006:
find_rc = 0
/*Do until return_code > 0*/
Do until find_rc > 0
  "FIND 'CLASS=FACILITY'"
  find_rc = return_code
  If return_code = 0 then do
    "FIND ' /" opta"' PREV"
    call Process_GSO_record
    parse var optline . "RACROUTE(" info ")" .
    If words(info) = 2 then do
      If wordpos("REQUEST=AUTH",info) = 0 then find_rc = 6
      If pos("FUNCRET(4)",optline) = 0 then find_rc = 6
      If pos("FUNCRSN(0)",optline) = 0 then find_rc = 6
      If pos("MODE(GLOBAL)",optline) = 0 then find_rc = 6
      If pos("RETCODE(4)",optline) = 0 then find_rc = 6
      call Edit_PDI
      leave
      end
    Else iterate
    end
  Else do
    opt = "SAFDEF.FAC"
    optline = "FUNCRET(4) FUNCRSN(0) ID(FACILITY) MODE(GLOBAL)",
      "RACROUTE(REQUEST=AUTH CLASS=FACILITY) RETCODE(4)@"
    end
  call Edit_PDI
  end
 
find_rc = 0
"CURSOR = 1 0"
"FIND 'REQSTOR=PROGMCHK'"
find_rc = return_code
If return_code = 0 then do
  "FIND ' /" opta"' PREV"
  call Process_GSO_record
  If pos("FUNCRET(4)",optline) = 0 then find_rc = 6
  If pos("FUNCRSN(0)",optline) = 0 then find_rc = 6
  If pos("ID(PROGMCHK)",optline) = 0 then find_rc = 6
  If pos("MODE(GLOBAL)",optline) = 0 then find_rc = 6
  If pos("REQUEST=FASTAUTH",optline) = 0 then find_rc = 6
  If pos("SUBSYS=CONTENTS",optline) = 0 then find_rc = 6
  If pos("RETCODE(4)",optline) = 0 then find_rc = 6
  end
Else do
  opt = "SAFDEF.PGM"
  optline = "FUNCRET(4) FUNCRSN(0) ID(PROGMCHK) MODE(GLOBAL)",
    "RACROUTE(REQUEST=FASTAUTH REQSTOR=PROGMCHK SUBSYS=CONTENTS)@"
  optline = optline"RETCODE(4)@"
  end
call Edit_PDI
 
Return
 
 
Edit_PDI:
findrc = find_rc
Address ISPEXEC "VPUT (CHK FINDRC OPT OPTLINE) ASIS"
Address ISPEXEC "EDIT DATAID("pdidd") MACRO("caam0007")",
  "MEMBER("pdinum")"
return_code = 0
findrc = 0
chk = "X"
optline = ""
Return
 
 
Process_GSO_record:
"(ROW,COL) = CURSOR"
"(DATA) = LINE" row
opt = word(data,1) word(data,2) word(data,3)
If row < lastline then,
  row = row + 1
Else,
  row = lastline
Do i = row to lastline until data = " "
  "(DATA) = LINE" i
  If data <> " " then do
    data = substr(strip(data,"T"),23)
    optline = optline""data"@"
    end
  end
"CURSOR =" i
Return
 
 
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 >= 16 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
 
 
