Russ Allbery wrote... > Christoph Biedl writes: > > > One thing I miss after a first check of the manpages: I'd like to store > > these "flagged" articles (i.e. rejected by cleanfeed but _not_ dropped, > > is there a better word for this?) in a separate buffer. This buffer may > > be rather small, e.g. rotate in 24 hours. That's enough time to retrieve > > the article in case I'd like to know why cleanfeed didn't like it but it > > wouldn't consume to much disk space/history/etc. Otherwise "Binary in > > non-binary group" articles would have an impact on the retenition time > > of regular articles. > > > Is it possible to use this flag as a storage criteria? A very short > > glance into the sources suggests this should be not too difficult. > > It's not currently possible to do this. It's certainly something that > would be desirable to add, although I'm not sure the best general way to > do it. See the attached patch applies to INN 2.4.2, "works for me". applies to CURRENT after a small modification, but not tested yet. The patch adds a "filtered:" clause to the storage.conf definitions that matches if the article was rejected by the Perl or Python filter (or TCL which I've ignored for known reasons). Two comments when using "dontfilterrejected" after the patch applied: 1. Regarding storage.conf: Since the default value for "filtered:" is "false", not "don't care", there must be at least two statements in the storage.conf. One with "filtered: true", one with the default "filtered: false" (may be omitted). Else innd will throttle due to a missing storage class. 2. No messages about rejections to syslog were written. This has been changed since I'd still like to see how the perl filter is working. Since "rejecting" is a wrong term I've changed that to "filtering". Therefore innreport needed a tweak, too. Enjoy, Christoph -- Attached file included as plaintext by Ecartis -- diff -bur testnews.OLD/doc/man/storage.conf.5 testnews/doc/man/storage.conf.5 --- testnews.OLD/doc/man/storage.conf.5 2004-12-22 05:21:19.000000000 +0100 +++ testnews/doc/man/storage.conf.5 2005-08-07 01:19:47.000000000 +0200 @@ -36,6 +36,7 @@ expires: [,] options: exactmatch: + filtered: } .fi @@ -122,6 +123,14 @@ described above.) This is a boolan value and ``true'', ``yes'' and ``on'' are usable to enable this key. The case of these values is not significant. The default is false. +.TP +.B filtered +If this key is set to ``true'', the article must have been rejected by the +Perl/Python filter. This also requires that ``dontfilterrejected'' is set +to ``true'' in +.IR inn.conf . +This is a boolan value and ``true'', ``yes'' and ``on'' are usable to enable +this key. The case of these values is not significant. The default is false. .PP If an article matches all of the constraints of an entry, it is stored via that storage method and is associated with that . This diff -bur testnews.OLD/include/storage.h testnews/include/storage.h --- testnews.OLD/include/storage.h 2004-12-22 05:21:19.000000000 +0100 +++ testnews/include/storage.h 2005-08-06 20:47:15.000000000 +0200 @@ -44,6 +44,7 @@ void *private; /* A pointer to method specific data */ time_t arrived; /* The time when the article arrived */ time_t expires; /* The time when the article will be expired */ + bool filtered; /* Article was marked by the filter */ char *groups; /* Where Newsgroups header starts */ int groupslen; /* Length of Newsgroups header */ TOKEN *token; /* A pointer to the article's TOKEN */ diff -bur testnews.OLD/innd/art.c testnews/innd/art.c --- testnews.OLD/innd/art.c 2005-01-29 02:05:24.000000000 +0100 +++ testnews/innd/art.c 2005-08-07 10:53:25.000000000 +0200 @@ -518,6 +518,7 @@ arth.arrived = (time_t)0; arth.token = (TOKEN *)NULL; arth.expires = data->Expires; + arth.filtered = data->Filtered; if (innconf->storeonxref) { arth.groups = data->Replic; arth.groupslen = data->ReplicLength; @@ -1886,6 +1887,10 @@ TMRstop(TMR_PYTHON); if (filterrc != NULL) { if (innconf->dontrejectfiltered) { + snprintf(cp->Error, sizeof(cp->Error), "%d %.200s", NNTP_REJECTIT_VAL, + filterrc); + syslog(L_NOTICE, "filtering[python] %s %s", HDR(HDR__MESSAGE_ID), + cp->Error); Filtered = true; } else { snprintf(cp->Error, sizeof(cp->Error), "%d %.200s", NNTP_REJECTIT_VAL, @@ -1913,6 +1918,10 @@ if (filterrc) { if (innconf->dontrejectfiltered) { Filtered = true; + snprintf(cp->Error, sizeof(cp->Error), "%d %.200s", NNTP_REJECTIT_VAL, + filterrc); + syslog(L_NOTICE, "filtering[perl] %s %s", HDR(HDR__MESSAGE_ID), + cp->Error); } else { snprintf(cp->Error, sizeof(cp->Error), "%d %.200s", NNTP_REJECTIT_VAL, filterrc); @@ -2295,6 +2304,7 @@ for (i = 0; (ngp = GroupPointers[i]) != NULL; i++) ngp->PostCount = 0; + data->Filtered = Filtered; token = ARTstore(cp); /* change trailing '\r\n' to '\0\n' of all system header */ for (i = 0 ; i < MAX_ARTHEADER ; i++) { diff -bur testnews.OLD/innd/innd.h testnews/innd/innd.h --- testnews.OLD/innd/innd.h 2004-12-22 05:21:19.000000000 +0100 +++ testnews/innd/innd.h 2005-08-06 20:51:22.000000000 +0200 @@ -197,6 +197,7 @@ int HeaderLines; /* number of header lines */ long BytesValue; /* size of stored article, "\r\n" is counted as 1 byte */ + bool Filtered; /* Marked by filter */ char Bytes[16]; /* generated Bytes header */ int BytesLength; /* generated Bytes header length */ char * BytesHeader; /* where Bytes header begins in diff -bur testnews.OLD/scripts/innreport_inn.pm testnews/scripts/innreport_inn.pm --- testnews.OLD/scripts/innreport_inn.pm 2004-12-22 05:21:19.000000000 +0100 +++ testnews/scripts/innreport_inn.pm 2005-08-07 00:27:02.000000000 +0200 @@ -244,8 +244,8 @@ # SERVER cancelled +id return 1 if $left =~ /^SERVER cancelled /o; } - # rejecting[perl] - if ($left =~ /^rejecting\[perl\] <[^>]+> \d+ (.*)/o) { + # rejecting[perl]/filtering[perl] + if ($left =~ /^(?:rejecting|filtering)\[perl\] <[^>]+> \d+ (.*)/o) { $innd_filter_perl{$1}++; return 1; } diff -bur testnews.OLD/storage/interface.c testnews/storage/interface.c --- testnews.OLD/storage/interface.c 2004-12-22 05:21:19.000000000 +0100 +++ testnews/storage/interface.c 2005-08-07 01:11:43.000000000 +0200 @@ -334,6 +334,7 @@ #define SMexpire 14 #define SMoptions 15 #define SMexactmatch 16 +#define SMfiltered 17 static CONFTOKEN smtoks[] = { { SMlbrace, "{" }, @@ -345,6 +346,7 @@ { SMexpire, "expires:" }, { SMoptions, "options:" }, { SMexactmatch, "exactmatch:" }, + { SMfiltered, "filtered:" }, { 0, 0 } }; @@ -371,6 +373,7 @@ char *options = 0; int inbrace; bool exactmatch = false; + bool filtered = false; /* if innconf isn't already read in, do so. */ if (innconf == NULL) { @@ -423,6 +426,7 @@ minexpire = 0; maxexpire = 0; exactmatch = false; + filtered = false; } else { type = tok->type; @@ -470,6 +474,12 @@ || strcasecmp(p, "on") == 0) exactmatch = true; break; + case SMfiltered: + if (strcasecmp(p, "true") == 0 + || strcasecmp(p, "yes") == 0 + || strcasecmp(p, "on") == 0) + filtered = true; + break; default: SMseterror(SMERR_CONFIG, "Unknown keyword in method declaration"); syslog(L_ERROR, "SM Unknown keyword in method declaration, line %d: %s", f->lineno, tok->name); @@ -512,6 +522,7 @@ sub->minexpire = minexpire; sub->maxexpire = maxexpire; sub->exactmatch = exactmatch; + sub->filtered = filtered; free(method); method = 0; @@ -694,7 +705,8 @@ (!sub->minexpire || article.expires >= sub->minexpire) && (!sub->maxexpire || (article.expires <= sub->maxexpire)) && MatchGroups(article.groups, article.groupslen, sub->pattern, - sub->exactmatch)) { + sub->exactmatch) && + (sub->filtered == article.filtered)) { if (InitMethod(typetoindex[sub->type])) return sub; } diff -bur testnews.OLD/storage/interface.h testnews/storage/interface.h --- testnews.OLD/storage/interface.h 2004-12-22 05:21:19.000000000 +0100 +++ testnews/storage/interface.h 2005-08-06 20:46:17.000000000 +0200 @@ -45,6 +45,7 @@ method */ bool exactmatch; /* all newsgroups to which article belongs should match the patterns */ + bool filtered; /* article was marked by the filter */ struct __S_SUB__ *next; } STORAGE_SUB;