Article delegate-en/3215 of [1-5169] on the server localhost:119
  upper oldest olders older1 this newer1 newers latest
search
[Top/Up] [oldest] - [Older+chunk] - [Newer+chunk] - [newest + Check]
[Reference:<_A3213@delegate-en.ML_>]
Newsgroups: mail-lists.delegate-en

[DeleGate-En] SHTML / SSI (Re: problem with CGI on Windows?)
06 May 2006 00:23:17 GMT feedback@delegate.org (Yutaka Sato)
The DeleGate Project


Martin,

In message <_A3213@delegate-en.ML_> on 05/04/06(02:01:52)
you Martin Vetter <pnieabdyi-h3lluohg4rxr.ml@ml.delegate.org> wrote:
 |> Anyway, I uploaded 9.2.0-pre12 binary including
 |> the patch for windows CGI and extensions for access counter.
 |
 |the CGI feature now works on Windows, thanks :o)
 |and the next problem shows up ...

Now I'm extending SSI (SHTML) supports in DeleGate mainly for access
counters.  As the basic feature of SHTML, I implemented #exec tag which
can be used to replace CGI.  SHTML is recomendable than CGI because:

 + it automatically hides the real filename of the executable file
 + it can be placed anywhere in the data directory

The enclosed patch enables the SHTML #exec tag, which can be used like
this:

// test.shtml
<H1>Sample SHTML#exec</H1>
DIR: <PRE><!--#exec cmd="dir.exe" --></PRE>
BAT: <PRE><!--#exec cmd="test.bat" --></PRE>


Cheers,
Yutaka
--
  D G   Yutaka Sato <y.sato@delegate.org> http://delegate.org/y.sato/
 ( - )  National Institute of Advanced Industrial Science and Technology
_<   >_ 1-1-4 Umezono, Tsukuba, Ibaraki, 305-8568 Japan
Do the more with the less -- B. Fuller

diff -cr ../delegate9.2.0-pre12/src/ssi.c ./src/ssi.c
*** ../delegate9.2.0-pre12/src/ssi.c	Wed May  3 18:57:22 2006
--- ./src/ssi.c	Sat May  6 08:59:45 2006
***************
*** 450,456 ****
--- 450,468 ----
  void SSI_exec(DGC*ctx,const char *ev[],PCStr(tag),PCStr(type),PCStr(command),FILE *htfp,Mssg *mssg)
  {	FILE *body = mssg->m_body;
  
+ 	FILE *fpv[2];
+ 	int pid,xpid;
+ 	int popenx(PCStr(command),PCStr(mode),FILE *io[2]);
+ 	int NoHangWait();
+ 
  	if( streq(type,"cmd") ){
+ 		pid = popenx(command,"r",fpv);
+ 		if( 0 < pid ){
+ 			if( fpv[1] && fpv[1] != fpv[0] ) fclose(fpv[1]);
+ 			copyfile1(fpv[0],body);
+ 			if( fpv[0] ) fclose(fpv[0]);
+ 			xpid = NoHangWait();
+ 		}
  	}else
  	if( streq(type,"cgi") ){
  	}else
diff -cr ../delegate9.2.0-pre12/src/filter.c ./src/filter.c
*** ../delegate9.2.0-pre12/src/filter.c	Sat Apr  8 20:39:51 2006
--- ./src/filter.c	Sat May  6 08:53:00 2006
***************
*** 1314,1319 ****
--- 1314,1323 ----
  			if( strchr(mode,'R') ){
  				dup2(1,2);
  			}
+ 			if( 1 ){
+ 				/* this is necessary at least for .bat */
+ 				setCloseOnExec(0);
+ 			}
  			setCloseOnExec(fromf[0]);
  		}
  		ws = setwaitspawn(MIN_DGSPAWN_WAIT-1);

  admin search upper oldest olders older1 this newer1 newers latest
[Top/Up] [oldest] - [Older+chunk] - [Newer+chunk] - [newest + Check]
@_@V