innfeed support for POST?

Russ Allbery rra at stanford.edu
Tue Mar 2 00:24:54 UTC 2004


Dan Hollis writes:

> what server you mailing from? i show no mails in my sendmail logs from=20
> stanford.edu except for the one you just sent now.

> my sendmail server does not silently delete anything, and rejections of=20
> any kind are very noisy and verbose.

Should be smtp.stanford.edu.

I'll attach the patch below for other people reading this thread, since
you do seem to be getting the list mail.

From: Dmitry Yasir <dima at scm.com.ua>
To: inn-patches at isc.org
Subject: Patch to innxmit (and nntpsend) for adding POST mode

			Hello!

	I'm pathed inn-2.3.2. This patches add POST mode sending for=20
innxmit (new key -R in command line). This is very useful if users works=20
with forums with work as NEWS and organization for writing to it in=20
news-readers.

P.S.
	If you have any questions, I'm happy to speak with you.

P.P.S.
	Sorry for bad english. :-(

--=20
 With best regards,
  Dmitry Yasir (=E4=CD=C9=D4=D2=C9=CA =F1=D3=D9=D2)



-- Attached file included as plaintext by Ecartis --
-- File: innxmit.patch

--- inn-2.3.2/backends/innxmit.c	Thu May  3 23:27:32 2001
+++ inn-2.3.2/backends/innxmit.c	Mon Mar 18 11:52:21 2002
@@ -2,6 +2,17 @@
 **
 **  Transmit articles to remote site.
 **  Modified for NNTP streaming: 3Jan96 Jerry Aguirre
+
+**  Modified for POST article send mode by Dmitry Yasir (dima at scm.com.ua) :
+**  18Mar2002
+**  Added option -R, with make POST article in READER mode.
+**  In POST send mode drop header lines :
+**  NNTP-Posting-Date:
+**  NNTP-Posting-Host:
+**  Xref:
+**  X-Server-Date:
+**  X-Trace:
+**  X-Complaints-To:
 */
 #include "config.h"
 #include "clibrary.h"
@@ -33,6 +44,8 @@
 # include <sys/select.h>
 #endif
=20
+#include <string.h>
+
 #define OUTPUT_BUFFER_SIZE	(16 * 1024)
=20
 /* Streaming extensions to NNTP.  This extension removes the lock-step
@@ -74,7 +87,7 @@
 static char modestream[] =3D "mode stream";
 static long retries =3D 0;
 static int logRejects =3D TRUE ;  /* syslog the 437 responses. */
-
+static int PostSendMode =3D FALSE; /* Send article with POST directive */
=20
=20
 /*
@@ -672,6 +685,197 @@
 
=20
 /*
+**  Send a article in POST mode to the server.
+*/
+STATIC BOOL
+REMsendarticle_post_mode(char *Article, char *MessageID, ARTHANDLE *art) {
+    char	buff[NNTP_STRLEN];
+    char *article_data_buff;=20
+    char *line_buffer;    /* buffer for current line of message */
+    const int max_line_size =3D 512;
+    char *source_pointer; /* current source pointer */
+    char *dest_pointer; /* current dest pointer */
+    int counter; /* number bytes thet a worked */
+    int new_message_size;
+    int flag;
+    int line_size_val; /* size of current string */
+
+    if (!REMflush())
+	return FALSE;
+=09
+    /* We must scan art->data buffer with lenth art->len and delete same
+       header lines
+    */
+=20=20=20=20
+    article_data_buff =3D (char *) malloc(sizeof(char) * art->len);
+=20=20=20=20
+    if(article_data_buff =3D=3D NULL)
+     return FALSE;
+=20=20=20=20=20
+    line_buffer =3D (char *) malloc(sizeof(char) * (max_line_size + 2));
+    if(line_buffer =3D=3D NULL)
+    {
+     free(article_data_buff);
+     return FALSE;
+    }
+=20=20=20=20=20
+    source_pointer =3D art->data;
+    dest_pointer =3D article_data_buff;
+    flag =3D 0;
+    counter =3D 0;
+    new_message_size =3D 0;
+=20=20=20=20
+    while(counter < art->len)
+    {
+     line_size_val =3D strchr(source_pointer, '\n') - source_pointer + 1;
+     if(line_size_val > max_line_size)
+     {
+      syslog(L_FATAL, "Too long line in article Header\n");
+      free(line_buffer);
+      free(article_data_buff);
+      return FALSE;
+     }
+=20=20=20=20=20=20=20=20=20=20
+     memcpy(line_buffer, source_pointer, line_size_val);
+     *(line_buffer + line_size_val) =3D '\0';
+
+     if(line_size_val <=3D 2)
+     {
+      /* Current line - is Header bode */
+      memcpy(dest_pointer, source_pointer, (art->len - counter));
+      new_message_size +=3D art->len - counter;
+      flag =3D 1;
+      break;
+     }
+=20=20=20=20=20
+     if(strstr(line_buffer, "NNTP-Posting-Date:") !=3D NULL)
+     {
+      counter +=3D line_size_val;
+      source_pointer +=3D line_size_val;
+      continue;
+     }
+=20=20=20=20=20
+     if(strstr(line_buffer, "NNTP-Posting-Host:") !=3D NULL)
+     {
+      counter +=3D line_size_val;
+      source_pointer +=3D line_size_val;
+      continue;=20=20=20=20=20=20
+     }
+=20=20=20=20=20
+     if(strstr(line_buffer, "Xref:") !=3D NULL)
+     {
+      counter +=3D line_size_val;
+      source_pointer +=3D line_size_val;
+      continue;=20=20=20=20=20=20
+     }
+=20=20=20=20=20
+     if(strstr(line_buffer, "X-Server-Date:") !=3D NULL)
+     {
+      counter +=3D line_size_val;
+      source_pointer +=3D line_size_val;
+      continue;=20=20=20=20=20=20
+     }
+=20=20=20=20=20
+     if(strstr(line_buffer, "X-Trace:") !=3D NULL)
+     {
+      counter +=3D line_size_val;
+      source_pointer +=3D line_size_val;
+      continue;=20=20=20=20=20=20
+     }
+=20=20=20=20=20
+     if(strstr(line_buffer, "X-Complaints-To:") !=3D NULL)
+     {
+      counter +=3D line_size_val;
+      source_pointer +=3D line_size_val;
+      continue;=20=20=20=20=20=20=20=20=20=20=20=20
+     }
+=20=20=20=20=20
+     memcpy(dest_pointer, source_pointer, line_size_val);
+     source_pointer +=3D line_size_val;
+     dest_pointer +=3D line_size_val;
+     counter +=3D line_size_val;
+     new_message_size +=3D line_size_val;
+    } /* end while */
+=20=20=20=20
+    free(line_buffer);
+=20=20=20=20
+    if(flag =3D=3D 0)
+    {
+     syslog(L_FATAL, "Internal error, flag=3D0\n");
+     free(article_data_buff);
+     return FALSE;
+    }
+
+    if (xwrite(ToServer, article_data_buff, new_message_size) < 0)
+    {
+	free(article_data_buff);
+	return FALSE;
+    }
+=20=20=20=20
+    free(article_data_buff);
+=20=20=20=20
+    if (GotInterrupt)
+	Interrupted(Article, MessageID);
+    if (Debug) {
+	(void)fprintf(stderr, "> [ article %d ]\n", art->len);
+	(void)fprintf(stderr, "> .\n");
+    }
+
+    if (CanStream) return TRUE;	/* streaming mode does not wait for ACK */
+
+    /* What did the remote site say? */
+    if (!REMread(buff, (int)sizeof buff)) {
+	(void)fprintf(stderr, "No reply after sending \"%s\", %s\n",
+		Article, strerror(errno));
+	return FALSE;
+    }
+    if (GotInterrupt)
+	Interrupted(Article, MessageID);
+    if (Debug)
+	(void)fprintf(stderr, "< %s", buff);
+
+    /* Parse the reply. */
+    switch (atoi(buff)) {
+    default:
+	(void)fprintf(stderr, "Unknown reply after \"%s\" -- %s",
+		Article, buff);
+	if (DoRequeue)
+	    Requeue(Article, MessageID);
+	break;
+    case NNTP_BAD_COMMAND_VAL:
+    case NNTP_SYNTAX_VAL:
+    case NNTP_ACCESS_VAL:
+	/* 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_RESENDIT_VAL:
+    case NNTP_GOODBYE_VAL:
+#if 0
+	syslog(L_NOTICE, GOT_RESENDIT, REMhost, MessageID, REMclean(buff));
+#endif
+	Requeue(Article, MessageID);
+	break;
+    case NNTP_TOOKIT_VAL:
+    case NNTP_POSTEDOK_VAL:
+	STATaccepted++;
+	STATacceptedsize +=3D (double)art->len;
+	break;
+    case NNTP_REJECTIT_VAL:
+        if (logRejects)
+            syslog(L_NOTICE, REJECTED, REMhost,
+                   MessageID, Article, REMclean(buff));
+	STATrejected++;
+	STATrejectedsize +=3D (double)art->len;
+	break;
+    }
+
+    /* Article sent, or we requeued it. */
+    return TRUE;
+} /* end REMsendarticle_post_mode() */
+
+
+/*
 **  Get the Message-ID header from an open article.
 */
 STATIC char *
@@ -891,7 +1095,7 @@
 STATIC NORETURN
 Usage() {
     (void)fprintf(stderr,
-	"Usage: innxmit [-a] [-c] [-d] [-p] [-r] [-s] [-t#] [-T#] host file\n");
+	"Usage: innxmit [-a] [-c] [-d] [-p] [-r] [-s] [-R] [-t#] [-T#] host file\=
n");
     exit(1);
 }
=20
@@ -1006,7 +1210,7 @@
     (void)umask(NEWSUMASK);
=20
     /* Parse JCL. */
-    while ((i =3D getopt(ac, av, "lacdprst:T:vP:")) !=3D EOF)
+    while ((i =3D getopt(ac, av, "lacdprsRt:T:vP:")) !=3D EOF)
 	switch (i) {
 	default:
 	    Usage();
@@ -1045,6 +1249,10 @@
 	case 'v':
 	    STATprint =3D TRUE;
 	    break;
+	case 'R':
+	    PostSendMode =3D TRUE;
+	    TryStream =3D FALSE; /* disable streaming mode */
+	    break;
 	}
     ac -=3D optind;
     av +=3D optind;
@@ -1375,13 +1583,29 @@
 	    }
 	    continue; /* next article */
 	}
-	(void)sprintf(buff, "ihave %s", MessageID);
-	if (!REMwrite(buff, (int)strlen(buff), FALSE)) {
-	    (void)fprintf(stderr, "Can't offer article, %s\n",
+=09
+	if(PostSendMode)
+	{
+	 (void)sprintf(buff, "post");
+	 if (!REMwrite(buff, (int)strlen(buff), FALSE))
+	 {
+	  (void)fprintf(stderr, "Can't send POST command, %s\n",
 		    strerror(errno));
-            article_free(art);
+           article_free(art);
+	   RequeueRestAndExit(Article, MessageID);
+	 }
+	} /* end if(PostSendMode) */
+	else
+	{
+	 (void)sprintf(buff, "ihave %s", MessageID);
+	 if (!REMwrite(buff, (int)strlen(buff), FALSE)) {
+	    (void)fprintf(stderr, "Can't offer article, %s\n",
+		strerror(errno));
+	    article_free(art);
 	    RequeueRestAndExit(Article, MessageID);
-	}
+	  }
+	 } /* end else */
+=09=20
 	STAToffered++;
 	if (Debug)
 	    (void)fprintf(stderr, "> %s\n", buff);
@@ -1390,7 +1614,10 @@
=20
 	/* Does he want it? */
 	if (!REMread(buff, (int)sizeof buff)) {
-	    (void)fprintf(stderr, "No reply to ihave, %s\n", strerror(errno));
+	 if(PostSendMode)
+	  (void)fprintf(stderr, "No reply to post, %s\n", strerror(errno));
+	 else
+          (void)fprintf(stderr, "No reply to ihave, %s\n", strerror(errno)=
);
             article_free(art);
 	    RequeueRestAndExit(Article, MessageID);
 	}
@@ -1425,6 +1652,10 @@
 	    if (!REMsendarticle(Article, MessageID, art))
 		RequeueRestAndExit(Article, MessageID);
 	    break;
+	case NNTP_START_POST_VAL:
+	    if(!REMsendarticle_post_mode(Article, MessageID, art))
+		RequeueRestAndExit(Article, MessageID);
+	    break;
 	case NNTP_HAVEIT_VAL:
 	    STATrefused++;
 	    break;

-- Attached file included as plaintext by Ecartis --
-- File: nntpsend.patch

--- inn-2.3.2/backends/nntpsend.in	Fri Mar 15 14:59:55 2002
+++ inn-2.3.2/backends/nntpsend.in	Fri Mar 15 15:25:04 2002
@@ -4,12 +4,13 @@
 ##  $Revision: 1.2 $
 ##  Send news via NNTP by running several innxmit processes in the backgro=
und.
 ##  Usage:
-##	nntpsend [-n][-p][-r][-s size][-S][-t timeout][-T limit][host fqdn]...
+##	nntpsend [-n][-p][-r][-R][-s size][-S][-t timeout][-T limit][host fqdn]=
...
 ##	-a		Always have innxmit rewrite the batchfile
 ##	-d		debug mode, run ixxmmits with debug as well
 ##	-D		same as -d except innxmits are not debugged
 ##	-p		Run innxmit with -p to prune batch files
 ##	-r		innxmit, don't requeue on unexpected error code
+##	-R		innxmit will send message in MODE READER by POST command
 ##	-s size		limit the =3Dn file to size bytes
 ##	-c		disable message-ID checking in streaming mode
 ##	-t timeout	innxmit timeout to make connection (def: 180)
@@ -38,6 +39,7 @@
 TIMELIMIT=3D
 PP_FLAG=3D
 NOLOCK=3D
+RM_FLAG=3D
=20
 ##  Parse JCL.
 MORETODO=3Dtrue
@@ -59,6 +61,9 @@
     X-r)
 	R_FLAG=3D"-r"
 	;;
+    X-R)
+	RM_FLAG=3D"-R"
+	;;
     X-S)
 	S_FLAG=3D"-S"
 	;;
@@ -219,6 +224,7 @@
     PP_PARAM=3D
     TIMEOUT_PARAM=3D
     TIMELIMIT_PARAM=3D
+    RM_PARAM=3D
     if [ -z "${FLAGS}" ]; then
 	MORETODO=3Dfalse
     else
@@ -241,6 +247,9 @@
 	X-r)
 	    R_PARAM=3D"-r"
 	    ;;
+	X-R)
+	    RM_PARAM=3D"-R"
+	    ;;
 	X-S)
 	    S_PARAM=3D"-S"
 	    ;;
@@ -316,6 +325,11 @@
     else
 	test -n "${R_PARAM}" && INNFLAGS=3D"${INNFLAGS} ${R_PARAM}"
     fi
+    if [ -n "${RM_FLAG}" ]; then
+	INNFLAGS =3D "${INNFLAGS} ${RP_FLAG}"
+    else
+	test -n "${RM_PARAM}" && INNFLAGS=3D"${INNFLAGS} ${RM_PARAM}"
+    fi
     if [ -n "${S_FLAG}" ]; then
 	INNFLAGS=3D"${INNFLAGS} ${S_FLAG}"
     else


--=20
Russ Allbery (rra at stanford.edu)             <http://www.eyrie.org/~eagle/>


More information about the inn-workers mailing list