INN commit: branches/2.4 (12 files)

INN Commit Russ_Allbery at isc.org
Sun Apr 6 13:49:57 UTC 2008


    Date: Sunday, April 6, 2008 @ 06:49:56
  Author: iulius
Revision: 7748

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:
  branches/2.4/doc/pod/inn.conf.pod
  branches/2.4/doc/pod/innd.pod
  branches/2.4/include/inn/innconf.h
  branches/2.4/innd/art.c
  branches/2.4/innd/cc.c
  branches/2.4/innd/innd.c
  branches/2.4/innd/innd.h
  branches/2.4/innd/site.c
  branches/2.4/lib/innconf.c
  branches/2.4/samples/inn.conf.in
  branches/2.4/scripts/inncheck.in
  branches/2.4/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 13:16:45 UTC (rev 7747)
+++ doc/pod/inn.conf.pod	2008-04-06 13:49:56 UTC (rev 7748)
@@ -215,6 +215,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 13:16:45 UTC (rev 7747)
+++ doc/pod/innd.pod	2008-04-06 13:49:56 UTC (rev 7748)
@@ -364,8 +364,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 13:16:45 UTC (rev 7747)
+++ include/inn/innconf.h	2008-04-06 13:49:56 UTC (rev 7748)
@@ -39,6 +39,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 13:16:45 UTC (rev 7747)
+++ innd/art.c	2008-04-06 13:49:56 UTC (rev 7748)
@@ -440,11 +440,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;
@@ -456,6 +462,8 @@
 	  }
 	  /* next to write */
 	  p = HDR(HDR__PATH);
+          if (data->Hassamecluster)
+            p += Pathcluster.used;
 	}
 	break;
       case HDR__XREF:
@@ -1944,10 +1952,18 @@
     return false;
   }
 
-  if (strncmp(Path.data, hops[0], Path.used - 1) == 0)
+  i = strlen(hops[0]);
+  if (i == Path.used - 1 &&
+    strncmp(Path.data, hops[0], Path.used - 1) == 0)
     data->Hassamepath = true;
   else
     data->Hassamepath = false;
+  if (Pathcluster.data != NULL &&
+    i == 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 13:16:45 UTC (rev 7747)
+++ innd/cc.c	2008-04-06 13:49:56 UTC (rev 7748)
@@ -1388,6 +1388,16 @@
 	    Pathalias.Used = strlen(innconf->pathalias) + 1;
 	    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

Modified: innd/innd.c
===================================================================
--- innd/innd.c	2008-04-06 13:16:45 UTC (rev 7747)
+++ innd/innd.c	2008-04-06 13:49:56 UTC (rev 7748)
@@ -477,6 +477,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 13:16:45 UTC (rev 7747)
+++ innd/innd.h	2008-04-06 13:49:56 UTC (rev 7748)
@@ -240,6 +240,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;
 
 /*
@@ -584,6 +586,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 13:16:45 UTC (rev 7747)
+++ innd/site.c	2008-04-06 13:49:56 UTC (rev 7748)
@@ -390,11 +390,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 13:16:45 UTC (rev 7747)
+++ lib/innconf.c	2008-04-06 13:49:56 UTC (rev 7748)
@@ -163,6 +163,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 13:16:45 UTC (rev 7747)
+++ samples/inn.conf.in	2008-04-06 13:49:56 UTC (rev 7748)
@@ -44,6 +44,7 @@
 maxartsize:             1000000
 maxconnections:         50
 #pathalias:
+#pathcluster:
 pgpverify:              @pgpverify@
 port:                   119
 refusecybercancels:     false

Modified: scripts/inncheck.in
===================================================================
--- scripts/inncheck.in	2008-04-06 13:16:45 UTC (rev 7747)
+++ scripts/inncheck.in	2008-04-06 13:49:56 UTC (rev 7748)
@@ -306,6 +306,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 13:16:45 UTC (rev 7747)
+++ tests/lib/innconf-t.c	2008-04-06 13:49:56 UTC (rev 7748)
@@ -52,7 +52,7 @@
     fclose(config);
     ok(7, !innconf_check("config/tmp"));
     unlink("config/tmp");
-    ok_string(8, "config/tmp:25: unknown parameter foo\n", errors);
+    ok_string(8, "config/tmp:26: unknown parameter foo\n", errors);
     errors_uncapture();
     free(errors);
     errors = NULL;



More information about the inn-committers mailing list