home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / srev13g.zip / USERCFG.CMD < prev    next >
OS/2 REXX Batch file  |  1999-06-19  |  20KB  |  545 lines

  1. /*   */
  2. usercfg:
  3.  
  4. CHECKIT=0   /* Change this to 0 if you want to enable REMOTE configuration by SUPERUSERS */
  5. USECOLOR='2dd52f'
  6.  
  7. /* ---------------- DO NOT MODIFY BELOW THIS LINE  ------------------ */
  8.  
  9. parse arg  ddir, tempfile, sel,list,verb ,uri,user, ,
  10.           basedir ,workdir,privset,enmadd,transaction,verbose, ,
  11.          servername,host_nickname,homedir,aparam,semqueue,prog_file,reqnum
  12.  
  13. /* parse arg ddir,tempfile,sel,list,verb,uri,user,basedir,workdir,privset,enmadd,transaction,verbose */
  14.  
  15. if verb="" then do
  16.    say " This SRE-Http add-on is NOT meant to be run from the command line."
  17.    say " It can be invoked by using CONFIGUR.HTM "
  18.    exit
  19. end  /* Do */
  20.  
  21. crlf='0d0a'x
  22.  
  23. list=translate(list, ' ', '+'||'090a0d'x)  /* Whitespace, etc. */
  24.  
  25. who2=extract('CLIENTADDR')
  26. saddr2=extract('SERVERADDR')
  27.  
  28. NO_REM=VALUE('SREF_NO_REMOTE_CONFIG',,'OS2ENVIRONMENT')
  29.  
  30. select
  31.    when checkit=1 | no_rem>0 then do
  32.  
  33. /* only if user = serveraddress !!! */
  34.      if who2<>saddr2 | no_rem=2 then do
  35.  
  36.         call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  37.         call lineout tempfile, "<html><head><title>SRE-HTTP  remote configuartor disabled </title>"
  38.         call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'"> '
  39.  
  40.         call lineout tempfile,' <strong> Action not allowed remotely.</strong> <pre>'
  41.         call lineout tempfile,' </body> </html> '
  42.         call lineout tempfile
  43.         foo=sref_gos('FILE ERASE TYPE text/html NAME' tempfile)
  44.         return 'USERCFG: action not allowed remotely. '
  45.      end
  46.    end
  47.    otherwise do
  48.       if wordpos('SUPERUSER',privset)=0 then do
  49.         'RESPONSE HTTP/1.1 401 Unauthorized '     /* Set HTTP response line */
  50.          att=sref_gmt()
  51.         'HEADER Noauto ADD Date: 'att
  52.  
  53.        'header add WWW-Authenticate: Basic Realm=<CONFIGURE>'  /* challenge */
  54.         call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  55.         call lineout tempfile, "<html><head><title>Not authorized </title>"
  56.         call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'"> '
  57.  
  58.         call lineout tempfile,' <strong> You do not have configuration rights.</strong> <pre>'
  59.         if who2=saddr2 then 
  60.                 call lineout tempfile,'<br> <Em> You may want to edit USERCFG.CMD </em> '
  61.         call lineout tempfile,' </body> </html> '
  62.         call lineout tempfile
  63.          iia=dosdir(tempfile,'s')
  64.         'FILE ERASE TYPE text/html NAME' tempfile
  65.         return '401 'iia' USERCFG: not permitted to configure. '
  66.       end
  67.    end
  68. end
  69.  
  70.  
  71.  
  72. list=strip(list)
  73. select 
  74.    when upper(list)='TODO=SHOW' | upper(list)='TODO=SHOW_HEADER' then
  75.         signal doshow
  76.    when upper(list)='TODO=SET' then
  77.         signal doset
  78.  
  79.    when upper(list)='TODO=CURRENT' then
  80.         signal showcurrent
  81.  
  82.    otherwise
  83.         signal dochange
  84. end  /* select */
  85.  
  86. /* jump here to show values */
  87. doshow:
  88. userfile=value(enmadd||'USER_FILE',,'os2environment')
  89. aa=sref_fileread(userfile,'lins',,'E')
  90.  
  91.  
  92.    call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  93.    call lineout tempfile, "<html><head><title>SRE-Http: view users </title>"
  94.     call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'"> '
  95.    
  96.  
  97.  
  98. call lineout tempfile, "<h1> SRE-Http: view users        </h1> <p>"
  99. call lineout tempfile, "<h2> List of "header" comments </h2> <pre> <blockquote>"
  100.  
  101. /* show "header comments" */
  102. iat=0
  103. do until iat >= lins.0
  104.    iat=iat+1
  105.    if  abbrev(strip(lins.iat),';')  then do
  106.         foo=strip(lins.iat) ;foo=strip(foo,'l',';')
  107.          call lineout tempfile, foo 
  108.    end  /* Do */
  109.    else do
  110.         leave
  111.    end
  112. end /* do -- iat is the first non header comment line  */
  113. call lineout tempfile, '</blockquote></pre> '
  114.  
  115. /* view descriptive header only? */
  116. if upper(list)='TODO=SHOW_HEADER' then do
  117.    call lineout tempfile,' <hr> </body></html>'
  118.    call lineout tempfile
  119.    foo=sref_gos('file erase  type text/html name  ' tempfile)
  120.    return ' done '
  121. end  /* Do */
  122.  
  123.  
  124.  
  125. /* read in usernames, etc */
  126. nusers=0
  127. call lineout tempfile, ' <hr> <h2> List of users </h2>  '
  128.  
  129. call lineout tempfile,'Notes: <ul> <li> Usernames/passwords are stored in: 'userfile
  130. call lineout tempfile,' <li> <em>Comments are in italics </em> '
  131. call lineout tempfile,' <li>  A <strong>* </strong> in the username or password signifies that <em>any entry is a match </em>'
  132. call lineout tempfile, ' <li> Entries with no <strong>host nickname</strong> apply to all requests</ul> <br>'
  133.  
  134. call lineout tempfile,' <table border=1> <th> Host Nickname </th>'
  135. call lineout tempfile,' <th> Username  </th>'
  136. call lineout tempfile,'  <th> Password </th>'
  137. call lineout tempfile,'  <th> Privileges list </th> <tr>'
  138.  
  139. do mm=iat to lins.0
  140.   if lins.mm=' ' then iterate
  141.   if  abbrev(strip(lins.mm),';') | lins.mm=' ' then do  
  142.        call lineout tempfile,'<td colspan=4>  <code>     </code> <em>' strip(strip(lins.mm),'l',';') '</em></td> <tr> '
  143.  
  144.   end
  145.   else do
  146.       if pos('//',lins.mm)>0 then
  147.            parse var lins.mm hostname '//' username password privs
  148.       else do
  149.            hostname=' .. '
  150.            parse var lins.mm username password privs
  151.       end  /* Do */
  152.       privs=strip(privs)
  153.       call lineout tempfile,'<td> <STRONG> 'hostname ' </STRONG></td>'
  154.       call lineout tempfile,'<td> <STRONG> 'username ' </STRONG></td>'
  155.       call lineout tempfile,'<td> <STRONG> ' password ' </STRONG></td>'
  156.       call lineout tempfile,'<td> <STRONG> ' privs  ' </STRONG></td> <tr>'
  157.   end /* do */
  158.  
  159. end
  160. call lineout tempfile,' </table>'
  161.  
  162. call lineout tempfile,' <hr> Thanks for checking </body></html>'
  163. call lineout tempfile
  164.  
  165. foo=sref_gos('file erase  type text/html name  ' tempfile)
  166. return ' done '
  167.  
  168.  
  169. /* jump here if "show current" chosen */
  170. showcurrent:
  171. foo=wait_queue('USER')
  172. call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  173. call lineout tempfile, "<html><head><title>SRE-http: list of usernames </title>"
  174. call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'">'
  175.  
  176. call lineout tempfile, '<h2>List of SRE-http Usernames/PWDS </h2>'
  177. call lineout tempfile,' This complete list of Usernames & passwords includes entries in default and host specific copies '
  178. call lineout tempfile,' of USERS.IN and ATTRIBS.CFG <hr width="30%">'
  179. call lineout tempfile,'<table border=1>'
  180.  
  181. call lineout tempfile,'<tr><th> Host <th> Username & <br> Password <th> Privileges'
  182. do forever
  183.   if foo='' then leave
  184.   parse var foo ah '//' a1 ',' a2 ','a3 (crlf) foo
  185.   a3a=''
  186.   do mm=1 to words(a3)
  187.     parse var a3 t3 a3 ; t3=strip(t3)
  188.     if abbrev(t3,'?')=1 then
  189.         a3a=a3a'  <em>secretpriv</em> '
  190.     else
  191.         a3a=a3a'  't3
  192.   end /* do */
  193.   call lineout tempfile,'<tr><td> 'ah  '<td> 'a1 '<br><tt>'a2 '</tt> <td> 'a3a  
  194. end
  195. call lineout tempfile,'</table></body></html>'
  196. call lineout tempfile
  197. foo=sref_gos('file erase  type text/html name  ' tempfile)
  198. return ' done '
  199.  
  200.  
  201.  
  202. /* jump here if "set values" chosen */
  203. doset:
  204. userfile=value(enmadd||'USER_FILE',,'os2environment')
  205. aa=sref_fileread(userfile,'lins',,'E')
  206.  
  207. call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  208. call lineout tempfile, "<html><head><title>SRE-Http: modify  users list </title>"
  209. call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'"> '
  210. call lineout tempfile,'<!--  a button bar. --> 'crlf ,
  211.            '<a href="/configur.htm">Configurator</a>||' crlf ,
  212.            '<a href="/config2?todo=SET">Parameters</a>||' crlf ,
  213.            '<a href="/usercfg?todo=SET">Usernames</a>||'  crlf ,
  214.            '<a href="/realmcfg?todo=SET">Define-Realms</a>||'||crlf ,
  215.            '<a href="/accescfg?todo=SET">Access-Controls||'  crlf ,
  216.            '<a href="/aliascfg?todo=SET">Aliases</a>||'  crlf ,
  217.            '<a href="/virtcfg?todo=SET">VirtualDir</a><p>'  
  218.  
  219.  
  220. /* ignore header stuff */
  221. iat=0
  222. do until iat >= lins.0
  223.    iat=iat+1
  224.    if  abbrev(strip(lins.iat),';') | lins.iat=' ' then iterate
  225.    leave
  226. end /* do -- iat is the first non header comment line  */
  227. call lineout tempfile, "<h1> SRE-Http: <A NAME="top">modify users list</A>  </h1> <p>"
  228. call lineout tempfile,' <blockquote> You can modify, remove, or add usernames, passwords, and privileges.'
  229. call lineout tempfile,' <br><em> Questions? <A HREF="#notes">The notes might help.</A> </em> </blockquote> '
  230. call lineout tempfile,' <h2> Modify or remove current users </h2>'
  231. call lineout tempfile,'<FORM ACTION="/usercfg" METHOD="GET">'
  232. call lineout tempfile,' <table border=1> <th> Host Nickname <br> (see <A HREF="#hosts">below</A>  for a <br>listing of current hosts) </th>'
  233. call lineout tempfile,' <th> Username  <br> (set to blank to  <br> delete the entry)</th>'
  234. call lineout tempfile,'  <th> Password </th>'
  235. call lineout tempfile,' <th> Superuser and <br>  INHOUSE privileges </th> '
  236. call lineout tempfile,'  <th> Space delimited list  of <br> other privileges </th> <tr>'
  237.  
  238. nhidden=0 ; mm=0
  239. do mm0=iat to lins.0
  240.     alin=translate(lins.mm0,' ','1a000d0a'x)
  241.     mm=mm+1
  242.     if  abbrev(strip(alin),';')=1 | alin=' ' then do
  243.         nhidden=nhidden+1
  244.         hiddens.nhidden='<INPUT TYPE="HIDDEN" name="COMMENT.'||mm||'"  value="'||alin||'" >'
  245.         iterate
  246.     end
  247.  
  248. /* non comment */
  249.     if pos('// ',alin)>0 then
  250.              parse var alin hostname '//' username password privs
  251.         else do
  252.              hostname='  '
  253.              parse var alin username password privs
  254.      end  /* Do */
  255.      call lineout tempfile,'<td> <EM>Host nickname:</EM> <br> <INPUT TYPE="text" NAME="hostname.'||mm||'"'
  256.      call lineout tempfile,'value="'hostname'" SIZE=8 MAXLENGTH=15> </td> '
  257.      call lineout tempfile,'<td> <EM>Username:</EM> <br> <INPUT TYPE="text" NAME="username.'||mm||'"'
  258.      call lineout tempfile,'value="'username'" SIZE=8 MAXLENGTH=15> </td> '
  259.      call lineout tempfile,'<td> <EM>Password:</EM> <br> <INPUT TYPE="text" NAME="password.'||mm||'"'
  260.      call lineout tempfile,'value="'password'" SIZE=8 MAXLENGTH=15> </td> '
  261.  
  262.      privs=strip(privs)
  263.      joe=wordpos('SUPERUSER',upper(privs))
  264.      issuper=0
  265.      if joe>0 then   do
  266.             issuper=1 ;   privs=delword(privs,joe,1)
  267.      end
  268.      inhouse=0
  269.      joe=wordpos('INHOUSE',upper(privs))
  270.      if joe>0 then  do
  271.             inhouse=1 ;   privs=delword(privs,joe,1)
  272.      end
  273.      call lineout tempfile,'  <td> <INPUT TYPE=CHECKBOX NAME="SUPERUSER.'mm||'" '
  274.      if issuper=1 then do
  275.           call lineout tempfile,' CHECKED > SUPERUSER? <br> '
  276.      end
  277.      else
  278.          call lineout tempfile,' >  SUPERUSER? <br> '
  279.      call lineout tempfile,' <INPUT TYPE=CHECKBOX NAME="INHOUSE.'mm||'" '
  280.      if inhouse=1 then do
  281.           call lineout tempfile,' CHECKED > INHOUSE ?</td>  '
  282.      end
  283.      else
  284.          call lineout tempfile,' >  INHOUSE?</td> '
  285.  
  286.      if privs='' then privs=' '
  287.      call fix_privs
  288.      
  289.      call lineout tempfile,'<td> <em>Other privileges: </em><br> <INPUT TYPE="text" NAME="privs.'||mm||'"'
  290.      call lineout tempfile,'value="'privs'" SIZE=10 MAXLENGTH=45>'
  291.      if privs_secret<>'' then call lineout tempfile,'<br><font size="-1">('||words(privs_secret)||' secret privs removed)'
  292.      call lineout tempfile,' </td>  '
  293.      if mm0<lins.0 then do
  294.            call lineout tempfile,'<tr>' ; call lineout tempfile,' '
  295.      end
  296. end
  297. call lineout tempfile,' '
  298.  
  299. /* --- allow user to enter a few new names */
  300. call lineout tempfile,' </table>  <p> <h2> Add new users </h2> <table border=1>'
  301. mm0=mm
  302. do mm=mm0+1 to mm0+3
  303.      call lineout tempfile,'<td> <EM>Host nickname:</EM> <br> <INPUT TYPE="text" NAME="hostname.'||mm||'"'
  304.      call lineout tempfile,'value=" " SIZE=8 MAXLENGTH=15> </td> '
  305.      call lineout tempfile,'<td> <EM>Username:</EM> <br> <INPUT TYPE="text" NAME="username.'||mm||'"'
  306.      call lineout tempfile,'value=" " SIZE=8 MAXLENGTH=15> </td> '
  307.      call lineout tempfile,'<td> <EM>Password:</EM> <br> <INPUT TYPE="text" NAME="password.'||mm||'"'
  308.      call lineout tempfile,'value=" " SIZE=8 MAXLENGTH=15> </td> '
  309.      call lineout tempfile,'  <td> <INPUT TYPE=CHECKBOX NAME="SUPERUSER.'mm||'"> SUPERUSER? <br> '
  310.      call lineout tempfile,'       <INPUT TYPE=CHECKBOX NAME="INHOUSE.'mm||'"> INHOUSE? </td> '
  311.      call lineout tempfile,'<td> <em>Other privileges: </em><br> <INPUT TYPE="text" NAME="privs.'||mm||'"'
  312.      call lineout tempfile,'value=" " SIZE=10 MAXLENGTH=45> </td>'
  313.      if mm<mm0+3 then call lineout tempfile,' <tr> '
  314. end
  315.  
  316. call lineout tempfile,'</table> <p>'
  317.  
  318.  
  319. /* ----- add comments information */
  320.  
  321. do jj=1 to nhidden
  322.    call lineout tempfile,hiddens.jj
  323. end /* do */
  324. call lineout tempfile,' <input type="hidden" name="entries" value="'||mm||'">'
  325. call lineout tempfile,' <input type="submit"> <input type="reset"> </form> '
  326.  
  327.  
  328. call lineout tempfile,' <hr> <h3> <A NAME="notes">Notes</A> </h3> <ul> <li> Usernames/passwords are stored in: 'userfile
  329. call lineout tempfile,' <li> To add more then 3 new names, just rerun this several times <br> or edit ' userfile 
  330. call lineout tempfile,' <li> Do you want to view a  more complete description of '
  331. call lineout tempfile,' <a href="/samples/users.doc"> User information</a>?'
  332. call lineout tempfile,' <li>View the <a href="/usercfg?TODO=CURRENT"> current set of username/passwords </a>?'
  333. call lineout tempfile,' <li> <em>Comments are NOT displayed </em>  <li> Case is ignored '
  334. call lineout tempfile,' <li> Use a <strong>* </strong> in the username or password to signify that <em>any entry is a match </em>'
  335. call lineout tempfile, ' <li> Entries with no <strong>host nickname</strong> will apply to all requests</ul> <br>'
  336.  
  337. call lineout tempfile,' <h3> A list of the <A NAME="hosts">current hosts</A> </h3>  <blockquote> '
  338.  
  339. ii=value(enmadd||'HOSTS.0',,'os2environment')
  340. if ii>0 then do
  341. call lineout tempfile,' <table> <th> IP address </th> <th> Host Nickname </th> <th> Data Directory </th> <tr> '
  342. do ll=1 to ii
  343.    wow=value(enmadd||'HOSTS.'||ll,,'os2environment')
  344.    parse var wow ip ',' hn ',' hdir
  345.    call lineout tempfile,' <td> ' ip  '</td> <td> ' hn ' </td> <td> ' hdir '</td> <tr> '
  346. end /* do */
  347. call lineout tempfile,' </table> </blockquote> '
  348. end
  349. else do
  350.   call lineout tempfile,' No HOSTS have been defined   </blockquote>'
  351. end
  352.  
  353. call lineout tempfile,' <p> <A HREF="#top">Return to the top of this form.</A>'
  354.  
  355. call lineout tempfile,'</body></html>'
  356. call lineout tempfile
  357.  
  358. foo=sref_gos('file erase  type text/html name  ' tempfile)
  359. return ' done '
  360.  
  361.  
  362. /* ********************** jump here to recrod changes */
  363. dochange:
  364.  
  365. parse upper var list foo 'ENTRIES=' nentries '&' .
  366. do ii1=1 to nentries
  367.    fillme.ii1.0=0
  368. end /* do */
  369.  
  370. do until list=""
  371.    parse var list aa '&' list
  372.    parse upper var aa avar '.' aind '=' aval
  373.    aval=packur(aval)
  374.    if abbrev(avar,'ENTRIES=')=1 then iterate
  375.    wow=fillme.aind.0+1
  376.    fillme.aind.0=wow
  377.    fillme.aind.wow.var=avar ; fillme.aind.wow.val=aval
  378.    select
  379.       when avar="COMMENT" then do
  380.           fillme.aind.type='COMMENT'
  381.           parse  var aa foo '=' aval
  382.           fillme.aind.wow.val=packur(aval)
  383.       end
  384.       when avar="USERNAME" then fillme.aind.type='USERNAME'
  385.       otherwise nop
  386.    end
  387. end /* do */
  388.  
  389. userfile=value(enmadd||'USER_FILE',,'os2environment')
  390. aa=sref_fileread(userfile,'lins',,'E')
  391.  
  392. /* pull "header comments" */
  393. iat=0
  394. do until iat >= lins.0
  395.    iat=iat+1
  396.    if  abbrev(strip(lins.iat),';')  then do
  397.        newlines.iat=lins.iat
  398.    end  /* Do */
  399.    else do
  400.         leave
  401.    end
  402. end /* do -- iat is the first non header comment line  */
  403. iat=iat-1
  404.  
  405. do uu=1 to nentries
  406.    select
  407.       when fillme.uu.type='COMMENT' then do
  408.           iat=iat+1
  409.           newlines.iat=fillme.uu.1.val
  410.       end
  411.       when fillme.uu.type='USERNAME' then do
  412.           username=' ' ; password='*' ; hostname=' ' ; privs=' '
  413.           inhouse=' ' ; superuser=' '
  414.           do uu2=1 to fillme.uu.0
  415.              chk1=fillme.uu.uu2.var
  416.              vvv=fillme.uu.uu2.val
  417.              select
  418.                 when chk1='USERNAME' then USERNAME=vvv
  419.                 when chk1='PASSWORD' then password=vvv
  420.                 when chk1='PRIVS' then privs=vvv
  421.                 when chk1='HOSTNAME' then hostname=vvv
  422.                 when chk1='SUPERUSER' then superuser='SUPERUSER'
  423.                 when chk1='INHOUSE' then inhouse='INHOUSE'
  424.                 otherwise nop
  425.              end
  426.           end
  427.           if username<>' ' then do
  428.               iat=iat+1
  429.               newlines.iat=''
  430.               if hostname<>' ' then
  431.                   newlines.iat=hostname||'// '
  432.               newlines.iat=newlines.iat||username' ' password '  ' superuser ' ' inhouse ' ' privs
  433.           end
  434.       end
  435.       otherwise do
  436.             nop
  437.       end  /* Do */
  438.  
  439.   end                   /* select over type */
  440. end                     /* do over entries */
  441.  
  442. /* save to userfile.. but rename access_file first */
  443. foo=lastpos('.',userfile)
  444. if foo=0 then
  445.    acf1=userfile||'.'
  446. else
  447.    acf1=left(userfile,foo)
  448. do hi=1 to 999
  449.    try1=acf1||hi
  450.    if stream(acf1||hi,'c','query exists')='' then leave
  451. end /* do */
  452. foo=dosrename(userfile,try1)
  453. newlines.0=iat
  454. foo=sref_filewrite(userfile,newlines,'R')
  455.  
  456.  
  457. call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  458. call lineout tempfile, "<html><head><titLE> SRE-Http: Changed list of Users</title>"
  459. call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'"> '
  460.  
  461. call lineout tempfile,' <h2> The list of Users has  been changed </h2>'
  462. call lineout tempfile,' The list of Users has been saved to: ' userfile
  463. call lineout tempfile,' <p> The old version of 'userfile' has been moved to ' try1
  464. call lineout tempfile,'<p> <a href="/config2.htm">Return to Intermediate Mode Configurator</a>'
  465.  
  466. call lineout tempfile,' </body> </html> '
  467. call lineout tempfile
  468.  
  469. foo=value('SREF_REDO',1,'os2environment')
  470. foo=sref_gos('FILE ERASE TYPE text/html NAME' tempfile)
  471. return 'done change '
  472.  
  473.  
  474. return 'done change '
  475.  
  476. /****************************/
  477. /* remove repeats, extract secret privileges.
  478.   This will modify privs, and create privs_secret  */
  479. fix_privs:
  480. p1=''
  481. secp1=''
  482. privs=translate(translate(privs,' ',','||'0d0a0900'x))
  483. do mm=1 to words(privs)
  484.    aw1=strip(word(privs,mm))
  485.    if abbrev(aw1,'?')=1 then do
  486.      aw1=substr(aw1,2)
  487.      if wordpos(aw1,secp1)=0 then secp1=secp1||aw1||' '
  488.    end
  489.    else do
  490.       if wordpos(aw1,p1)=0 then p1=p1||aw1||' '
  491.    end
  492. end
  493. privs=p1
  494. privs_secret=secp1
  495. return 1
  496.  
  497.  
  498.  
  499.  
  500. /* ------------------------------------------------------ */
  501. /* query and wait on helper thread */
  502. /* ------------------------------------------------------*/
  503. wait_queue:procedure expose enmadd transaction semqueue host_nickname
  504. parse arg athread
  505. again1t:
  506.  
  507. parse var semqueue mysem myqueue
  508.  
  509. basesem='\SEM32\'||enmadd
  510.  
  511. goober=enmadd||athread
  512.  a=rxqueue('s',goober)
  513.  queue  transaction ' ' host_nickname ',' myqueue ',' mysem ', *LIST* '
  514.  
  515.   a=eventsem_reset(mysem)
  516.   dothread=basesem||athread
  517.  
  518.   a=eventsem_post(dothread)
  519. again2t:
  520.   a=eventsem_wait(mysem,90000)  /* max wait of 90 seconds */
  521.  
  522.   if a<>0 then do
  523.         ss=sref_error(mytid','athread' A Fatal Semaphore failure: 'a,1)
  524.         'response HTTP/1.1 503 Service Unavailable'
  525.         String 'Web server is temporarily busy '
  526.         exit ' '
  527.   end
  528.   a=rxqueue('s',myqueue)
  529.  
  530.   parse pull aline
  531.  
  532.   PARSE VAR ALINE idnum ',' aline
  533.   idnum=strip(translate(idnum,' ','000d0a'x));TRANSACTION=STRIP(TRANSACTION)
  534.   if idnum<>transaction then  do /*wierd error: got someone else's message! */
  535.         ss=sref_error(mytid','athread' A  Semaphore failure: 'a,1)
  536.         'response HTTP/1.1 503 Service Unavailable'
  537.         String 'Web server is temporarily busy '
  538.         exit ' '
  539.   end
  540.  
  541.   return aline
  542.  
  543.  
  544.  
  545.