INN commit: trunk (5 files)
INN Commit
rra at isc.org
Sat Sep 25 21:32:08 UTC 2010
Date: Saturday, September 25, 2010 @ 14:32:07
Author: iulius
Revision: 9115
innd, as a relaying agent, now examines the Injection-Date: header,
when present. It contains the posting date (used for history).
makehistory now also uses it, when present.
Otherwise, the Date: header is used.
nnrpd, as an injecting agent, checks whether the Date: header field
is not too far in the past. It is a recommendation of RFC 5537
since not all news servers support the Injection-Date: header. (The
article would then suffer from poorer propagation.)
Modified:
trunk/doc/pod/news.pod
trunk/expire/makehistory.c
trunk/innd/art.c
trunk/nnrpd/post.c
trunk/scripts/innreport_inn.pm
--------------------------+
doc/pod/news.pod | 6 ++++++
expire/makehistory.c | 36 ++++++++++++++++++++++++++++++------
innd/art.c | 39 ++++++++++++++++++++++++++++-----------
nnrpd/post.c | 9 +++++++++
scripts/innreport_inn.pm | 13 +++++++++----
5 files changed, 82 insertions(+), 21 deletions(-)
Modified: doc/pod/news.pod
===================================================================
--- doc/pod/news.pod 2010-09-24 20:15:47 UTC (rev 9114)
+++ doc/pod/news.pod 2010-09-25 21:32:07 UTC (rev 9115)
@@ -160,6 +160,12 @@
=item *
+The Injection-Date: header, when present, is now used by B<innd> and
+B<makehistory> to determine the posting date of an article. Otherwise,
+the Date: header is used.
+
+=item *
+
It is now possible to run a script at the end of the execution of
B<innshellvars> scripts. If a file named F<innshellvars.local>,
F<innshellvars.pl.local> or F<innshellvars.tcl.local> is present and
Modified: expire/makehistory.c
===================================================================
--- expire/makehistory.c 2010-09-24 20:15:47 UTC (rev 9114)
+++ expire/makehistory.c 2010-09-25 21:32:07 UTC (rev 9115)
@@ -95,6 +95,7 @@
static char BYTES[] = "Bytes";
static char DATE[] = "Date";
static char EXPIRES[] = "Expires";
+static char INJECTIONDATE[] = "Injection-Date";
static char LINES[] = "Lines";
static char MESSAGEID[] = "Message-ID";
static char XREF[] = "Xref";
@@ -104,6 +105,7 @@
static ARTOVERFIELD *Bytesp = (ARTOVERFIELD *)NULL;
static ARTOVERFIELD *Datep = (ARTOVERFIELD *)NULL;
static ARTOVERFIELD *Expp = (ARTOVERFIELD *)NULL;
+static ARTOVERFIELD *InjectionDatep = (ARTOVERFIELD *)NULL;
static ARTOVERFIELD *Linesp = (ARTOVERFIELD *)NULL;
static ARTOVERFIELD *Msgidp = (ARTOVERFIELD *)NULL;
static ARTOVERFIELD *Xrefp = (ARTOVERFIELD *)NULL;
@@ -465,6 +467,9 @@
if (strncasecmp(extraoverview->strings[i],
EXPIRES, strlen(EXPIRES)) == 0)
Expp = fp;
+ if (strncasecmp(extraoverview->strings[i],
+ INJECTIONDATE, strlen(INJECTIONDATE)) == 0)
+ InjectionDatep = fp;
fp++;
}
@@ -476,6 +481,8 @@
Missfieldsize++;
if (Expp == (ARTOVERFIELD *)NULL)
Missfieldsize++;
+ if (InjectionDatep == (ARTOVERFIELD *)NULL)
+ Missfieldsize++;
if (Linesp == (ARTOVERFIELD *)NULL)
Missfieldsize++;
if (Msgidp == (ARTOVERFIELD *)NULL)
@@ -510,6 +517,15 @@
fp->HeaderLength = 0;
Expp = fp++;
}
+ if (InjectionDatep == (ARTOVERFIELD *)NULL) {
+ fp->NeedHeadername = true;
+ fp->Headername = xstrdup(INJECTIONDATE);
+ fp->HeadernameLength = strlen(INJECTIONDATE);
+ fp->Header = (char *)NULL;
+ fp->HasHeader = false;
+ fp->HeaderLength = 0;
+ InjectionDatep = fp++;
+ }
if (Linesp == (ARTOVERFIELD *)NULL) {
fp->NeedHeadername = false;
fp->Headername = xstrdup(LINES);
@@ -722,14 +738,22 @@
* newer than start time of makehistory.
*/
- if (!Datep->HasHeader) {
+ if (!InjectionDatep->HasHeader && !Datep->HasHeader) {
Posted = Arrived;
} else {
- buffer_set(&buffer, Datep->Header, Datep->HeaderLength);
- buffer_append(&buffer, NUL, 1);
- Posted = parsedate_rfc5322_lax(buffer.data);
- if (Posted == (time_t) -1)
- Posted = Arrived;
+ if (InjectionDatep->HasHeader) {
+ buffer_set(&buffer, InjectionDatep->Header, InjectionDatep->HeaderLength);
+ buffer_append(&buffer, NUL, 1);
+ Posted = parsedate_rfc5322_lax(buffer.data);
+ if (Posted == (time_t) -1)
+ Posted = Arrived;
+ } else {
+ buffer_set(&buffer, Datep->Header, Datep->HeaderLength);
+ buffer_append(&buffer, NUL, 1);
+ Posted = parsedate_rfc5322_lax(buffer.data);
+ if (Posted == (time_t) -1)
+ Posted = Arrived;
+ }
}
if (Expp->HasHeader) {
Modified: innd/art.c
===================================================================
--- innd/art.c 2010-09-24 20:15:47 UTC (rev 9114)
+++ innd/art.c 2010-09-25 21:32:07 UTC (rev 9115)
@@ -1041,17 +1041,34 @@
}
}
- /* Is article too old? */
- /* assumes Date header is required header */
- p = HDR(HDR__DATE);
- data->Posted = parsedate_rfc5322_lax(p);
- if (data->Posted == (time_t) -1) {
- sprintf(buff, "%d Bad \"Date\" header -- \"%s\"",
- ihave ? NNTP_FAIL_IHAVE_REJECT : NNTP_FAIL_TAKETHIS_REJECT,
- MaxLength(p, p));
- TMRstop(TMR_ARTCLEAN);
- return false;
+ /* Is the article too old? */
+ /* Assumes the Date: header is a required header.
+ * Check the presence of the Injection-Date: header field before.
+ * Set the time the article was posted. */
+ if (HDR_FOUND(HDR__INJECTION_DATE)) {
+ p = HDR(HDR__INJECTION_DATE);
+ data->Posted = parsedate_rfc5322_lax(p);
+
+ if (data->Posted == (time_t) -1) {
+ sprintf(buff, "%d Bad \"Injection-Date\" header -- \"%s\"",
+ ihave ? NNTP_FAIL_IHAVE_REJECT : NNTP_FAIL_TAKETHIS_REJECT,
+ MaxLength(p, p));
+ TMRstop(TMR_ARTCLEAN);
+ return false;
+ }
+ } else {
+ p = HDR(HDR__DATE);
+ data->Posted = parsedate_rfc5322_lax(p);
+
+ if (data->Posted == (time_t) -1) {
+ sprintf(buff, "%d Bad \"Date\" header -- \"%s\"",
+ ihave ? NNTP_FAIL_IHAVE_REJECT : NNTP_FAIL_TAKETHIS_REJECT,
+ MaxLength(p, p));
+ TMRstop(TMR_ARTCLEAN);
+ return false;
+ }
}
+
if (innconf->artcutoff != 0) {
long cutoff = innconf->artcutoff * 24 * 60 * 60;
@@ -1064,7 +1081,7 @@
}
}
if (data->Posted > Now.tv_sec + DATE_FUZZ) {
- sprintf(buff, "%d Article posted in the future -- \"%s\"",
+ sprintf(buff, "%d Article injected or posted in the future -- \"%s\"",
ihave ? NNTP_FAIL_IHAVE_REJECT : NNTP_FAIL_TAKETHIS_REJECT,
MaxLength(p, p));
TMRstop(TMR_ARTCLEAN);
Modified: nnrpd/post.c
===================================================================
--- nnrpd/post.c 2010-09-24 20:15:47 UTC (rev 9114)
+++ nnrpd/post.c 2010-09-25 21:32:07 UTC (rev 9115)
@@ -384,6 +384,15 @@
return "Can't parse Date: header";
if (t > now + DATE_FUZZ)
return "Article posted in the future";
+ /* This check is done for Date: by nnrpd.
+ * innd, as a relaying agent, does not check it when an Injection-Date:
+ * header is present. */
+ if (innconf->artcutoff != 0) {
+ long cutoff = innconf->artcutoff * 24 * 60 * 60;
+ if (t < now - cutoff)
+ return "Article posted too far in the past (check still "
+ "done for legacy reasons on the Date: header)";
+ }
}
/* Newsgroups: is checked later. */
Modified: scripts/innreport_inn.pm
===================================================================
--- scripts/innreport_inn.pm 2010-09-24 20:15:47 UTC (rev 9114)
+++ scripts/innreport_inn.pm 2010-09-25 21:32:07 UTC (rev 9115)
@@ -413,8 +413,8 @@
$innd_no_colon_space{$server}++;
return 1;
}
- # 437 Article posted in the future -- "xxxxx"
- if ($left =~ /(\S+) <[^>]+> (?:437|439) Article posted in the future -- \"[^\"]+\"/o) {
+ # 437 Article injected or posted in the future -- "xxxxx"
+ if ($left =~ /(\S+) <[^>]+> (?:437|439) Article injected or posted in the future -- \"[^\"]+\"/o) {
my $server = $1;
$server = lc $server unless $CASE_SENSITIVE;
$innd_posted_future{$server}++;
@@ -1807,8 +1807,13 @@
$rnews_bogus_date{$1}++;
return 1;
}
- # rejected 437 Article posted in the future
- if ($left =~ /rejected (?:437|439) Article posted in the future -- \"(.*)\"$/o) {
+ # rejected 437 Bad "Injection-Date"
+ if ($left =~ /rejected (?:437|439) Bad \"Injection-Date\" (.*)$/o) {
+ $rnews_bogus_date{$1}++;
+ return 1;
+ }
+ # rejected 437 Article injected or posted in the future
+ if ($left =~ /rejected (?:437|439) Article injected or posted in the future -- \"(.*)\"$/o) {
$rnews_bogus_date{"(future) $1"}++;
return 1;
}
More information about the inn-committers
mailing list