Endevor

 View Only

 Running a step of a processor under Endevor Alternate ID

Charles Gaskell's profile image
Charles Gaskell posted Dec 11, 2023 06:49 PM

We have a COBOL compile generate processor which has a step to do an automatic DB2 bind. The processor runs in batch. The step in the processor which does the bind actually runs a Rexx, which works out which binds are required, creates and places the BIND PACKAGE commands onto the stack, then issues a DSN(ssid) TSO command to connect to the DB2, which processes the commands on the stack and does the bind.

The issue we have is that the whole of the Processor runs under the ownership of the person adding the COBOL source into Endevor, including the step that runs the Rexx to do the bind, so the person adding in the source needs to have DB2 authority to bind the package.

Is there any way of getting (just) the step of the Processor that runs the Rexx to run using the Endevor Alternate ID, so that we only need to give authority to do BIND PACKAGE to the Endevor alternate user and not everyone that adds in the source? If so, how do I do it? I have tried RTFM, but couldn't really find the answer. We definitely have the Endevor alternate ID defined in C1DEFLTS via RACFUID=<altname>, but it doesn't get used as the user when connecting to DB2.

Dave Harding's profile image
Broadcom Employee Dave Harding

Hi Charles, 

 
Yes-
 
//*********************************************************************
//* PERFORM DB2 BIND 
//*********************************************************************
//DB2BIND  EXEC PGM=IKJEFT01
//STEPLIB  DD DISP=SHR,DSN=&SDSNEXIT
//         DD DISP=SHR,DSN=&SDSNLOAD
//DBRMLIB  DD DSN=&DBRMLIB(&C1ELEMENT),
//            DISP=SHR,ALLOC=LMAP
//SYSTSIN  DD *    SWAP TO ENDEVOR ALTERNATE ID
  EXEC 'NDV.ENDEVOR.CSIQCLS0(SWAP2ALT)'

//         DD DSN=&&BINDCARD,DISP=(OLD,DELETE)
//         DD *    SWAP BACK TO USER'S       ID
  EXEC 'NDV.ENDEVOR.CSIQCLS0(SWAP2USR)'

//SYSTSPRT DD DSN=&&BINDLST,DISP=(OLD,PASS)
//*
Here's SWAP2ALT

/*  REXX  */
/* See CA's  Tech Document
   Document ID:    TEC315509
   Title:  Alternate ID Swapping for DB2 Binds, Under CA Endevor
         Switch to Endevor AltID

   Can be called from either a TSO or non-TSO environment
*/

   STRING = "ALLOC DD(LGNT$$$I) DUMMY REUSE"
   CALL BPXWDYN STRING;
   STRING = "ALLOC DD(LGNT$$$O) DUMMY REUSE"
   CALL BPXWDYN STRING;
  "Execio 0 Diskr LGNT$$$I (Open "   /*  Switch to Endevor AltID */
   STRING = "ALLOC DD(READER)",
              " RECFM(F) BLKSIZE(80) LRECL(80)",
               "SYSOUT(A) WRITER(INTRDR) REUSE " ;
   CALL BPXWDYN STRING;

   Exit

And here's SWAP2USR- 

/*  REXX  */
/* See CA's  Tech Document
   Document ID:    TEC315509
   Title:  Alternate ID Swapping for DB2 Binds, Under CA Endevor
         Switch to User's id

   Can be called from either a TSO or non-TSO environment
*/
  "Execio 0 Diskr LGNT$$$I (Finis"   /*  Switch to User's id */
  "Execio 0 Diskr LGNT$$$O (Open "
  "Execio 0 Diskr LGNT$$$O (Finis"
   STRING = "FREE DD(LGNT$$$I)" ;
   CALL BPXWDYN STRING;
   STRING = "FREE DD(LGNT$$$O)" ;
   CALL BPXWDYN STRING;

   Exit

Guy Derkinderen's profile image
Broadcom Employee Guy Derkinderen

Hello Charles,

ENDEVOR ALTID swapping is done at the TCB level, while the DB2 commands use the address space userid.

To handle this situation, extra logic has to be added to the processor to tell ENDEVOR to set the ALTID at the address space level. This is documented in topic Alternate ID and LGNT$$$I LGNT$$$O.

I hope that this helps.

Guy Derkinderen

Jose Benigno Gonzalez's profile image
Broadcom Employee Jose Benigno Gonzalez
Hi Charles,
By default, all Processor Steps run under the ALTID at least you specify ALTID=N keyword at the STEP definition.
Although the step is executed under the Alternate ID, the creation or deletion of files during the activation of the step is carried out under the security context (user ID) of the user who performs the action in Endevor.
During the execution of a program under Endevor control, you could switch the security context between user ID and Alternate ID using the allocation of special ddnames provided by Endevor: LGNT$$$I and LGNT$$$O. If you wanted to change the step processor to the Alternate ID security context, you would need to execute an open instruction on the LGNT$$$I ddname using the primitives provided by the programming language you used (Cobol: Open, Assembler: Open Macro , c/c++: fopen("dd:LGNT$$$I", "w"), etc.). If you want to return to the user's execution context environment, you must first close the LGNT$$$I ddname using the instruction provided by the programming language and then open the LGNT$$$O ddname following the same procedure described above for LGNT$$$I.
Broadly speaking, the effect caused by opening/closing these special ddnames is the change of the user ID in the field pointed to by ACEEUNAM in the ACEE control block. The address of the ACEE is obtained from the TCBSENV field in the TCB control block of the task.
The ddnames LGNT$$$I and LGNT$$$O could be pre-allocated in the Endevor processor step or allocated dynamically in the program using BPXWDYN  / TSO ALLOC command  /SVC 99 (depending on the language).
Things change a bit when you try to run the LGN$$$I/LGNT$$$0 logic described above under Db2, depending on whether DB2 security is under SAF control. If it is not, DB2 uses the ASXBUSER value of the Address Space Extension Block (ASXB) to determine the security context . If SAF is being used, the value of the user ID field in the ACEE control block pointed to by ASXBSENV field of ASXB is used. The LGN$$$I/LGNT$$$0 mechanism updates both fields. You can find this information in the Endevor documentation on our Broadcom support portal.
Below you will find a REXX template which uses the ddname logic, executing DB2 Command Processor (DSN SYSTEM) and intercepting the output generated by it. BuildBindCard Procedure is not included in the template but the main goal of this procedure is to build the Bind Card according to your standards/needs. Hope this can help:
/*REXX**************************************************************/ 

parse upper arg DB2ssid    

/* "alloc FI(LGNT$$$I) DUMMY REUSE"                                  
"alloc FI(LGNT$$$O) DUMMY REUSE" */                                  
                                                         
call BuildBindCard

queue strip(BindCard)                                                
queue "END"    

/*
    Swap to Alternate User ID
*/
"execio 0 diskw LGNT$$$I (open"                                      
                                                                     
                                                                     
x=outtrap('BindOutput.',,noconcat)                                    
                                                                     
"DSN SYSTEM("DB2ssid")"                                              
db2_rc = rc                                                          
                                                                     
x=outtrap("OFF")                                                      
                                                           
                                                                     
Say ''                                                                
Say 'BINDPKG02I Output generated by the Bind Process:'          
Say ''                                                                
                                                                     
Do i=1 to BindOutput.0                                                
  Say '           'BindOutput.i                                      
End

say ' '                                                              
                                                                     
/*
    Swap to caller User ID
*/
                                                     
"execio 0 diskw LGNT$$$I (finis"                                      
"execio 0 diskw LGNT$$$O (open"                                      
"execio 0 diskw LGNT$$$O (finis"                                      
                                                                     
                                                                     
Select                                                                
                                                                     
  When db2_rc = 0 Then Do                                            
                                                                     
    Say '*******************************************'||,              
        '************'                                                
    say ''                                                            
    say ' B I N D   O K.'                              
    say ''                                                            
    Say '*******************************************'||,              
        '************'                                                
    say ''                                                            
    Say 'BINDPKG01I DB2 Command Processor has executed',          
        'the BIND Command succesfully.'                          
    say ''                                                            
                                                                     
  End /*rc = 0*/                                                      
                                                                     
  When db2_rc > 4 Then Do                                            
                                                                     
    Say '*******************************************'||,              
        '************'                                                
    say ''                                                            
    say ' B I N D   E R R O R'                                  
    say ''                                                            
    Say '*******************************************'||,              
        '************'                                                
    say ''                                                            
    Say 'BINDPKG01E DB2 Command Processor has issued',          
        'an error during BIND Command execution.'                      
    say ''                                                            
                                                                     
  End                                                                
                                                                     
  When db2_rc = 4 Then Do                                            
                                                                     
    Say '*******************************************'||,              
        '************'                                                
    say ''                                                            
    say ' B I N D   W A R N I N G'                              
    say ''                                                            
    Say '*******************************************'||,              
        '************'                                                
    say ''                                                            
                                                                     
                                                                     
  otherwise ;                                                        
                                                                     
End /* Select */                                                      
                                                                     
Return db2_rc                                                        

         

Roberta Jones's profile image
Broadcom Employee Roberta Jones

Hi Charles - You may also want to review this knowledge document! 

https://knowledge.broadcom.com/external/article/9569/alternate-id-swapping-for-db2-binds-unde.html

Jose Benigno Gonzalez's profile image
Broadcom Employee Jose Benigno Gonzalez

Hi Charles,

Take a look to the attachment.

BR,

JB