midrange.com code scratchpad
Name:
FTPEXIT
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
03/10/2011 02:23:13 pm
IP:
Logged
Description:
restrict FTP subcommands from Exit point: QIBM_QTMF_SERVER_REQ Format: VLRQ0100

This program prevents basic users from leaving their home directories & allows developers to change name formats, etc.
Code:
  1.      hoption(*nodebugio:*srcstmt) dftactgrp(*no) actgrp(*caller)
  2.  
  3.      dFTPExit          pr
  4.      d ApplicationID                 10i 0
  5.      d OperationID                   10i 0
  6.      d UserProfile                   10a
  7.      d IPAddress                     15a
  8.      d IPAddressLen                  10i 0
  9.      d OperationInfo                999a    Options(*VarSize)
  10.      d OperationLen                  10i 0
  11.      d AllowOperation                10i 0
  12.  
  13.      dFTPExit          pi
  14.      d ApplicationID                 10i 0
  15.      d OperationID                   10i 0
  16.      d UserProfile                   10a
  17.      d IPAddress                     15a
  18.      d IPAddressLen                  10i 0
  19.      d OperationInfo                999a    Options(*VarSize)
  20.      d OperationLen                  10i 0
  21.      d AllowOperation                10i 0
  22.  
  23.      dHomeDir          s            999a   Varying
  24.  
  25.      dLower            c                   Const('abcdefghijklmnopqrstuvwxyz')
  26.      dUpper            c                   Const('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
  27.  
  28.      dNeverAllow       c                   Const(-1)
  29.      dDontAllow        c                   Const(0)
  30.      dAllow            c                   Const(1)
  31.      dAlwaysAllow      c                   Const(2)
  32.  
  33.      dStartFTP         c                   Const(0)
  34.      dCreateDir        c                   Const(1)
  35.      dDeleteDir        c                   Const(2)
  36.      dChangeDir        c                   Const(3)
  37.      dListDir          c                   Const(4)
  38.      dDeleteFile       c                   Const(5)
  39.      dPutFile          c                   Const(6)
  40.      dGetFile          c                   Const(7)
  41.      dRenameFile       c                   Const(8)
  42.      dCLCmd            c                   Const(9)
  43.  
  44.       /free
  45.  
  46.          Select;
  47.            When ApplicationID = 0;
  48.              ExSR ClientRequest;
  49.  
  50.            When ApplicationID = 1;
  51.              If OperationID = StartFTP;
  52.                AllowOperation = Allow;
  53.                *InLR = *On;
  54.                Return;
  55.              EndIf;
  56.              ExSR ServerRequest;
  57.          EndSl;
  58.  
  59.          *InLR = *On;
  60.          Return;
  61.  
  62.          BegSR ClientRequest;
  63.          EndSR;
  64.  
  65.          BegSR ServerRequest;
  66.            Select;
  67.              When %Subst(UserProfile:1:1) = 'Q';
  68.                AllowOperation = AlwaysAllow;
  69.  
  70.              Other;
  71.                If UserProfile = 'XXXXXXTWH'
  72.                  Or UserProfile = 'XXXXXXJDS'
  73.                  Or UserProfile = 'XXXXXXDBJ'
  74.                  Or UserProfile = 'XXXXXXBOB'
  75.                  Or UserProfile = 'XXXXXXREM'
  76.                  Or UserProfile = 'XXXXXXMLS'
  77.                  Or UserProfile = 'XXXXXXCAT'
  78.                  Or UserProfile = 'XXXXXXJEN';
  79.                  AllowOperation = AlwaysAllow;
  80.                Else;
  81.                  If OperationID = ChangeDir;
  82.                    HomeDir = '/home/' + %Trim(UserProfile);
  83.                    If %Scan(HomeDir:OperationInfo) = 0;
  84.                      AllowOperation = DontAllow;
  85.                    Else;
  86.                      AllowOperation = Allow;
  87.                    EndIf;
  88.                  Else;
  89.                    AllowOperation = Allow;
  90.                  EndIf;
  91.                EndIf;
  92.            EndSl;
  93.          EndSR;
  94.  
© 2004-2019 by midrange.com generated in 0.006s valid xhtml & css