home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / srev13g.zip / ACCESCFG.CMD next >
OS/2 REXX Batch file  |  1999-06-27  |  36KB  |  838 lines

  1. /*  */
  2. accescfg:
  3.  
  4. CHECKIT=0   /* Change this to 0 if you want to enable REMOTE configuration by SUPERUSERS */
  5.  
  6. /* background color */
  7. USECOLOR='2dd52f'
  8.  
  9. /* ---------------- DO NOT MODIFY BELOW THIS LINE  ------------------ */
  10.  
  11. parse arg  ddir, tempfile, sel,list,verb ,uri,user, ,
  12.           basedir ,workdir,privset,enmadd,transaction,verbose, ,
  13.          servername,host_nickname,homedir,aparam,semqueue,prog_file,reqnum
  14.  
  15.  
  16. /* parse arg ddir,tempfile,sel,list,verb,uri,user,basedir,workdir,privset,enmadd,transaction,verbose */
  17.  
  18. list=translate(list, ' ', '+'||'090a0d'x)  /* Whitespace, etc. */
  19. crlf='0d0a'x
  20.  
  21. if verb="" then do
  22.    say " This SRE-http add-on is NOT meant to be run from the command line."
  23.    say " It can be invoked by using CONFIGUR.HTM "
  24.    exit
  25. end  /* Do */
  26.  
  27.  
  28.  
  29. who2=extract('CLIENTADDR')
  30. saddr2=extract('SERVERADDR')
  31.  
  32. NO_REM=VALUE('SREF_NO_REMOTE_CONFIG',,'OS2ENVIRONMENT')
  33.  
  34.  
  35. select
  36.    when checkit=1 | no_rem> 0 then do
  37.  
  38. /* only if user = serveraddress !!! */
  39.      if who2<>saddr2 | no_rem=2 then do
  40.  
  41.         call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  42.         call lineout tempfile, "<html><head><title>SRE-http  remote configurator disabled </title>"
  43.         call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'"> '
  44.  
  45.         call lineout tempfile,' <strong> Action not allowed remotely.</strong> <pre>'
  46.         call lineout tempfile,' </body> </html> '
  47.         call lineout tempfile
  48.         foo=sref_gos('FILE ERASE TYPE text/html NAME' tempfile)
  49.         return 'ACCESCFG: action not allowed remotely. '
  50.      end
  51.    end
  52.    otherwise do
  53.       if wordpos('SUPERUSER',privset)=0 then do
  54.         'RESPONSE HTTP/1.1 401 Unauthorized '     /* Set HTTP response line */
  55.          att=sref_gmt()
  56.         'HEADER Noauto ADD Date: 'att
  57.  
  58.         'header add WWW-Authenticate: Basic Realm=<CONFIGURE>'  /* challenge */
  59.  
  60.         call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  61.         call lineout tempfile, "<html><head><title>Not authorized </title>"
  62.         call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'"> '
  63.  
  64.  
  65.         call lineout tempfile,' <strong> You do not have configuration rights.</strong> <pre>'
  66.         if who2=saddr2 then 
  67.                 call lineout tempfile,'<br> <Em> You may want to edit ACCESCFG.CMD </em> '
  68.         call lineout tempfile,' </body> </html> '
  69.         call lineout tempfile
  70.          iia=dosdir(tempfile,'s')
  71.  
  72.         'FILE ERASE TYPE text/html NAME' tempfile
  73.         return '401 'iia' ACCESCFG: not permitted to configure. '
  74.       end
  75.    end
  76. end
  77.  
  78. list=strip(list)
  79. select 
  80.    when upper(list)='TODO=SHOW' | upper(list)='TODO=SHOW_HEADER' then
  81.         signal doshow
  82.  
  83.    when upper(list)='TODO=CURRENT' then
  84.         signal showcurrent
  85.  
  86.  
  87.    when upper(list)='TODO=SET' then
  88.         signal doset
  89.    otherwise
  90.         signal dochange
  91. end  /* select */
  92.  
  93.  
  94. /* jump here to show values */
  95. doshow:
  96.  
  97.  
  98. accessfile=value(enmadd||'ACCESS_FILE',,'os2environment')
  99.    call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  100.    call lineout tempfile, "<html><head><title>SRE-http: SEL-Specific access control </title>"
  101.    call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'"> '
  102.  
  103.  
  104. aa=sref_fileread(accessfile,'lins',,'E')
  105. foo=do_extends(1)
  106.  
  107. call lineout tempfile, "<h1> SRE-http:  SEL-Specific access control  </h1> <p>"
  108. if upper(list)='TODO=SHOW' then
  109.   call lineout tempfile, "<h2> List of "header" comments </h2> <pre> <blockquote>"
  110. else
  111.   call lineout tempfile, "<h3> Brief descripton  </h3> <pre> <blockquote>"
  112.  
  113. /* show "header comments" */
  114. iat=0
  115. do until iat >= lins.0
  116.    iat=iat+1
  117.    if  abbrev(strip(lins.iat),';')  then do
  118.         foo=strip(lins.iat) ;foo=strip(foo,'l',';')
  119.          call lineout tempfile, foo 
  120.    end  /* Do */
  121.    else do
  122.         leave
  123.    end
  124. end /* do -- iat is the first non header comment line  */
  125. call lineout tempfile, '</blockquote></pre> '
  126.  
  127. /* view descriptive header only? */
  128. if upper(list)='TODO=SHOW_HEADER' then do
  129.    call lineout tempfile,' <hr> </body></html>'
  130.    call lineout tempfile
  131.    'file erase  type text/html name  ' tempfile
  132.    return ' done '
  133. end  /* Do */
  134.  
  135.  
  136.  
  137. /* read in usernames, etc */
  138. nusers=0
  139. call lineout tempfile, '<hr> <h2> A List of selector specific access controls </h2> '
  140. call lineout tempfile,' Notes: <ul> '
  141. call lineout tempfile,' <li> SEL-specific access controls are stored in: ' accessfile
  142. call lineout tempfile,' <li> <em>Comments are in italics </em> '
  143. call lineout tempfile,' <li> In <b>Candiate SEL:</b> The <strong>*</strong> character is used as a wildcard (for an arbitrarily long string)'
  144. call lineout tempfile, ' <li> Entries with no <strong>Host Nickname</strong> apply to all requests'
  145. call lineout tempfile,' <li> The <strong>Realm</strong> is sent to the client (when responding to UnAuthorized requests),'
  146. call lineout tempfile,'  and as a shorthand for a <EM>set of resource privileges</EM>'
  147. call lineout tempfile,' <li> The <em>optional</em> <strong> Failure File</strong> is used when responding to <code>Unauthorized</code> requests <br>'
  148. call lineout tempfile,' <li> The <em>optional </em> <b> ADV_OPTS</b> (advanced options</u>) is used to specify additional <em>request selector </em> options '
  149. call lineout tempfile,' <LI>In the <STRONG>Resource Privileges</STRONG> list: <menu> <li><STRONG> *</STRONG> :  <em>any privilege will do</em> '
  150. call lineout tempfile,' <LI><STRONG> NO</STRONG> : No accesss (SUPERUSERS and In-House users only!)  </menu> </ul> '
  151. call lineout tempfile,' <table border=1> <th> Host Nickname </th>'
  152. call lineout tempfile,' <th> Candidate SEL or <br> Realm Name </u> </th>'
  153. call lineout tempfile,'  <th> Resource Privileges  </th>'
  154. call lineout tempfile,'  <th> Permissions list ......</th> <th> Realm </th> <th>Failure File  </th><th> Adv_opts File</th> <tr>'
  155.  
  156. do mm=iat to lins.0
  157.   if lins.mm=' ' then iterate
  158.   stlin=upper(strip(lins.mm))
  159.   if  abbrev(stlin,';')=1 then do
  160.        call lineout tempfile,'<td colspan=5>  <code>     </code> <em>' strip(strip(lins.mm),'l',';') '</em></td> <tr> '
  161.   end
  162.   else do
  163.       if abbrev(stlin,'!REALM')=1  then do
  164.          parse var stlin foo candurl accpriv
  165.          call lineout tempfile,'<td colspan=2>  ......... <em> Realm name: </em> <STRONG> ' candurl '</STRONG> </td>'
  166.          call lineout tempfile,'<td colspan=4>    <STRONG> 'accpriv '</STRONG> </td> <tr>'
  167.       end
  168.       else do
  169.         if pos('// ',lins.mm)>0 then do
  170.            parse var stlin hostname '//' candurl accpriv ',' permissions ',' realm ',' fail_file ',' adv_opts
  171.         end
  172.         else do
  173.            hostname=' .. '
  174.            parse var stlin candurl accpriv ',' permissions ',' realm ',' fail_file ',' adv_opts
  175.         end  /* Do */
  176.        IF ACCPRIV=' ' THEN ACCPRIV='*'
  177.        IF PERMISSIONS=' ' THEN PERMISSIONS='..'
  178.        IF REALM=' ' THEN REALM='..'
  179.        if fail_file=' ' then fail_file='..'
  180.        if adv_opts=' ' then adv_opts='..'
  181.        call lineout tempfile,'<td>     <STRONG>  'hostname '</STRONG> </td>'
  182.        call lineout tempfile,'<td>    <STRONG> ' candurl '</STRONG> </td>'
  183.        call lineout tempfile,'<td>    <STRONG> 'accpriv '</STRONG> </td>'
  184.        call lineout tempfile,'<td>    <STRONG> 'permissions ' </STRONG></td> '
  185.        call lineout tempfile,'<td>    <STRONG> 'realm'  </STRONG></td> '
  186.        call lineout tempfile,'<td>    <STRONG> ' fail_file'  </STRONG> </td> '
  187.        call lineout tempfile,'<td>    <STRONG> ' adv_opts'  </STRONG></td> <tr>'
  188.  
  189.  
  190.     end /* do  urls */
  191.   end           /* non comment line */
  192.  
  193. end /* mm */
  194. call lineout tempfile,' </table>'
  195.  
  196. call lineout tempfile,'<hr><h3> Definitions of the Permissions </h3>'
  197. foo=show_permissions()
  198.  
  199.  
  200.  
  201. call lineout tempfile,' <hr> Thanks for checking </body></html>'
  202.  
  203. call lineout tempfile
  204.  
  205. 'file erase  type text/html name  ' tempfile
  206. return ' done '
  207.  
  208.  
  209. /* jump here if "set values" chosen */
  210. showcurrent:
  211. foo=wait_queue('ACCESS')
  212. call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  213. call lineout tempfile, "<html><head><title>SRE-http: list of access controls </title>"
  214. call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'">'
  215.  
  216. call lineout tempfile, '<h2>List of SRE-http ACCESS controls  </h2>'
  217. call lineout tempfile,' This complete list of ACCESS controls includes entries in default and host specific copies '
  218. call lineout tempfile,' of ACCESS.IN and ATTRIBS.CFG <hr width="30%">'
  219. call lineout tempfile,'<table border=1>'
  220. call lineout tempfile,'<tr><th> Host <th><u>Realm</u> <br>& Selector ',
  221.                     '<th>Privileges '
  222. call lineout tempfile,'<th>Failure<th> Permissions <TH> <u>AdvOptFile</u> <br>& Options '
  223.  
  224. do forever
  225.   if foo='' then leave
  226.   parse var foo aline (crlf) foo
  227.   parse var aline ah '//' aurl ','aprivs ','stf ';'aperm
  228.   parse var stf  arealm ',' afail ','aadv ',' OPTLIST
  229.   oolist=''
  230.   do forever
  231.       if optlist='' then leave
  232.       parse var optlist abo '|#|' optlist
  233.       oolist=abo'<br>'oolist
  234.   end /* do */
  235.   call lineout tempfile,'<tr><td> 'ah '<td><u>'arealm'</u><br>' aurl '<td> 'aprivs
  236.   call lineout tempfile,'<td> 'afail'<td> 'aperm '<TD><u>'aadv'</u><BR>'OoLIST
  237. end
  238. call lineout tempfile,'</table></body></html>'
  239. call lineout tempfile
  240. foo=sref_gos('file erase  type text/html name  ' tempfile)
  241. return foo
  242.  
  243.  
  244. /* jump here if "set values" chosen */
  245. doset:
  246. accessfile=value(enmadd||'access_FILE',,'os2environment')
  247. aa=sref_fileread(accessfile,'lins',,'E')
  248. foo=do_extends(1)
  249.  
  250. call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  251. call lineout tempfile, "<html><head><title>SRE-http: modify  SEL-specific access controls </title>"
  252.  call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'"> '
  253. call lineout tempfile,'<!--  a button bar. --> 'crlf ,
  254.            '<a href="/configur.htm">Configurator</a>||' crlf ,
  255.            '<a href="/config2?todo=SET">Parameters</a>||' crlf ,
  256.            '<a href="/usercfg?todo=SET">Usernames</a>||'  crlf ,
  257.            '<a href="/realmcfg?todo=SET">Define-Realms</a>||'||crlf ,
  258.            '<a href="/accescfg?todo=SET">Access-Controls||'  crlf ,
  259.            '<a href="/aliascfg?todo=SET">Aliases</a>||'  crlf ,
  260.            '<a href="/virtcfg?todo=SET">VirtualDir</a><p>'  
  261.  
  262.  
  263.  
  264. /* ignore header stuff */
  265. iat=0
  266. do until iat >= lins.0
  267.    iat=iat+1
  268.    if  abbrev(strip(lins.iat),';') | lins.iat=' ' then iterate
  269.    leave
  270. end /* do -- iat is the first non header comment line  */
  271. call lineout tempfile, "<h1> SRE-http: modify <A NAME="top">SEL-specific access controls</A>  </h1> <p>"
  272. call lineout tempfile,' <blockquote> You can modify, remove, or add SEL-specific access controls and realm definitions.'
  273. call lineout tempfile,' <br><em> Questions? <A HREF="#notes">The notes might help.</A> </em> </blockquote> '
  274. call lineout tempfile,' <h2> Modify or remove SEL-specific access controls </h2>'
  275. call lineout tempfile,'  Note that the input fields are wider then the displayed area. '
  276. call lineout tempfile,'<FORM ACTION="/accescfg" METHOD="POST">'
  277. call lineout tempfile,' <table border=1> <th> Host Nickname  <br> (see below  for a <br>listing of <A HREF="#hosts">current hosts</A>) </th>'
  278. call lineout tempfile,' <th> Candidate SEL  <br> (set to blank to  <br> delete the entry)</th>'
  279. call lineout tempfile,'  <th> Resource privileges <br>  (a space delimited list) </th>'
  280. call lineout tempfile,' <th nowrap> Permissions list............</th> '
  281. call lineout tempfile,'  <th nowrap>Realm, <br> Failure File, <br>  Advanced options File</th> <tr>'
  282.  
  283. nhidden=0 ; mm=0 ; nrealms=0
  284. do mm0=iat to lins.0
  285.     alin=strip(translate(lins.mm0,' ','1a000d0a'x))
  286.     mm=mm+1
  287.  
  288. /* non comment */
  289.     select
  290.       when  abbrev(alin,';')=1 | alin=' ' then do /* comment */
  291.          nhidden=nhidden+1
  292.          alin=sref_replacestrg(alin,'"','"','ALL')
  293.          hiddens.nhidden='<INPUT TYPE="HIDDEN" name="COMMENT.'||mm||'"  value="'||alin||'" >'
  294.          iterate
  295.        end
  296.        when abbrev(alin,'!REALM') then do       /* realm definition */
  297.           parse var alin foo1 realmname accprivs
  298.           nrealms=nrealms+1
  299.           realmvs.therealmname.nrealms=realmname
  300.           realmvs.theaccprivs.nrealms=accprivs
  301.           realmvs.themm.nrealms=mm
  302.           iterate
  303.        end
  304.        when pos('// ',alin)>0 then do   /* host specific entry */
  305.              parse var alin hostname '//' candurl accprivs ',' permlist ',' realm ',' fail_file ',' adv_opts
  306.        end
  307.        otherwise do                     /* generic entry */
  308.              hostname='  '
  309.              parse var alin  candurl accprivs ',' permlist ',' realm ',' fail_file ',' adv_opts
  310.        end
  311.      end  /* Do */
  312.  
  313.      accprivs2="";atmp="";crlf='0d0a'x
  314.      do iww1=1 to words(accprivs)
  315.         if atmp="" then 
  316.            atmp=strip(word(accprivs,iww1))
  317.         else
  318.            atmp=atmp' 'strip(word(accprivs,iww1))
  319.         if length(atmp)>14 then do
  320.              if accprivs2='' then
  321.                 accprivs2=atmp
  322.              else
  323.                 accprivs2=accprivs2||crlf||atmp
  324.              atmp=''
  325.         end  /* Do */
  326.      end /* do */
  327.      accprivs2=accprivs2||crlf||atmp
  328.  
  329.      call lineout tempfile,'<td> <EM>Host nickname:</EM> <br> <INPUT TYPE="text" NAME="hostname.'||mm||'"'
  330.      call lineout tempfile,'value="'hostname'" SIZE=8 MAXLENGTH=95> </td> '
  331.      call lineout tempfile,'<td> <EM>Candidate SEL:</EM> <br> <INPUT TYPE="text" NAME="candurl.'||mm||'"'
  332.      call lineout tempfile,'value="'candurl'" SIZE=20 MAXLENGTH=95> </td> '
  333.      call lineout tempfile,'<td> <EM>Resource privileges:</EM> <br>'
  334.      call lineout tempfile,' <TEXTAREA NAME="accprivs.'||mm||'" rows=3 cols=22 >'
  335.      call lineout tempfile,accprivs2||'</textarea>  </td> '
  336.      cacheok=0  ;   yes_ssi=0;   NO_SSI=0  ;     NO_SSP=0 ;no_code=0
  337.      ADELETE=0 ;     APUT=0
  338.      NO_VIRTUAL=0 ;     NO_ALIAS=0  ;     NO_POSTFILTER=0
  339.      no_htaccess=0
  340.  
  341.      IF wordpos('CACHE',upper(permlist))>0 then            CACHEOK=1
  342.      IF wordpos('CACHE*',upper(permlist))>0 then            CACHEOK=2
  343.      IF wordpos('NOCACHE',upper(permlist))>0 then            CACHEOK=0
  344.  
  345.      if wordpos('NO_SSI',upper(permlist))>0 then            NO_SSI=1
  346.      if wordpos('YES_SSI',upper(permlist))>0 then           YES_SSI=1
  347.  
  348.      if wordpos('NO_SSP',upper(permlist))>0 then            NO_SSP=1
  349.      if wordpos('NO_CODE',upper(permlist))>0 then            NO_CODE=1
  350.      if wordpos('DELETE',upper(permlist))>0 then            ADELETE=1
  351.      if wordpos('PUT',upper(permlist))>0 then              APUT=1
  352.      if wordpos('NO_HTACCESS',upper(permlist))>0 then         NO_htaccess=1
  353.      if wordpos('NO_VIRTUAL',upper(permlist))>0 then         NO_VIRTUAL=1
  354.      if wordpos('NO_ALIAS',upper(permlist))>0 then          NO_ALIAS=1
  355.      if wordpos('NO_POSTFILTER',upper(permlist))>0 then      NO_POSTFILTER=1
  356.  
  357. /*say mm cacheok no_ssi yes_ssi no_code no_ssp adelete aput no_virtual no_alias no_postfilter no_htaccess */
  358.  
  359.     call lineout tempfile,' <td>'
  360.     coka=0
  361.     if cacheok>0 then coka=1 
  362.     a=MAKECHECK('Cache?','CACHE',MM,coka)
  363.     coka=0
  364.  
  365.     if cacheok>1 then coka=1 
  366.     a=MAKECHECK('Cache*?)','CACHE*',MM,coka)
  367.     call lineout tempfile,' <br>'
  368.  
  369.     if cacheok=0 then coka=1 
  370.     a=MAKECHECK('NoCache?)','NOCACHE',MM,coka)
  371.     call lineout tempfile,' <br>'
  372.  
  373.     a=makecheck('No SSI? ', 'NO_SSI',mm,no_ssi)
  374.     call lineout tempfile,'  | '
  375.     a=makecheck('YES SSI?', 'YES_SSI',mm,yes_ssi)
  376.     call lineout tempfile,' <br> '
  377.  
  378.     a=makecheck('No SSP ', 'NO_SSP',mm,no_ssp)
  379.     call lineout tempfile,' <br>'
  380.     a=makecheck('No CODE ', 'NO_CODE',mm,no_code)
  381.     call lineout tempfile,' <br>'
  382.     a=makecheck('DELETE?   ', 'DELETE',mm,adelete)
  383.     call lineout tempfile,' |'
  384.     a=makecheck('PUT? ', 'PUT',mm,aput)
  385.     call lineout tempfile,' <br> '
  386.     a=makecheck('No HTACCESS?  ', 'NO_HTACCESS',mm,no_htaccess)
  387.     call lineout tempfile,' <br>'
  388.     a=makecheck('No Virtual?  ', 'NO_VIRTUAL',mm,no_virtual)
  389.     call lineout tempfile,' <br>'
  390.     a=makecheck('No Alias? ', 'NO_ALIAS',mm,no_alias)
  391.     call lineout tempfile,' <br>'
  392.     a=makecheck('No Postfilter? ', 'NO_POSTFILTER',mm,no_postfilter)
  393.     call lineout tempfile,' </td>'
  394.  
  395.      realm=strip(realm); fail_file=strip(fail_file) ;adv_opts=strip(adv_opts)
  396.      call lineout tempfile,'<td> <em>Realm: </em><br> <INPUT TYPE="text" NAME="realm.'||mm||'"'
  397.      call lineout tempfile,'value="'realm'" SIZE=15 MAXLENGTH=95>   '
  398.      call lineout tempfile,'<br> <em>Failure File: </em><br> <INPUT TYPE="text" NAME="fail_file.'||mm||'"'
  399.      call lineout tempfile,'value="'fail_file'" SIZE=15 MAXLENGTH=95> <br> '
  400.      call lineout tempfile,'<br> <em>Adv_opts File: </em><br> <INPUT TYPE="text" NAME="adv_opts.'||mm||'"'
  401.      call lineout tempfile,'value="'adv_opts'" SIZE=15 MAXLENGTH=35> <br>'
  402.  
  403.      call lineout tempfile,' </td> '
  404.  
  405.      if mm0<lins.0 then do
  406.            call lineout tempfile,'<tr>' ; call lineout tempfile,' '
  407.      end
  408. end
  409. call lineout tempfile,' </table>' ; call lineout tempfile,' '
  410.  
  411. if nrealms>0 then do
  412.   call lineout tempfile,' '; call lineout tempfile,'<p><h2> Modify/delete Realms </h2>'
  413.   call lineout tempfile,' <table border=1> '
  414.   call lineout tempfile,' <th> Realm name <br> (set to blank to   delete <br> the entry)</th>'
  415.   call lineout tempfile,'  <th> Realm-specific resource privileges list </th> <tr>'
  416.   do jh=1 to nrealms
  417.      call lineout tempfile,'<td> <EM>Realm name:</EM> <br> <INPUT TYPE="text" NAME="realmname.'||realmvs.themm.jh||'"'
  418.      call lineout tempfile,'value="'realmvs.therealmname.jh'" SIZE=8 MAXLENGTH=95> </td> '
  419.      call lineout tempfile,'<td> <EM>Resource privileges:</EM> <br> <INPUT TYPE="text" NAME="accprivs.'||realmvs.themm.jh||'"'
  420.      call lineout tempfile,'value="'realmvs.theaccprivs.jh'" SIZE=40 MAXLENGTH=95> </td> '
  421.      if jh<nrealms then do
  422.        call lineout tempfile,'<tr>' ; call lineout tempfile,' '
  423.      end
  424.  end /* do jh */
  425.  call lineout tempfile,'</table>' ; call lineout tempfile,' '
  426. end
  427.  
  428. /* --- allow user to enter a few new names */
  429. call lineout tempfile,' </table>  <hr width=40%> <h2> Add new SEL-specific access controls </h2> '
  430. mm0=mm
  431. call lineout tempfile,' <table border=1> <th> Host Nickname  </th>'
  432. call lineout tempfile,' <th> Candidate SEL  </th>'
  433. call lineout tempfile,'  <th> Resource privileges </th>'
  434. call lineout tempfile,' <th nowrap>Permissions list .....</th> '
  435. call lineout tempfile,'  <th nowrap>Realm  <br> Failure File <br> & Adv_opts</th> <tr>'
  436.  
  437. do mm=mm0+1 to mm0+3
  438.      call lineout tempfile,'<td> <EM>Host nickname:</EM> <br> <INPUT TYPE="text" NAME="hostname.'||mm||'"'
  439.      call lineout tempfile,'value=" " SIZE=8 MAXLENGTH=95> </td> '
  440.      call lineout tempfile,'<td> <EM>Candidate SEL:</EM> <br> <INPUT TYPE="text" NAME="candurl.'||mm||'"'
  441.      call lineout tempfile,'value=" " SIZE=20 MAXLENGTH=95> </td> '
  442.  
  443.      call lineout tempfile,'<td> <EM>Resource privileges:</EM> <br>'
  444.      call lineout tempfile,' <TEXTAREA NAME="accprivs.'||mm||'" rows=3 cols=22 >'
  445.      call lineout tempfile,'</textarea>  </td> '
  446.  
  447.     call lineout tempfile,' <td>'
  448.  
  449.     coka=0
  450.     if cacheok>0 then coka=1 
  451.     a=MAKECHECK('Cache?','CACHE',MM,coka)
  452.     coka=0
  453.  
  454.     if cacheok>1 then coka=1 
  455.     a=MAKECHECK('Cache*?)','CACHE*',MM,coka)
  456.     call lineout tempfile,' <br>'
  457.  
  458.     if cacheok=0 then coka=1 
  459.     a=MAKECHECK('NoCache?)','NOCACHE',MM,coka)
  460.     call lineout tempfile,' <br>'
  461.  
  462.  
  463.     a=makecheck('No SSI?  ', 'NO_SSI',mm,0)
  464.     call lineout tempfile,' || '
  465.     a=makecheck('Yes SSI?', 'YES_SSI',mm,0)
  466.     call lineout tempfile,'<br> '
  467.  
  468.     a=makecheck('No SSP? ', 'NO_SSP',mm,0)
  469.     call lineout tempfile,' <br>'
  470.     a=makecheck('No CODE? ', 'NO_CODE',mm,0)
  471.     call lineout tempfile,' <br>'
  472.     a=makecheck('DELETE?  ', 'DELETE',mm,0)
  473.     call lineout tempfile,' || '
  474.     a=makecheck('PUT? ', 'PUT',mm,0)
  475.     call lineout tempfile,' <br>'
  476.      a=makecheck('No HTACCESS?  ', 'NO_HTACCESS',mm,0)
  477.      call lineout tempfile,' <br>'
  478.     a=makecheck('No Virtual?  ', 'NO_VIRTUAL',mm,0)
  479.     call lineout tempfile,' <br>' 
  480.     a=makecheck('No Alias? ', 'NO_ALIAS',mm,0)
  481.     call lineout tempfile,' <br>'
  482.     a=makecheck('No Postfilter? ', 'NO_POSTFILTER',mm,0)
  483.     call lineout tempfile,' </td>'
  484.  
  485.      call lineout tempfile,'<td> <em>Realm: </em><br> <INPUT TYPE="text" NAME="realm.'||mm||'"'
  486.      call lineout tempfile,'value=" " SIZE=12 MAXLENGTH=95> <br>'
  487.  
  488.      call lineout tempfile,'<em>Failure File: </em><br> <INPUT TYPE="text" NAME="fail_file.'||mm||'"'
  489.      call lineout tempfile,'value=" " SIZE=12 MAXLENGTH=95> <br>'
  490.  
  491.      call lineout tempfile,'<em>Adv_opts File: </em><br> <INPUT TYPE="text" NAME="adv_opts.'||mm||'"'
  492.      call lineout tempfile,'value=" " SIZE=12 MAXLENGTH=95>'
  493.  
  494.      call lineout tempfile,' </td>'
  495.  
  496.      if mm<mm0+3 then call lineout tempfile,' <tr> '
  497. end
  498. call lineout tempfile,'</table> <p>'
  499.  
  500. call lineout tempfile,' <h3> Define a new realm </h3> '
  501. mm0=mm0+4
  502. call lineout tempfile,' <u><EM>Realm name:</EM></u>  <INPUT TYPE="text" NAME="realmname.'||mm0||'"'
  503. call lineout tempfile,'value=" " SIZE=8 MAXLENGTH=95>  <br>  '
  504. call lineout tempfile,' <u><EM>Realm-specific resource privileges:</EM></u>  '
  505. call lineout tempfile,' <INPUT TYPE="text" NAME="accprivs.'||mm0||'"'
  506. call lineout tempfile,'value=" " SIZE=40 MAXLENGTH=95>  '
  507.  
  508.  
  509.  
  510. /* ----- add comments information */
  511.  
  512. do jj=1 to nhidden
  513.    call lineout tempfile,hiddens.jj
  514. end /* do */
  515. call lineout tempfile,' <input type="hidden" name="entries" value="'||mm0||'"> <p> '
  516. call lineout tempfile,' <p><input type="submit"> <input type="reset"> </form> '
  517.  
  518.  
  519. call lineout tempfile,' <hr> <h3> <A NAME="notes">Notes</A> </h3> <ul>'
  520. call lineout tempfile,' <li> SEL-specific privileges are stored in: 'accessfile
  521.  
  522. call lineout tempfile,'<li> There are two types of <b>resource privileges </b>:'
  523. call lineout tempfile,'<dl><dt>ONE_OF (the default type).'
  524. call lineout tempfile,'<dd> The client must have "one of" the  ONE_OF privileges.'
  525. call lineout tempfile,'<dt> MUST_HAVE (start with the & character)'
  526. call lineout tempfile,'<dd> The client "must have" <b>all</b> the MUST_HAVE privileges.'
  527. call lineout tempfile,'</dl>'
  528. call lineout tempfile,' Note: if only one privilege is specified, these two types are equivalent.<p>'
  529. call lineout tempfile,' <LI>There are two special ONE_OF privileges: <menu> <li> <STRONG>*</STRONG> :  <em>any privilege will do</em> '
  530. call lineout tempfile,' <LI> <STRONG>NO</STRONG> : No access allowed (SUPERUSERS and INHOUSE user only!) </menu>'
  531. call lineout tempfile,' <li> Do you want to view a  more complete description of '
  532. call lineout tempfile,' <a href="/samples/in_files.doc"> access controls  </a>?'
  533. call lineout tempfile,' <li>View the <a href="/accescfg?TODO=CURRENT">access controls  </a>?'
  534.  
  535.  
  536. call lineout tempfile,' <li> To add more entries, just rerun this several times <br> or edit ' accessfile
  537. call lineout tempfile,' <li> <em>Comments are NOT displayed </em>  <li> Case is ignored '
  538. call lineout tempfile,' <li> Use a<strong>* </strong> in the <em>candidate SEL </em> as a wildcard character</em>'
  539. call lineout tempfile,'<pre> <em>Discussion of match precedence and wildcarding</em>:'
  540. call lineout tempfile,'   Entries are checked using a "multiple wildcard" algorithim.  '                
  541. call lineout tempfile,'   If several entries can match the selector...  '                               
  542. call lineout tempfile,'     1) Exact matches always take precedence    '                                
  543. call lineout tempfile,'     2) The wildcard match that has the most "early character" matches wins  '   
  544. call lineout tempfile,'     Thus, if your selector is FOOD/FRUIT/ORANGES.HTM         '                  
  545. call lineout tempfile,'     then the order (with first being chosen before last) is: '                  
  546. call lineout tempfile,'               FOOD/FRUIT/ORANGES.HTM  (the exact match)'                        
  547. call lineout tempfile,'               FOOD/FRUIT/*HTM                     '                             
  548. call lineout tempfile,'               FOOD/FRUIT/*                       '                              
  549. call lineout tempfile,'               FOOD/*IT/*HTM                     '                               
  550. call lineout tempfile,'               FOOD/*.HTM                       '                                
  551. call lineout tempfile,'               FOOD*                           '                                 
  552. call lineout tempfile,'     (these entries can appear in any order in this file, with no   '
  553. call lineout tempfile,'      effect on precedence).'          
  554. call lineout tempfile,' </pre><li> Definitions of the permissions:'
  555. call show_permissions
  556.  
  557. call lineout tempfile, ' <li> Entries with no <strong>host nickname</strong> will apply to all requests'
  558. call lineout tempfile,' <li> If specified (and if <var>ACCESS_FAIL_FILE</var>  < > 0): the <em>failure file</em> is sent '
  559. call lineout tempfile,'   if the client does not have access privileges.'
  560. call lineout tempfile,' <li> The ADV_OPTS file (the <u>advanced options file</u>) should be relative to the GoServe working directory "'
  561. call lineout tempfile,'</ul> <br>'
  562.  
  563.  
  564. call lineout tempfile,' <h3> A list of the <A NAME="hosts">current hosts</A> </h3>  <blockquote> '
  565. ii=value(enmadd||'HOSTS.0',,'os2environment')
  566. if ii=0 then do
  567.    call lineout tempfile,'<strong>There are no hosts defined</strong>'
  568. end 
  569. else do
  570.   hlist=sref_value('$HOSTS.0',,'USE')
  571.   call lineout tempfile,' <table> <th> IP address </th> <th> Host Nickname </th> <th> Data Directory </th> <tr> '
  572.   do ll=1 to words(hlist)
  573.       hh=strip(translate(word(hlist,ll)))
  574.       wow=sref_value('$HOSTS.'||hh,,'use')
  575.       parse var wow ip ',' hn ',' hdir
  576.      call lineout tempfile,' <td> ' ip  '</td> <td> ' hn ' </td> <td> ' hdir '</td> <tr> '
  577.   end /* do */
  578.   call lineout tempfile,' </table> </blockquote>'
  579. end
  580.  
  581.  
  582.  
  583. call lineout tempfile,' <p> <A HREF="#top">Return to the top of this form.</A>'
  584. call lineout tempfile,'</body></html>'
  585. call lineout tempfile
  586.  
  587. 'file erase  type text/html name  ' tempfile
  588. return ' done '
  589.  
  590.  
  591.  
  592. /* jump here to recrod changes */
  593. dochange:
  594. parse upper var list foo 'ENTRIES=' nentries '&' .
  595. do ii1=1 to nentries
  596.    fillme.ii1.0=0
  597. end /* do */
  598.  
  599. do until list=""
  600.    parse var list aa '&' list
  601.    parse upper var aa avar '.' aind '=' aval
  602.    aval=packur(aval)
  603.    aval=translate(aval,' ','0d0a'x)
  604.    if abbrev(avar,'ENTRIES=')=1 then iterate
  605.    wow=fillme.aind.0+1
  606.    fillme.aind.0=wow
  607.    fillme.aind.wow.var=avar ; fillme.aind.wow.val=aval
  608.    select
  609.       when avar="COMMENT" then do
  610.           fillme.aind.type='COMMENT'
  611.           parse  var aa foo '=' aval
  612.           fillme.aind.wow.val=packur(aval)
  613.       end
  614.       when avar="CANDURL" then fillme.aind.type='URL'
  615.       when avar="REALMNAME" then fillme.aind.type='REALM'
  616.       
  617.       otherwise nop
  618.    end
  619. end /* do */
  620.  
  621. accessfile=value(enmadd||'ACCESS_FILE',,'os2environment')
  622. aa=sref_fileread(accessfile,'lins',,'E')
  623. foo=do_extends(1)
  624.  
  625. /* pull "header comments" */
  626. iat=0
  627. do until iat >= lins.0
  628.    iat=iat+1
  629.    if  abbrev(strip(lins.iat),';')  then do
  630.        newlines.iat=lins.iat
  631.    end  /* Do */
  632.    else do
  633.         leave
  634.    end
  635. end /* do -- iat is the first non header comment line  */
  636. iat=iat-1
  637.  
  638. do uu=1 to nentries
  639.    select
  640.       when fillme.uu.type='COMMENT' then do
  641.           iat=iat+1
  642.           newlines.iat=fillme.uu.1.val
  643.       end
  644.       when fillme.uu.type='REALM'  then do
  645.           isname=' ' ; ispriv=' ' ;
  646.           do uu2=1 to fillme.uu.0
  647.              chk1=fillme.uu.uu2.var
  648.              if chk1='REALMNAME' then
  649.                 isname=fillme.uu.uu2.val
  650.              if chk1='ACCPRIVS' then
  651.                 ispriv=fillme.uu.uu2.val
  652.           end
  653.           if isname<>' ' then do
  654.               iat=iat+1
  655.               newlines.iat='!REALM '||isname||' '||ispriv
  656.           end
  657.       end
  658.  
  659.       when fillme.uu.type='URL' then do
  660.           candurl=' ' ; permlist=' ' ; ishost=' ' ; isrealm=' ' ; ispriv=' '
  661.           isfailfile=' '; isadv_opts=' '
  662.           do uu2=1 to fillme.uu.0
  663.              chk1=fillme.uu.uu2.var
  664.              vvv=fillme.uu.uu2.val
  665.              select
  666.                 when chk1='CANDURL' then candurl=vvv
  667.                 when chk1='ACCPRIVS' then ispriv=vvv
  668.                 when chk1='REALM' then isrealm=vvv
  669.                 when chk1='FAIL_FILE' then isfailfile=vvv
  670.                 when chk1='HOSTNAME' then ishost=vvv
  671.                 when chk1="ADV_OPTS" then isadv_opts=vvv
  672.                 otherwise  permlist=permlist' ' chk1
  673.              end
  674.           end
  675.           if candurl<>' ' then do
  676.               iat=iat+1
  677.               newlines.iat=''
  678.               if ishost<>' ' then
  679.                   newlines.iat=ishost||'// '
  680.               newlines.iat=newlines.iat||candurl' 'ispriv ' , ' permlist ' , ' isrealm ' , ' isfailfile ',' isadv_opts
  681.           end
  682.       end
  683.       otherwise do
  684.             nop
  685.       end  /* Do */
  686.  
  687.   end                   /* select over type */
  688. end                     /* do over entries */
  689.  
  690. /* save to access_file.. but rename access_file first */
  691. foo=lastpos('.',accessfile)
  692. if foo=0 then
  693.    acf1=accessfile||'.'
  694. else
  695.    acf1=left(accessfile,foo)
  696. do hi=1 to 999
  697.    try1=acf1||hi
  698.    if stream(acf1||hi,'c','query exists')='' then leave
  699. end /* do */
  700. foo=dosrename(accessfile,try1)
  701. newlines.0=iat
  702. foo=sref_filewrite(accessfile,newlines,'R')
  703.  
  704.  
  705. call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  706. call lineout tempfile, "<html><head><titLE> SRE-http: Changed SEL-specific access controls </title>"
  707.  call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'"> '
  708.  
  709. call lineout tempfile,' <h2> SEL-specific access controls have been changed </h2>'
  710. call lineout tempfile,' The SEL-specific access controls have been saved to: ' accessfile
  711. call lineout tempfile,' <p> The old version of 'accessfile' has been moved to ' try1
  712. call lineout tempfile,'<p> <a href="/config2.htm">Return to Intermediate Mode Configurator</a>'
  713.  
  714. call lineout tempfile,' </body> </html> '
  715. call lineout tempfile
  716.  
  717. foo=value('SREF_REDO',1,'os2environment')
  718.  
  719. foo=sref_gos('FILE ERASE TYPE text/html NAME' tempfile)
  720. return 'done change '
  721.  
  722.  
  723. MAKECHECK:PROCEDURE expose tempfile
  724.   PARSE ARG message, ANAME, MM ,ISIT
  725.   FOO=' <INPUT TYPE="CHECKBOX" NAME="'||ANAME||'.'||MM||'"'
  726.   if isit=1 then
  727.       foo=foo||' VALUE=1 checked> '||message
  728.   else
  729.       foo=foo||'VALUE=1 >'||message
  730.   foo=foo
  731.   call lineout tempfile,foo
  732.   return 1
  733.  
  734. /************/
  735. /* Redo ulist, by treating lines starting with , as continuation lines */
  736. do_extends:procedure expose lins.
  737.  
  738. if lins.0=0 then return
  739. isnew=1
  740. tmps.1=lins.1
  741. do mm=2 to lins.0
  742.    ali=strip(lins.mm)
  743.    if abbrev(ali,',')=0 then do
  744.         isnew=isnew+1
  745.         tmps.isnew=lins.mm
  746.     end
  747.     else do
  748.         tmps.isnew=tmps.isnew||substr(ali,2)
  749.     end
  750. end
  751. do mm=1 to isnew
  752.     lins.mm=tmps.mm
  753. end
  754. lins.0=isnew
  755. return 0
  756.  
  757.  
  758. /* display permissions definitions */
  759. show_permissions:procedure expose tempfile
  760. call lineout tempfile,' <pre>'
  761. call lineout tempfile,'          NO_SSI : NO_SSI means "no server side include allowed for this '
  762. call lineout tempfile,'                   selector (SEL) (or a "path" of selectors, if a * appears).  '
  763. call lineout tempfile,'         YES_SSI : YES_SSI means "force SRE-http to check this selector (if it '
  764. call lineout tempfile,'                   is an HTML document) for SSIs.  YES_SSI overrides NO_SSI'
  765. call lineout tempfile,'          NO_SSP : NO_SSP means "no server side processing allowed for this selector".'
  766. call lineout tempfile,'                    (this is rarely used)'
  767. call lineout tempfile,'          NO_CODE: NO_CODE means "do not process SELECT or INTERPRET CODE '
  768. call lineout tempfile,'                   ssi keyphrases". It is a subset of NO_SSP (and is ignored if'
  769. call lineout tempfile,'                   a NO_SSP is present).'
  770. call lineout tempfile,'          CACHE:   If present, then ALWAYS cache this selector (given GoServes'
  771. call lineout tempfile,'                    caching is turned on).'
  772. call lineout tempfile,'                   Typically, if logon controls or access controls are in place,'
  773. call lineout tempfile,'                   then no caching is permittted.  Use of CACHE allows one'
  774. call lineout tempfile,'                   to override this general rule for certain files'
  775. call lineout tempfile,'                   (such as sets of commonly used .GIF files).'
  776. call lineout tempfile,'          CACHE*:  As above, but also enables the GoServe cache'
  777. call lineout tempfile,'                   (CACHE* supersedes CACHE -- we recommend not selecting'
  778. call lineout tempfile,'                    both CACHE and CACHE* )'
  779. call lineout tempfile,'         NOCACHE:  Do NOT cache this response (overrides CACHE and CACHE*)'
  780. call lineout tempfile,'             PUT : Allow PUT method requests to "copy information to" this selector.'
  781. call lineout tempfile,'           DELETE: Allow DELETE method request to "delete" this selector.'
  782. call lineout tempfile,'      NO_HTACCESS: HTACCESS files will not be used for this selector'
  783. call lineout tempfile,'         NO_ALIAS: Aliasing will NOT be done on this selector'
  784. call lineout tempfile,'       NO_VIRTUAL: Virtual directory lookup will NOT be done on this selector'
  785. call lineout tempfile,'                   NOTE: server side includes and server side processing'
  786. call lineout tempfile,'                        (including CGI-BIN scripts) ignore this directive.'
  787. call lineout tempfile,'                        Thus, NO_VIRTUAL should NOT be used as a security'
  788. call lineout tempfile,'                        tool.'
  789. call lineout tempfile,'     NO_POSTFILTER: Post-filter processing and file recording will NOT'
  790. call lineout tempfile,'                         be done on this selector </pre>'
  791. return 0
  792.  
  793. /* ------------------------------------------------------ */
  794. /* query and wait on helper thread */
  795. /* ------------------------------------------------------*/
  796. wait_queue:procedure expose enmadd transaction semqueue host_nickname
  797. parse arg athread
  798. again1t:
  799.  
  800. parse var semqueue mysem myqueue
  801.  
  802. basesem='\SEM32\'||enmadd
  803.  
  804. goober=enmadd||athread
  805.  a=rxqueue('s',goober)
  806.  queue  transaction ' ' host_nickname ',' myqueue ',' mysem ', *LIST* '
  807.  
  808.   a=eventsem_reset(mysem)
  809.   dothread=basesem||athread
  810.  
  811.   a=eventsem_post(dothread)
  812. again2t:
  813.   a=eventsem_wait(mysem,90000)  /* max wait of 90 seconds */
  814.  
  815.   if a<>0 then do
  816.         ss=sref_error(mytid','athread' A Fatal Semaphore failure: 'a,1)
  817.         'response HTTP/1.1 503 Service Unavailable'
  818.         String 'Web server is temporarily busy '
  819.         exit ' '
  820.   end
  821.   a=rxqueue('s',myqueue)
  822.  
  823.   parse pull aline
  824.  
  825.   PARSE VAR ALINE idnum ',' aline
  826.   idnum=strip(translate(idnum,' ','000d0a'x));TRANSACTION=STRIP(TRANSACTION)
  827.   if idnum<>transaction then  do /*wierd error: got someone else's message! */
  828.         ss=sref_error(mytid','athread' A  Semaphore failure: 'a,1)
  829.         'response HTTP/1.1 503 Service Unavailable'
  830.         String 'Web server is temporarily busy '
  831.         exit ' '
  832.   end
  833.  
  834.   return aline
  835.  
  836.  
  837.  
  838.