INN commit: branches/2.5 (innd/nc.c nnrpd/misc.c)

INN Commit rra at isc.org
Sun Nov 15 09:17:59 UTC 2009


    Date: Sunday, November 15, 2009 @ 01:17:59
  Author: iulius
Revision: 8753

* Improve logging of MODE commands in news.notice.

* Specify that MODE READER cannot be sent after a successful
authentication because the client is known as a reader.

Modified:
  branches/2.5/innd/nc.c
  branches/2.5/nnrpd/misc.c

--------------+
 innd/nc.c    |   30 ++++++++++++++++--------------
 nnrpd/misc.c |    3 ++-
 2 files changed, 18 insertions(+), 15 deletions(-)

Modified: innd/nc.c
===================================================================
--- innd/nc.c	2009-11-15 09:17:43 UTC (rev 8752)
+++ innd/nc.c	2009-11-15 09:17:59 UTC (rev 8753)
@@ -708,23 +708,26 @@
 **  The MODE command.  Hand off the channel.
 */
 static void
-NCmode(CHANNEL *cp, int ac, char *av[])
+NCmode(CHANNEL *cp, int ac UNUSED, char *av[])
 {
+    char buff[SMBUF];
     HANDOFF h;
 
     cp->Start = cp->Next;
 
-    if (ac > 1 && strcasecmp(av[1], "READER") == 0 && !innconf->noreader) {
+    if (strcasecmp(av[1], "READER") == 0 && !innconf->noreader) {
         /* MODE READER. */
+        syslog(L_NOTICE, "%s NCmode \"MODE READER\" received",
+               CHANname(cp));
         if (!cp->CanAuthenticate) {
             /* AUTHINFO has already been successfully used. */
-            NCwritereply(cp, NNTP_ACCESS);
+            snprintf(buff, sizeof(buff), "%d Already authenticated as a feeder",
+                     NNTP_ERR_ACCESS);
+            NCwritereply(cp, buff);
             return;
         }
         if (NNRPReason != NULL && !innconf->readerswhenstopped) {
             /* Server paused or throttled. */
-            char buff[SMBUF];
-
             snprintf(buff, sizeof(buff), "%d %s", NNTP_FAIL_ACTION, NNRPReason);
             NCwritereply(cp, buff);
             return;
@@ -732,29 +735,28 @@
             /* We will hand off the channel to nnrpd. */
             h = HOnnrpd;
         }
-    } else if (ac > 1 && strcasecmp(av[1], "STREAM") == 0 &&
+    } else if (strcasecmp(av[1], "STREAM") == 0 &&
                (!StreamingOff && cp->Streaming)) {
         /* MODE STREAM. */
-	char buff[16];
-
-	snprintf(buff, sizeof(buff), "%d StreamOK.", NNTP_OK_STREAM);
+        snprintf(buff, sizeof(buff), "%d Streaming permitted", NNTP_OK_STREAM);
 	NCwritereply(cp, buff);
 	syslog(L_NOTICE, "%s NCmode \"MODE STREAM\" received",
                CHANname(cp));
         return;
-    } else if (ac > 1 && strcasecmp(av[1], "CANCEL") == 0 && cp->privileged) {
+    } else if (strcasecmp(av[1], "CANCEL") == 0 && cp->privileged) {
         /* MODE CANCEL */
-        char buff[16];
-
         cp->State = CScancel;
-        snprintf(buff, sizeof(buff), "%d CancelOK.", NNTP_OK_MODE_CANCEL);
+        snprintf(buff, sizeof(buff), "%d Cancels permitted", NNTP_OK_MODE_CANCEL);
         NCwritereply(cp, buff);
         syslog(L_NOTICE, "%s NCmode \"MODE CANCEL\" received",
                 CHANname(cp));
         return;
     } else {
         /* Unknown MODE command or readers not allowed. */
-        NCwritereply(cp, NCbadsubcommand);
+        snprintf(buff, sizeof(buff), "%d Unknown MODE variant", NNTP_ERR_SYNTAX);
+        NCwritereply(cp, buff);
+        syslog(L_NOTICE, "%s bad_command MODE %s", CHANname(cp),
+               MaxLength(av[1], av[1]));
         return;
     }
 

Modified: nnrpd/misc.c
===================================================================
--- nnrpd/misc.c	2009-11-15 09:17:43 UTC (rev 8752)
+++ nnrpd/misc.c	2009-11-15 09:17:59 UTC (rev 8753)
@@ -459,7 +459,8 @@
 
     /* If the client is already authenticated, STARTTLS is not possible. */
     if (PERMauthorized && !PERMneedauth && !PERMcanauthenticate) {
-        Reply("%d Already authenticated\r\n", NNTP_ERR_ACCESS);
+        Reply("%d Already authenticated without the use of a security layer\r\n",
+              NNTP_ERR_ACCESS);
         return;
     }
 




More information about the inn-committers mailing list