INN commit: trunk (5 files)

INN Commit rra at isc.org
Sun May 24 10:24:01 UTC 2020


    Date: Sunday, May 24, 2020 @ 03:24:01
  Author: iulius
Revision: 10381

rnews:  new -d flag to log duplicates

When -d is used, rnews will syslog the message-ID and the Path header
value of each article rejected as a duplicate by the server.

It was previously only a compile-time option (DO_RNEWS_LOG_DUPS in
options.h), which I am unsure worked fine because there were several
wordings in the rnews code:  DONT_RNEWS_LOG_DUPS, SYSLOG_RNEWS_LOG_DUPS,
FILE_RNEWS_LOG_DUPS.

Remove INN_PATH_RNEWS_DUP_LOG (hard-coded to "/dev/null").  One can now
parameter its syslog configuration to obtain that information, if needed.

Modified:
  trunk/doc/pod/news.pod
  trunk/doc/pod/rnews.pod
  trunk/frontends/rnews.c
  trunk/include/inn/options.h
  trunk/include/inn/paths.h.in

------------------------+
 doc/pod/news.pod       |    5 +++++
 doc/pod/rnews.pod      |    7 ++++++-
 frontends/rnews.c      |   39 +++++++++++++++------------------------
 include/inn/options.h  |    3 ---
 include/inn/paths.h.in |    1 -
 5 files changed, 26 insertions(+), 29 deletions(-)

Modified: doc/pod/news.pod
===================================================================
--- doc/pod/news.pod	2020-05-24 09:55:35 UTC (rev 10380)
+++ doc/pod/news.pod	2020-05-24 10:24:01 UTC (rev 10381)
@@ -38,6 +38,11 @@
 B<rnews> just logs and discards any articles that are rejected or cannot
 be parsed for some reason.
 
+=item *
+
+Added new B<-d> flag to B<rnews> to log via syslog the message-ID and the
+Path header value of each article rejected as a duplicate.
+
 =back
 
 =head1 Changes in 2.6.3

Modified: doc/pod/rnews.pod
===================================================================
--- doc/pod/rnews.pod	2020-05-24 09:55:35 UTC (rev 10380)
+++ doc/pod/rnews.pod	2020-05-24 10:24:01 UTC (rev 10381)
@@ -4,7 +4,7 @@
 
 =head1 SYNOPSIS
 
-B<rnews> [B<-bNUv>] [B<-h> I<host>] [B<-P> I<port>] [B<-rS> I<server>]
+B<rnews> [B<-abdNUv>] [B<-h> I<host>] [B<-P> I<port>] [B<-rS> I<server>]
 [I<file>]
 
 =head1 DESCRIPTION
@@ -91,6 +91,11 @@
 be backed up in the F<bad> sub-directory of I<pathincoming> (as set
 in F<inn.conf>).
 
+=item B<-d>
+
+If B<-d> is given, B<rnews> will log via syslog the message-ID and the
+Path header value of each article rejected as a duplicate by the server.
+
 =item B<-h> I<host>
 
 If B<-h> is given, B<rnews> will log the message ID and I<host> via syslog

Modified: frontends/rnews.c
===================================================================
--- frontends/rnews.c	2020-05-24 09:55:35 UTC (rev 10380)
+++ frontends/rnews.c	2020-05-24 10:24:01 UTC (rev 10381)
@@ -36,6 +36,7 @@
 
 static bool     additionalUnpackers = true;
 static bool     backupBad = false;
+static bool     logDuplicates = false;
 static bool     Verbose = false;
 static const char	*InputFile = "stdin";
 static char	*UUCPHost;
@@ -227,12 +228,7 @@
     const char		*id = NULL;
     char                *msgid;
     char		buff[SMBUF];
-#if	defined(FILE_RNEWS_LOG_DUPS)
-    FILE		*F;
-#endif	/* defined(FILE_RNEWS_LOG_DUPS) */
-#if	!defined(DONT_RNEWS_LOG_DUPS)
     char		path[40];
-#endif	/* !defined(DONT_RNEWS_LOG_DUPS) */
 
     /* Empty article? */
     if (*article == '\0')
@@ -253,13 +249,13 @@
 	    id = p;
 	    continue;
 	}
-#if	!defined(DONT_RNEWS_LOG_DUPS)
-	if (IS_PATH(hp)) {
-	    strlcpy(path, p, sizeof(path));
-	    if ((q = strchr(path, '\r')) != NULL)
-		*q = '\0';
-	}
-#endif	/* !defined(DONT_RNEWS_LOG_DUPS) */
+        if (logDuplicates) {
+            if (IS_PATH(hp)) {
+                strlcpy(path, p, sizeof(path));
+                if ((q = strchr(path, '\r')) != NULL)
+                    *q = '\0';
+            }
+        }
     }
 
     /* Send the NNTP "ihave" message. */
@@ -302,17 +298,9 @@
     case NNTP_CONT_IHAVE:
 	break;
     case NNTP_FAIL_IHAVE_REFUSE:
-#if	defined(SYSLOG_RNEWS_LOG_DUPS)
-	*p = '\0';
-        notice("duplicate %s %s", id, path);
-#endif	/* defined(SYSLOG_RNEWS_LOG_DUPS) */
-#if	defined(FILE_RNEWS_LOG_DUPS)
-	if ((F = fopen(INN_PATH_RNEWS_DUP_LOG, "a")) != NULL) {
-	    *p = '\0';
-	    fprintf(F, "duplicate %s %s\n", id, path);
-	    fclose(F);
-	}
-#endif	/* defined(FILE_RNEWS_LOG_DUPS) */
+        if (logDuplicates) {
+            notice("duplicate %s %s", msgid, path);
+        }
         free(wirefmt);
 	return true;
     }
@@ -893,7 +881,7 @@
     /* Parse JCL. */
     fd = STDIN_FILENO;
     mode = '\0';
-    while ((i = getopt(ac, av, "abh:NP:r:S:Uv")) != EOF)
+    while ((i = getopt(ac, av, "abdh:NP:r:S:Uv")) != EOF)
 	switch (i) {
 	default:
 	    die("usage error");
@@ -904,6 +892,9 @@
         case 'b':
             backupBad = true;
             break;
+        case 'd':
+            logDuplicates = true;
+            break;
 	case 'h':
 	    UUCPHost = *optarg ? optarg : NULL;
 	    break;

Modified: include/inn/options.h
===================================================================
--- include/inn/options.h	2020-05-24 09:55:35 UTC (rev 10380)
+++ include/inn/options.h	2020-05-24 10:24:01 UTC (rev 10381)
@@ -50,9 +50,6 @@
    for the full algorithm. */
 #define DO_MUNGE_GECOS
 
-/* Define if rnews should syslog articles rejected as duplicates. */
-/* #undef DO_RNEWS_LOG_DUPS */
-
 /* Value to pass to dbzincore() inside innd.  Under some bizarre low memory
    circumstance, you may want this not to be 1, but normally you always want
    to load the full history indexes into innd's memory.  Has no effect if

Modified: include/inn/paths.h.in
===================================================================
--- include/inn/paths.h.in	2020-05-24 09:55:35 UTC (rev 10380)
+++ include/inn/paths.h.in	2020-05-24 10:24:01 UTC (rev 10381)
@@ -86,7 +86,6 @@
 
 /* Absolute paths. */
 #define INN_PATH_TMP                    "@PATH_TMP@"
-#define INN_PATH_RNEWS_DUP_LOG          "/dev/null"
 
 /* Always relative to pathtmp. */
 #define INN_PATH_TEMPACTIVE             "activeXXXXXX"



More information about the inn-committers mailing list