INN commit: trunk (include/inn/nntp.h innd/nc.c)

INN Commit Russ_Allbery at isc.org
Sun Aug 24 08:47:09 UTC 2008


    Date: Sunday, August 24, 2008 @ 01:47:08
  Author: iulius
Revision: 7959

Return 403 in response to MODE READER when the server is paused or throttled.
Do not close the connection.
(400 was previously sent.)

Modified:
  trunk/include/inn/nntp.h
  trunk/innd/nc.c

--------------------+
 include/inn/nntp.h |    2 ++
 innd/nc.c          |   47 +++++++++++++++++++++++++++++++++--------------
 2 files changed, 35 insertions(+), 14 deletions(-)

Modified: include/inn/nntp.h
===================================================================
--- include/inn/nntp.h	2008-08-24 07:36:22 UTC (rev 7958)
+++ include/inn/nntp.h	2008-08-24 08:47:08 UTC (rev 7959)
@@ -57,6 +57,7 @@
     NNTP_OK_BODY                = 222,
     NNTP_OK_STAT                = 223,
     NNTP_OK_OVER                = 224,
+    NNTP_OK_HDR                 = 225,
     NNTP_OK_NEWNEWS             = 230,
     NNTP_OK_NEWGROUPS           = 231,
     NNTP_OK_IHAVE               = 235,
@@ -65,6 +66,7 @@
     NNTP_CONT_POST              = 340,
     NNTP_FAIL_TERMINATING       = 400,
     NNTP_FAIL_WRONG_MODE        = 401, /* Wrong mode (e.g. not reader) */
+    NNTP_FAIL_ACTION            = 403, /* Internal fault or temporary problem */
     NNTP_FAIL_BAD_GROUP         = 411, /* Group unknown */
     NNTP_FAIL_NO_GROUP          = 412, /* Not in a newsgroup */
     NNTP_FAIL_NO_ARTICLE        = 420, /* No current article */

Modified: innd/nc.c
===================================================================
--- innd/nc.c	2008-08-24 07:36:22 UTC (rev 7958)
+++ innd/nc.c	2008-08-24 08:47:08 UTC (rev 7959)
@@ -411,6 +411,9 @@
 
 /*
 **  The "help" command.
+**  As MODE STREAM is recognized, we still display "mode" when
+**  noreader is set to true or the server is paused or throttled
+**  with readerswhenstopped set to false.
 */
 static void
 NChelp(CHANNEL *cp)
@@ -652,33 +655,49 @@
 	continue;
     cp->Start = cp->Next;
 
-    if (strcasecmp(p, "reader") == 0 && !innconf->noreader)
-	h = HOnnrpd;
-    else if (strcasecmp(p, "stream") == 0 &&
+    if (strcasecmp(p, "reader") == 0 && !innconf->noreader) {
+        /* MODE READER */
+        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;
+        } else {
+            /* We will hand off the channel to nnrpd. */
+            h = HOnnrpd;
+        }
+    } else if (strcasecmp(p, "stream") == 0 &&
              (!StreamingOff && cp->Streaming)) {
+        /* MODE STREAM */
 	char buff[16];
 
 	snprintf(buff, sizeof(buff), "%d StreamOK.", NNTP_OK_STREAM);
 	NCwritereply(cp, buff);
 	syslog(L_NOTICE, "%s NCmode \"mode stream\" received",
 		CHANname(cp));
-	return;
+        return;
     } else if (strcasecmp(p, "cancel") == 0 && cp->privileged) {
-       char buff[16];
+        /* MODE CANCEL */
+        char buff[16];
 
-       cp->State = CScancel;
-       snprintf(buff, sizeof(buff), "%d CancelOK.", NNTP_OK_MODE_CANCEL);
-       NCwritereply(cp, buff);
-       syslog(L_NOTICE, "%s NCmode \"mode cancel\" received",
-               CHANname(cp));
-       return;
+        cp->State = CScancel;
+        snprintf(buff, sizeof(buff), "%d CancelOK.", NNTP_OK_MODE_CANCEL);
+        NCwritereply(cp, buff);
+        syslog(L_NOTICE, "%s NCmode \"mode cancel\" received",
+                CHANname(cp));
+        return;
     } else {
-	NCwritereply(cp, NCbadsubcommand);
-	return;
+        /* Unknown MODE command or readers not allowed. */
+        NCwritereply(cp, NCbadsubcommand);
+        return;
     }
+
+    /* Hand off if reached. */
     RChandoff(cp->fd, h);
     if (NCcount > 0)
-	NCcount--;
+        NCcount--;
     CHANclose(cp, CHANname(cp));
 }
 



More information about the inn-committers mailing list