Article delegate-en/371 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:<_A366@delegate-en.ML_>]
Newsgroups: mail-lists.delegate-en

[DeleGate-En] Re: Hot do you apply filters conditionally based on the web site being requested?
23 Mar 1999 18:57:46 GMT ysato@etl.go.jp (Yutaka Sato)


On 03/18/99(16:30) you Phill Edwards <pnyaqbdyi-5vjbuj5a4ilr.ml@ml.delegate.org> wrote
in <_A366@delegate-en.ML_>
 |I've got as far as applying filters to html which is being passed from 
 |Delegate where the Content-Type is html. This works great. I'm now trying 
 |to understand how to apply different filters to different web sites. I've 
 |tried using Server and Server-Host, eg
 |#!cfi
 |Server-Host: www.ozemail.com.au
 |Filter: /usr/home/phill/working/delegate.sh

Sorry but matching by "Server-Host" is not implemented yet, and it
will be far less efficient than matching with CMAP with "dstHostList"
restriction, like one in your example.

 |I've also tried
 |CMAP="/usr/home/phill/working/delegate.cfi:FTOCL:http:www.ozemail.com.au:*"

This must work.

 |but that didn't work because it tried to execute cfi as a unix shell script 
 |which wasn't valid.

I fixed the problem with the enclosed patch.  It also fixes problems
which occurs when "CGI:" is used instead of "Filter:", and when a
complex shell commands is specified for Filter or CGI.

Cheers,
Yutaka
--
Yutaka Sato <ysato@etl.go.jp> http://www.etl.go.jp/~ysato/   @ @ 
Computer Science Division, Electrotechnical Laboratory      ( - )
1-1-4 Umezono, Tsukuba, Ibaraki, 305-8568 Japan            _<   >_

diff -c -r ../delegate5.9.1/src/filter.c ./src/filter.c
*** ../delegate5.9.1/src/filter.c	Mon Mar 15 19:48:03 1999
--- ./src/filter.c	Wed Mar 24 02:52:52 1999
***************
*** 166,171 ****
--- 166,172 ----
  	Connection *Conn;
  {	char *fname,*filter;
  	static char filterb[2048];
+ 	char *cfi;
  
  	filter = NULL;
  
***************
*** 175,180 ****
--- 176,185 ----
  		if( filterb[0] ){
  			filter = filterb;
  			Verbose("## gotFilter[%s][%s]\n",fname,filter);
+ 			if( cfi = open_cfi(filterb) ){
+ 				strcpy(filterb,cfi);
+ 				free(cfi);
+ 			}
  		}
  	}
  	if( filter == NULL )
***************
*** 532,537 ****
--- 537,546 ----
  	char *what,*command;
  {	char execpath[1024],*av[128],argb[1024];
  
+ 	/* if with some command syntax ... */
+ 	if( strpbrk(command,"\r\n|()[]<>{}:;") )
+ 		Finish(system(command));
+ 	else
  	if( 0 <= scanComArg(command,execpath,av,128,argb) )
  		Execvp(what,execpath,av);
  	else	Finish(system(command));
diff -c -r ../delegate5.9.1/filters/cfi.c ./filters/cfi.c
*** ../delegate5.9.1/filters/cfi.c	Fri Aug 21 22:23:42 1998
--- ./filters/cfi.c	Wed Mar 24 03:38:21 1999
***************
*** 457,471 ****
--- 457,474 ----
  	FILE *tmp;
  	char *xhead,*dp;
  	char url[4096],ourl[4096];
+ 	char **oenv;
  
  	xhead = strdup(head);
  	scan_http_request(oreq,NULL,ourl,NULL);
  	scan_http_request(req,NULL,url,NULL);
  	cgi_makeenv(conninfo,req,xhead,ourl,url,"","",NULL,ev,eb);
+ 	oenv = environ;
  	environ = ev;
  
  	tmp = TMPFILE("CFI-system_CGI");
  	System(cgi,in,tmp);
+ 	environ = oenv;
  	fseek(tmp,0,0);
  	if( dp = strstr(head,"\r\n\r\n") )
  		dp[2] = 0;

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