Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!brutus.cs.uiuc.edu!tut.cis.ohio-state.edu!purdue!spaf From: spaf@cs.purdue.EDU (Gene Spafford) Newsgroups: news.admin Subject: Tired of bogus subject lines? Message-ID: <7921@medusa.cs.purdue.edu> Date: 8 Sep 89 19:01:44 GMT Sender: news@cs.purdue.EDU Reply-To: spaf@arthur.cs.purdue.edu (Gene Spafford) Organization: Department of Computer Science, Purdue University Lines: 153 This is a terrible kludge, but I am sooo tired of seeing those bogus "Re^2:" subject lines.... They aren't the proper format for follow-up subjects according to the RFC, and they don't track with "rn" when trying to read news. I was trying to catch up on a few weeks of back news and kept reencountering threads of discussions broken by that obnoxious "Re^2:" So, I whipped up the enclosed program and installed it in our news library with the following sys file line: complain:world,all:BU:/usr/lib/news/complain < %s It sends mail to the author of the article complaining about the non-standard, non-conformant use of that string. If enough of you out there install it on your systems too, maybe the volume of mail will convince people to fix the software. As I said, it's a hack -- it works on Sequents and Suns, but no claims that it will work anywhere else. It also assumes you have /usr/lib/sendmail as your mail agent. Feel free to modify it to fit your system. #include #include extern char *malloc (); extern int strlen (); extern FILE *popen (); #define NEWSTRING(ptr) {if((ptr = malloc(slen+1)) == NULL) \ return (-1); else strcpy(ptr, cptr);} main () { char *reply = NULL, *sender = NULL, *from = NULL, *messageid = NULL; register char *cptr; register int slen; char tbuf[512]; while (fgets (tbuf, 512, stdin) != NULL) { if (*tbuf != '\n' && isspace(*tbuf)) continue; else if (*tbuf == '\n') break; /* find the : and convert header to lower case */ for (cptr = tbuf; *cptr && *cptr != ':'; cptr++) if (isupper (*cptr)) *cptr = tolower (*cptr); /* If no : found, we are out of the header */ if (!*cptr) break; *++cptr = '\0'; cptr++; while (*cptr && *cptr == ' ') cptr++; slen = strlen (cptr); if (cptr[slen - 1] == '\n') cptr[--slen] = 0; if (strcmp ("subject:", tbuf) == 0) { if (!isbadsub (cptr)) return (0); } else if (strcmp ("sender:", tbuf) == 0) NEWSTRING(sender) else if (strcmp ("reply-to:", tbuf) == 0) NEWSTRING(reply) else if (strcmp ("from:", tbuf) == 0) NEWSTRING(from) else if (strcmp ("message-id:", tbuf) == 0) NEWSTRING(messageid) } /* If we get this far, we have a bogus subject line. * We also have a reply address we can use to send * mail to tell them about it. */ if (reply) complain (reply, messageid); else if (sender) complain (sender, messageid); else if (from) complain (from, messageid); else return (-1); return (0); } int isbadsub (subjectline) char *subjectline; { int i; /* only check here is for first 4 characters being "Re^2" */ for (i = 0; i < 2; i++) if (isupper (subjectline[i])) subjectline[i] = tolower (subjectline[i]); return (!strncmp (subjectline, "re^2:", 5)); } #define OUT(ss) fputs(ss, mailer) complain (addressee, messageid) char *addressee, *messageid; { FILE *mailer; char hostname[64]; gethostname(hostname, 64); mailer = popen ("/usr/lib/sendmail -t", "w"); if (mailer == NULL) { perror ("Cannot open mailer"); exit (-1); } fprintf (mailer, "To: %s\n", addressee); OUT("Subject: Invalid format in Usenet posting\n"); OUT("Reply-to: nobody\n"); fprintf(mailer, "From: news@%s\n\n", hostname); fprintf (mailer, "Your Usenet posting with message id %s\n", messageid); OUT("has an invalid subject line, as defined by RFC 1036, the "); OUT("Usenet format\nstandard document.\n\n"); OUT("Your posting software is either broken or producing articles\n"); OUT("that do not conform to the required standard format.\nPlease "); OUT("fix your software, or discontinue its use.\n\nThis was an "); OUT("automated message."); pclose (mailer); } -- Gene Spafford NSF/Purdue/U of Florida Software Engineering Research Center, Dept. of Computer Sciences, Purdue University, W. Lafayette IN 47907-2004 Internet: spaf@cs.purdue.edu uucp: ...!{decwrl,gatech,ucbvax}!purdue!spaf