INN commit: branches/2.5 (include/nntp.h innd/nc.c)

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


    Date: Sunday, November 15, 2009 @ 01:20:09
  Author: iulius
Revision: 8759

Return 502 (permission denied) or 401 MODE-READER to LIST
commands when the feeder cannot use LIST commands.

Modified:
  branches/2.5/include/nntp.h
  branches/2.5/innd/nc.c

----------------+
 include/nntp.h |    2 --
 innd/nc.c      |   25 ++++++++++++++++++-------
 2 files changed, 18 insertions(+), 9 deletions(-)

Modified: include/nntp.h
===================================================================
--- include/nntp.h	2009-11-15 09:19:55 UTC (rev 8758)
+++ include/nntp.h	2009-11-15 09:20:09 UTC (rev 8759)
@@ -24,13 +24,11 @@
 
 #include "inn/nntp.h"
 
-#define NNTP_BAD_COMMAND		"500 Syntax error or bad command"
 #define NNTP_ACCESS			"502 Permission denied"
 #define NNTP_LIST_FOLLOWS		"215"
 #define NNTP_ARTICLE_FOLLOWS		"220"
 #define NNTP_REJECTIT_EMPTY		"437 Empty article"
 #define NNTP_POSTEDOK			"240 Article posted"
-#define NNTP_BAD_SUBCMD			"501 Bad subcommand"
 #define NNTP_NOTINGROUP			"412 Not in a newsgroup"
 #define NNTP_NOSUCHGROUP		"411 No such group"
 #define NNTP_NEWNEWSOK			"230 New news follows"

Modified: innd/nc.c
===================================================================
--- innd/nc.c	2009-11-15 09:19:55 UTC (rev 8758)
+++ innd/nc.c	2009-11-15 09:20:09 UTC (rev 8759)
@@ -114,8 +114,6 @@
 static char		*NCquietlist[] = { INND_QUIET_BADLIST };
 static const char	NCterm[] = "\r\n";
 static const char 	NCdot[] = "." ;
-static const char	NCbadcommand[] = NNTP_BAD_COMMAND;
-static const char       NCbadsubcommand[] = NNTP_BAD_SUBCMD;
 
 /*
 ** Clear the WIP entry for the given channel.
@@ -433,6 +431,7 @@
 static void
 NCauthinfo(CHANNEL *cp, int ac, char *av[])
 {
+    char *buff = NULL;
     cp->Start = cp->Next;
 
     if (!cp->CanAuthenticate) {
@@ -450,7 +449,9 @@
 
     /* Now make sure we're getting only AUTHINFO PASS commands. */
     if (ac < 3 || strcasecmp(av[1], "PASS") != 0) {
-	NCwritereply(cp, NNTP_BAD_SUBCMD);
+        xasprintf(&buff, "%d Syntax error", NNTP_ERR_SYNTAX);
+        NCwritereply(cp, buff);
+        free(buff);
 	return;
     }
 
@@ -665,17 +666,24 @@
 }
 
 /*
-**  The LIST command.  Send the required file.
+**  The LIST command.  Send relevant lines of required file.
 */
 static void
 NClist(CHANNEL *cp, int ac, char *av[])
 {
     char *p, *q, *end, *path;
+    char *buff = NULL;
 
     cp->Start = cp->Next;
 
     if (cp->Nolist) {
-	NCwritereply(cp, NCbadcommand);
+        if ((innconf->noreader)
+            || (NNRPReason != NULL && !innconf->readerswhenstopped))
+            xasprintf(&buff, "%d Permission denied", NNTP_ERR_ACCESS);
+        else
+            xasprintf(&buff, "%d MODE-READER", NNTP_FAIL_WRONG_MODE);
+        NCwritereply(cp, buff);
+        free(buff);
 	return;
     }
 
@@ -701,7 +709,9 @@
 	}
 	end = p + strlen(p);
     } else {
-	NCwritereply(cp, NCbadsubcommand);
+        xasprintf(&buff, "%d Unknown LIST keyword", NNTP_ERR_SYNTAX);
+        NCwritereply(cp, buff);
+        free(buff);
 	return;
     }
 
@@ -1043,7 +1053,8 @@
           NCwritereply(cp, buff);
           break;
         }
-	NCwritereply(cp, NCbadcommand);
+        snprintf(buff, sizeof(buff), "%d What?", NNTP_ERR_COMMAND);
+	NCwritereply(cp, buff);
 	cp->Start = cp->Next;
 
 	/* Channel could have been freed by above NCwritereply if




More information about the inn-committers mailing list