INN commit: branches/2.5/backends (innxbatch.c innxmit.c nntpget.c)

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


    Date: Sunday, November 15, 2009 @ 01:28:57
  Author: iulius
Revision: 8798

RFC 3977 compliance:

* innxbatch and innxmit now recognize 403 for a problem
preventing the action from being taken.

* innxmit now also recognizes 501 when there is a syntax
error and considers it as a reject (IHAVE/CHECK/TAKETHIS).

Modified:
  branches/2.5/backends/innxbatch.c
  branches/2.5/backends/innxmit.c
  branches/2.5/backends/nntpget.c

-------------+
 innxbatch.c |    4 +++-
 innxmit.c   |   49 ++++++++++++++++++++++++++++++++-----------------
 nntpget.c   |    8 ++++----
 3 files changed, 39 insertions(+), 22 deletions(-)

Modified: innxbatch.c
===================================================================
--- innxbatch.c	2009-11-15 09:28:47 UTC (rev 8797)
+++ innxbatch.c	2009-11-15 09:28:57 UTC (rev 8798)
@@ -248,6 +248,7 @@
     break;
   case NNTP_FAIL_XBATCH:
   case NNTP_FAIL_TERMINATING:
+  case NNTP_FAIL_ACTION:
     notice("%s xbatch failed %s", REMhost, buf);
     STATrejected++;
     return false;
@@ -495,7 +496,7 @@
     if (GotInterrupt) Interrupted();
 
     /* Offer the xbatch. */
-    snprintf(buff, sizeof(buff), "xbatch %d", XBATCHsize);
+    snprintf(buff, sizeof(buff), "XBATCH %d", XBATCHsize);
     if (!REMwrite(ToServer, buff)) {
       syswarn("cannot offer xbatch to %s", REMhost);
       ExitWithStats(1);
@@ -519,6 +520,7 @@
       break;
     case NNTP_FAIL_XBATCH:
     case NNTP_FAIL_TERMINATING:
+    case NNTP_FAIL_ACTION:
       /* Most likely out of space -- no point in continuing. */
       notice("%s xbatch failed %s", REMhost, buff);
       ExitWithStats(1);

Modified: innxmit.c
===================================================================
--- innxmit.c	2009-11-15 09:28:47 UTC (rev 8797)
+++ innxmit.c	2009-11-15 09:28:57 UTC (rev 8798)
@@ -297,7 +297,7 @@
 static void
 ExitWithStats(int x)
 {
-    static char		QUIT[] = "quit";
+    static char		QUIT[] = "QUIT";
     double		usertime;
     double		systime;
 
@@ -644,14 +644,14 @@
 	    Requeue(Article, MessageID);
 	break;
     case NNTP_ERR_COMMAND:
-    case NNTP_ERR_SYNTAX:
     case NNTP_ERR_ACCESS:
-	/* The receiving server is likely confused...no point in continuing */
+        /* The receiving server is likely confused... no point in continuing! */
         syslog(L_FATAL, GOT_BADCOMMAND, REMhost, MessageID, REMclean(buff));
         RequeueRestAndExit(Article, MessageID);
         /* NOTREACHED */
     case NNTP_FAIL_IHAVE_DEFER:
     case NNTP_FAIL_TERMINATING:
+    case NNTP_FAIL_ACTION:
 	Requeue(Article, MessageID);
 	break;
     case NNTP_OK_IHAVE:
@@ -659,6 +659,7 @@
 	STATacceptedsize += (double)art->len;
 	break;
     case NNTP_FAIL_IHAVE_REJECT:
+    case NNTP_ERR_SYNTAX:
         if (logRejects)
             syslog(L_NOTICE, REJECTED, REMhost,
                    MessageID, Article, REMclean(buff));
@@ -733,8 +734,8 @@
 check(int i) {
     char	buff[NNTP_MAXLEN_COMMAND];
 
-    /* send "check <ID>" to the other system */
-    snprintf(buff, sizeof(buff), "check %s", stbuf[i].st_id);
+    /* Send "CHECK <mid>" to the other system. */
+    snprintf(buff, sizeof(buff), "CHECK %s", stbuf[i].st_id);
     if (!REMwrite(buff, (int)strlen(buff), false)) {
         syswarn("cannot check article");
 	return true;
@@ -765,10 +766,10 @@
              stbuf[i].st_fname);
         return true;
     }
-    /* send "takethis <ID>" to the other system */
-    snprintf(buff, sizeof(buff), "takethis %s", stbuf[i].st_id);
+    /* Send "TAKETHIS <mid>" to the other system. */
+    snprintf(buff, sizeof(buff), "TAKETHIS %s", stbuf[i].st_id);
     if (!REMwrite(buff, (int)strlen(buff), false)) {
-        syswarn("cannot send takethis");
+        syswarn("cannot send TAKETHIS");
         return true;
     }
     if (Debug)
@@ -801,7 +802,7 @@
 
     while(true) {
 	if (!REMread(buff, (int)sizeof buff)) {
-            syswarn("no reply to check");
+            syswarn("no reply to CHECK");
 	    return true;
 	}
 	if (GotInterrupt)
@@ -811,9 +812,15 @@
 
 	/* Parse the reply. */
 	resp =  atoi(buff);
-	/* Skip the 1XX informational messages */
-	if ((resp >= 100) && (resp < 200)) continue;
+
+	/* Skip the 1XX informational messages. */
+	if ((resp >= 100) && (resp < 200))
+            continue;
+
 	switch (resp) { /* first time is to verify it */
+        case NNTP_ERR_SYNTAX:
+            /* Nothing we can check here. */
+            break;
 	case NNTP_FAIL_CHECK_REFUSE:
 	case NNTP_OK_CHECK:
 	case NNTP_OK_TAKETHIS:
@@ -834,6 +841,7 @@
 	    }
 	    break;
 	case NNTP_FAIL_TERMINATING:
+        case NNTP_FAIL_ACTION:
 	    /* Most likely out of space -- no point in continuing. */
 	    syslog(L_NOTICE, IHAVE_FAIL, REMhost, REMclean(buff));
 	    return true;
@@ -845,6 +853,7 @@
 						    buff);
 	    return (true);
 	}
+
 	switch (resp) { /* now we take some action */
 	case NNTP_FAIL_CHECK_DEFER:	/* remote wants it later */
 	    /* try again now because time has passed */
@@ -857,6 +866,8 @@
 		strel(i); /* release entry */
 	    }
 	    break;
+
+        case NNTP_ERR_SYNTAX:
 	case NNTP_FAIL_CHECK_REFUSE:	/* remote doesn't want it */
 	    strel(i); /* release entry */
 	    STATrefused++;
@@ -1184,7 +1195,8 @@
 		    CanStream = true;
 		    break;
                 case NNTP_FAIL_AUTH_NEEDED: /* authentication refusal */
-		case NNTP_ERR_COMMAND: /* normal refusal */
+		case NNTP_ERR_COMMAND: /* unknown MODE command */
+                case NNTP_ERR_SYNTAX:  /* unknown STREAM keyword */
 		    CanStream = false;
 		    break;
 		}
@@ -1213,7 +1225,9 @@
 		switch (atoi(buff)) {
 		case 250:		/* YES! */
 		    break;
-		case NNTP_ERR_COMMAND: /* normal refusal */
+                case NNTP_FAIL_AUTH_NEEDED: /* authentication refusal */
+		case NNTP_ERR_COMMAND: /* unknown MODE command */
+                case NNTP_ERR_SYNTAX:  /* unknown STREAM keyword */
                     die("%s not allowed -- %s", modeheadfeed, buff);
 		default:
                     die("unknown reply to %s -- %s", modeheadfeed, buff);
@@ -1390,7 +1404,7 @@
 	    }
 	    continue; /* next article */
 	}
-	snprintf(buff, sizeof(buff), "ihave %s", MessageID);
+	snprintf(buff, sizeof(buff), "IHAVE %s", MessageID);
 	if (!REMwrite(buff, (int)strlen(buff), false)) {
             syswarn("cannot offer article");
             article_free(art);
@@ -1404,7 +1418,7 @@
 
 	/* Does he want it? */
 	if (!REMread(buff, (int)sizeof buff)) {
-            syswarn("no reply to ihave");
+            syswarn("no reply to IHAVE");
             article_free(art);
 	    RequeueRestAndExit(Article, MessageID);
 	}
@@ -1421,12 +1435,12 @@
 		Requeue(Article, MessageID);
 	    break;
         case NNTP_ERR_COMMAND:
-        case NNTP_ERR_SYNTAX:
         case NNTP_ERR_ACCESS:
-            /* The receiving server is likely confused...no point in continuing */
+            /* The receiving server is likely confused... no point in continuing! */
             syslog(L_FATAL, GOT_BADCOMMAND, REMhost, MessageID, REMclean(buff));
 	    RequeueRestAndExit(Article, MessageID);
 	    /* NOTREACHED */
+        case NNTP_FAIL_ACTION:
         case NNTP_FAIL_AUTH_NEEDED:
 	case NNTP_FAIL_IHAVE_DEFER:
 	case NNTP_FAIL_TERMINATING:
@@ -1439,6 +1453,7 @@
 		RequeueRestAndExit(Article, MessageID);
 	    break;
 	case NNTP_FAIL_IHAVE_REFUSE:
+        case NNTP_ERR_SYNTAX:
 	    STATrefused++;
 	    break;
 	}

Modified: nntpget.c
===================================================================
--- nntpget.c	2009-11-15 09:28:47 UTC (rev 8797)
+++ nntpget.c	2009-11-15 09:28:57 UTC (rev 8798)
@@ -43,7 +43,7 @@
 */
 static struct iovec	SITEvec[2];
 static char		SITEv1[] = "\r\n";
-static char		READER[] = "mode reader";
+static char		READER[] = "MODE READER";
 static unsigned long	STATgot;
 static unsigned long	STAToffered;
 static unsigned long	STATsent;
@@ -161,7 +161,7 @@
 {
     char	buff[NNTP_MAXLEN_COMMAND];
 
-    SITEwrite(sp, "quit", 4);
+    SITEwrite(sp, "QUIT", 4);
     SITEread(sp, buff);
 }
 
@@ -359,7 +359,7 @@
 	if (Offer) {
 	    /* See if the local server wants it. */
 	    STAToffered++;
-	    snprintf(buff, sizeof(buff), "ihave %s", mesgid);
+	    snprintf(buff, sizeof(buff), "IHAVE %s", mesgid);
 	    if (!SITEwrite(Local, buff, (int)strlen(buff))
 	     || !SITEread(Local, buff)) {
                 syswarn("cannot offer %s", mesgid);
@@ -370,7 +370,7 @@
 	}
 
 	/* Try to get the article. */
-	snprintf(buff, sizeof(buff), "article %s", mesgid);
+	snprintf(buff, sizeof(buff), "ARTICLE %s", mesgid);
 	if (!SITEwrite(Remote, buff, (int)strlen(buff))
 	 || !SITEread(Remote, buff)) {
             syswarn("cannot get %s", mesgid);




More information about the inn-committers mailing list