INN commit: branches/2.5 (4 files)

INN Commit rra at isc.org
Wed Aug 5 21:02:53 UTC 2009


    Date: Wednesday, August 5, 2009 @ 14:02:53
  Author: iulius
Revision: 8557

A wrong source was logged to the news log for local postings,
especially when the local server was not listed in incoming.conf
(RChostname() then returned a wrong static buffer and ARTlog()
also did not handle the case of a local connection).

Also fix the initialization of data->FeedsiteLength when needed.

Modified:
  branches/2.5/doc/pod/news.pod
  branches/2.5/innd/art.c
  branches/2.5/innd/chan.c
  branches/2.5/innd/rc.c

------------------+
 doc/pod/news.pod |    7 +++++++
 innd/art.c       |   33 +++++++++++++++++++++++++--------
 innd/chan.c      |    3 ++-
 innd/rc.c        |    2 ++
 4 files changed, 36 insertions(+), 9 deletions(-)

Modified: doc/pod/news.pod
===================================================================
--- doc/pod/news.pod	2009-08-05 21:01:48 UTC (rev 8556)
+++ doc/pod/news.pod	2009-08-05 21:02:53 UTC (rev 8557)
@@ -31,6 +31,13 @@
 
 =item *
 
+Fixed the source which is logged to the F<news> log file for local
+postings when the local server is not listed in F<incoming.conf>.
+A wrong name was used, taken amongst known peers.  The source is now
+logged as C<localhost>.
+
+=item *
+
 A new B<-L> flag has been added by Jonathan Kamens to B<makehistory>
 so as to specify a load average limit.  If the system load average exceeds
 the specified limit, B<makehistory> sleeps until it goes below the limit.

Modified: innd/art.c
===================================================================
--- innd/art.c	2009-08-05 21:01:48 UTC (rev 8556)
+++ innd/art.c	2009-08-05 21:02:53 UTC (rev 8557)
@@ -400,23 +400,35 @@
 
     /* Set up the headers that we want to use.  We only need to parse the path
        on rejections if logipaddr is false or we can't find a good host. */
-    if (innconf->logipaddr && cp->Address.ss_family != 0)
-        data->Feedsite = RChostname(cp);
-    else {
+    if (innconf->logipaddr) {
+        if (cp->Address.ss_family != 0) {
+            data->Feedsite = RChostname(cp);
+        } else {
+            data->Feedsite = "localhost";
+        }
+    } else {
         if (HDR_FOUND(HDR__PATH)) {
             HDR_PARSE_START(HDR__PATH);
             hopcount =
                 ARTparsepath(HDR(HDR__PATH), HDR_LEN(HDR__PATH), &data->Path);
             HDR_PARSE_END(HDR__PATH);
             hops = data->Path.List;
-            if (hopcount > 0 && hops != NULL && hops[0] != NULL)
+            if (hopcount > 0 && hops != NULL && hops[0] != NULL) {
                 data->Feedsite = hops[0];
-            else
+            } else {
                 data->Feedsite = "localhost";
-        } else if (cp->Address.ss_family != 0) {
-            data->Feedsite = RChostname(cp);
+            }
+        } else {
+            if (cp->Address.ss_family != 0) {
+                data->Feedsite = RChostname(cp);
+            } else {
+                data->Feedsite = "localhost";
+            }
         }
     }
+
+    data->FeedsiteLength = strlen(data->Feedsite);
+
     ARTlog(data, ART_REJECT, text != NULL ? text : cp->Error);
 
     if (HDR_FOUND(HDR__MESSAGE_ID))
@@ -804,6 +816,7 @@
   data->CurHeader = data->LastCRLF = data->Body = cp->Start;
   data->BytesHeader = NULL;
   data->Feedsite = "?";
+  data->FeedsiteLength = strlen(data->Feedsite);
   *cp->Error = '\0';
 }
 
@@ -1967,7 +1980,11 @@
   /* We have not parsed the Path: header yet.  We do not check for logipaddr
    * right now (it will be done afterwards and change data->Feedsite
    * in consequence).  We assign a feed site for the next call to ARTlog(). */
-  data->Feedsite = RChostname(cp);
+  if (cp->Address.ss_family != 0) {
+    data->Feedsite = RChostname(cp);
+  } else {
+    data->Feedsite = "localhost";
+  }
   if (data->Feedsite == NULL)
     data->Feedsite = CHANname(cp);
   data->FeedsiteLength = strlen(data->Feedsite);

Modified: innd/chan.c
===================================================================
--- innd/chan.c	2009-08-05 21:01:48 UTC (rev 8556)
+++ innd/chan.c	2009-08-05 21:02:53 UTC (rev 8557)
@@ -456,7 +456,8 @@
         snprintf(cp->Name, sizeof(cp->Name), "remconn:%d", cp->fd);
         break;
     case CTreject:
-        snprintf(cp->Name, sizeof(cp->Name), "%s rejected", RChostname(cp));
+        snprintf(cp->Name, sizeof(cp->Name), "%s rejected",
+                 cp->Address.ss_family == 0 ? "localhost" : RChostname(cp));
         break;
     case CTnntp:
         snprintf(cp->Name, sizeof(cp->Name), "%s:%d",

Modified: innd/rc.c
===================================================================
--- innd/rc.c	2009-08-05 21:01:48 UTC (rev 8556)
+++ innd/rc.c	2009-08-05 21:02:53 UTC (rev 8557)
@@ -1675,6 +1675,8 @@
 
 /*
 **  Find the name of a remote host we've connected to.
+**  Note that when cp->Address.ss_family is 0, the connection is local
+**  and the caller should use "localhost".
 */
 char *
 RChostname(const CHANNEL *cp)




More information about the inn-committers mailing list