home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Spezial / SPEZIAL2_97.zip / SPEZIAL2_97.iso / ANWEND / ONLINE / SREFPRC1 / SPECIAL.SRF < prev    next >
Text File  |  1997-03-02  |  4KB  |  124 lines

  1. /*-----------------------------------------------*/
  2. /* Do special requests: return 0 if okay, 1 if bad  */
  3. /*-----------------------------------------------*/
  4. sref_special_request:
  5. parse arg sel0,privset,the_realm,os2e,enmadd,tempfile
  6.  
  7.  parse var sel0 sel '?' args  /* there may be some arguments */
  8.  sel=translate(sel)
  9.  amessage="Special request processed: "||sel0
  10.  
  11.  select
  12.     when sel='!PING'  then do
  13.        'STRING Ping!'
  14.         return amessage
  15.      end
  16.      when sel='!STATISTICS' then  do
  17.       'CONTROL STATISTICS'
  18.         return amessage
  19.     end
  20.  
  21.     when left(sel,5)='!HOST' then do
  22.        if args<> " " then sel="!HOST?"||args
  23.        foo=rxqueue('s','session')
  24.        sel=translate(sel,' ','?+&')
  25.        sel=word(sel,2)
  26.        sref_host(sel) /* a ping */
  27.        return amessage
  28.     end
  29.     when sel="!SAVE" | sel="!RESET" |  abbrev(sel,"!VARIABLE")=1 ,
  30.         | sel='!WRITE_CACHE'  then do
  31. /* see if have proper privs. If not, reask username (so, only return if valid */
  32.       a=check_privs2(privset,'SUPERUSER CONTROL',1,the_realm)
  33.       select
  34.         when sel='!SAVE'       then do
  35.            'CONTROL MOVEAUDIT'
  36.             return amessage
  37.          end
  38.          when sel='!RESET'   then do
  39.             foo=value('SREF_REDO',1,'os2environment')
  40.             if abbrev(upper(args),"PARAM")=0 then 'CONTROL RESET ALL'
  41.             return amessage
  42.         end
  43.         when abbrev(sel,'!VARIABLE')=1   then do
  44.              dog=show_env_vars(args)  /* call as routine-- needs globals */
  45.              dog
  46.              return amessage
  47.          end
  48.          when sel='!WRITE_CACHE' then do
  49.             'STRING  The caches for the RECORD_ALL_FILE, and common-log file,  have been written to disk'
  50.             return amessage
  51.          end
  52.  
  53.          otherwise do
  54.              amessage='Unknown special request:'||sel0
  55.              return amessage
  56.          end
  57.        end
  58.     end
  59.     otherwise  do
  60.        amessage='Unknown special request:'||sel0
  61.        return amessage
  62.     end
  63.  
  64.  end                 /*select */
  65.  
  66. /* ----------------------------------------------------------------------- */
  67. /* SHOWVARS: Show values of listed variables (extract from environment)   */
  68. /* ----------------------------------------------------------------------- */
  69.  
  70. show_env_vars:procedure expose enmadd os2e tempfile
  71. parse arg alist
  72.   call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  73.  
  74.   call lineout tempfile, "<html><head><title> SRE-FILTER variables </title>"
  75.   call lineout tempfile, "</head>"
  76.   call lineout tempfile, "<body><h2>Values of selected environment variables</h2>"
  77.   call lineout tempfile,' <pre>'
  78.   do forever
  79.       parse var alist repargn '&' alist
  80.       if pos('=',repargn)>0 then parse var repargn . '=' repargn
  81.       putme=value(enmadd||repargn,,os2e)
  82.       if putme=" " then putme='n.a.'
  83.       putme=sref_replacestrg(putme,'<','<','ALL')
  84.       putme=sref_replacestrg(putme,'>','>','ALL')
  85.       call lineout tempfile, repargn '    =     '  putme
  86.       if alist="" then leave
  87.   end
  88.   call lineout tempfile,' </pre>'
  89.  
  90.  
  91.   call lineout tempfile, ' </body> </html> '
  92.   call lineout tempfile
  93.   return  ' FILE ERASE TYPE text/html NAME ' tempfile
  94.  
  95. /*--------------------------------------------------*/
  96. /* check user privileges (privset) against a url specific privilege list (aprivs)
  97. if one of them matches, return >0 value
  98. if no match, and reask=1, the query client for new username,etc.*/
  99. /* ----------------------------------------------- */
  100.  
  101. check_privs2: procedure
  102. parse upper arg privset , aprivs , reask , the_realm
  103. select
  104.     when wordpos('NO',aprivs)>0 then do
  105.         return 0
  106.     end
  107.     when aprivs="" | wordpos('*',aprivs)>0 | wordpos('YES',aprivs)>0 then do
  108.         return 1
  109.     end
  110.     otherwise do
  111.        do mm=1 to words(aprivs)
  112.           if wordpos(word(aprivs,mm),privset)>0 then do
  113.                return mm
  114.           end
  115.       end  
  116.     end
  117.  end    /* select */
  118.  
  119. /* if here, failure , so signal caller to ask authorization */
  120. exit -1
  121.  
  122.  
  123.  
  124.