INN commit: trunk (12 files)
INN Commit
Russ_Allbery at isc.org
Sun Apr 6 13:16:46 UTC 2008
Date: Sunday, April 6, 2008 @ 06:16:45
Author: iulius
Revision: 7747
This patch adds a new inn.conf parameter called "pathcluster"
which allows to append a common name to the Path: header
on all incoming articles. "pathhost" and "pathalias" (if set)
are still appended to the path as usual, but "pathcluster"
is always appended as the last element (e.g. on the leftmost
side of the Path: header).
If the last pathname of the incoming article is the same as
"pathcluster", it is stripped from the path.
Thanks to Miquel van Smoorenburg for this patch.
Modified:
trunk/doc/pod/inn.conf.pod
trunk/doc/pod/innd.pod
trunk/include/inn/innconf.h
trunk/innd/art.c
trunk/innd/cc.c
trunk/innd/innd.c
trunk/innd/innd.h
trunk/innd/site.c
trunk/lib/innconf.c
trunk/samples/inn.conf.in
trunk/scripts/inncheck.in
trunk/tests/lib/innconf-t.c
-----------------------+
doc/pod/inn.conf.pod | 10 ++++++++++
doc/pod/innd.pod | 5 +++--
include/inn/innconf.h | 1 +
innd/art.c | 20 ++++++++++++++++++--
innd/cc.c | 10 ++++++++++
innd/innd.c | 9 +++++++++
innd/innd.h | 3 +++
innd/site.c | 17 ++++++++++++-----
lib/innconf.c | 1 +
samples/inn.conf.in | 1 +
scripts/inncheck.in | 3 +++
tests/lib/innconf-t.c | 2 +-
12 files changed, 72 insertions(+), 10 deletions(-)
Modified: doc/pod/inn.conf.pod
===================================================================
--- doc/pod/inn.conf.pod 2008-04-06 10:38:54 UTC (rev 7746)
+++ doc/pod/inn.conf.pod 2008-04-06 13:16:45 UTC (rev 7747)
@@ -237,6 +237,16 @@
a particular organization to add a common identity string to the
Path: header. The default value is unset.
+=item I<pathcluster>
+
+If set, this value is appended to the Path: header of accepted posts
+(after I<pathhost>) if it isn't already present as the last element
+of the Path: header. The main purpose of this parameter is to make
+several news servers appear as one server. The default value is unset.
+
+Note that the Path: header reads right to left, so appended means inserted
+at the leftmost side of the Path: header.
+
=item I<pgpverify>
Whether to enable PGP verification of control messages other than cancel.
Modified: doc/pod/innd.pod
===================================================================
--- doc/pod/innd.pod 2008-04-06 10:38:54 UTC (rev 7746)
+++ doc/pod/innd.pod 2008-04-06 13:16:45 UTC (rev 7747)
@@ -360,8 +360,9 @@
The local site's name (as set with the I<pathhost> parameter in
F<inn.conf>) and an exclamation point are prepended to the Path: header,
provided the first site name in the Path: header is different from the
-local one. In addition, I<pathalias> may be similarly prepended to the
-Path: header; see inn.conf(5) for the details.
+local one. In addition, I<pathalias> and I<pathcluster> may be similarly
+respectively prepended and appended to the Path: header; see inn.conf(5)
+for the details.
The Xref: header is removed and a new one created.
Modified: include/inn/innconf.h
===================================================================
--- include/inn/innconf.h 2008-04-06 10:38:54 UTC (rev 7746)
+++ include/inn/innconf.h 2008-04-06 13:16:45 UTC (rev 7747)
@@ -41,6 +41,7 @@
long maxartsize; /* Reject articles bigger than this */
long maxconnections; /* Max number of incoming NNTP connections */
char *pathalias; /* Prepended Host for the Path: line */
+ char *pathcluster; /* Appended Host for the Path: line */
bool pgpverify; /* Verify control messages with pgpverify? */
long port; /* Which port innd should listen on */
bool refusecybercancels; /* Reject message IDs with "<cancel."? */
Modified: innd/art.c
===================================================================
--- innd/art.c 2008-04-06 10:38:54 UTC (rev 7746)
+++ innd/art.c 2008-04-06 13:16:45 UTC (rev 7747)
@@ -473,11 +473,17 @@
for (p = Article->data + cp->Start, j = 0 ; j < i ; j++) {
switch (hp[j].index) {
case HDR__PATH:
- if (!data->Hassamepath || data->AddAlias) {
+ if (!data->Hassamepath || data->AddAlias || Pathcluster.used) {
/* write heading data */
iov[iovcnt].iov_base = (char *) p;
iov[iovcnt++].iov_len = HDR(HDR__PATH) - p;
arth.len += HDR(HDR__PATH) - p;
+ /* append clusterpath */
+ if (Pathcluster.used) {
+ iov[iovcnt].iov_base = Pathcluster.data;
+ iov[iovcnt++].iov_len = Pathcluster.used;
+ arth.len += Pathcluster.used;
+ }
/* now append new one */
iov[iovcnt].iov_base = Path.data;
iov[iovcnt++].iov_len = Path.used;
@@ -489,6 +495,8 @@
}
/* next to write */
p = HDR(HDR__PATH);
+ if (data->Hassamecluster)
+ p += Pathcluster.used;
}
break;
case HDR__XREF:
@@ -1933,10 +1941,18 @@
return false;
}
- if (strncmp(Path.data, hops[0], Path.used - 1) == 0)
+ i = strlen(hops[0]);
+ if (i == (signed int) Path.used - 1 &&
+ strncmp(Path.data, hops[0], Path.used - 1) == 0)
data->Hassamepath = true;
else
data->Hassamepath = false;
+ if (Pathcluster.data != NULL &&
+ i == (signed int) Pathcluster.used - 1 &&
+ strncmp(Pathcluster.data, hops[0], Pathcluster.used - 1) == 0)
+ data->Hassamecluster = true;
+ else
+ data->Hassamecluster = false;
if (Pathalias.data != NULL &&
!ListHas((const char **)hops, (const char *)innconf->pathalias))
data->AddAlias = true;
Modified: innd/cc.c
===================================================================
--- innd/cc.c 2008-04-06 10:38:54 UTC (rev 7746)
+++ innd/cc.c 2008-04-06 13:16:45 UTC (rev 7747)
@@ -1381,6 +1381,16 @@
Pathalias.Data = xmalloc(Pathalias.Used + 1);
sprintf(Pathalias.Data, "%s!", innconf->pathalias);
}
+ if (Pathcluster.Used > 0)
+ free(Pathcluster.Data);
+ if (innconf->pathcluster == NULL) {
+ Pathcluster.Used = 0;
+ Pathcluster.Data = NULL;
+ } else {
+ Pathcluster.Used = strlen(innconf->pathcluster) + 1;
+ Pathcluster.Data = xmalloc(Pathcluster.Used + 1);
+ sprintf(Pathcluster.Data, "%s!", innconf->pathcluster);
+ }
}
#endif
#ifdef DO_PERL
Modified: innd/innd.c
===================================================================
--- innd/innd.c 2008-04-06 10:38:54 UTC (rev 7746)
+++ innd/innd.c 2008-04-06 13:16:45 UTC (rev 7747)
@@ -463,6 +463,15 @@
Pathalias.data = xmalloc(Pathalias.size);
snprintf(Pathalias.data, Pathalias.size, "%s!", innconf->pathalias);
}
+ if (innconf->pathcluster == NULL) {
+ Pathcluster.used = 0;
+ Pathcluster.data = NULL;
+ } else {
+ Pathcluster.used = strlen(innconf->pathcluster) + 1;
+ Pathcluster.size = Pathcluster.used + 1;
+ Pathcluster.data = xmalloc(Pathcluster.size);
+ snprintf(Pathcluster.data, Pathcluster.size, "%s!", innconf->pathcluster);
+ }
/* Trace history ? */
if (innconf->stathist != NULL) {
syslog(L_NOTICE, "logging hist stats to %s", innconf->stathist);
Modified: innd/innd.h
===================================================================
--- innd/innd.h 2008-04-06 10:38:54 UTC (rev 7746)
+++ innd/innd.h 2008-04-06 13:16:45 UTC (rev 7747)
@@ -229,6 +229,8 @@
bool AddAlias; /* Whether Pathalias should be added
to this article */
bool Hassamepath; /* Whether this article matches Path */
+ bool Hassamecluster; /* Whether this article matches
+ Pathcluster */
} ARTDATA;
@@ -575,6 +577,7 @@
extern bool Tracing;
EXTERN struct buffer Path;
EXTERN struct buffer Pathalias;
+EXTERN struct buffer Pathcluster;
EXTERN char * ModeReason; /* NNTP reject message */
EXTERN char * NNRPReason; /* NNRP reject message */
EXTERN char * Reservation; /* Reserved lock message */
Modified: innd/site.c
===================================================================
--- innd/site.c 2008-04-06 10:38:54 UTC (rev 7746)
+++ innd/site.c 2008-04-06 13:16:45 UTC (rev 7747)
@@ -398,11 +398,18 @@
case FEED_PATH:
if (Dirty)
buffer_append(bp, ITEMSEP, strlen(ITEMSEP));
- if (!Data->Hassamepath)
- buffer_append(bp, Path.data, Path.used);
- if (Data->AddAlias)
- buffer_append(bp, Pathalias.data, Pathalias.used);
- buffer_append(bp, HDR(HDR__PATH), HDR_LEN(HDR__PATH));
+ if (!Data->Hassamepath || Data->AddAlias || Pathcluster.used) {
+ if (Pathcluster.used)
+ buffer_append(bp, Pathcluster.data, Pathcluster.used);
+ buffer_append(bp, Path.data, Path.used);
+ if (Data->AddAlias)
+ buffer_append(bp, Pathalias.data, Pathalias.used);
+ }
+ if (Data->Hassamecluster)
+ buffer_append(bp, HDR(HDR__PATH) + Pathcluster.used,
+ HDR_LEN(HDR__PATH) - Pathcluster.used);
+ else
+ buffer_append(bp, HDR(HDR__PATH), HDR_LEN(HDR__PATH));
break;
case FEED_REPLIC:
if (Dirty)
Modified: lib/innconf.c
===================================================================
--- lib/innconf.c 2008-04-06 10:38:54 UTC (rev 7746)
+++ lib/innconf.c 2008-04-06 13:16:45 UTC (rev 7747)
@@ -164,6 +164,7 @@
{ K(nntplinklog), BOOL (false) },
{ K(noreader), BOOL (false) },
{ K(pathalias), STRING (NULL) },
+ { K(pathcluster), STRING (NULL) },
{ K(pauseretrytime), NUMBER (300) },
{ K(peertimeout), NUMBER (3600) },
{ K(port), NUMBER (119) },
Modified: samples/inn.conf.in
===================================================================
--- samples/inn.conf.in 2008-04-06 10:38:54 UTC (rev 7746)
+++ samples/inn.conf.in 2008-04-06 13:16:45 UTC (rev 7747)
@@ -47,6 +47,7 @@
maxartsize: 1000000
maxconnections: 50
#pathalias:
+#pathcluster:
pgpverify: @DO_PGPVERIFY@
port: 119
refusecybercancels: false
Modified: scripts/inncheck.in
===================================================================
--- scripts/inncheck.in 2008-04-06 10:38:54 UTC (rev 7746)
+++ scripts/inncheck.in 2008-04-06 13:16:45 UTC (rev 7747)
@@ -299,6 +299,9 @@
# } elsif ( $k eq "pathalias" ) {
# print "$file:$line: pathalias has a ! in it\n"
# if $v =~ /!/;
+# } elsif ( $k eq "pathcluster" ) {
+# print "$file:$line: pathcluster has a ! in it\n"
+# if $v =~ /!/;
# } elsif ( $k eq "server" ) {
# print "$file:$line: server (`$v') isn't local hostname\n"
# if $pedantic && $fqdn !~ /^$v/;
Modified: tests/lib/innconf-t.c
===================================================================
--- tests/lib/innconf-t.c 2008-04-06 10:38:54 UTC (rev 7746)
+++ tests/lib/innconf-t.c 2008-04-06 13:16:45 UTC (rev 7747)
@@ -55,7 +55,7 @@
fclose(config);
ok(7, !innconf_check("config/tmp"));
unlink("config/tmp");
- ok_string(8, "config/tmp:26: unknown parameter foo\n", errors);
+ ok_string(8, "config/tmp:27: unknown parameter foo\n", errors);
errors_uncapture();
free(errors);
errors = NULL;
More information about the inn-committers
mailing list