[news.admin] A fix for non-compliant Message-ID's

brendan@cs.widener.edu (Brendan Kehoe) (06/21/91)

This is a patch to the CNews extensions that I wrote; among other
things, it fixes the problem of having '.' at the beginning or end of
a Message-ID. (It also fixes a couple of things with spacefor; a small
bug and support for Ultrix.)

The full set is on ftp.cs.widener.edu in pub/cnews.set.shar.Z, or by
writing to archive-server@cs.widener.edu with a `Subject:' line of:
	send widener cnews.set.shar

The kit includes rewrites (in C, rather than shell scripts) for
anne.jones, tear, and spacefor.

Enjoy. Any bugs, suggestions, etc, should go to me.

-- cut --
diff -rc ../old/Makefile ./Makefile
*** ../old/Makefile	Thu Jun 20 13:48:44 1991
--- ./Makefile	Thu Jun 20 13:36:32 1991
***************
*** 2,8 ****
  #
  # This is available via anon FTP at 192.55.239.132 (ftp.cs.widener.edu)
  #
! # Last Updated: 03/26/91
  #
  # Step 1 - Edit anne.h, spacefor.h, and to customize them for your site.
  # Step 2 - Set up BINDIR, CC, CFLAGS, and CNEWSLIB for your configuration.
--- 2,8 ----
  #
  # This is available via anon FTP at 192.55.239.132 (ftp.cs.widener.edu)
  #
! # Last Updated: 06/20/91
  #
  # Step 1 - Edit anne.h, spacefor.h, and to customize them for your site.
  # Step 2 - Set up BINDIR, CC, CFLAGS, and CNEWSLIB for your configuration.
***************
*** 27,32 ****
--- 27,33 ----
  # If you're running AIX 2.2.1 on an IBM RT use -DAIX
  # If you're on an Altos system, use -DALTOS (note only spacefor uses this)
  # If you're using System V/386, use -DSysV386
+ # If you're using Ultrix, use -DULTRIX
  # Note for SunOS 4.1: I expressly didn't use -O2 or higher because of
  #  the many bugreports that are logged discounting their accuracy. (Most
  #  notable is -O2, generally accepted, even in the Gnu Project.)
diff -rc ../old/anne.jones.c ./anne.jones.c
*** ../old/anne.jones.c	Thu Jun 20 13:48:45 1991
--- ./anne.jones.c	Thu Jun 20 13:48:17 1991
***************
*** 113,121 ****
        }
      } else {
        
!       /*
! 	if gecos has '&', use capitalized login name
! 	*/
        if ((strchr(pent->pw_gecos, '&') != (char *) NULL)) {
  	name = safemalloc(strlen(pent->pw_name) + 1);
  	strcpy(name, pent->pw_name);
--- 113,119 ----
        }
      } else {
        
!       /* if gecos has '&', use capitalized login name */
        if ((strchr(pent->pw_gecos, '&') != (char *) NULL)) {
  	name = safemalloc(strlen(pent->pw_name) + 1);
  	strcpy(name, pent->pw_name);
diff -rc ../old/anne.misc.c ./anne.misc.c
*** ../old/anne.misc.c	Thu Jun 20 13:48:46 1991
--- ./anne.misc.c	Thu Jun 20 13:47:36 1991
***************
*** 1,5 ****
  /*
!  * anne.jones - anne.misc.c - 03/26/91
   *
   * Miscellaneous routines used by anne.jones
   */
--- 1,5 ----
  /*
!  * anne.jones - anne.misc.c - 06/20/91
   *
   * Miscellaneous routines used by anne.jones
   */
***************
*** 180,185 ****
--- 180,191 ----
     * (zeeff@b-tech.ann-arbor.mi.us). Palkovic@linac.fnal.gov, 3/22/91.
     *
     * A string of some valid message id characters
+    *
+    * 06/20/91 - changed the string to be RFC1036-compliant (no '.'s; they
+    *            could end up at the front or back of the local part of
+    *            the Message-ID, which is a nono; also put the lowercase
+    *            letters in, since according to the RFC AaA and aAa should
+    *            qualify as unique id's
     */
  
  void
***************
*** 186,192 ****
  rand_id(s)
  char *s;
  {
!    static char string[] = "!#._+-=ABCDFGHJKLMNPQRSTVWXYZ1234567890";
     register int size = sizeof(string) - 1;
     long num;
  
--- 192,198 ----
  rand_id(s)
  char *s;
  {
!    static char string[] = "!#_+-=ABCDFGHJKLMNPQRSTVWXYZ1234567890abcdefghijklmnopqrstuvwxyz";
     register int size = sizeof(string) - 1;
     long num;
  
diff -rc ../old/spacefor.c ./spacefor.c
*** ../old/spacefor.c	Thu Jun 20 13:48:47 1991
--- ./spacefor.c	Thu Jun 20 13:57:55 1991
***************
*** 1,5 ****
  /*
!  * spacefor - spacefor.c - 04/29/91 - Brendan Kehoe
   *
   * a replacement for the spacefor shell script
   *
--- 1,5 ----
  /*
!  * spacefor - spacefor.c - 06/20/91 - Brendan Kehoe
   *
   * a replacement for the spacefor shell script
   *
***************
*** 10,15 ****
--- 10,18 ----
   *
   * NEWSCTL and NEWSARTS have to be exported into the environment before
   *  this is called for it to work
+  *
+  * v1.1a - 05/27/91 - fixed the desire for non-1024 blks (vato@warwick.ac.uk)
+  * v1.1b - 06/20/91 - added Ultrix (thanks to stealth@engin.umich.edu)
   */
  
  #include <stdio.h>
***************
*** 16,35 ****
  #include <ctype.h>
  #include <sys/types.h>
  #include "spacefor.h"
  #ifdef HAVE_STATFS
  #include <stdlib.h> /* note: ALTOS & SysV386 need this */
! #if defined(ALTOS) || defined(SysV386)
! #include <sys/statfs.h>
! #else /* !ALTOS && !SysV386 */
! #include <sys/vfs.h>
! #endif
  #else /* !HAVE_STATFS */
! #include <sys/stat.h>
! #include <ustat.h>
  #endif /* HAVE_STATFS */
  
  #ifdef SysV386
! #define f_bavail f_bfree      /* SysV386 uses f_bfree instead: john@jwt.uucp */
  #endif /* SysV386 */
  
  int
--- 19,45 ----
  #include <ctype.h>
  #include <sys/types.h>
  #include "spacefor.h"
+ 
  #ifdef HAVE_STATFS
  #include <stdlib.h> /* note: ALTOS & SysV386 need this */
! # if defined(ALTOS) || defined(SysV386)
! #  include <sys/statfs.h>
! # else /* !ALTOS && !SysV386 */
! #  ifdef ULTRIX
! #   include <sys/param.h>
! #   include <sys/mount.h>
! #   define f_bavail fd_req.bfreen
! #  else /* !ULTRIX */
! #   include <sys/vfs.h>
! #  endif /* ULTRIX */
! # endif /* ALTOS || SysV386 */
  #else /* !HAVE_STATFS */
! #  include <sys/stat.h>
! #  include <ustat.h>
  #endif /* HAVE_STATFS */
  
  #ifdef SysV386
! # define f_bavail f_bfree      /* SysV386 uses f_bfree instead: john@jwt.uucp */
  #endif /* SysV386 */
  
  int
***************
*** 38,48 ****
--- 48,64 ----
       char **argv;
  {
  #ifdef HAVE_STATFS
+ #ifdef ULTRIX
+   struct fs_data b;
+ #else /* !ULTRIX */
    struct statfs b;
+ #endif /* ULTRIX */
+ 
  #else /* !HAVESTATFS */
    struct stat b;
    struct ustat device;
  #endif /* HAVESTATFS */
+ 
    int nb, desire = 0, num_items;
    char *arg, path_buf[100], *news_arts, *news_ctl;
    extern char *getenv();
***************
*** 107,127 ****
   * Beware: with all of the dependancies included, this is MESSY as HELL
   */
  #ifdef HAVE_STATFS
! # if defined(ALTOS) || defined(SysV386) /* this is for an Altos 2000/386 
! 					   and System V/386 */
    if (statfs(arg, &b, sizeof(struct statfs), 0) < 0) {
! # else /* !ALTOS && !SysV386 */
    if (statfs(arg, &b) < 0) {
! # endif /* ALTOS && !SysV386 */
      nb = 0;
      fprintf(stderr, "%s: Can't statfs() `%s'\n", *argv, arg);
    } else
!     nb = ((int)b.f_bavail - desire) * BLK_SIZE / num_items;
  #ifdef DEBUG
    printf("nb = (b.f_bavail - desire) * BLK_SIZE / num_items;\n");
    printf("%d = (%ld - %d) * %d / %d;\n", nb, b.f_bavail, desire, BLK_SIZE, 
  	 num_items);
  #endif /* DEBUG */
  #else /* !HAVESTATFS */
    if (stat(arg,&b)) {
      nb = 0;         /* can't stat arg */
--- 123,157 ----
   * Beware: with all of the dependancies included, this is MESSY as HELL
   */
  #ifdef HAVE_STATFS
! 
! /* this is for an Altos 2000/386, System V/386, and Ultrix */
! # if defined(ALTOS) || defined(SysV386) || defined(ULTRIX)
! 
! #ifdef ULTRIX
!   if (statfs(arg, &b, sizeof(struct fs_data), 0) < 0) {
! #else /* !ULTRIX -> ALTOS || SysV386 */
    if (statfs(arg, &b, sizeof(struct statfs), 0) < 0) {
! #endif /* ULTRIX */
! 
! # else /* !ALTOS && !SysV386 && !ULTRIX */
    if (statfs(arg, &b) < 0) {
! # endif /* ALTOS || SysV386 || ULTRIX*/
! 
      nb = 0;
      fprintf(stderr, "%s: Can't statfs() `%s'\n", *argv, arg);
    } else
!     /* thanks to Ian Dickinson (vato@warwick.ac.uk) for spotting this bug;
!        now the desire (in blocks) is converted to kilobytes; it hadn't
!        been noticed cuz BLKSIZE was == 1024; once it wasn't 1024, the
!        bug appeared */
!     nb = (((int)b.f_bavail * (int)b.f_bsize) - (desire * 1024)) / num_items;
! 
  #ifdef DEBUG
    printf("nb = (b.f_bavail - desire) * BLK_SIZE / num_items;\n");
    printf("%d = (%ld - %d) * %d / %d;\n", nb, b.f_bavail, desire, BLK_SIZE, 
  	 num_items);
  #endif /* DEBUG */
+ 
  #else /* !HAVESTATFS */
    if (stat(arg,&b)) {
      nb = 0;         /* can't stat arg */
***************
*** 132,142 ****
--- 162,174 ----
        fprintf(stderr, "%s: Can't ustat() `%s'\n", *argv, b.st_dev);
      } else
        nb = (device.f_tfree - desire) * BLK_SIZE / num_items;
+ 
  #ifdef DEBUG
    printf("nb = (device.f_tfree - desire) * BLK_SIZE / num_items;\n");
    printf("%d = (%d - %d) * %d / %d;\n", nb, device.f_tfree, desire, BLK_SIZE,
  	 num_items);
  #endif /* DEBUG */
+ 
  #endif /* HAVESTATFS */
    
    if (nb > 10000)
diff -rc ../old/spacefor.h ./spacefor.h
*** ../old/spacefor.h	Thu Jun 20 13:48:47 1991
--- ./spacefor.h	Thu Jun 20 13:51:29 1991
***************
*** 3,11 ****
   */
  
  #define	UUCP_DIR	"/usr/spool/uucp"   /* Your uucp spool directory */
- /*
-  * #undef HAVE_STATFS for Ultrix; it's got one, but not what we want to use
-  */
  #define HAVE_STATFS			    /* have the statfs() call? */
  
  /*
--- 3,8 ----
***************
*** 13,18 ****
--- 10,19 ----
   * with 512-byte blocks, you don't have to do anything. If you've got a
   * special case, go below and do as directed.
   */
+ #ifdef ULTRIX
+ #define BSD
+ #endif
+ 
  #ifdef BSD
  #define BLK_SIZE        1024
  #else /* !BSD */

-- cut --
-- 
     Brendan Kehoe - Widener Sun Network Manager - brendan@cs.widener.edu
  Widener University in Chester, PA                A Bloody Sun-Dec War Zone
  "Ya know, kitten tacos are really better than anything you've ever tasted
    before!"  "Oh, really."                              -- Rush Limbaugh

brendan@cs.widener.edu (Brendan Kehoe) (06/21/91)

brendan@cs.widener.edu wrote:
>This is a patch to the CNews extensions that I wrote; among other
>things, it fixes the problem of having '.' at the beginning or end of
>a Message-ID. (It also fixes a couple of things with spacefor; a small
>bug and support for Ultrix.)

 I should clarify that this fixes the '.' problem with Message-ID
headers created by the anne.jones that is included *in this set*; the
"pure" CNews does NOT generate these Message-ID's.

-- 
     Brendan Kehoe - Widener Sun Network Manager - brendan@cs.widener.edu
  Widener University in Chester, PA                A Bloody Sun-Dec War Zone
  "Ya know, kitten tacos are really better than anything you've ever tasted
    before!"  "Oh, really."                              -- Rush Limbaugh

neighorn@qiclab.scn.rain.com (Steven C. Neighorn) (06/28/91)

In article <TWK-JMB@cs.widener.edu> brendan@cs.widener.edu writes:

>  # Note for SunOS 4.1: I expressly didn't use -O2 or higher because of
>  #  the many bugreports that are logged discounting their accuracy. (Most
>  #  notable is -O2, generally accepted, even in the Gnu Project.)

First of all, thanks for your patches.

Also, it should be noted that, at least using Sun's unbundled C (SPARC
Compiler 1.1), the options "-fast -O4" can be used with CNews without
harm, and at a fair increase in speed on some of the programs (they
know who they are)... The -O4 overrides -fast's -O2 default. Expire,
relaynews, and updatemin all show marked improvement. Much to my
shame, I have not tried pushing the limits on the supplied C compiler,
since I much prefer the unbunbled C, the list of options to make /bin/cc
do any kind of optimizations are lengthy, and because of the numerous
outstanding (heh heh) bugs against /bin/cc. I wish Sun would ship the
unbundled compiler with the OS, or perhaps sell it for some nominal
materials fee.

I have been running the latest (3/24) CNews on several SPARC and Moto boxes
compiled/optimized with the unbundled compiler since late March.

Another system tweak (a lot of people are probably already doing this,
but it can't hurt to repeat it) which might interest admins is to replace the
vendor supplied compress with the recently posted Compress 4.1, and
compile the new compress with all the optimizations possible turned
on. I have done this to dozens of Sun systems I take care of, and see
anywhere from %10 to 25% improvement on compress and 10-15% improvement
on uncompress. Part of this improvement is due to the changing of the
division hash to an xor, and part is due to the higher levels of
optimization used on the source. Changing to the 4.1 version and
compiling with normal opt, or compiling 4.0 with full optimization
does not match 4.1 source with full opt.


-- 
Steven C. Neighorn neighorn@qiclab.scn.rain.com/neighorn@gooeyduck.West.Sun.COM
Sun Microsystems, Inc.    "Where we DESIGN the Star Fighters that defend the
8705 SW Nimbus Drive, #300    frontier against Xur and the Ko-dan Armada"
Beaverton, Oregon 97005       work: (503) 627-0451 / home: (503) 641-3469