Yahoo Groups archive

Milter-greylist

Index last updated: 2026-04-28 23:32 UTC

Thread

pattern for regex and comment

pattern for regex and comment

2004-10-17 by Hajimu UMEMOTO

Hi,

A friend of mine found a problem.  The following line causes parser
error:

	addr 192.168.0.0/24	# http://localhost/

It seems that `addr 192.168.0.0' is matched with netblock as `ADDR IPADDR',
and `/24 # http:/' is matched with regex.
The following patch fixes it as workaround:

Index: conf_lex.l
diff -u conf_lex.l.orig conf_lex.l
--- conf_lex.l.orig	Sun Oct 17 23:15:29 2004
+++ conf_lex.l	Mon Oct 18 00:08:44 2004
@@ -40,7 +40,7 @@
 all		[Aa][Ll][Ll]
 delay		-?[0-9]+[smhdw]?
 path		"\""[^"\n]+"\""
-regex		"/"[^/\n]+"/"
+regex		"/"[^/#\n]+"/"
 dumpfreq	[Dd][Uu][Mm][Pp][Ff][Rr][Ee][Qq]:?
 timeout		[Tt][Ii][Mm][Ee][Oo][Uu][Tt]:?
 domain		[Dd][Oo][Mm][Aa][Ii][Nn]:?


Sincerely,

--
Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan
ume@...  ume@{,jp.}FreeBSD.org
http://www.imasy.org/~ume/

Re: [milter-greylist] pattern for regex and comment

2004-10-17 by manu@netbsd.org

Hajimu UMEMOTO <ume@...> wrote:

>       addr 192.168.0.0/24     # http://localhost/

Fix in conf_lex.l:
> -regex                "/"[^/\n]+"/"
> +regex                "/"[^/#\n]+"/"

That makes illegal a # in the regex, something that might not be
desirable. Moreover comment at the end of the line are not really
supported. See greylist.conf(5):

NAME
     greylist.conf - milter-greylist configuration file

DESCRIPTION
     greylist.conf configures milter-greylist(8) operation. The format
     is simple: each line contains a keyword and an optionnal
     argument. Any line starting with a # is considered as a comment and
     is ignored. Blank lines are ignored as well. Comments at the end of
     are accepted in some situations, but do not take them as granted.

-- 
Emmanuel Dreyfus
Il y a 10 sortes de personnes dans le monde: ceux qui comprennent 
le binaire et ceux qui ne le comprennent pas.
manu@...

Re: [milter-greylist] pattern for regex and comment

2004-10-17 by Hajimu UMEMOTO

Hi,

>>>>> On Sun, 17 Oct 2004 20:27:39 +0200
>>>>> manu@... said:

manu> That makes illegal a # in the regex, something that might not be
manu> desirable.

Ah, yes, I thought it.  However, # should not apper in email address
nor domain name.  So, it is workaround. :-)

manu> Moreover comment at the end of the line are not really
manu> supported. See greylist.conf(5):

Okay, thanks.  I didn't see it in detail.

Sincerely,

--
Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan
ume@...  ume@{,jp.}FreeBSD.org
http://www.imasy.org/~ume/

Re: [milter-greylist] pattern for regex and comment

2004-10-17 by manu@netbsd.org

Hajimu UMEMOTO <ume@...> wrote:

> Ah, yes, I thought it.  However, # should not apper in email address
> nor domain name.  So, it is workaround. :-)

According to the revelant RFC, it is legal. I copied the regex from the
RFC:  
atext           [A-Za-z0-9!#$%&'*+/=?$^_`}{|~.-]{1,}
qtext           "\""[!-~]{1,}"\""
mailbox         {atext}|{qtext}

Support for funky chars like # is there to enable interoperability with
non Internet mail systems. Something that may be a bit outdated today,
but the RFC is the standard and the standard is there to be enforced,
isn't it?

-- 
Emmanuel Dreyfus
Il y a 10 sortes de personnes dans le monde: ceux qui comprennent 
le binaire et ceux qui ne le comprennent pas.
manu@...

Re: [milter-greylist] pattern for regex and comment

2004-10-17 by Hajimu UMEMOTO

Hi,

>>>>> On Sun, 17 Oct 2004 20:48:21 +0200
>>>>> manu@... said:

manu> Support for funky chars like # is there to enable interoperability with
manu> non Internet mail systems. Something that may be a bit outdated today,
manu> but the RFC is the standard and the standard is there to be enforced,
manu> isn't it?

I agree.

Sincerely,

--
Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan
ume@...  ume@{,jp.}FreeBSD.org
http://www.imasy.org/~ume/

Re: [milter-greylist] pattern for regex and comment

2004-10-19 by Hajimu UMEMOTO

Hi,

>>>>> On Sun, 17 Oct 2004 20:27:39 +0200
>>>>> manu@... said:

manu> Moreover comment at the end of the line are not really
manu> supported. See greylist.conf(5):

After some thought, I gave thought that it is still better to have
less restriction.  How about this patch?  It makes regex to match just
after from, rcpt or domain.

Index: conf_lex.l
diff -u conf_lex.l.orig conf_lex.l
--- conf_lex.l.orig	Sun Oct 17 23:15:29 2004
+++ conf_lex.l	Tue Oct 19 19:00:26 2004
@@ -48,6 +48,8 @@
 port		[Pp][Oo][Rr][Tt]
 star		"*"
 
+%s S_REGEX
+
 
 %{
 	#include "config.h"
@@ -74,8 +76,8 @@
 {blank}
 {comment}
 {addr}		{ return ADDR; }
-{from}		{ return FROM; }
-{rcpt}		{ return RCPT; }
+{from}		{ BEGIN(S_REGEX); return FROM; }
+{rcpt}		{ BEGIN(S_REGEX); return RCPT; }
 {peer}		{ return PEER; }
 {autowhite}	{ return AUTOWHITE; }
 {lazyaw}	{ return LAZYAW; }
@@ -99,7 +101,7 @@
 {all}		{ return ALL; }
 {dumpfreq}	{ return GLDUMPFREQ; }
 {timeout}	{ return GLTIMEOUT; }
-{domain}	{ return DOMAIN; }
+{domain}	{ BEGIN(S_REGEX); return DOMAIN; }
 {syncaddr}	{ return SYNCADDR; }
 {port}		{ return PORT; }
 {star}		{ return STAR; }
@@ -146,7 +148,7 @@
 			yylval.domainname[ADDRLEN] = '\0';
 			return DOMAINNAME; 
 		}
-{regex}		{
+<S_REGEX>{regex} {
 			strncpy(yylval.regex, yytext, REGEXLEN);
 			yylval.regex[PATHLEN] = '\0';
 			return REGEX;
@@ -156,6 +158,7 @@
 			return CIDR; 
 		}
 \n		{ 
+			BEGIN(0);
 			conf_line++; 
 			return yytext[0]; 
 		}



Sincerely,

--
Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan
ume@...  ume@{,jp.}FreeBSD.org
http://www.imasy.org/~ume/

Re: [milter-greylist] pattern for regex and comment

2004-10-21 by manu@netbsd.org

Hajimu UMEMOTO <ume@...> wrote:

> -{regex}              {
> +<S_REGEX>{regex} {
>                       strncpy(yylval.regex, yytext, REGEXLEN);
>                       yylval.regex[PATHLEN] = '\0';
>                       return REGEX;

It breaks at mine on this change:
flex -oconf_lex.c conf_lex.l
"conf_lex.l", line 150: unrecognized rule
"conf_lex.l", line 151: unrecognized rule
"conf_lex.l", line 154: unknown error processing section 1
"conf_lex.l", line 169: fatal parse error

Any hint?

-- 
Emmanuel Dreyfus
Il y a 10 sortes de personnes dans le monde: ceux qui comprennent 
le binaire et ceux qui ne le comprennent pas.
manu@...

Re: [milter-greylist] pattern for regex and comment

2004-10-21 by Hajimu UMEMOTO

Hi,

>>>>> On Thu, 21 Oct 2004 08:34:45 +0200
>>>>> manu@... said:

manu> It breaks at mine on this change:
manu> flex -oconf_lex.c conf_lex.l
manu> "conf_lex.l", line 150: unrecognized rule
manu> "conf_lex.l", line 151: unrecognized rule
manu> "conf_lex.l", line 154: unknown error processing section 1
manu> "conf_lex.l", line 169: fatal parse error

manu> Any hint?

Umm, it's strange.  I can comlile it on both FreeBSD 5.3-Rc1 and
4.10-RELEASE just fine.
IIRC, you are using NetBSD.  So, I've just tried on NetBSD 1.6.2 with
success:

ume@pug:~/milter-greylist-1.5.10:320> flex -oconf_lex.c conf_lex.l
ume@pug:~/milter-greylist-1.5.10:321> ll conf_lex.c
-rw-rw-r--  1 ume  users  65850 Oct 21 16:11 conf_lex.c
ume@pug:~/milter-greylist-1.5.10:322> flex -V
flex version 2.5.4
ume@pug:~/milter-greylist-1.5.10:323> uname -a
NetBSD pug 1.6.2_STABLE NetBSD 1.6.2_STABLE (GENERIC_XCAST6) #0: Tue May 25 11:50:09 JST 2004     root@pug:/usr/src/sys/arch/i386/compile/GENERIC_XCAST6 i386

The flex version is 2.5.4 on both FreeBSD and NetBSD.
Which version of flex are you using?

Sincerely,

--
Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan
ume@...  h-umemoto@...  ume@{,jp.}FreeBSD.org
http://www.imasy.org/~ume/

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.