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

[DeleGate-En] Re: User-Text
11 Jun 2003 17:54:52 GMT feedback@delegate.org (Yutaka Sato)


Hi,

On 06/09/03(00:12) you "Fryscak Jan, Scio" <p5qeabdyi-fjxi26avzhtr.ml@ml.delegate.org> wrote
in <_A2284@delegate-en.ML_>
 |I'm trying to configure delegate as a smtp proxy and I'd like to REJECT
 |emails containing some words, but "User-Text" just allows to ACCEPT
 |emails containing some words... I've tried to use "!" without success

"ACCEPT/User-Text: Condition" checks a message body line by line, and
accept it when a line is found which matches the Condition.  Thus
"ACCEPT/User-Text: !word" will accept any message which contains a
line without "word".  Maybe I should introduce
"REJECT/User-Text: Condition" which will reject a message containing
a line matching to the Condition.  The enclosed patch will implement it.

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

*** dist/delegate8.5.5/src/smtpgate.c	Sun Apr  6 04:27:00 2003
--- src/smtpgate.c	Thu Jun 12 02:36:39 2003
***************
*** 121,130 ****
  #define ACC_CLIENT_HOST		25
  #define ACC_MESSAGE_ID		26
  #define ACC_USERTEXT		27
  
! #define CTL_SENDER		28
! #define CTL_MYAUTH		29
! #define NPARAMS			30 /* last element above + 1 */
  
  typedef struct {
  	char	*p_abbr;
--- 121,133 ----
  #define ACC_CLIENT_HOST		25
  #define ACC_MESSAGE_ID		26
  #define ACC_USERTEXT		27
+ #define ACC_CONTTYPE		28
  
! #define CTL_SENDER		29
! #define CTL_MYAUTH		30
! #define NPARAMS			31 /* last element above + 1 */
! 
! #define REJ_USERTEXT		(NPARAMS+ACC_USERTEXT)
  
  typedef struct {
  	char	*p_abbr;
***************
*** 166,171 ****
--- 169,175 ----
  	{"ch",	1,"ACCEPT",	"Client-Host"	},
  	{"mi",	1,"ACCEPT",	"Message-Id"	},
  	{"at",  1,"ACCEPT",	"User-Text"	},
+ 	{"ac",	1,"ACCEPT",	"Content-Type"	},
  
  	{"cs",	0,"CONTROL",	"SENDER"	},
  	{"ma",	1,"CONTROL",	"MYAUTH"	},
***************
*** 176,186 ****
--- 180,196 ----
  	PSPEC *ps;
  	char *dp;
  	char pfix[128],name[128];
+ 	int reject;
  
  	pfix[0] = name[0] = 0;
  	if( dp = strchr(pname,'/') )
  		sscanf(pname,"%[^/]/%s",pfix,name);
  	else	strcpy(name,pname);
+ 	reject = 0;
+ 	if( strcaseeq(pfix,"REJECT") ){
+ 		strcpy(pfix,"ACCEPT");
+ 		reject = 1;
+ 	}
  
  	for( px = 0; px < NPARAMS; px++ ){
  		ps = &param_spec[px];
***************
*** 192,198 ****
--- 202,212 ----
  				continue;
  		}
  		if( strcasecmp(name,ps->p_name) == 0 )
+ 		{
+ 			if( reject )
+ 				return NPARAMS+px;
  			return px;
+ 		}
  		if( strcasecmp(name,ps->p_abbr) == 0 )
  			return px;
  	}
***************
*** 200,206 ****
--- 214,223 ----
  }
  
  typedef struct gateway {
+ 	/*
  	char	*g_pv[NPARAMS];
+ 	*/
+ 	char	*g_pv[NPARAMS*2];
  	char	 g_dontovw[NPARAMS];	/* don't overwrite */
  	char	*g_outheaders[32];
  	int	 g_outheaderN;
***************
*** 362,367 ****
--- 379,389 ----
  					Gw->g_outheaderN,vp);
  				Gw->g_outheaders[Gw->g_outheaderN++] = stralloc(vp);
  			}else
+ 			if( NPARAMS <= px ){
+ 				lfprintf(log,NULL,"conf + %s/%s:%s\r\n",
+ 					"REJECT",param_spec[px-NPARAMS].p_name,vp);
+ 				Gw->g_pv[px] = stralloc(vp);
+ 			}else
  			if( Gw->g_pv[px] == 0 || px == INHERIT ){
  				lfprintf(log,NULL,"conf + %s/%s:%s\r\n",
  					param_spec[px].p_pfix,param_spec[px].p_name,vp);
***************
*** 1794,1799 ****
--- 1816,1842 ----
  	scan_FTOSV(Conn,filter);
  	return 0;
  }
+ static find_usertext(tc,mfp,soff,log,p1)
+ 	FILE *tc,*mfp,*log;
+ 	char *p1;
+ {	char line[128];
+ 	int match;
+ 
+ 	match = 0;
+ 	if( fgetsHeaderField(mfp,"Subject",line,sizeof(line)) != 0 )
+ 		match = strmatch_list(line,p1,"",NULL,NULL);
+ 	if( match == 0 ){
+ 		RFC821_skipheader(mfp,NULL,NULL);
+ 		while( fgets(line,sizeof(line),mfp) != NULL ){
+ 			if( strmatch_list(line,p1,"",NULL,NULL) ){
+ 				match = 1;
+ 				break;
+ 			}
+ 		}
+ 		fseek(mfp,soff,0);
+ 	}
+ 	return match;
+ }
  
  #define DEFAULT_CONF "/-/builtin/config/smtpgate/@default/conf";
  
***************
*** 1946,1951 ****
--- 1989,2003 ----
  			}
  		}
  	}
+ 	if( p1 = getv(ACC_CONTTYPE) ){
+ 		char ty[128];
+ 		if( fgetsHeaderField(mfp,"Content-Type",ty,sizeof(ty)) != 0 ){
+ 			if( tobe_rejected(tc,"Content-Type",ty,p1,log) != 0 ){
+ 				rcode = -1;
+ 				goto EXIT;
+ 			}
+ 		}
+ 	}
  	if( p1 = getv(ACC_MAX_BYTES) ){
  		int max,siz;
  		max = kmxatoi(p1);
***************
*** 1993,1998 ****
--- 2045,2064 ----
  			goto EXIT;
  		}
  	}
+ 	if( p1 = getv(ACC_USERTEXT) ){
+ 		if( find_usertext(tc,mfp,soff,log,p1) == 0 ){
+ 			lfprintf(log,tc,"554 not include keyword\r\n");
+ 			rcode = -1;
+ 			goto EXIT;
+ 		}
+ 	}
+ 	if( p1 = getv(REJ_USERTEXT) ){
+ 		if( find_usertext(tc,mfp,soff,log,p1) ){
+ 			lfprintf(log,tc,"554 include forbidden keyword\r\n");
+ 			rcode = -1;
+ 			goto EXIT;
+ 		}
+ 	}
  	if( p1 = getv(ACC_MAX_EXCLAMS) ){
  		int chcount[256],max;
  
***************
*** 2002,2030 ****
  			lfprintf(log,NULL,"reject %s -- Max-Exclams: %d<%d\r\n",
  				"TOO MANY EXCLAMATIONS",max,chcount['!']);
  			lfprintf(log,tc,"554 too many exclamations\r\n");
- 			rcode = -1;
- 			goto EXIT;
- 		}
- 	}
- 	if( p1 = getv(ACC_USERTEXT) ){
- 		char line[128];
- 		int match;
- 
- 		match = 0;
- 		if( fgetsHeaderField(mfp,"Subject",line,sizeof(line)) != 0 )
- 			match = strmatch_list(line,p1,"",NULL,NULL);
- 		if( match == 0 ){
- 			RFC821_skipheader(mfp,NULL,NULL);
- 			while( fgets(line,sizeof(line),mfp) != NULL ){
- 				if( strmatch_list(line,p1,"",NULL,NULL) ){
- 					match = 1;
- 					break;
- 				}
- 			}
- 			fseek(mfp,soff,0);
- 		}
- 		if( match == 0 ){
- 			lfprintf(log,tc,"554 not include keyword\r\n");
  			rcode = -1;
  			goto EXIT;
  		}
--- 2068,2073 ----

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