[news.software.b] Making local groups from mailing lists - recnews change

john@xanth.UUCP (John Owens) (06/17/87)

We receive several mailing lists at ODU, and we recently started
gatewaying them into semi-local newsgroups, named after the mailing
list (mail.gamemasters, for example).  To allow users to followup the
articles, or to seem to "post" to the group, we wanted to mark the
groups as moderated, but there was no good way to get an Approved:
header on the article so it wouldn't just bounce back to the list.

To fix this, I added a third parameter to recnews.  If used, it will
pass the string with a "-a" flag to inews.  It's OK to use '' for the
second argument, since the code already checked for the first
character non-null.  (They're all static char arrays.)

Strangely, the INCLUSIVE case can never be reached, since type() never
returns INCLUSIVE.  What's the history here?  The reason I was
concerned is that inews -p is documented not to take the -a flag, so I
was wondering what the appropriate action would be, but I left it
alone since it couldn't be reached.

The declaration and use of index was fixed, and now the only
complaints from lint are about "return value always unused".

*** /tmp/,RCSt1014087	Wed Jun 17 02:09:37 1987
--- recnews.c		Wed Jun 17 02:09:39 1987
***************
*** 1,5 ****
  /*
!  * recnews [to newsgroup] [from user]
   *
   * Process a news article which has been mailed to some group like msgs.
   * Such articles are in normal mail format and have never seen the insides
--- 1,5 ----
  /*
!  * recnews [to newsgroup] [from user] [approved by]
   *
   * Process a news article which has been mailed to some group like msgs.
   * Such articles are in normal mail format and have never seen the insides
***************
*** 21,26 ****
--- 21,27 ----
   *		machine.  post-unix-wizards (on the local machine) should
   *		be part of the master mailing list somewhere (on a different
   *		machine.)
+  *	in-gamemasters: "|/usr/lib/news/recnews mail.gamemasters '' news"
   *
   * Recnews is primarily useful in remote places on the usenet which collect
   * mail from mailing lists and funnel them into the network.  It is also
***************
*** 33,44 ****
   * by the time inews is run, it's in the background and too late to
   * ask permission.  If you depend heavily on recordings you probably
   * should not allow recnews (and thus the mail interface) to be used.
! *
   * 1) We leave the from line alone.  Just escape the double quotes, but let the
   *    mailer do the rest.
   * 2) We give precedence to "From:" over "From " or ">From " in determining
   *    who the article is really from.
   *    Modifications by rad@tek
   */
  
  #ifdef SCCSID
--- 34,48 ----
   * by the time inews is run, it's in the background and too late to
   * ask permission.  If you depend heavily on recordings you probably
   * should not allow recnews (and thus the mail interface) to be used.
!  *
   * 1) We leave the from line alone.  Just escape the double quotes, but let the
   *    mailer do the rest.
   * 2) We give precedence to "From:" over "From " or ">From " in determining
   *    who the article is really from.
   *    Modifications by rad@tek
+  *
+  * John@ODU.EDU: add third argument to cause inews to be invoked with -a,
+  *		 for use with local groups for mailing lists with 2.11.
   */
  
  #ifdef SCCSID
***************
*** 88,97 ****
  char	to[BFSZ];		/* Destination of mail (msgs, etc) */
  char	subject[BFSZ];		/* subject of message */
  char	newsgroup[BFSZ];	/* newsgroups of message */
  int	fromset;		/* from passed on command line */
  char	cmdbuf[BFSZ];		/* command to popen */
  
! extern	char	*strcat(), *strcpy();
  extern	FILE	*popen();
  char	*any();
  
--- 92,102 ----
  char	to[BFSZ];		/* Destination of mail (msgs, etc) */
  char	subject[BFSZ];		/* subject of message */
  char	newsgroup[BFSZ];	/* newsgroups of message */
+ char	approved[BFSZ];		/* Approved: */
  int	fromset;		/* from passed on command line */
  char	cmdbuf[BFSZ];		/* command to popen */
  
! extern	char	*strcat(), *strcpy(), *index();
  extern	FILE	*popen();
  char	*any();
  
***************
*** 115,120 ****
--- 120,129 ----
  		strcpy(to, argv[1]);
  	if (argc > 2)
  		strcpy(from, argv[2]);
+ 	if (argc > 3 && *argv[3]) {
+ 		strcpy(approved, "-a ");
+ 		strcat(approved, argv[3]);
+ 	}
  
  	/*
  	 * Flag that we know who message is from to avoid trying to 
***************
*** 187,195 ****
  		case BLANK:
  			state = READING;
  			strcpy(newsgroup, to);
! 			sprintf(cmdbuf, "exec %s -t \"%s\" -n \"%s\" -f \"%s\"",
  				inews, *subject ? subject : "(none)",
! 				newsgroup, from);
  #ifdef debug
  			pipe = stdout;
  			printf("BLANK: %s\n", cmdbuf);
--- 196,205 ----
  		case BLANK:
  			state = READING;
  			strcpy(newsgroup, to);
! 			sprintf(cmdbuf,
! 				"exec %s -t \"%s\" -n \"%s\" -f \"%s\" %s",
  				inews, *subject ? subject : "(none)",
! 				newsgroup, from, *approved ? approved : 0);
  #ifdef debug
  			pipe = stdout;
  			printf("BLANK: %s\n", cmdbuf);
***************
*** 214,221 ****
  				if (subject[strlen(subject)-1] == '\n')
  					subject[strlen(subject)-1] = '\0';
  			}
! 			sprintf(cmdbuf, "exec \"%s\" -t \"%s\" -n \"%s\" -f \"%s\"",
! 				inews, subject, newsgroup, from);
  #ifdef debug
  			pipe = stdout;
  			printf("TEXT: %s\n", cmdbuf);
--- 224,233 ----
  				if (subject[strlen(subject)-1] == '\n')
  					subject[strlen(subject)-1] = '\0';
  			}
! 			sprintf(cmdbuf,
! 				"exec \"%s\" -t \"%s\" -n \"%s\" -f \"%s\" %s",
! 				inews, subject, newsgroup, from,
! 				*approved ? approved : 0);
  #ifdef debug
  			pipe = stdout;
  			printf("TEXT: %s\n", cmdbuf);
***************
*** 298,304 ****
  		*q++ = *p;
  	}
  	q[-1] = '\0';
! 	if ((p=(char *)index(fbuf,'\n')) != NULL)
  		*p = '\0';
  	if (buf[4] == ':')
  		fromset++;
--- 310,316 ----
  		*q++ = *p;
  	}
  	q[-1] = '\0';
! 	if ((p=index(fbuf,'\n')) != NULL)
  		*p = '\0';
  	if (buf[4] == ':')
  		fromset++;

-- 
John Owens		Old Dominion University - Norfolk, Virginia, USA
john@ODU.EDU		old arpa: john%odu.edu@RELAY.CS.NET
+1 804 440 4529		old uucp: {seismo,harvard,sun,hoptoad}!xanth!john