eps@toaster.SFSU.EDU (Eric P. Scott) (12/20/89)
This article documents significant changes to NNTP 1.5.7 at SFSU. The actual code we're running includes additional "screwup" monitoring deemed not of general interest. common/conf.h.dist Mandatory fix: NeXTs are 4.3 systems, not 4.2 systems!! inews/uname.c Local hack: We run clusters where all machines are "equivalent" and a "server" handles all mail. The local hostname is the WRONG thing to use; the name of the server machine must be inserted. To maximize portability I pick it out of the Pnews script. This also deals with "I don't have a domain in my name" problems. It just parallels what's already there; a good rewrite wouldn't hurt! server/serve.c Recommended enhancement: if NOLOGIN is defined, nntpd will quit with 400 reply if that file exists. NOLOGIN would presumably be defined as "/etc/nologin" on BSD systems, "/nologin" on USG systems. xfer/nntpxfer.c Grab bag: index() wasn't declared (oops), and DBM wasn't being used if the conf.h file specified NDBM. DBM has to be defined as something (just #define DBM isn't good enough) because of the way that ndbm masquerades as dbm. Feeding RNEWS to popen() really loses--you get all these useless shell processes. You want an "exec" in there. "Integrating" nntpxfer with everything else is one of those ideas that "looks good on paper" but caused many more headaches than the 1.5.6 version did. I've also added some sanity checking and fixed one really heinous typo. (edito?) xmit/nntpxmit.h Welcome to the wonderful world of NeXT! signal() can be a floor wax AND a dessert topping! Is it int or void? Yes! And no, it still doesn't compile without warnings. -=EPS=- ------- *** common/conf.h.dist.orig Fri Nov 10 23:42:19 1989 --- common/conf.h.dist Tue Dec 19 22:17:14 1989 *************** *** 122,129 **** #ifdef BSD_43 /* And now more assumptions! */ # ifndef sun ! # ifndef READ_SUPER # define READ_SUPER # endif # endif # ifndef NDBM --- 122,131 ---- #ifdef BSD_43 /* And now more assumptions! */ # ifndef sun ! # ifndef NeXT /* not a NeXT */ ! # ifndef READ_SUPER # define READ_SUPER + # endif # endif # endif # ifndef NDBM *** inews/uname.c.orig Fri Dec 18 15:16:45 1987 --- inews/uname.c Tue Dec 19 22:04:28 1989 *************** *** 27,32 **** --- 27,62 ---- #include <stdio.h> #include "../common/conf.h" + #ifdef PNNAME + #define HDRFILE "/usr/local/bin/Pnews" + + uname(uptr) + char *uptr; + { + char buf[BUFSIZ]; + FILE *fd; + + fd = fopen(HDRFILE, "r"); + if (fd == NULL) { + fprintf(stderr, "Cannot open %s\n", HDRFILE); + exit(1); + } + + for (;;) { /* each line in the file */ + if (fgets(buf, sizeof buf, fd) == NULL) { + fprintf(stderr, "no sysname in %s\n", HDRFILE); + fclose(fd); + exit(2); + } + if (sscanf(buf, "sitename=\"%[^\"]\"", uptr) == 1) { + fclose(fd); + return; + } + } + } + # define DONE + #endif + #ifdef UNAME # define DONE #endif /* UNAME */ *** server/serve.c.orig Mon Aug 28 00:22:58 1989 --- server/serve.c.Tue Dec 19 22:08:12 1989 *************** *** 149,154 **** --- 149,167 ---- exit(1); } + #ifdef NOLOGIN + if (access(NOLOGIN, 0)>=0) { + printf( + "%d %s NNTP server host logins disabled. Try later.\r\n", + ERR_GOODBYE, host); + (void) fflush(stdout); + #ifdef LOG + syslog(LOG_INFO, "%s host logins disabled", hostname); + #endif + exit(1); + } + #endif + /* If we can talk, proceed with initialization */ ngpermcount = get_nglist(&ngpermlist, gdbuf); *** xfer/nntpxfer.c.orig Fri Nov 10 23:58:45 1989 --- xfer/nntpxfer.c Tue Dec 19 22:24:55 1989 *************** *** 20,25 **** --- 20,30 ---- */ #include "../common/conf.h" + #ifdef NDBM + #define DBM DBM_INTERNAL + #endif + #undef RNEWS + #define RNEWS "exec /usr/bin/rnews" #include <sys/types.h> #ifdef NDIR *************** *** 48,53 **** --- 53,59 ---- char *malloc(); char *strcpy(); char *strcat(); + char *index(); char *rindex(); long time(); u_long inet_addr(); *************** *** 228,233 **** --- 234,245 ---- continue; } artlist[newart] = malloc((unsigned)(strlen(buf)+1)); + if (!(artlist[newart] = + malloc((unsigned)(strlen(buf)+1)))) { + fputs("malloc failure!\n", stderr); + omitupdate++; + continue; + } (void) strcpy(artlist[newart], buf); newart++; } *************** *** 361,367 **** #ifdef BSD43 FD_ZERO(&rf); FD_SET(server, &rf); ! r = select(20, (fd_set *)&rf, (fd_set *)0, (fd_set *)&rf, &tv);#else BSD43 rf = 1 << server; r = select(20, (int *)&rf, (int *)0, (int *)&rf, &tv); #endif BSD43 --- 373,380 ---- #ifdef BSD43 FD_ZERO(&rf); FD_SET(server, &rf); ! r = select(20, (fd_set *)&rf, (fd_set *)0, (fd_set *)&rf, &tv); ! #else BSD43 rf = 1 << server; r = select(20, (int *)&rf, (int *)0, (int *)&rf, &tv); #endif BSD43 *************** *** 397,402 **** --- 410,420 ---- return(strlen(buf)); } j++; p++; + if (j>=BUFSIZ) { + fputs("sockread buffer overflow\n", stderr); + (void)close(server); + exit(1); + } } perror("sockread"); (void) close(server); *** xmit/nntpxmit.h.orig Sun Oct 29 21:58:32 1989 --- xmit/nntpxmit.h Tue Dec 19 03:05:24 1989 *************** *** 9,15 **** --- 9,19 ---- #ifdef SIGRET #undef SIGRET #endif + #ifdef __STRICT_BSD__ + #define SIGRET int /* NeXT gcc */ + #else #define SIGRET void /* Newfangled signal() returns void, old returns int */ + #endif typedef SIGRET (*ifunp)(); /* pointer to function that returns */ /* whatever signal() returns */