顯示具有 Exit point 標籤的文章。 顯示所有文章
顯示具有 Exit point 標籤的文章。 顯示所有文章

星期一, 11月 27, 2023

AS/400 Journal ODBC Exit Program

Following code from AS/400 Journal ODBC Security

Attach this program to QIBM_QZDA_INIT exit point.?This program handles the ODBC security by rejecting request to users who are not authorized to the ODBC *AUTL.?Make sure you create the ODBC authorization list first.



/*------------------------------------------------------------------*/
/*                                                                  */
/*  System name  . . . :‚  Technical Support                       €*/
/*  Module/Program . . :‚  EXTDBSE                                 €*/
/*  Text . . . . . . . :‚  Exit program for Database Server entry  €*/
/*                                                                  */
/*  Author . . . . . . :‚  Alex Nubla                              €*/
/*  Creation date. . . :‚  10/13/98                                €*/
/*  Description  . . . :   This is the exit point program for       */
/*                         QIBM_QZDA_INIT.                          */
/*                         This program handles the ODBC security   */
/*                         by rejecting requests from users who     */
/*                         are not authorized in ODBC authorization */
/*                         list                                     */
/*                                                                  */
/*------------------------------------------------------------------*/
             pgm        (&Okay         /* 1=Allow; 0=Reject     */   +
                         &Request  )   /* Parameter Structure   */

/*--------------------------------------------------------*/
/*  declaration                                           */
/*--------------------------------------------------------*/
             dcl        &Okay      *char    1
             dcl        &Request   *char   34

             dcl        &User      *char   10
             dcl        &SvrId     *char   10
             dcl        &Format    *char    8
             dcl        &Func      *char    4

/*--------------------------------------------------------*/
/*  error message variables                               */
/*--------------------------------------------------------*/
             dcl        &error     *lgl                   /* std err */
             dcl        &msgid     *char    7             /* std err */
             dcl        &msgkey    *char    4             /* std err */
             dcl        &msgdta    *char  100             /* std err */
             dcl        &msgf      *char   10             /* std err */
             dcl        &msgflib   *char   10             /* std err */
             dcl        &msgtyp    *char   10  '*DIAG'    /* std err */
             dcl        &msgtypctr *char    4 X'00000001' /* std err */
             dcl        &pgmmsgq   *char   10  '*'        /* std err */
             dcl        &stkctr    *char    4 X'00000001' /* std err */
             dcl        &errbytes  *char    4 X'00000000' /* std err */

             monmsg     msgid(cpf0000) exec(goto error)

             chgvar     &User      %sst(&Request    1   10)
             chgvar     &SvrId     %sst(&Request   11   10)
             chgvar     &Format    %sst(&Request   21    8)
             chgvar     &Func      %sst(&Request   28    4)

/*--------------------------------------------------------*/
/*  Check if user has *USE authority to ODBC              */
/*--------------------------------------------------------*/
             chgvar     &Okay      '1'

             addlible   techlib    *last
             monmsg     cpf0000

             chkaut     user(&User)         +
                         obj(ODBC)          +
                         objtype(*AUTL)     +
                         aut(*USE)
             monmsg     cpf9802             exec(do)
               chgvar     &Okay      '0'
             enddo

             Goto       End

/*--------------------------------------------------------*/
/*  error routine:                                        */
/*--------------------------------------------------------*/
 error:
             if         &error     (goto errordone)
               else      chgvar       &error  '1'
          /*----------------------------------------------*/
          /*  move all *DIAG message to *PRV program queue*/
          /*----------------------------------------------*/
             call       QMHMOVPM   (&msgkey      +
                                    &msgtyp      +
                                    &msgtypctr   +
                                    &pgmmsgq     +
                                    &stkctr      +
                                    &errbytes)
          /*----------------------------------------------*/
          /*  resend the last *ESCAPE message             */
          /*----------------------------------------------*/
 errordone:
             call       QMHRSNEM   (&msgkey      +
                                    &errbytes)
             monmsg     cpf0000    exec(do)
               sndpgmmsg  msgid(cpf3cf2) msgf(QCFPMSG) +
                            msgdta('QMHRSNEM') msgtype(*escape)
               monmsg     cpf0000
             enddo
 end:        endpgm




星期四, 11月 02, 2023

2002-12-09 如何限制使用 PWRDWNSYS 關機指令, 防止不小心執行關機動作?


如何限制使用 PWRDWNSYS 關機指令, 防止不小心執行關機動作?

PWRDWNSYS 關機指令的系統預設權限如下:

                             Edit Object Authority                             
                                                                               
 Object . . . . . . . :   PWRDWNSYS       Owner  . . . . . . . :   QSYS        
   Library  . . . . . :     QSYS          Primary group  . . . :   *NONE       
 Object type  . . . . :   *CMD            ASP device . . . . . :   *SYSBAS     
                                                                               
 Type changes to current authorities, press Enter.                             
                                                                               
   Object secured by authorization list  . . . . . . . . . . . .   *NONE       
                                                                               
                          Object                                               
 User        Group       Authority                                             
 QSYS                    *ALL                                                  
 QSYSOPR                 *USE                                                  
 *PUBLIC                 *EXCLUDE                                              
由上述畫面可知 QSYSOPR 有使用權限, 但公共權限為 *EXCLUDE 亦即非指定使用者是無
法使用的, 所以此 PWRDWNSYS 的使用權限需要針對單一使用者個別授權才能使用, 你可
以使用 EDTOBJAUT 指令授權某些人可以使用, 但仍然會有被授權使用者使用者不小心下
了 PWRDWNSYS 指令, 如輸入 PWRDWNSYS 直接按 Enter 執行鍵或按 F4 鍵欲檢視 PWRDWNSYS 
指令的參數, 欲取消參數畫面需按 F3 或 F12 鍵, 有可能疏忽而按了 Enter 執行鍵, 
此指令一執行是無法取消的,所以要非常謹慎, 所以系統也提供一個程序檢核點(Exit Point) QIBM_QWC_PWRDWNSYS,
作為在關機前的準備動作檢查, 每個應用系統有可能需要在關機前作某些清除動作, 讓應
用系統能正常終止, 以防止下次開機時無法啟動, 所以系統提供此程序檢核點(Exit Point) 
QIBM_QWC_PWRDWNSYS, 讓系統管理人員能進一步確認整個關機的步驟, 我們可以利用此程序檢核點(Exit Point) QIBM_QWC_PWRDWNSYS,
連結程序檢核程式(Exit Program), 來作為是否執行關機動作的再次確認. 
此範例程式是將關機訊息送至 QSYSOPR 訊息佇列, 若 QSYSOPR 回應 'G' or 'g' 時, 
系統執行關機動作, 若回應其他訊息, 則系統不會執行此關機動作, 但此訊息會一直留在
QSYSOPR 訊息佇列等待回應正確的回應值 'G', 你可以在 DSPMSG QSYSOPR 畫面按 F11 
清除此訊息. 此種方式是系統管理上需要防止不正常關機的最佳方式.



File  : QCLSRC
Member: PWRDWNSYSC
Type  : CLP
Version : V5R1  以後(因 V5R1 才提供 程序檢核點(Exit Point) QIBM_QWC_PWRDWNSYS)
Usage : CRTCLPGM PWRDWNSYS


PGM                                                                    
DCL        VAR(&REPLY) TYPE(*CHAR) LEN(1)                              
SNDUSRMSG  MSGID(CPF9898) MSGF(QCPFMSG) +                              
             MSGDTA('PWRDWNSYS will be processed as +                  
             soon as you respond to this message.  +                   
             Enter G to continue.') VALUES('G') +                      
             TOUSR(QSYSOPR) MSGRPY(&REPLY)                             
ENDPGM                                                                 

設定方式 :
ADDEXITPGM EXITPNT(QIBM_QWC_PWRDWNSYS) FORMAT(PWRD0100) PGMNBR(1)
           PGM(your-library-name/PWRDWNSYSC)    */   



2002-11-25 如何於 AS/400(iSeries) SEU 中的 comment line 加上顏色 ?


如何於 AS/400(iSeries) SEU 中的 comment line 加上顏色 ?

要於 AS/400(iSeries) SEU 中的 comment line 加上顏色, 可以利用 Client Access 的鍵盤設定鍵盤組合(可以從 http://www.geocities.com/vengoal/
中的 每週小錦囊 中取得), 但若連線程式不是 Client Access 時要如何做呢?系統提
供一個 exit point QIBM_QSU_LCMD 聯結處理程式即可達到 comment line 上色的目的.處理程式如下,但只限於 RPG 及 RPGLE 有效:

編譯完成後執行下述指令:

ADDEXITPGM EXITPNT(QIBM_QSU_LCMD) FORMAT(EXTP0100) PGMNBR(*LOW)
PGM(yourlib/SEUCOLOR)                                                  
SignOff 後, 從新SignOn 進入 SEU 編輯 RPG 或 RPGLE source, 將游標移至編輯區(游標要在程式碼編輯區), 
按 F7 或 F8,就可以變色了.


File  : QRPGLESRC
Member: SEUSOLOR
Type  : RPGLE
Usage : CRTBNDRPG yourlib/SEUCOLOR
Version: V3


      *
      * Header information
      *
     D HeaderInfo      DS                  BASED(Parm1)
     D  RecLength              1      4B 0
     D  CursorRRN              5      8B 0
     D  CursorPos              9     12B 0
     D  CCSID                 13     16B 0
     D  Records               17     20B 0
     D  MemberName            21     30
     D  FileName              31     40
     D  LibraryName           41     50
     D  MemberType            51     60
     D  CmdKey                61     61
     D  Mode                  62     62
     D  SplitSess             63     63
     D  Res                   64     64
      *
      * Return Codes
      *
     DReturnInfo       DS                  BASED(Parm2)
     D RetCode                 1      1
     D Res2                    2      4
     D OutRecs                 5      8B 0
     D InsertSequence          9     15
     D Res3                   16     37
      *
      * Line Command and Text
      *
     D LinInfomation   DS                  BASED(Parm3)
     D  Command1               1      7
     D  Return1                8     20
     D  Text1                 21    100
     D  Command2             101    107
     D  Reutrn2              108    120
     D  Text2                121    200
      *
      * Entry Parameters declarations
      *
     D Parm1           S               *
     D Parm2           S               *
     D Parm3           S               *
      *
     C     *Entry        Plist
     C                   Parm                    Parm1
     C                   Parm                    Parm2
     C                   Parm                    Parm3
      *
     C                   Exsr      DoProcess
     C                   Seton                                        LrRt
      **********************************************************************
     C     DoProcess     BEGSR
      *    ===================
     C                   Select
      *
      * When F7 is used
      *
     C                   When      CmdKey='7' and CurSorPos<>0
      * Get Line1 Text and change color to White
     C                   Eval      %Subst(Text1:6:2)=X'22'+'*'
      * Show that data was changed
     C                   Exsr      #UpInf
      *
      * When F8 is used
      *
     C                   When      Cmdkey='8' and CursorPos<>0
      * Change Color to Blue
     C                   Eval      %Subst(Text1:6:2)=X'3a'+'*'
      * Show that data was changed
     C                   Exsr      #UpInf
     C                   EndSl
      *
     C                   EndSr
      *=====================================================================
      * Return codes set to update
      *=====================================================================
     C     #UpInf        BegSr
      *    ===================
     C                   Eval      OutRecs=1
     C                   Eval      Retcode='0'
     C                   EndSr