I wonder whether something along those lines could be done:
--- grey.c 2009-02-17 20:39:54.000000000 +0100
+++ grey.c-mine 2009-02-17 21:08:27.000000000 +0100
@@ -321,6 +321,8 @@
while ((buf = fgetln(fp, &len))) {
if (buf[len-1] == '\n')
len--;
+ if (!strlen(buf) || buf[0] == '#')
+ continue;
if ((m = malloc(sizeof(struct mail_addr))) == NULL)
goto bad;
if ((len + 1) > sizeof(m->addr)) {
I regularely feel surprised not being able to comment my entries ;)
Cheers,
Stephan
--
-----------------------------------------------------------
StarTek - secure by design Tel ++41 44 500 111-0
Postfach 19 Fax ++41 44 500 111-2
CH-8118 Pfaffhausen/ZH Web http://startek.ch
RSA public key for email: http://startek.ch/people/star.key
-----------------------------------------------------------
This diff is very wrong. To know why, read the fgetln(3) manpage. -Otto
Ups, the man page is _very_ clear indeed ;)
OK, but it would be handy to allow comments. The attached patch honors
fgetln(3) habit not to return C style strings. But it does not detect
empty lines, i.e. lines with len==0.
--- grey.c.orig Tue Feb 17 23:27:39 2009
+++ grey.c Tue Feb 17 23:30:57 2009
@@ -321,6 +321,8 @@
while ((buf = fgetln(fp, &len))) {
if (buf[len-1] == '\n')
len--;
+ if ( len && (buf[0]=='#') )
+ continue;
if ((m = malloc(sizeof(struct mail_addr))) == NULL)
goto bad;
if ((len + 1) > sizeof(m->addr)) {
Umm, may be --- if (!len || (buf[0] == '#')) --- ?
This would skip also empty lines. This would be another handy feature. But I didn't want to chance too many things at once to minimize the risk that nothing is merged into the tree. This is not the first time we see patches for comments in spamd.alloweddomains on the mailinglist, but none of them were accepted.
no, this is what I use, it also prevents a failure if someone has a trailing space after the mailaddress (allow entry)
Index: grey.c
===================================================================
RCS file: /cvs/src/libexec/spamd/grey.c,v
retrieving revision 1.45
diff -u -r1.45 grey.c
--- grey.c 7 Dec 2008 21:12:52 -0000 1.45
+++ grey.c 18 Feb 2009 06:02:00 -0000
@@ -319,6 +319,18 @@
SLIST_REMOVE_HEAD(&match_suffix, entry);
if ((fp = fopen(alloweddomains_file, "r")) != NULL) {
while ((buf = fgetln(fp, &len))) {
+ /* strip white space-characters */
+ while (len > 0 && isspace(buf[len-1]))
+ len--;
+ while (len > 0 && isspace(*buf)) {
+ buf++;
+ len--;
+ }
+ /* jump over comments and blank lines */
+ if (*buf == '#' || *buf == '\n')
+ continue;
+ if (len == 0)
+ continue;
if (buf[len-1] == '\n')
len--;
if ((m = malloc(sizeof(struct mail_addr))) == NULL)
--
Jetzt 1 Monat kostenlos! GMX FreeDSL - Telefonanschluss + DSL
f|r nur 17,95 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a
You should do your len check before the check for '#' and '\n'. --patrick
you are right.
Index: grey.c
===================================================================
RCS file: /cvs/src/libexec/spamd/grey.c,v
retrieving revision 1.45
diff -u -r1.45 grey.c
--- grey.c 7 Dec 2008 21:12:52 -0000 1.45
+++ grey.c 18 Feb 2009 06:02:00 -0000
@@ -319,6 +319,18 @@
SLIST_REMOVE_HEAD(&match_suffix, entry);
if ((fp = fopen(alloweddomains_file, "r")) != NULL) {
while ((buf = fgetln(fp, &len))) {
+ /* strip white space-characters */
+ while (len > 0 && isspace(buf[len-1]))
+ len--;
+ while (len > 0 && isspace(*buf)) {
+ buf++;
+ len--;
+ }
+ /* jump over comments and blank lines */
+ if (len == 0)
+ continue;
+ if (*buf == '#' || *buf == '\n')
+ continue;
if (buf[len-1] == '\n')
len--;
if ((m = malloc(sizeof(struct mail_addr))) == NULL)
--
Jetzt 1 Monat kostenlos! GMX FreeDSL - Telefonanschluss + DSL
f|r nur 17,95 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a
ahh.. why are you doing it there? I don't think that does what you think it does :) I suggest you not mess with the fgetln/malloc dance. -Bob
