Subject: v09i048: UUmail 4.X patch Newsgroups: mod.sources Approved: rs@mirror.TMC.COM Submitted by: rice!cortex!sob (Stan Barber) Mod.sources: Volume 9, Issue 48 Archive-name: uumail.pch [ The version published in Volume 8 of mod.sources had already integrated Patch 1. --r$ ] System: uumail version 4.2 Patch #: 2 Priority: REQUIRED Subject: General fixes to getpath.c rmail.c uumail.c Configure Makefile.SH From: smb!dave, atelabs!cds Description: Some typos in the declaration of Version and bangpath. The Putfrom routine was not rebuilding the From_ line correctly. Configure needed to identify 8086 and z8000 machines for their need for seperate I and D. Default log, Alias and paths files are now created if the user wants them created. Getpaths calls uuname twice when it only has to call it once. Makefile will not protect the naive installed from killing his copy of REALUUX. uumail can now double as address as well as uupath. Repeat by: Feed uumail a message with lots of From_ lines and see what Putfrom does when it rebuilds them. The Configure problems are obvious ones. rmail did not make sure that the argv was terminated with NULL. Fix: Fix the typos. Add the code to fix the problems in Putfrom. Replace the code in getpaths to call uuname only once and make a linked list. Fix Makefile. Add support for address into uumail. From rn, say "| patch -d DIR", where DIR is your rn source directory. Outside of rn, say "cd DIR; patch i8086.c + #ifdef i8086 + exit 0 + #else + exit 1 + #endif + EOT + $cpp i8086.c | grep exit >i8086 + chmod 755 i8086 + $eunicefix i8086 + rm i8086.c + if i8086; then + echo "This looks like an 8086-based computer to me." + else + echo "This doesn't look like an 8086-based computer to me." + fi + + : check for z8000 + echo " " + cat <<'EOT' >z8000.c + #ifdef z8000 + exit 0 + #else + exit 1 + #endif + EOT + $cpp z8000.c | grep exit >z8000 + chmod 755 z8000 + $eunicefix z8000 + rm z8000.c + + if z8000; then + echo "This looks like a z8000-based computer to me." + else + echo "This doesn't look like a z8000-based computer to me." + fi + : see if sh knows # comments echo " " echo "Checking your sh to see if it knows about # comments..." *************** *** 803,809 **** $echo " " case "$libexp" in blurfl*) ;; ! *) $echo "File $libexp not found";; esac $echo $n "Where is your uumail log file (~name okay)? [$dflt] $c" . myread --- 854,868 ---- $echo " " case "$libexp" in blurfl*) ;; ! *) $echo "File $libexp not found" ! $echo $n "Shall I create it for you? $c" ! . myread ! case "$ans" in ! y*) $echo $n "OK... I will create it for you... $c" ! cp /dev/null $libexp ! $echo "done" ;; ! esac ! ;; esac $echo $n "Where is your uumail log file (~name okay)? [$dflt] $c" . myread *************** *** 865,871 **** $echo " " case "$libexp" in blurfl*) ;; ! *) $echo "File $libexp not found";; esac $echo $n "Where is your uucp map database (~name okay)? [$dflt] $c" . myread --- 924,943 ---- $echo " " case "$libexp" in blurfl*) ;; ! *) $echo "File $libexp not found" ! $echo $n "Shall I create it for you? $c" ! . myread ! case "$ans" in ! y*) $echo $n "OK... I will create it for you... $c" ! for i in `cat uucp.local` ! do ! $echo "$i $i!%s" >> $libexp ! done ! $echo "done" ;; ! *) $echo "OK, you create it and run Configure when you are done." ! exit 1 ;; ! esac ! ;; esac $echo $n "Where is your uucp map database (~name okay)? [$dflt] $c" . myread *************** *** 948,954 **** $echo " " case "$libexp" in blurfl*) ;; ! *) $echo "File $libexp not found";; esac $echo $n "Where is your aliases file (~name okay)? [$dflt] $c" . myread --- 1020,1036 ---- $echo " " case "$libexp" in blurfl*) ;; ! *) $echo "File $libexp not found" ! $echo $n "Shall I create it for you? $c" ! . myread ! case "$ans" in ! y*) $echo $n "OK... I will create it for you... $c" ! $echo "Postmaster: root" > $libexp ! $echo "done" ;; ! *) $echo "OK, you create it and run Configure when you are done." ! exit 1 ;; ! esac ! ;; esac $echo $n "Where is your aliases file (~name okay)? [$dflt] $c" . myread *************** *** 1221,1227 **** : see if we should throw a -i into the Makefile $echo " " ! if pdp11; then if $contains '\-i' $mansrc/cc.1 >/dev/null 2>&1 ; then $echo $n "Your system appears to have separate I and D space. Is this true? [y] $c" . myread --- 1303,1309 ---- : see if we should throw a -i into the Makefile $echo " " ! if pdp11 || i8086 || z8000; then if $contains '\-i' $mansrc/cc.1 >/dev/null 2>&1 ; then $echo $n "Your system appears to have separate I and D space. Is this true? [y] $c" . myread *************** *** 1239,1245 **** esac fi else ! $echo "Not a pdp11--assuming no separate I and D." fi : index or strcpy --- 1321,1327 ---- esac fi else ! $echo "Not a pdp11 or i8086 or z8000 --assuming no separate I and D." fi : index or strcpy *************** *** 1882,1886 **** case "$ans" in y*) makedepend;; esac ! $rm -f uucp.local myread loc filexp bsd pdp11 v7 usg eunice ! : end of Configure --- 1964,1967 ---- case "$ans" in y*) makedepend;; esac ! $rm -f uucp.local myread loc filexp bsd pdp11 z8000 i8086 v7 usg eunice Index: uumail.c Prereq: 4.2 *** /tmp/,RCSt1003985 Wed Mar 18 14:00:02 1987 --- /tmp/,RCSt2003985 Wed Mar 18 14:00:07 1987 *************** *** 20,25 **** --- 20,34 ---- or any damage it may cause to any data of any kind anywhere. *************************************************************************** * $Log: uumail.c,v $ + * Revision 4.4 87/03/18 13:53:44 sob + * More fixes to Putfrom. Added support for uumail acting as the + * address command. Some cleanup of parts of the code. + * + * Revision 4.3 87/03/17 14:48:15 sob + * Made some minor changes in Putfrom suggest by smail 2.3 posting. + * Other bug fixes as well. + * Stan + * * Revision 4.2 87/02/02 15:43:50 sob * Added fix for lost line at the beginning of the message problems * *************** *** 206,213 **** --- 215,224 ---- #include "uuconf.h" #include "patchlevel.h" + #include EXTERN bool uupath; + EXTERN bool addrcmd; extern int errno; extern struct passwd *getpwuid(); extern FILE *popen(); *************** *** 221,227 **** extern bool nghborflag; EXTERN char progname[12]; EXTERN char *paths; ! char * bangpath[BUFSIZ]; char templet[64]; struct mailname addrlist; /* list of addresses */ int local; --- 232,238 ---- extern bool nghborflag; EXTERN char progname[12]; EXTERN char *paths; ! char bangpath[BUFSIZ]; char templet[64]; struct mailname addrlist; /* list of addresses */ int local; *************** *** 276,283 **** if (p++ == NULL) p = *av; strcpy(progname ,p); ! if(strcmp(p,"uupath") == 0) uupath = TRUE; while ((p = *++av) != NULL && p[0] == '-') { switch (p[1]) --- 287,296 ---- if (p++ == NULL) p = *av; strcpy(progname ,p); ! if(strcmp(p,"uupath") == 0) /* this is the uupath command */ uupath = TRUE; + if(strcmp(p,"address") == 0) /* this is the address command */ + addrcmd = TRUE; while ((p = *++av) != NULL && p[0] == '-') { switch (p[1]) *************** *** 402,408 **** /* If this is not uupath, then there must be a letter */ ! if (!uupath) { #ifdef DEBUG if (Debug) (void) printf("Mail from %s\n",from); --- 415,421 ---- /* If this is not uupath, then there must be a letter */ ! if (!uupath && !addrcmd) { #ifdef DEBUG if (Debug) (void) printf("Mail from %s\n",from); *************** *** 494,521 **** } r = malloc(PATHSIZ); strcpy(r,p); ! if (index(p,'@') != NULL) handle = ALL; /* try one */ ! form = resolve(p,path,user); if ( (form == LOCAL && path[0] == '\0') || form == ERROR || form == ROUTE || form == DOMAIN){ ! if (user[0] != '\0') strcpy(p,user); path[0] = user[0] = '\0'; /* try two */ ! if (index(p,'@') != NULL) handle = ALL; ! form = resolve(p,path,user); } /* we could punt at this point, but let's forward it to a known host that might be able to resolve it */ #ifdef KNOWNHOST /* ugly... alternate suggestions welcome */ ! if ( (exitstat || form == ERROR) ! && (index(r,'@') != NULL || index(r,'!') != NULL) ){ ! strcpy(p,KNOWNHOST); ! strcat(p,"!"); ! strcat(p,r); user[0] = '\0'; ! form = resolve(p,path,user); } #endif --- 507,534 ---- } r = malloc(PATHSIZ); strcpy(r,p); ! if (index(r,'@') != NULL) handle = ALL; /* try one */ ! form = resolve(r,path,user); if ( (form == LOCAL && path[0] == '\0') || form == ERROR || form == ROUTE || form == DOMAIN){ ! if (user[0] != '\0') strcpy(r,user); path[0] = user[0] = '\0'; /* try two */ ! if (index(r,'@') != NULL) handle = ALL; ! form = resolve(r,path,user); } /* we could punt at this point, but let's forward it to a known host that might be able to resolve it */ #ifdef KNOWNHOST /* ugly... alternate suggestions welcome */ ! if ((addrcmd == FALSE) && (((exitstat || form == ERROR) ! && (index(p,'@') != NULL || index(p,'!') != NULL) ))){ ! strcpy(r,KNOWNHOST); ! strcat(r,"!"); ! strcat(r,p); user[0] = '\0'; ! form = resolve(r,path,user); } #endif *************** *** 527,535 **** if (exitstat || form == ERROR ) /* no match in pathalias database */ { ! deadletter(tmpf,local,exitstat,p); ! unlink(templet); ! exit(exitstat); } --- 540,555 ---- if (exitstat || form == ERROR ) /* no match in pathalias database */ { ! if (addrcmd) { ! fprintf(stderr,"%s cannot be resolved.\n", ! lp->m_name); ! break; ! } else { ! deadletter(tmpf,local,exitstat,p); ! unlink(templet); ! exit(exitstat); /* this may be the wrong approach */ ! } ! } *************** *** 539,545 **** local = 1; } } /* end of else uupath */ ! #else else { p = index(q,'!'); --- 559,565 ---- local = 1; } } /* end of else uupath */ ! #else /* not RESOLVE */ else { p = index(q,'!'); *************** *** 565,576 **** } } } ! #endif #ifdef DEBUG if(Debug>3) (void) fprintf(stderr, ! "p = %s path = %s user = %s\n",p, path,user); #endif if (uupath) --- 585,596 ---- } } } ! #endif /* end RESOLVE */ #ifdef DEBUG if(Debug>3) (void) fprintf(stderr, ! "address = %s path = %s user = %s\n",p, path,user); #endif if (uupath) *************** *** 580,585 **** --- 600,611 ---- lp->m_name,path); continue; } + else if (addrcmd) + { + (void) printf("Address %s resolves to %s!%s.\n", + lp->m_name, path, user); + continue; + } else { if (local) *************** *** 619,624 **** --- 645,656 ---- } } pipeout: + + if(addrcmd) + { + printf("Address %s pipes output to %s.\n",lp->m_name,cmd); + continue; + } else { #ifdef DEBUG if (Debug) (void) fprintf(stderr,"Command is %s\n",cmd); #endif *************** *** 658,663 **** --- 690,696 ---- #ifdef LOG maillog(cmd); #endif + } } } #ifdef DEBUG *************** *** 684,691 **** char *asctime(); struct tm *bp, *localtime(); char *tp, *zp,*c; ! int parts,fromflag=0; ! char *partv[16]; char buf[BUFSIZ], addr[PATHSIZ], domain[PATHSIZ], user[NAMESIZ]; int form; extern build(); --- 717,724 ---- char *asctime(); struct tm *bp, *localtime(); char *tp, *zp,*c; ! int i,parts,fromflag=0; ! char *partv[128]; char buf[BUFSIZ], addr[PATHSIZ], domain[PATHSIZ], user[NAMESIZ]; int form; extern build(); *************** *** 745,750 **** --- 778,811 ---- */ if (bangpath[0] == '\0') strcpy(bangpath,from); + parts = ssplit(bangpath,'!',partv); + /* null terminate each part of partv */ + for (i = 0;i < (parts-1);i++){ + tp = partv[i]; + if(*tp == '\0') continue; + zp = partv[i+1]; + zp--; + *zp = '\0'; + zp++; + } + /* now eliminate duplicate parts */ + for (i = 0; i < ( parts - 2) ; i++){ + tp = partv[i]; + zp = partv[i+1]; + if(strcmp(tp,zp) == 0) + *tp = '\0'; + } + buf[0] = '\0'; + /* reassemble the line */ + for ( i = 0;i<(parts-1);i++){ + if ((partv[i][0] == '\0') || ((buf[0] == '\0') && + (strcmp(partv[i],Myname) == 0))) continue; + (void) strcat(buf,partv[i]); + (void) strcat(buf, "!"); + } + + (void) strcat(buf,partv[i]); + (void) strcpy(bangpath,buf); /* overwrite old bangpath */ /* * Format time */ Index: getpath.c Prereq: 4.0 *** /tmp/,RCSt1004133 Wed Mar 18 14:59:23 1987 --- /tmp/,RCSt2004133 Wed Mar 18 14:59:26 1987 *************** *** 39,44 **** --- 39,50 ---- * modified to rewind path file (if open), rather than open again * * $Log: getpath.c,v $ + * Revision 4.2 87/03/18 13:54:28 sob + * Added some fixes to handle domain searches better. + * + * Revision 4.1 87/03/17 14:47:44 sob + * Replaced old getneighbors with a new version supplied by smb!dave + * * Revision 4.0 86/11/17 16:02:15 sob * Release version 4.0 -- uumail * *************** *** 160,178 **** #include #endif ! static char rcsid[] = "$Header: getpath.c,v 4.0 86/11/17 16:02:15 sob Exp $"; extern char * index(); ! extern FILE * fopen (), *popen(); FILE * in; bool nghborflag,gotneighbors; - char **neighbors, *n_array; /* rct */ int getpath (sysname, pathname, pathfile) char *sysname, *pathname,*pathfile; { ! int indx,x; char ACsysname[NAMESIZ]; /* alternate case sysname */ #ifdef UUDBM datum lhs,rhs; #else --- 166,192 ---- #include #endif ! static char rcsid[] = "$Header: getpath.c,v 4.2 87/03/18 13:54:28 sob Exp $"; extern char * index(); ! extern char * malloc(); extern FILE * fopen (), *popen(); FILE * in; bool nghborflag,gotneighbors; + struct system { + char *s_name; + struct system *s_next; + }; + + static struct system head = {NULL, NULL}; + + int getpath (sysname, pathname, pathfile) char *sysname, *pathname,*pathfile; { ! int indx,x,t; char ACsysname[NAMESIZ]; /* alternate case sysname */ + struct system *sys = &head; #ifdef UUDBM datum lhs,rhs; #else *************** *** 187,207 **** long last; static char buf[256]; #else ! char * p, * q, t; #endif #endif /* build sysname in the alternate case to conform to methods in SMAIL */ ! if (*(sysname) == '.' || isupper(*sysname)) /* a kludge */ { for (x=0;xs_name){ ! if (!strcmp(sysname,sys->s_name) ! || !strcmp(ACsysname,sys->s_name)){ ! strcpy(pathname,sys->s_name); ! strcat(pathname,"!%s"); return(EX_OK); } ! sys = sys->s_next; } } /* not a neighbor, let's look in the database */ *************** *** 397,491 **** } #endif ! getneighbors() ! { ! FILE *ppntr; ! char * ptr; ! int x = 0; ! char n_neigh[16], *calloc(); /* rct */ ! int nelem = 0; /* rct */ ! gotneighbors = TRUE; ! ! /* ! * Let's get the number of neighbors we have. ! * ! * Beginning of added code. --rct ! */ ! ! if((ppntr = popen("uuname | wc -l", "r")) != NULL){ ! #ifdef DEBUG ! if(Debug > 2) ! (void)fprintf(stderr, "Starting uuname | wc -l\n"); #endif } ! else{ ! (void)fprintf(stderr, "Error: popen\(\"uuname | wc -l\"\)\n"); ! exit(1); } ! if((fgets(n_neigh, sizeof(n_neigh), ppntr)) != (char *)0){ ! if((ptr = index(n_neigh, '\n')) != (char *)0) ! *ptr = '\0'; ! } ! else{ ! (void)fprintf(stderr, "Error: fgets\(n_neigh\)\n"); ! exit(2); ! } ! #ifdef DEBUG ! if (Debug > 2) ! (void)fprintf(stderr, "n_neigh = %s\n", n_neigh); ! #endif ! (void)pclose(ppntr); ! ! /* ! * Allocate storage for neighbors based on n_neigh. ! * Assumption being made here is that no system has a name ! * longer than 14 characters. If this assumption ever turns ! * out to be wrong, lots of other code will break before this ! * does! --rct ! */ ! ! nelem = atoi(n_neigh) + 2; ! ! if(((neighbors = (char **)calloc((unsigned)nelem, ! sizeof(char **))) == (char **)0) || ! ((n_array = calloc((unsigned)nelem, 15)) == (char *)0)){ ! (void)fprintf(stderr, "Error: getneighbors\(\): calloc\(\)\n"); ! exit(3); ! } ! ! /* ! * Set up pointers. ! */ ! ! for(x = 0; x < nelem; x++) ! neighbors[x] = &n_array[x * 15]; ! ! /* ! * Now, let's read them in! ! * ! * End of added code. --rct ! */ ! ! if ((ppntr = popen("uuname", "r")) != NULL) { ! #ifdef DEBUG ! if (Debug>2) ! (void)fprintf(stderr, "Starting uuname\n"); ! #endif ! x = 0; ! while((fgets(neighbors[x], 15, ppntr)) != NULL){ ! if ((ptr = index(neighbors[x], '\n')) != NULL) ! *ptr = '\0'; ! #ifdef DEBUG ! if (Debug>4) ! (void) fprintf(stderr, "Neighbor # %d: %s\n", ! x + 1, neighbors[x]); ! #endif ! x++; ! } ! (void) pclose(ppntr); ! } ! strcpy(neighbors[x], Myname); } --- 417,459 ---- } #endif ! /* ! * The getneighbors subroutine is ! * Copyright (C) Dave Settle Thorn-EMI Datasolve Mar 1987 ! * You can do anything with this, except sell it for profit, or remove ! * this copyright notice. {used by permission -- sob} ! * ! * read list of direct connections from "uuname" ! */ ! getneighbors(){ ! char name[32], *p; ! struct system *sys = &head; ! FILE *cmd; ! int i; ! /* ! */ ! if((cmd = popen("uuname", "r")) == NULL) { ! #ifdef notdef ! perror("uuname"); ! return(EX_NOHOST); /* we don't really care */ ! #else ! return; #endif } ! while(fgets(name, sizeof name, cmd)) { ! i = strlen(name); ! name[i - 1] = '\0'; /* chop off newline */ ! p = malloc(i + 1); ! strcpy(p, name); ! sys->s_name = p; /* store system name */ ! sys->s_next = (struct system *) malloc(sizeof (struct system)); ! sys = sys->s_next; ! sys->s_name = NULL; ! sys->s_next = (struct system *) 0; } ! gotneighbors = TRUE; ! pclose(cmd); } Index: rmail.c Prereq: 4.0 *** /tmp/,RCSt1003977 Wed Mar 18 13:59:22 1987 --- /tmp/,RCSt2003977 Wed Mar 18 13:59:23 1987 *************** *** 1,5 **** #ifndef lint ! static char rcsid[]="$Header: rmail.c,v 4.0 86/11/17 16:02:32 sob Exp $"; #endif --- 1,5 ---- #ifndef lint ! static char rcsid[]="$Header: rmail.c,v 4.1 87/03/17 15:49:04 sob Exp $"; #endif *************** *** 44,50 **** register char *cp; register char *uf; /* ptr into ufrom */ int i; ! # ifdef DEBUG if (argc > 1 && strcmp(argv[1], "-T") == 0) { --- 44,50 ---- register char *cp; register char *uf; /* ptr into ufrom */ int i; ! argv[argc] = NULL; # ifdef DEBUG if (argc > 1 && strcmp(argv[1], "-T") == 0) {