chip@ateng.UUCP (Chip Salzenberg) (01/07/88)
Comp.sources.misc: Volume 2, Issue 3 Archive-Name: smail-xenix-v3 Submitted-By: chip@ateng.UUCP (Chip Salzenberg) Comp.sources.misc: Volume 2, Issue 3 Archive-Name: smail-xenix-v3 Submitted-By: chip@ateng.UUCP (Chip Salzenberg) Brandon: Recently, you sent out a small patch to smail that I made and then posted in comp.unix.xenix. I did *not* intend that patch for comp.sources.misc! I was working on a complete set of patches that would take a stock smail 2.5 and make it usable under Xenix. Well, here it is. Please post this. [Then why did you send it to sources-misc@ncoast? ++bsa] BTW, I earlier posted a sharchive of smail mods to comp.unix.xenix. For all you readers of c.u.x that used those mods -- USE THESE NEW PATCHES INSTEAD. Why? 1. Cleaner mods 2. Better comments 3. Explicit support for Micnet/Xenix-Net 4. Support for /etc/systemid file (no need to relink your kernel to change your machine name) Herein you will find a sharchive that contains a new Makefile, a set of patches to the smail sources, a replacement for the troublesome /usr/lib/mail/execmail program, and a script to install them both. All a Xenix user needs to start running smail is (1) the smail 2.5 sources, (2) this sharchive, and (3) Larry Wall's patch program. "Shar and enjoy." #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the "#! /bin/sh" line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # X.README # X.PATCHES # Makefile # execm.c # install_smail # This archive created: Tue Dec 29 10:41:42 1987 export PATH; PATH=/bin:$PATH : echo 'shar: extracting "X.README" (2816 characters) ' if test -f 'X.README' then echo 'shar: will not overwrite existing file "X.README" ' else sed 's/^X//' << \SHAR_EOF > 'X.README' XX.README X XThis file describes how to use my smail 2.5 patches for SCO Xenix System V. X XTo use these patches, you need either (1) Larry Wall's "patch" program, or X(2) lots of patience while you apply these changes by hand. X XSo, here it is: X X 1. Find your original, untouched smail 2.5 sources. Copy these X to a new directory. (We'll call it "/usr/src/xsmail".) X X 2. Move the files in this sharchive (Makefile, X.README, X X.PATCHES, execm.c, install_smail) into /usr/src/xsmail. X This will overwrite the distributed Makefile. X X 3. Run "patch <X.PATCHES". No patches should fail; if any do, X then you probably started with modified sources or with the X wrong version of smail. X X (This step will leave ".orig" files lying around. You may X remove these at any time, but I'd leave them until installation X is complete just to be on the safe side. And if any patches X fail, those patches will be in ".rej" files.) X X 4. Examine defs.h and configure it for your installation. X Specifically, if you're running Micnet or Xenix-Net, you'll X probably want to uncomment "#define MICNET". (Or you can X define it in the Makefile.) X X 5. Run "make" to make smail and execm. X X 6. >As root<, run "./install_smail". X XIf you do the above steps, the following will have occurred: X X Smail is installed as /usr/bin/smail. X X /usr/bin/rmail is moved to /usr/bin/rmail.x and never used again. X X /usr/bin/smail is linked to /usr/bin/rmail. X X /usr/lib/mail/execmail is moved to /usr/lib/mail/execmail.x, which X smail uses for delivering local mail. (If you define MICNET when X compiling smail, then execmail.x is used for delivering _all_ mail, X not just local mail.) X X The program execm.c is installed as /usr/lib/mail/execmail. This X "fake" execmail just parses its arguments and executes smail. I X would have just linked /usr/bin/smail to /usr/lib/mail/execmail, X but their arguments are different. (The /bin/mail program uses X execmail to do its work.) X XUsers of /bin/mail note: If you want to use Internet-style addresses with X/bin/mail, you have to add the line "set execmail" to /usr/lib/mail/mailrc. XOtherwise, /bin/mail assumes that addresses without bangs must be valid Xlocal users. X XOne final comment: I'd like to have some idea of how widely used these Xpatches are. So when you get it working -- or if you can't! -- drop me a Xline and tell me about it. (My address is chip@ateng. If you can't get a Xvalid path, try codas!ateng!chip or uunet!ateng!chip.) X X 28 December 1987 X Chip Salzenberg <chip@ateng.UUCP> X A T Engineering, Tampa, FL SHAR_EOF if test 2816 -ne `wc -c < 'X.README'` then echo 'shar: error transmitting "X.README" (should have been 2816 characters) ' fi chmod 644 'X.README' fi # end of overwriting check : echo 'shar: extracting "X.PATCHES" (10886 characters) ' if test -f 'X.PATCHES' then echo 'shar: will not overwrite existing file "X.PATCHES" ' else sed 's/^X//' << \SHAR_EOF > 'X.PATCHES' X XIndex: alias.c X*** ../smail2.5/alias.c Mon Dec 21 18:29:55 1987 X--- ../smail/alias.c Thu Sep 24 13:00:56 1987 X*************** X*** 460,462 **** X X! while((*p != NULL) && (*p != '#')) { X b = p; X--- 460,462 ---- X X! while((*p != '\0') && (*p != '#')) { X b = p; X XIndex: defs.h X*** ../smail2.5/defs.h Mon Dec 21 18:29:57 1987 X--- ../smail/defs.h Mon Dec 28 09:45:49 1987 X*************** X*** 18,19 **** X--- 18,47 ---- X X+ /* X+ ** Modified for SCO Xenix by Chip Salzenberg (chip@ateng.UUCP). X+ ** Released to Usenet on 01 Dec 1987. X+ ** Further modified 23 Dec 1987. X+ ** X+ ** Additions: X+ ** X+ ** EXECMAIL is defined as the renamed /usr/lib/mail/execmail. X+ ** Under Xenix, this is the local delivery agent. X+ ** X+ ** SMARTMAILER is now automatically defined if either SENDMAIL X+ ** or EXECMAIL is defined. This is useful for code that depends X+ ** on properties that these programs have in common (automatic X+ ** bouncing of failed mail, for example). X+ ** X+ ** MICNET should be defined if Micnet or Xenix-Net is in use. X+ ** In this case, execmail is used for _all_ mail, which allows X+ ** the automatic routing of UUCP mail to a gateway. However, X+ ** execmail sends one file per recipient, even if the recipients X+ ** are all on the same (remote) machine. This is not exactly X+ ** a bug; it just increases UUCP connect time. I personally X+ ** leave MICNET undefined. X+ ** X+ ** HOSTFILE is the name of a file containing the hostname. X+ ** Under Xenix, this is "/etc/systemid". HOSTFILE overrides X+ ** UNAME/GETHOSTNAME. X+ */ X+ X #ifndef VERSION X*************** X*** 32,34 **** X X! /* if defined, HOSTNAME overrides UNAME and GETHOSTNAME */ X /*#define HOSTNAME "host" /* literal name */ X--- 60,69 ---- X X! /* if defined, HOSTFILE overrides UNAME and GETHOSTNAME */ X! #ifndef HOSTFILE X! #ifdef M_XENIX X! #define HOSTFILE "/etc/systemid" /* read host name from this file */ X! #endif X! #endif X! X! /* if defined, HOSTNAME overrides HOSTFILE, UNAME, and GETHOSTNAME */ X /*#define HOSTNAME "host" /* literal name */ X*************** X*** 105,107 **** X X! #define ALIAS "/usr/lib/aliases" /* location of mail aliases */ X /*#define CASEALIAS /* make aliases case sensitive */ X--- 140,147 ---- X X! /* Location of mail aliases */ X! #ifdef M_XENIX X! #define ALIAS "/usr/lib/mail/saliases" X! #else X! #define ALIAS "/usr/lib/aliases" X! #endif X /*#define CASEALIAS /* make aliases case sensitive */ X*************** X*** 125,126 **** X--- 165,170 ---- X X+ /* list of Full Name, address pairs */ X+ #ifdef M_XENIX X+ #define FULLNAME "/usr/lib/mail/fullnames" X+ #else X #define FULLNAME "/usr/lib/fullnames" X*************** X*** 126,128 **** X #define FULLNAME "/usr/lib/fullnames" X! /* list of Full Name, address pairs */ X X--- 170,172 ---- X #define FULLNAME "/usr/lib/fullnames" X! #endif X X*************** X*** 144,146 **** X X! /*#define LOG "/usr/spool/uucp/mail.log" /* log of uucp mail */ X /*#define RECORD "/tmp/mail.log" /* record of uucp mail */ X--- 188,190 ---- X X! #define LOG "/usr/spool/uucp/mail.log" /* log of uucp mail */ X /*#define RECORD "/tmp/mail.log" /* record of uucp mail */ X*************** X*** 162,165 **** X X! #ifndef SMAIL X! #define SMAIL "/bin/smail" /* location of smail command */ X #endif X--- 206,212 ---- X X! #ifndef SMAIL /* location of smail command */ X! #ifdef M_XENIX X! #define SMAIL "/usr/bin/smail" X! #else X! #define SMAIL "/bin/smail" X #endif X*************** X*** 165,166 **** X--- 212,214 ---- X #endif X+ #endif X X*************** X*** 179,182 **** X X! #define RMAIL(flags,from,sys) "%s -a%s %s - %s!rmail",UUX,from,flags,sys /* */ X! /*#define RMAIL(flags,from,sys) "%s %s - %s!rmail",UUX,flags,sys /* */ X X--- 227,230 ---- X X! /*#define RMAIL(flags,from,sys) "%s -a%s %s - %s!rmail",UUX,from,flags,sys /* */ X! #define RMAIL(flags,from,sys) "%s %s - %s!rmail",UUX,flags,sys /* */ X X*************** X*** 187,188 **** X--- 235,238 ---- X X+ /* We're letting sendmail do lots of work for us. */ X+ X #define HANDLE JUSTUUCP /* see HANDLE definition below */ X*************** X*** 195,197 **** X X! #else X X--- 245,247 ---- X X! #else /* !SENDMAIL */ X X*************** X*** 197,200 **** X X! #define HANDLE ALL X! #define ROUTING JUSTDOMAIN X X--- 247,249 ---- X X! /* We don't have sendmail, so we'll do the work ourselves. */ X X*************** X*** 200,205 **** X X! #ifdef BSD X! #define LMAIL(frm,sys) "/bin/mail" /* BSD local delivery agent */ X! #else X! #define LMAIL(frm,sys) "/bin/lmail" /* SV local delivery agent */ X #endif X--- 249,255 ---- X X! #define HANDLE ALL /* see HANDLE definition below */ X! #define ROUTING ALWAYS /* see ROUTING definition below */ X! X! #ifdef BSD /* BSD local delivery agent */ X! #define LMAIL(frm,sys) "/bin/mail" X #endif X*************** X*** 206,207 **** X--- 256,267 ---- X X+ #ifdef M_XENIX /* Xenix local delivery agent (renamed) */ X+ #define EXECMAIL "/usr/lib/mail/execmail.x" X+ #define LMAIL(frm,sys) "%s -m -f '%s'",EXECMAIL,frm X+ /*#define MICNET /* give all mail to execmail, never uux */ X+ #endif X+ X+ #ifndef LMAIL /* Default local delivery agent */ X+ #define LMAIL(frm,sys) "/bin/lmail" X+ #endif X+ X #define LARG(user) " '%s'",postmaster(user) X*************** X*** 210,212 **** X X! #endif X X--- 270,272 ---- X X! #endif /* !SENDMAIL */ X X XIndex: deliver.c X*** ../smail2.5/deliver.c Mon Dec 21 18:29:59 1987 X--- ../smail/deliver.c Wed Dec 23 12:19:33 1987 X*************** X*** 7,8 **** X--- 7,24 ---- X X+ /* X+ ** Modified for SCO Xenix by Chip Salzenberg (chip@ateng.UUCP). X+ ** Released to Usenet on 01 Dec 1987. X+ ** Further modified 23 Dec 1987. X+ ** X+ ** Additions: X+ ** X+ ** If MICNET is defined, then LMAIL (execmail) is used to X+ ** deliver all mail, even remote mail. See defs.h for a X+ ** discussion of the tradeoffs of this feature. X+ ** X+ ** Some #ifdefs are now SMARTMAILER instead of SENDMAIL. X+ ** This is because execmail has some of the intelligent X+ ** features of sendmail, i.e. automatic mail return. X+ */ X+ X #ifndef lint X*************** X*** 219,222 **** X command = scommand; X- } else if (form == LOCAL) { X- command = lcommand; X } else { X--- 235,236 ---- X*************** X*** 222,226 **** X } else { X! command = rcommand; X! if(flags == uux_noqueue) { X! noqcnt++; X } X--- 236,250 ---- X } else { X! #ifdef MICNET X! /* Xenix system running Micnet -- let execmail X! * handle all messages except retries. X! */ X! command = lcommand; X! #else X! if (form == LOCAL) { X! command = lcommand; X! } else { X! command = rcommand; X! if(flags == uux_noqueue) { X! noqcnt++; X! } X } X*************** X*** 226,227 **** X--- 250,252 ---- X } X+ #endif X } X*************** X*** 271,273 **** X if (form == LOCAL) { X! #ifdef SENDMAIL X (void) sprintf(buf, LFROM(from, nows, hostname)); X--- 296,298 ---- X if (form == LOCAL) { X! #ifdef SMARTMAILER X (void) sprintf(buf, LFROM(from, nows, hostname)); X*************** X*** 283,285 **** X } else { X! *p = NULL; X (void) sprintf(buf, RFROM(p+1, nows, from)); X--- 308,310 ---- X } else { X! *p = '\0'; X (void) sprintf(buf, RFROM(p+1, nows, from)); X*************** X*** 372,378 **** X (void) fseek(spoolfp, message, 0); X! #ifdef SENDMAIL X! /* if we have sendmail, then it X! ** was handed the mail, which failed. X! ** sendmail returns the failed mail X! ** for us, so we need not do it again. X */ X--- 397,402 ---- X (void) fseek(spoolfp, message, 0); X! #ifdef SMARTMAILER X! /* Mail is automatically returned X! ** by sendmail and execmail, so we X! ** need not do it again. X */ X XIndex: headers.c X*** ../smail2.5/headers.c Mon Dec 21 18:30:06 1987 X--- ../smail/headers.c Wed Dec 23 12:26:43 1987 X*************** X*** 5,6 **** X--- 5,18 ---- X X+ /* X+ ** Modified for SCO Xenix by Chip Salzenberg (chip@ateng.UUCP). X+ ** Released to Usenet on 01 Dec 1987. X+ ** Further modified 23 Dec 1987. X+ ** X+ ** Additions: X+ ** X+ ** Understand "a%b" to mean "a@b". (This is a judgement call. X+ ** I prefer to accept any mail that I can understand, not just X+ ** that which is "correct.") X+ */ X+ X #ifndef lint X*************** X*** 155,156 **** X--- 167,179 ---- X } X+ /* X+ ** Try splitting at %. If it works, this is user%domain, which we choose X+ ** to understand as user@domain. Prefer the righthand % in a%b%c. X+ ** (This code allows 'user%foo@mydom' to mean '@mydom,user@foo'.) X+ */ X+ if ((parts = ssplit(address, '%', partv)) >= 2) { X+ (void) strcpy(domain, partv[parts-1]); X+ (void) strncpy(user, partv[0], partv[parts-1]-partv[0]-1); X+ user[partv[parts-1]-partv[0]-1] = '\0'; X+ return (DOMAIN); X+ } X /* X XIndex: misc.c X*** ../smail2.5/misc.c Mon Dec 21 18:30:19 1987 X--- ../smail/misc.c Wed Dec 23 12:30:02 1987 X*************** X*** 5,6 **** X--- 5,21 ---- X X+ /* X+ ** Modified for SCO Xenix by Chip Salzenberg (chip@ateng.UUCP). X+ ** Released to Usenet on 01 Dec 1987. X+ ** Further modified 23 Dec 1987. X+ ** X+ ** Additions: X+ ** X+ ** If HOSTFILE is defined, read it to look for the hostname. X+ ** (This file is typically "/etc/systemid" on Xenix systems.) X+ ** If HOSTFILE is missing, try uname() or gethostname(). X+ ** X+ ** Write only the basename of the program in the log file, X+ ** just to make the log file easier to read. X+ */ X+ X #ifndef lint X*************** X*** 53,57 **** X X! logtime = strcpy(tbuf, nows); X! logtime[16] = '\0'; X! logtime += 4; X X--- 68,75 ---- X X! /* To make the log file look nicer, show only the basename of X! * the command. X! */ X! if (*command == '/') X! { X! char *p, *ecmd; X X*************** X*** 57,58 **** X--- 75,92 ---- X X+ if ( (ecmd = index(command, ' ')) != 0 ) X+ *ecmd = '\0'; X+ X+ if ( (p = rindex(command, '/')) != 0 ) X+ command = p + 1; X+ X+ if ( ecmd != 0 ) X+ *ecmd = ' '; X+ } X+ X+ /* Time (now). X+ */ X+ strcpy(tbuf, nows); X+ tbuf[16] = '\0'; X+ logtime = &tbuf[4]; X+ X cmask = umask(0); X*************** X*** 313,314 **** X--- 347,363 ---- X (void) strcpy(hostname, HOSTNAME); X+ #endif X+ #ifdef HOSTFILE X+ if (!*hostname) { X+ FILE *fp; X+ char *p; X+ X+ if ((fp = fopen(HOSTFILE, "r")) != NULL) { X+ if (fgets(hostname, SMLBUF - 1, fp) != NULL X+ && (p = index(hostname, '\n')) != NULL) X+ *p = '\0'; X+ else X+ *hostname = '\0'; X+ fclose(fp); X+ } X+ } X #endif X XIndex: nptx.c X*** ../smail2.5/nptx.c Mon Dec 21 18:30:20 1987 X--- ../smail/nptx.c Thu Sep 24 13:07:13 1987 X*************** X*** 127,129 **** X (void) strcpy(nl[i], p+1); X! *p = NULL; X } X--- 127,129 ---- X (void) strcpy(nl[i], p+1); X! *p = '\0'; X } X*************** X*** 164,166 **** X (void) strcpy(il[ii], pi+1); X! *pi = NULL; X } X--- 164,166 ---- X (void) strcpy(il[ii], pi+1); X! *pi = '\0'; X } SHAR_EOF if test 10886 -ne `wc -c < 'X.PATCHES'` then echo 'shar: error transmitting "X.PATCHES" (should have been 10886 characters) ' fi chmod 644 'X.PATCHES' fi # end of overwriting check : echo 'shar: extracting "Makefile" (1427 characters) ' if test -f 'Makefile' then echo 'shar: will not overwrite existing file "Makefile" ' else sed 's/^X//' << \SHAR_EOF > 'Makefile' X# Makefile for smail X# @(#)Makefile 2.5 (smail) 9/15/87 X# X# Modified for SCO Xenix by Chip Salzenberg <chip@ateng.UUCP>. X# Released to Usenet on 01 Dec 1987. X# Fixed as per comments of Chris Lewis <uunet!mnetor!spectrix!clewis>. X# X# With the addition of the `xenix' pseudo-target, this makefile now makes X# both smail and execm by default. X# X# Use the `install_smail' script to install the resulting binaries. X XCFLAGS = -O XLDFLAGS = -i XSHELL = /bin/sh XCOPY = copy -om X X# X# System V Release 2.0 sites can use -lmalloc for a faster malloc X# X#LIBS = -lmalloc X XOBJECTS = main.o map.o resolve.o deliver.o misc.o alias.o pw.o headers.o getpath.o str.o getopt.o X Xxenix: smail execm Xall: smail svbinmail lcasep pathproc mkfnames nptx execm X Xsmail: $(OBJECTS) X $(CC) $(LDFLAGS) -F 4000 $(OBJECTS) -o smail $(LIBS) X X$(OBJECTS): defs.h X $(CC) $(CFLAGS) -c $< X Xexecm: execm.c X $(CC) $(CFLAGS) $(LDFLAGS) execm.c -o execm X Xsvbinmail: svbinmail.c defs.h X $(CC) $(CFLAGS) $(LDFLAGS) svbinmail.c -o svbinmail X Xlcasep: lcasep.c X $(CC) $(CFLAGS) $(LDFLAGS) lcasep.c -o lcasep X Xpathproc: pathproc.sh X $(COPY) pathproc.sh pathproc X chmod 755 pathproc X Xmkfnames: mkfnames.sh X $(COPY) mkfnames.sh mkfnames X chmod 755 mkfnames X Xnptx: nptx.o pw.o str.o X $(CC) $(CFLAGS) nptx.o pw.o str.o -o nptx $(LIBS) X Xclean: X rm -f *.o *.ln a.out core X Xclobber: clean X rm -f smail rmail lcasep pathproc mkfnames svbinmail nptx execm SHAR_EOF if test 1427 -ne `wc -c < 'Makefile'` then echo 'shar: error transmitting "Makefile" (should have been 1427 characters) ' fi chmod 644 'Makefile' fi # end of overwriting check : echo 'shar: extracting "execm.c" (747 characters) ' if test -f 'execm.c' then echo 'shar: will not overwrite existing file "execm.c" ' else sed 's/^X//' << \SHAR_EOF > 'execm.c' X/* X * execm.c X * X * This program is a substitute for Xenix's /usr/lib/mail/execmail. X * X * Written by Chip Salzenberg (chip@ateng.UUCP). X * Released to Usenet on 01 Dec 1987. X * X * Do what you want with it; I'm not responsible for lost mail, X * but I don't expect that this little program will lose anything. X */ X X#include <stdio.h> X Xmain(argc, argv) Xint argc; Xchar **argv; X{ X char *progname = argv[0]; X X /* X * Drop the execmail options. X */ X while (argv[1][0] == '-') X { X switch (argv[1][1]) X { X case 'f': X case 'h': X argv += 2; X break; X default: X ++argv; X break; X } X } X X argv[0] = progname; X execv("/usr/bin/smail", argv); X execv("/bin/smail", argv); X X fprintf(stderr, "%s: can't execute smail!\n", progname); X exit(1); X} SHAR_EOF if test 747 -ne `wc -c < 'execm.c'` then echo 'shar: error transmitting "execm.c" (should have been 747 characters) ' fi chmod 644 'execm.c' fi # end of overwriting check : echo 'shar: extracting "install_smail" (1137 characters) ' if test -f 'install_smail' then echo 'shar: will not overwrite existing file "install_smail" ' else sed 's/^X//' << \SHAR_EOF > 'install_smail' X: install_smail X# Shell script to install smail in a Xenix System V system. X# X# Written by Chip Salzenberg (chip@ateng.UUCP). X# Released to Usenet on 01 Dec 1987. X# X# Note that this script renames the standard Xenix rmail and execmail X# programs to rmail.x and execmail.x respectively. If those `.x' files X# already exist, then no renaming takes place, so you can run this script X# more than once without losing those renamed programs. X# X# BTW, be sure to test everything thoroughly; a broken mail system is X# sure to upset any users on your system. X XCOPY="copy -m" XSMAIL="/usr/bin/smail" XRMAIL="/usr/bin/rmail" XEXECM="/usr/lib/mail/execmail" X Xfor f in smail execm Xdo X if [ ! -x $f ]; then X echo "You need to compile $f first." X exit 1 X fi Xdone X Xecho "Installing current smail -- you have 5 seconds to abort." Xsleep 5 X Xif [ ! -f $RMAIL.x ]; then X mv $RMAIL $RMAIL.x Xfi Xrm -f $RMAIL Xif [ ! -f $EXECM.x ]; then X mv $EXECM $EXECM.x Xfi Xrm -f $EXECM X X$COPY execm $EXECM Xchown bin $EXECM Xchgrp bin $EXECM Xchmod 755 $EXECM X Xrm -f $SMAIL $RMAIL X$COPY smail $SMAIL Xchown bin $SMAIL Xchgrp bin $SMAIL Xchmod 755 $SMAIL Xln $SMAIL $RMAIL SHAR_EOF if test 1137 -ne `wc -c < 'install_smail'` then echo 'shar: error transmitting "install_smail" (should have been 1137 characters) ' fi chmod 755 'install_smail' fi # end of overwriting check # End of shell archive exit 0 -- Chip Salzenberg UUCP: "{codas,uunet}!ateng!chip" A T Engineering My employer's opinions are a trade secret. Chip's Observation: "Anything that works is better than anything that doesn't."