Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 exptools 1/6/84; site ihnp4.UUCP
Path: utzoo!watmath!clyde!floyd!harpo!ihnp4!gjm
From: gjm@ihnp4.UUCP (Gary J. Murakami)
Newsgroups: net.mail
Subject: sendmail nameserver alias fix
Message-ID: <564@ihnp4.UUCP>
Date: Wed, 21-Mar-84 23:29:10 EST
Article-I.D.: ihnp4.564
Posted: Wed Mar 21 23:29:10 1984
Date-Received: Thu, 22-Mar-84 04:19:31 EST
Organization: AT&T Bell Labs, Naperville, IL
Lines: 157


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$+.$+		$:$  *  definitions for byte/block operations
>  */
> #ifdef USG
> #include 
> #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 
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