gjm@ihnp4.UUCP (Gary J. Murakami) (03/22/84)
A few months back, I posted and enhancement to sendmail that added a generalized nameserver function. I recently found out that this had a side effect of breaking aliases with continuation lines. Attached are the changed modules including the fix/patch/kludge which saves/restores the value of DelimChar around the prescan() call for the nameserver result. Gary Murakami AT&T Bell Laboratories ihnp4!gjm --------- sendmail.h,main.c,parseaddr.c: nameserver enhancement DN/usr/lib/mail/postperson R$+.$+ $:$<N$1.$2 The RHS is expanded and the result is compressed into a single string used as the sole argument to the command in macro N. The output of the command (single line) is returned if the command is succesful, otherwise the RHS input argument is returned. In the interests of efficiency, the command must be an executable object that accepts a single argument (address). ------------------------------------------------------------------- diff osrc/sendmail.h src/sendmail.h: 27a28,37 > * definitions for byte/block operations > */ > #ifdef USG > #include <memory.h> > #define bzero(d,l) memset(d,'\0',l) > #define bcopy(s,d,l) memcpy(d,s,l) > #define bmove(s,d,l) memcpy(d,s,l) > #endif USG > > /* 285a296 > # define CALLNAME '\035' /* call nameserver */ ------------------------------------------------------------------- diff osrc/main.c src/main.c null message fix aka /bin/mail nameserver enhancement freeze/thaw fixes for frozen configuration 66c66 < extern int finis(); --- > extern int collect(),finis(); 525a526,528 > # ifdef LOG > syslog(LOG_INFO, "queue run started, interval=%d", QueueIntvl); > # endif LOG 585c588,589 < collect(FALSE); --- > if (collect(FALSE) == FALSE) > finis(); 699a704 > '<', CALLNAME, 758c763 < extern char edata; --- > char *start; 777a783 > start = Version; 781,782c787,788 < write(f, (char *) &edata, fhdr.frzinfo.frzbrk - &edata) != < (fhdr.frzinfo.frzbrk - &edata)) --- > write(f, (char *) start, fhdr.frzinfo.frzbrk - start) != > (fhdr.frzinfo.frzbrk - start)) 785a792 > syslog(LOG_INFO, "froze start=0x%X end=0x%X", (char *) start, fhdr.frzinfo.frzbrk); 809c816 < extern char edata; --- > char *start; 837a845 > start = Version; 840,841c848,849 < if (read(f, (char *) &edata, fhdr.frzinfo.frzbrk - &edata) != < (fhdr.frzinfo.frzbrk - &edata)) --- > if (read(f, (char *) start, fhdr.frzinfo.frzbrk - start) != > (fhdr.frzinfo.frzbrk - start)) 883a892,895 > > #ifdef USG > setpgrp(); > #endif USG ------------------------------------------------------------------- diff osrc/parseaddr.c src/parseaddr.c 0a1 > # include <fcntl.h> 462a464,471 > char command[MAXLINE]; /* nameserver command name */ > char namearg[MAXLINE]; /* nameserver command arguement */ > char nameret[MAXLINE]; /* nameserver result */ > FILE *fnames; /* nameserver stream */ > int fildes[2],nstatus,pid; /* nameserver pipe, exit, pid */ > char *DelimSave; /* save DelimChar */ > extern int execl(),fcntl(),pipe(); /* system calls */ > extern char *macvalue(); /* nameserver defined in macro */ 680a690,734 > } > else if (**npvp == CALLNAME) /* nameserver call */ > { > bmove((char *) &npvp[2], (char *) pvp, > (avp - npvp - 2) * sizeof *avp); > (void) strcpy(namearg,""); > for (avp = &npvp[2]; *avp != NULL; avp++) > (void) strcat(namearg,*avp); > (void) strcpy(command,macvalue(*npvp[1],CurEnv)); > # ifdef DEBUG > if (tTd(21, 3)) > printf("-----nameserver: %s\n", command); > # endif DEBUG > if (pipe(fildes) == 0) > { > if ((pid = fork()) == 0) /* child */ > { > (void) close(fildes[0]); > (void) close(1); > (void) fcntl(fildes[1],F_DUPFD,1); > (void) close(fildes[1]); > (void) execl(command,command,namearg,0); > exit(1); > } > if (pid > 0) /* parent */ > { > (void) close(fildes[1]); > fnames = fdopen(fildes[0],"r"); > fgets(nameret,MAXLINE,fnames); > /* sendtolist/parseaddr/prescan() */ > DelimSave = DelimChar; > if (wait(&nstatus) == pid > && nstatus == 0) > pvp = prescan(nameret,'\n'); > (void) fclose(fnames); > DelimChar = DelimSave; > } > } > # ifdef DEBUG > if (tTd(21, 3)) > { > printf("nameserver return:"); > printav(pvp); > } > # endif DEBUG