xref: /original-bsd/usr.sbin/sendmail/src/readcf.c (revision f4a18198)
1 /*
2  * Copyright (c) 1983 Eric P. Allman
3  * Copyright (c) 1988, 1993
4  *	The Regents of the University of California.  All rights reserved.
5  *
6  * %sccs.include.redist.c%
7  */
8 
9 #ifndef lint
10 static char sccsid[] = "@(#)readcf.c	8.24 (Berkeley) 06/17/94";
11 #endif /* not lint */
12 
13 # include "sendmail.h"
14 # include <pwd.h>
15 # include <grp.h>
16 #if NAMED_BIND
17 # include <resolv.h>
18 #endif
19 
20 /*
21 **  READCF -- read control file.
22 **
23 **	This routine reads the control file and builds the internal
24 **	form.
25 **
26 **	The file is formatted as a sequence of lines, each taken
27 **	atomically.  The first character of each line describes how
28 **	the line is to be interpreted.  The lines are:
29 **		Dxval		Define macro x to have value val.
30 **		Cxword		Put word into class x.
31 **		Fxfile [fmt]	Read file for lines to put into
32 **				class x.  Use scanf string 'fmt'
33 **				or "%s" if not present.  Fmt should
34 **				only produce one string-valued result.
35 **		Hname: value	Define header with field-name 'name'
36 **				and value as specified; this will be
37 **				macro expanded immediately before
38 **				use.
39 **		Sn		Use rewriting set n.
40 **		Rlhs rhs	Rewrite addresses that match lhs to
41 **				be rhs.
42 **		Mn arg=val...	Define mailer.  n is the internal name.
43 **				Args specify mailer parameters.
44 **		Oxvalue		Set option x to value.
45 **		Pname=value	Set precedence name to value.
46 **		Vversioncode[/vendorcode]
47 **				Version level/vendor name of
48 **				configuration syntax.
49 **		Kmapname mapclass arguments....
50 **				Define keyed lookup of a given class.
51 **				Arguments are class dependent.
52 **
53 **	Parameters:
54 **		cfname -- control file name.
55 **		safe -- TRUE if this is the system config file;
56 **			FALSE otherwise.
57 **		e -- the main envelope.
58 **
59 **	Returns:
60 **		none.
61 **
62 **	Side Effects:
63 **		Builds several internal tables.
64 */
65 
66 readcf(cfname, safe, e)
67 	char *cfname;
68 	bool safe;
69 	register ENVELOPE *e;
70 {
71 	FILE *cf;
72 	int ruleset = 0;
73 	char *q;
74 	struct rewrite *rwp = NULL;
75 	char *bp;
76 	auto char *ep;
77 	int nfuzzy;
78 	char *file;
79 	bool optional;
80 	char buf[MAXLINE];
81 	register char *p;
82 	extern char **copyplist();
83 	struct stat statb;
84 	char exbuf[MAXLINE];
85 	char pvpbuf[MAXLINE + MAXATOM];
86 	extern char *munchstring();
87 	extern void makemapentry();
88 
89 	FileName = cfname;
90 	LineNumber = 0;
91 
92 	cf = fopen(cfname, "r");
93 	if (cf == NULL)
94 	{
95 		syserr("cannot open");
96 		exit(EX_OSFILE);
97 	}
98 
99 	if (fstat(fileno(cf), &statb) < 0)
100 	{
101 		syserr("cannot fstat");
102 		exit(EX_OSFILE);
103 	}
104 
105 	if (!S_ISREG(statb.st_mode))
106 	{
107 		syserr("not a plain file");
108 		exit(EX_OSFILE);
109 	}
110 
111 	if (OpMode != MD_TEST && bitset(S_IWGRP|S_IWOTH, statb.st_mode))
112 	{
113 		if (OpMode == MD_DAEMON || OpMode == MD_FREEZE)
114 			fprintf(stderr, "%s: WARNING: dangerous write permissions\n",
115 				FileName);
116 #ifdef LOG
117 		if (LogLevel > 0)
118 			syslog(LOG_CRIT, "%s: WARNING: dangerous write permissions",
119 				FileName);
120 #endif
121 	}
122 
123 #ifdef XLA
124 	xla_zero();
125 #endif
126 
127 	while ((bp = fgetfolded(buf, sizeof buf, cf)) != NULL)
128 	{
129 		if (bp[0] == '#')
130 		{
131 			if (bp != buf)
132 				free(bp);
133 			continue;
134 		}
135 
136 		/* map $ into \201 for macro expansion */
137 		for (p = bp; *p != '\0'; p++)
138 		{
139 			if (*p == '#' && p > bp && ConfigLevel >= 3)
140 			{
141 				/* this is an on-line comment */
142 				register char *e;
143 
144 				switch (*--p & 0377)
145 				{
146 				  case MACROEXPAND:
147 					/* it's from $# -- let it go through */
148 					p++;
149 					break;
150 
151 				  case '\\':
152 					/* it's backslash escaped */
153 					(void) strcpy(p, p + 1);
154 					break;
155 
156 				  default:
157 					/* delete preceeding white space */
158 					while (isascii(*p) && isspace(*p) && p > bp)
159 						p--;
160 					if ((e = strchr(++p, '\n')) != NULL)
161 						(void) strcpy(p, e);
162 					else
163 						p[0] = p[1] = '\0';
164 					break;
165 				}
166 				continue;
167 			}
168 
169 			if (*p != '$')
170 				continue;
171 
172 			if (p[1] == '$')
173 			{
174 				/* actual dollar sign.... */
175 				(void) strcpy(p, p + 1);
176 				continue;
177 			}
178 
179 			/* convert to macro expansion character */
180 			*p = MACROEXPAND;
181 		}
182 
183 		/* interpret this line */
184 		errno = 0;
185 		switch (bp[0])
186 		{
187 		  case '\0':
188 		  case '#':		/* comment */
189 			break;
190 
191 		  case 'R':		/* rewriting rule */
192 			for (p = &bp[1]; *p != '\0' && *p != '\t'; p++)
193 				continue;
194 
195 			if (*p == '\0')
196 			{
197 				syserr("invalid rewrite line \"%s\" (tab expected)", bp);
198 				break;
199 			}
200 
201 			/* allocate space for the rule header */
202 			if (rwp == NULL)
203 			{
204 				RewriteRules[ruleset] = rwp =
205 					(struct rewrite *) xalloc(sizeof *rwp);
206 			}
207 			else
208 			{
209 				rwp->r_next = (struct rewrite *) xalloc(sizeof *rwp);
210 				rwp = rwp->r_next;
211 			}
212 			rwp->r_next = NULL;
213 
214 			/* expand and save the LHS */
215 			*p = '\0';
216 			expand(&bp[1], exbuf, &exbuf[sizeof exbuf], e);
217 			rwp->r_lhs = prescan(exbuf, '\t', pvpbuf,
218 					     sizeof pvpbuf, NULL);
219 			nfuzzy = 0;
220 			if (rwp->r_lhs != NULL)
221 			{
222 				register char **ap;
223 
224 				rwp->r_lhs = copyplist(rwp->r_lhs, TRUE);
225 
226 				/* count the number of fuzzy matches in LHS */
227 				for (ap = rwp->r_lhs; *ap != NULL; ap++)
228 				{
229 					char *botch;
230 
231 					botch = NULL;
232 					switch (**ap & 0377)
233 					{
234 					  case MATCHZANY:
235 					  case MATCHANY:
236 					  case MATCHONE:
237 					  case MATCHCLASS:
238 					  case MATCHNCLASS:
239 						nfuzzy++;
240 						break;
241 
242 					  case MATCHREPL:
243 						botch = "$0-$9";
244 						break;
245 
246 					  case CANONNET:
247 						botch = "$#";
248 						break;
249 
250 					  case CANONUSER:
251 						botch = "$:";
252 						break;
253 
254 					  case CALLSUBR:
255 						botch = "$>";
256 						break;
257 
258 					  case CONDIF:
259 						botch = "$?";
260 						break;
261 
262 					  case CONDELSE:
263 						botch = "$|";
264 						break;
265 
266 					  case CONDFI:
267 						botch = "$.";
268 						break;
269 
270 					  case HOSTBEGIN:
271 						botch = "$[";
272 						break;
273 
274 					  case HOSTEND:
275 						botch = "$]";
276 						break;
277 
278 					  case LOOKUPBEGIN:
279 						botch = "$(";
280 						break;
281 
282 					  case LOOKUPEND:
283 						botch = "$)";
284 						break;
285 					}
286 					if (botch != NULL)
287 						syserr("Inappropriate use of %s on LHS",
288 							botch);
289 				}
290 			}
291 			else
292 				syserr("R line: null LHS");
293 
294 			/* expand and save the RHS */
295 			while (*++p == '\t')
296 				continue;
297 			q = p;
298 			while (*p != '\0' && *p != '\t')
299 				p++;
300 			*p = '\0';
301 			expand(q, exbuf, &exbuf[sizeof exbuf], e);
302 			rwp->r_rhs = prescan(exbuf, '\t', pvpbuf,
303 					     sizeof pvpbuf, NULL);
304 			if (rwp->r_rhs != NULL)
305 			{
306 				register char **ap;
307 
308 				rwp->r_rhs = copyplist(rwp->r_rhs, TRUE);
309 
310 				/* check no out-of-bounds replacements */
311 				nfuzzy += '0';
312 				for (ap = rwp->r_rhs; *ap != NULL; ap++)
313 				{
314 					char *botch;
315 
316 					botch = NULL;
317 					switch (**ap & 0377)
318 					{
319 					  case MATCHREPL:
320 						if ((*ap)[1] <= '0' || (*ap)[1] > nfuzzy)
321 						{
322 							syserr("replacement $%c out of bounds",
323 								(*ap)[1]);
324 						}
325 						break;
326 
327 					  case MATCHZANY:
328 						botch = "$*";
329 						break;
330 
331 					  case MATCHANY:
332 						botch = "$+";
333 						break;
334 
335 					  case MATCHONE:
336 						botch = "$-";
337 						break;
338 
339 					  case MATCHCLASS:
340 						botch = "$=";
341 						break;
342 
343 					  case MATCHNCLASS:
344 						botch = "$~";
345 						break;
346 					}
347 					if (botch != NULL)
348 						syserr("Inappropriate use of %s on RHS",
349 							botch);
350 				}
351 			}
352 			else
353 				syserr("R line: null RHS");
354 			break;
355 
356 		  case 'S':		/* select rewriting set */
357 			for (p = &bp[1]; isascii(*p) && isspace(*p); p++)
358 				continue;
359 			if (!isascii(*p) || !isdigit(*p))
360 			{
361 				syserr("invalid argument to S line: \"%.20s\"",
362 					&bp[1]);
363 				break;
364 			}
365 			ruleset = atoi(p);
366 			if (ruleset >= MAXRWSETS || ruleset < 0)
367 			{
368 				syserr("bad ruleset %d (%d max)", ruleset, MAXRWSETS);
369 				ruleset = 0;
370 			}
371 			rwp = NULL;
372 			break;
373 
374 		  case 'D':		/* macro definition */
375 			p = munchstring(&bp[2], NULL);
376 			define(bp[1], newstr(p), e);
377 			break;
378 
379 		  case 'H':		/* required header line */
380 			(void) chompheader(&bp[1], TRUE, e);
381 			break;
382 
383 		  case 'C':		/* word class */
384 			/* scan the list of words and set class for all */
385 			expand(&bp[2], exbuf, &exbuf[sizeof exbuf], e);
386 			for (p = exbuf; *p != '\0'; )
387 			{
388 				register char *wd;
389 				char delim;
390 
391 				while (*p != '\0' && isascii(*p) && isspace(*p))
392 					p++;
393 				wd = p;
394 				while (*p != '\0' && !(isascii(*p) && isspace(*p)))
395 					p++;
396 				delim = *p;
397 				*p = '\0';
398 				if (wd[0] != '\0')
399 					setclass(bp[1], wd);
400 				*p = delim;
401 			}
402 			break;
403 
404 		  case 'F':		/* word class from file */
405 			for (p = &bp[2]; isascii(*p) && isspace(*p); )
406 				p++;
407 			if (p[0] == '-' && p[1] == 'o')
408 			{
409 				optional = TRUE;
410 				while (*p != '\0' && !(isascii(*p) && isspace(*p)))
411 					p++;
412 				while (isascii(*p) && isspace(*p))
413 					*p++;
414 			}
415 			else
416 				optional = FALSE;
417 			file = p;
418 			while (*p != '\0' && !(isascii(*p) && isspace(*p)))
419 				p++;
420 			if (*p == '\0')
421 				p = "%s";
422 			else
423 			{
424 				*p = '\0';
425 				while (isascii(*++p) && isspace(*p))
426 					continue;
427 			}
428 			fileclass(bp[1], file, p, safe, optional);
429 			break;
430 
431 #ifdef XLA
432 		  case 'L':		/* extended load average description */
433 			xla_init(&bp[1]);
434 			break;
435 #endif
436 
437 		  case 'M':		/* define mailer */
438 			makemailer(&bp[1]);
439 			break;
440 
441 		  case 'O':		/* set option */
442 			setoption(bp[1], &bp[2], safe, FALSE, e);
443 			break;
444 
445 		  case 'P':		/* set precedence */
446 			if (NumPriorities >= MAXPRIORITIES)
447 			{
448 				toomany('P', MAXPRIORITIES);
449 				break;
450 			}
451 			for (p = &bp[1]; *p != '\0' && *p != '=' && *p != '\t'; p++)
452 				continue;
453 			if (*p == '\0')
454 				goto badline;
455 			*p = '\0';
456 			Priorities[NumPriorities].pri_name = newstr(&bp[1]);
457 			Priorities[NumPriorities].pri_val = atoi(++p);
458 			NumPriorities++;
459 			break;
460 
461 		  case 'T':		/* trusted user(s) */
462 			/* this option is obsolete, but will be ignored */
463 			break;
464 
465 		  case 'V':		/* configuration syntax version */
466 			for (p = &bp[1]; isascii(*p) && isspace(*p); p++)
467 				continue;
468 			if (!isascii(*p) || !isdigit(*p))
469 			{
470 				syserr("invalid argument to V line: \"%.20s\"",
471 					&bp[1]);
472 				break;
473 			}
474 			ConfigLevel = strtol(p, &ep, 10);
475 			if (ConfigLevel >= 5)
476 			{
477 				/* level 5 configs have short name in $w */
478 				p = macvalue('w', e);
479 				if (p != NULL && (p = strchr(p, '.')) != NULL)
480 					*p = '\0';
481 			}
482 			if (*ep++ == '/')
483 			{
484 				/* extract vendor code */
485 				for (p = ep; isascii(*p) && isalpha(*p); )
486 					p++;
487 				*p = '\0';
488 
489 				if (!setvendor(ep))
490 					syserr("invalid V line vendor code: \"%s\"",
491 						ep);
492 			}
493 			break;
494 
495 		  case 'K':
496 			makemapentry(&bp[1]);
497 			break;
498 
499 		  default:
500 		  badline:
501 			syserr("unknown control line \"%s\"", bp);
502 		}
503 		if (bp != buf)
504 			free(bp);
505 	}
506 	if (ferror(cf))
507 	{
508 		syserr("I/O read error", cfname);
509 		exit(EX_OSFILE);
510 	}
511 	fclose(cf);
512 	FileName = NULL;
513 
514 	if (stab("host", ST_MAP, ST_FIND) == NULL)
515 	{
516 		/* user didn't initialize: set up host map */
517 		strcpy(buf, "host host");
518 #if NAMED_BIND
519 		if (ConfigLevel >= 2)
520 			strcat(buf, " -a.");
521 #endif
522 		makemapentry(buf);
523 	}
524 }
525 /*
526 **  TOOMANY -- signal too many of some option
527 **
528 **	Parameters:
529 **		id -- the id of the error line
530 **		maxcnt -- the maximum possible values
531 **
532 **	Returns:
533 **		none.
534 **
535 **	Side Effects:
536 **		gives a syserr.
537 */
538 
539 toomany(id, maxcnt)
540 	char id;
541 	int maxcnt;
542 {
543 	syserr("too many %c lines, %d max", id, maxcnt);
544 }
545 /*
546 **  FILECLASS -- read members of a class from a file
547 **
548 **	Parameters:
549 **		class -- class to define.
550 **		filename -- name of file to read.
551 **		fmt -- scanf string to use for match.
552 **		safe -- if set, this is a safe read.
553 **		optional -- if set, it is not an error for the file to
554 **			not exist.
555 **
556 **	Returns:
557 **		none
558 **
559 **	Side Effects:
560 **
561 **		puts all lines in filename that match a scanf into
562 **			the named class.
563 */
564 
565 fileclass(class, filename, fmt, safe, optional)
566 	int class;
567 	char *filename;
568 	char *fmt;
569 	bool safe;
570 	bool optional;
571 {
572 	FILE *f;
573 	struct stat stbuf;
574 	char buf[MAXLINE];
575 
576 	if (tTd(37, 2))
577 		printf("fileclass(%s, fmt=%s)\n", filename, fmt);
578 
579 	if (filename[0] == '|')
580 	{
581 		syserr("fileclass: pipes (F%c%s) not supported due to security problems",
582 			class, filename);
583 		return;
584 	}
585 	if (stat(filename, &stbuf) < 0)
586 	{
587 		if (tTd(37, 2))
588 			printf("  cannot stat (%s)\n", errstring(errno));
589 		if (!optional)
590 			syserr("fileclass: cannot stat %s", filename);
591 		return;
592 	}
593 	if (!S_ISREG(stbuf.st_mode))
594 	{
595 		syserr("fileclass: %s not a regular file", filename);
596 		return;
597 	}
598 	if (!safe && access(filename, R_OK) < 0)
599 	{
600 		syserr("fileclass: access denied on %s", filename);
601 		return;
602 	}
603 	f = fopen(filename, "r");
604 	if (f == NULL)
605 	{
606 		syserr("fileclass: cannot open %s", filename);
607 		return;
608 	}
609 
610 	while (fgets(buf, sizeof buf, f) != NULL)
611 	{
612 		register STAB *s;
613 		register char *p;
614 # ifdef SCANF
615 		char wordbuf[MAXNAME+1];
616 
617 		if (sscanf(buf, fmt, wordbuf) != 1)
618 			continue;
619 		p = wordbuf;
620 # else /* SCANF */
621 		p = buf;
622 # endif /* SCANF */
623 
624 		/*
625 		**  Break up the match into words.
626 		*/
627 
628 		while (*p != '\0')
629 		{
630 			register char *q;
631 
632 			/* strip leading spaces */
633 			while (isascii(*p) && isspace(*p))
634 				p++;
635 			if (*p == '\0')
636 				break;
637 
638 			/* find the end of the word */
639 			q = p;
640 			while (*p != '\0' && !(isascii(*p) && isspace(*p)))
641 				p++;
642 			if (*p != '\0')
643 				*p++ = '\0';
644 
645 			/* enter the word in the symbol table */
646 			setclass(class, q);
647 		}
648 	}
649 
650 	(void) fclose(f);
651 }
652 /*
653 **  MAKEMAILER -- define a new mailer.
654 **
655 **	Parameters:
656 **		line -- description of mailer.  This is in labeled
657 **			fields.  The fields are:
658 **			   P -- the path to the mailer
659 **			   F -- the flags associated with the mailer
660 **			   A -- the argv for this mailer
661 **			   S -- the sender rewriting set
662 **			   R -- the recipient rewriting set
663 **			   E -- the eol string
664 **			The first word is the canonical name of the mailer.
665 **
666 **	Returns:
667 **		none.
668 **
669 **	Side Effects:
670 **		enters the mailer into the mailer table.
671 */
672 
673 makemailer(line)
674 	char *line;
675 {
676 	register char *p;
677 	register struct mailer *m;
678 	register STAB *s;
679 	int i;
680 	char fcode;
681 	auto char *endp;
682 	extern int NextMailer;
683 	extern char **makeargv();
684 	extern char *munchstring();
685 	extern long atol();
686 
687 	/* allocate a mailer and set up defaults */
688 	m = (struct mailer *) xalloc(sizeof *m);
689 	bzero((char *) m, sizeof *m);
690 	m->m_eol = "\n";
691 
692 	/* collect the mailer name */
693 	for (p = line; *p != '\0' && *p != ',' && !(isascii(*p) && isspace(*p)); p++)
694 		continue;
695 	if (*p != '\0')
696 		*p++ = '\0';
697 	m->m_name = newstr(line);
698 
699 	/* now scan through and assign info from the fields */
700 	while (*p != '\0')
701 	{
702 		auto char *delimptr;
703 
704 		while (*p != '\0' && (*p == ',' || (isascii(*p) && isspace(*p))))
705 			p++;
706 
707 		/* p now points to field code */
708 		fcode = *p;
709 		while (*p != '\0' && *p != '=' && *p != ',')
710 			p++;
711 		if (*p++ != '=')
712 		{
713 			syserr("mailer %s: `=' expected", m->m_name);
714 			return;
715 		}
716 		while (isascii(*p) && isspace(*p))
717 			p++;
718 
719 		/* p now points to the field body */
720 		p = munchstring(p, &delimptr);
721 
722 		/* install the field into the mailer struct */
723 		switch (fcode)
724 		{
725 		  case 'P':		/* pathname */
726 			m->m_mailer = newstr(p);
727 			break;
728 
729 		  case 'F':		/* flags */
730 			for (; *p != '\0'; p++)
731 				if (!(isascii(*p) && isspace(*p)))
732 					setbitn(*p, m->m_flags);
733 			break;
734 
735 		  case 'S':		/* sender rewriting ruleset */
736 		  case 'R':		/* recipient rewriting ruleset */
737 			i = strtol(p, &endp, 10);
738 			if (i < 0 || i >= MAXRWSETS)
739 			{
740 				syserr("invalid rewrite set, %d max", MAXRWSETS);
741 				return;
742 			}
743 			if (fcode == 'S')
744 				m->m_sh_rwset = m->m_se_rwset = i;
745 			else
746 				m->m_rh_rwset = m->m_re_rwset = i;
747 
748 			p = endp;
749 			if (*p++ == '/')
750 			{
751 				i = strtol(p, NULL, 10);
752 				if (i < 0 || i >= MAXRWSETS)
753 				{
754 					syserr("invalid rewrite set, %d max",
755 						MAXRWSETS);
756 					return;
757 				}
758 				if (fcode == 'S')
759 					m->m_sh_rwset = i;
760 				else
761 					m->m_rh_rwset = i;
762 			}
763 			break;
764 
765 		  case 'E':		/* end of line string */
766 			m->m_eol = newstr(p);
767 			break;
768 
769 		  case 'A':		/* argument vector */
770 			m->m_argv = makeargv(p);
771 			break;
772 
773 		  case 'M':		/* maximum message size */
774 			m->m_maxsize = atol(p);
775 			break;
776 
777 		  case 'L':		/* maximum line length */
778 			m->m_linelimit = atoi(p);
779 			break;
780 
781 		  case 'D':		/* working directory */
782 			m->m_execdir = newstr(p);
783 			break;
784 		}
785 
786 		p = delimptr;
787 	}
788 
789 	/* do some heuristic cleanup for back compatibility */
790 	if (bitnset(M_LIMITS, m->m_flags))
791 	{
792 		if (m->m_linelimit == 0)
793 			m->m_linelimit = SMTPLINELIM;
794 		if (ConfigLevel < 2)
795 			setbitn(M_7BITS, m->m_flags);
796 	}
797 
798 	/* do some rationality checking */
799 	if (m->m_argv == NULL)
800 	{
801 		syserr("M%s: A= argument required", m->m_name);
802 		return;
803 	}
804 	if (m->m_mailer == NULL)
805 	{
806 		syserr("M%s: P= argument required", m->m_name);
807 		return;
808 	}
809 
810 	if (NextMailer >= MAXMAILERS)
811 	{
812 		syserr("too many mailers defined (%d max)", MAXMAILERS);
813 		return;
814 	}
815 
816 	s = stab(m->m_name, ST_MAILER, ST_ENTER);
817 	if (s->s_mailer != NULL)
818 	{
819 		i = s->s_mailer->m_mno;
820 		free(s->s_mailer);
821 	}
822 	else
823 	{
824 		i = NextMailer++;
825 	}
826 	Mailer[i] = s->s_mailer = m;
827 	m->m_mno = i;
828 }
829 /*
830 **  MUNCHSTRING -- translate a string into internal form.
831 **
832 **	Parameters:
833 **		p -- the string to munch.
834 **		delimptr -- if non-NULL, set to the pointer of the
835 **			field delimiter character.
836 **
837 **	Returns:
838 **		the munched string.
839 */
840 
841 char *
842 munchstring(p, delimptr)
843 	register char *p;
844 	char **delimptr;
845 {
846 	register char *q;
847 	bool backslash = FALSE;
848 	bool quotemode = FALSE;
849 	static char buf[MAXLINE];
850 
851 	for (q = buf; *p != '\0'; p++)
852 	{
853 		if (backslash)
854 		{
855 			/* everything is roughly literal */
856 			backslash = FALSE;
857 			switch (*p)
858 			{
859 			  case 'r':		/* carriage return */
860 				*q++ = '\r';
861 				continue;
862 
863 			  case 'n':		/* newline */
864 				*q++ = '\n';
865 				continue;
866 
867 			  case 'f':		/* form feed */
868 				*q++ = '\f';
869 				continue;
870 
871 			  case 'b':		/* backspace */
872 				*q++ = '\b';
873 				continue;
874 			}
875 			*q++ = *p;
876 		}
877 		else
878 		{
879 			if (*p == '\\')
880 				backslash = TRUE;
881 			else if (*p == '"')
882 				quotemode = !quotemode;
883 			else if (quotemode || *p != ',')
884 				*q++ = *p;
885 			else
886 				break;
887 		}
888 	}
889 
890 	if (delimptr != NULL)
891 		*delimptr = p;
892 	*q++ = '\0';
893 	return (buf);
894 }
895 /*
896 **  MAKEARGV -- break up a string into words
897 **
898 **	Parameters:
899 **		p -- the string to break up.
900 **
901 **	Returns:
902 **		a char **argv (dynamically allocated)
903 **
904 **	Side Effects:
905 **		munges p.
906 */
907 
908 char **
909 makeargv(p)
910 	register char *p;
911 {
912 	char *q;
913 	int i;
914 	char **avp;
915 	char *argv[MAXPV + 1];
916 
917 	/* take apart the words */
918 	i = 0;
919 	while (*p != '\0' && i < MAXPV)
920 	{
921 		q = p;
922 		while (*p != '\0' && !(isascii(*p) && isspace(*p)))
923 			p++;
924 		while (isascii(*p) && isspace(*p))
925 			*p++ = '\0';
926 		argv[i++] = newstr(q);
927 	}
928 	argv[i++] = NULL;
929 
930 	/* now make a copy of the argv */
931 	avp = (char **) xalloc(sizeof *avp * i);
932 	bcopy((char *) argv, (char *) avp, sizeof *avp * i);
933 
934 	return (avp);
935 }
936 /*
937 **  PRINTRULES -- print rewrite rules (for debugging)
938 **
939 **	Parameters:
940 **		none.
941 **
942 **	Returns:
943 **		none.
944 **
945 **	Side Effects:
946 **		prints rewrite rules.
947 */
948 
949 printrules()
950 {
951 	register struct rewrite *rwp;
952 	register int ruleset;
953 
954 	for (ruleset = 0; ruleset < 10; ruleset++)
955 	{
956 		if (RewriteRules[ruleset] == NULL)
957 			continue;
958 		printf("\n----Rule Set %d:", ruleset);
959 
960 		for (rwp = RewriteRules[ruleset]; rwp != NULL; rwp = rwp->r_next)
961 		{
962 			printf("\nLHS:");
963 			printav(rwp->r_lhs);
964 			printf("RHS:");
965 			printav(rwp->r_rhs);
966 		}
967 	}
968 }
969 
970 /*
971 **  SETOPTION -- set global processing option
972 **
973 **	Parameters:
974 **		opt -- option name.
975 **		val -- option value (as a text string).
976 **		safe -- set if this came from a configuration file.
977 **			Some options (if set from the command line) will
978 **			reset the user id to avoid security problems.
979 **		sticky -- if set, don't let other setoptions override
980 **			this value.
981 **		e -- the main envelope.
982 **
983 **	Returns:
984 **		none.
985 **
986 **	Side Effects:
987 **		Sets options as implied by the arguments.
988 */
989 
990 static BITMAP	StickyOpt;		/* set if option is stuck */
991 
992 
993 #if NAMED_BIND
994 
995 struct resolverflags
996 {
997 	char	*rf_name;	/* name of the flag */
998 	long	rf_bits;	/* bits to set/clear */
999 } ResolverFlags[] =
1000 {
1001 	"debug",	RES_DEBUG,
1002 	"aaonly",	RES_AAONLY,
1003 	"usevc",	RES_USEVC,
1004 	"primary",	RES_PRIMARY,
1005 	"igntc",	RES_IGNTC,
1006 	"recurse",	RES_RECURSE,
1007 	"defnames",	RES_DEFNAMES,
1008 	"stayopen",	RES_STAYOPEN,
1009 	"dnsrch",	RES_DNSRCH,
1010 	"true",		0,		/* to avoid error on old syntax */
1011 	NULL,		0
1012 };
1013 
1014 #endif
1015 
1016 setoption(opt, val, safe, sticky, e)
1017 	char opt;
1018 	char *val;
1019 	bool safe;
1020 	bool sticky;
1021 	register ENVELOPE *e;
1022 {
1023 	register char *p;
1024 	extern bool atobool();
1025 	extern time_t convtime();
1026 	extern int QueueLA;
1027 	extern int RefuseLA;
1028 	extern bool Warn_Q_option;
1029 	extern bool trusteduser();
1030 
1031 	if (tTd(37, 1))
1032 		printf("setoption %c=%s", opt, val);
1033 
1034 	/*
1035 	**  See if this option is preset for us.
1036 	*/
1037 
1038 	if (!sticky && bitnset(opt, StickyOpt))
1039 	{
1040 		if (tTd(37, 1))
1041 			printf(" (ignored)\n");
1042 		return;
1043 	}
1044 
1045 	/*
1046 	**  Check to see if this option can be specified by this user.
1047 	*/
1048 
1049 	if (!safe && RealUid == 0)
1050 		safe = TRUE;
1051 	if (!safe && strchr("bCdeijLmoprsvw7", opt) == NULL)
1052 	{
1053 		if (opt != 'M' || (val[0] != 'r' && val[0] != 's'))
1054 		{
1055 			if (tTd(37, 1))
1056 				printf(" (unsafe)");
1057 			if (RealUid != geteuid())
1058 			{
1059 				if (tTd(37, 1))
1060 					printf("(Resetting uid)");
1061 				(void) setgid(RealGid);
1062 				(void) setuid(RealUid);
1063 			}
1064 		}
1065 	}
1066 	if (tTd(37, 1))
1067 		printf("\n");
1068 
1069 	switch (opt)
1070 	{
1071 	  case '7':		/* force seven-bit input */
1072 		SevenBit = atobool(val);
1073 		break;
1074 
1075 	  case 'A':		/* set default alias file */
1076 		if (val[0] == '\0')
1077 			setalias("aliases");
1078 		else
1079 			setalias(val);
1080 		break;
1081 
1082 	  case 'a':		/* look N minutes for "@:@" in alias file */
1083 		if (val[0] == '\0')
1084 			SafeAlias = 5 * 60;		/* five minutes */
1085 		else
1086 			SafeAlias = convtime(val, 'm');
1087 		break;
1088 
1089 	  case 'B':		/* substitution for blank character */
1090 		SpaceSub = val[0];
1091 		if (SpaceSub == '\0')
1092 			SpaceSub = ' ';
1093 		break;
1094 
1095 	  case 'b':		/* min blocks free on queue fs/max msg size */
1096 		p = strchr(val, '/');
1097 		if (p != NULL)
1098 		{
1099 			*p++ = '\0';
1100 			MaxMessageSize = atol(p);
1101 		}
1102 		MinBlocksFree = atol(val);
1103 		break;
1104 
1105 	  case 'c':		/* don't connect to "expensive" mailers */
1106 		NoConnect = atobool(val);
1107 		break;
1108 
1109 	  case 'C':		/* checkpoint every N addresses */
1110 		CheckpointInterval = atoi(val);
1111 		break;
1112 
1113 	  case 'd':		/* delivery mode */
1114 		switch (*val)
1115 		{
1116 		  case '\0':
1117 			e->e_sendmode = SM_DELIVER;
1118 			break;
1119 
1120 		  case SM_QUEUE:	/* queue only */
1121 #ifndef QUEUE
1122 			syserr("need QUEUE to set -odqueue");
1123 #endif /* QUEUE */
1124 			/* fall through..... */
1125 
1126 		  case SM_DELIVER:	/* do everything */
1127 		  case SM_FORK:		/* fork after verification */
1128 			e->e_sendmode = *val;
1129 			break;
1130 
1131 		  default:
1132 			syserr("Unknown delivery mode %c", *val);
1133 			exit(EX_USAGE);
1134 		}
1135 		break;
1136 
1137 	  case 'D':		/* rebuild alias database as needed */
1138 		AutoRebuild = atobool(val);
1139 		break;
1140 
1141 	  case 'E':		/* error message header/header file */
1142 		if (*val != '\0')
1143 			ErrMsgFile = newstr(val);
1144 		break;
1145 
1146 	  case 'e':		/* set error processing mode */
1147 		switch (*val)
1148 		{
1149 		  case EM_QUIET:	/* be silent about it */
1150 		  case EM_MAIL:		/* mail back */
1151 		  case EM_BERKNET:	/* do berknet error processing */
1152 		  case EM_WRITE:	/* write back (or mail) */
1153 			HoldErrs = TRUE;
1154 			/* fall through... */
1155 
1156 		  case EM_PRINT:	/* print errors normally (default) */
1157 			e->e_errormode = *val;
1158 			break;
1159 		}
1160 		break;
1161 
1162 	  case 'F':		/* file mode */
1163 		FileMode = atooct(val) & 0777;
1164 		break;
1165 
1166 	  case 'f':		/* save Unix-style From lines on front */
1167 		SaveFrom = atobool(val);
1168 		break;
1169 
1170 	  case 'G':		/* match recipients against GECOS field */
1171 		MatchGecos = atobool(val);
1172 		break;
1173 
1174 	  case 'g':		/* default gid */
1175 		if (isascii(*val) && isdigit(*val))
1176 			DefGid = atoi(val);
1177 		else
1178 		{
1179 			register struct group *gr;
1180 
1181 			DefGid = -1;
1182 			gr = getgrnam(val);
1183 			if (gr == NULL)
1184 				syserr("readcf: option g: unknown group %s", val);
1185 			else
1186 				DefGid = gr->gr_gid;
1187 		}
1188 		break;
1189 
1190 	  case 'H':		/* help file */
1191 		if (val[0] == '\0')
1192 			HelpFile = "sendmail.hf";
1193 		else
1194 			HelpFile = newstr(val);
1195 		break;
1196 
1197 	  case 'h':		/* maximum hop count */
1198 		MaxHopCount = atoi(val);
1199 		break;
1200 
1201 	  case 'I':		/* use internet domain name server */
1202 #if NAMED_BIND
1203 		UseNameServer = TRUE;
1204 		for (p = val; *p != 0; )
1205 		{
1206 			bool clearmode;
1207 			char *q;
1208 			struct resolverflags *rfp;
1209 
1210 			while (*p == ' ')
1211 				p++;
1212 			if (*p == '\0')
1213 				break;
1214 			clearmode = FALSE;
1215 			if (*p == '-')
1216 				clearmode = TRUE;
1217 			else if (*p != '+')
1218 				p--;
1219 			p++;
1220 			q = p;
1221 			while (*p != '\0' && !(isascii(*p) && isspace(*p)))
1222 				p++;
1223 			if (*p != '\0')
1224 				*p++ = '\0';
1225 			for (rfp = ResolverFlags; rfp->rf_name != NULL; rfp++)
1226 			{
1227 				if (strcasecmp(q, rfp->rf_name) == 0)
1228 					break;
1229 			}
1230 			if (rfp->rf_name == NULL)
1231 				syserr("readcf: I option value %s unrecognized", q);
1232 			else if (clearmode)
1233 				_res.options &= ~rfp->rf_bits;
1234 			else
1235 				_res.options |= rfp->rf_bits;
1236 		}
1237 		if (tTd(8, 2))
1238 			printf("_res.options = %x\n", _res.options);
1239 #else
1240 		usrerr("name server (I option) specified but BIND not compiled in");
1241 #endif
1242 		break;
1243 
1244 	  case 'i':		/* ignore dot lines in message */
1245 		IgnrDot = atobool(val);
1246 		break;
1247 
1248 	  case 'j':		/* send errors in MIME (RFC 1341) format */
1249 		SendMIMEErrors = atobool(val);
1250 		break;
1251 
1252 	  case 'J':		/* .forward search path */
1253 		ForwardPath = newstr(val);
1254 		break;
1255 
1256 	  case 'k':		/* connection cache size */
1257 		MaxMciCache = atoi(val);
1258 		if (MaxMciCache < 0)
1259 			MaxMciCache = 0;
1260 		break;
1261 
1262 	  case 'K':		/* connection cache timeout */
1263 		MciCacheTimeout = convtime(val, 'm');
1264 		break;
1265 
1266 	  case 'l':		/* use Errors-To: header */
1267 		UseErrorsTo = atobool(val);
1268 		break;
1269 
1270 	  case 'L':		/* log level */
1271 		if (safe || LogLevel < atoi(val))
1272 			LogLevel = atoi(val);
1273 		break;
1274 
1275 	  case 'M':		/* define macro */
1276 		define(val[0], newstr(&val[1]), CurEnv);
1277 		sticky = FALSE;
1278 		break;
1279 
1280 	  case 'm':		/* send to me too */
1281 		MeToo = atobool(val);
1282 		break;
1283 
1284 	  case 'n':		/* validate RHS in newaliases */
1285 		CheckAliases = atobool(val);
1286 		break;
1287 
1288 	    /* 'N' available -- was "net name" */
1289 
1290 	  case 'O':		/* daemon options */
1291 		setdaemonoptions(val);
1292 		break;
1293 
1294 	  case 'o':		/* assume old style headers */
1295 		if (atobool(val))
1296 			CurEnv->e_flags |= EF_OLDSTYLE;
1297 		else
1298 			CurEnv->e_flags &= ~EF_OLDSTYLE;
1299 		break;
1300 
1301 	  case 'p':		/* select privacy level */
1302 		p = val;
1303 		for (;;)
1304 		{
1305 			register struct prival *pv;
1306 			extern struct prival PrivacyValues[];
1307 
1308 			while (isascii(*p) && (isspace(*p) || ispunct(*p)))
1309 				p++;
1310 			if (*p == '\0')
1311 				break;
1312 			val = p;
1313 			while (isascii(*p) && isalnum(*p))
1314 				p++;
1315 			if (*p != '\0')
1316 				*p++ = '\0';
1317 
1318 			for (pv = PrivacyValues; pv->pv_name != NULL; pv++)
1319 			{
1320 				if (strcasecmp(val, pv->pv_name) == 0)
1321 					break;
1322 			}
1323 			if (pv->pv_name == NULL)
1324 				syserr("readcf: Op line: %s unrecognized", val);
1325 			PrivacyFlags |= pv->pv_flag;
1326 		}
1327 		break;
1328 
1329 	  case 'P':		/* postmaster copy address for returned mail */
1330 		PostMasterCopy = newstr(val);
1331 		break;
1332 
1333 	  case 'q':		/* slope of queue only function */
1334 		QueueFactor = atoi(val);
1335 		break;
1336 
1337 	  case 'Q':		/* queue directory */
1338 		if (val[0] == '\0')
1339 			QueueDir = "mqueue";
1340 		else
1341 			QueueDir = newstr(val);
1342 		if (RealUid != 0 && !safe)
1343 			Warn_Q_option = TRUE;
1344 		break;
1345 
1346 	  case 'R':		/* don't prune routes */
1347 		DontPruneRoutes = atobool(val);
1348 		break;
1349 
1350 	  case 'r':		/* read timeout */
1351 		settimeouts(val);
1352 		break;
1353 
1354 	  case 'S':		/* status file */
1355 		if (val[0] == '\0')
1356 			StatFile = "sendmail.st";
1357 		else
1358 			StatFile = newstr(val);
1359 		break;
1360 
1361 	  case 's':		/* be super safe, even if expensive */
1362 		SuperSafe = atobool(val);
1363 		break;
1364 
1365 	  case 'T':		/* queue timeout */
1366 		p = strchr(val, '/');
1367 		if (p != NULL)
1368 		{
1369 			*p++ = '\0';
1370 			TimeOuts.to_q_warning = convtime(p, 'd');
1371 		}
1372 		TimeOuts.to_q_return = convtime(val, 'h');
1373 		break;
1374 
1375 	  case 't':		/* time zone name */
1376 		TimeZoneSpec = newstr(val);
1377 		break;
1378 
1379 	  case 'U':		/* location of user database */
1380 		UdbSpec = newstr(val);
1381 		break;
1382 
1383 	  case 'u':		/* set default uid */
1384 		if (isascii(*val) && isdigit(*val))
1385 			DefUid = atoi(val);
1386 		else
1387 		{
1388 			register struct passwd *pw;
1389 
1390 			DefUid = -1;
1391 			pw = getpwnam(val);
1392 			if (pw == NULL)
1393 				syserr("readcf: option u: unknown user %s", val);
1394 			else
1395 				DefUid = pw->pw_uid;
1396 		}
1397 		setdefuser();
1398 		break;
1399 
1400 	  case 'V':		/* fallback MX host */
1401 		FallBackMX = newstr(val);
1402 		break;
1403 
1404 	  case 'v':		/* run in verbose mode */
1405 		Verbose = atobool(val);
1406 		break;
1407 
1408 	  case 'w':		/* if we are best MX, try host directly */
1409 		TryNullMXList = atobool(val);
1410 		break;
1411 
1412 	    /* 'W' available -- was wizard password */
1413 
1414 	  case 'x':		/* load avg at which to auto-queue msgs */
1415 		QueueLA = atoi(val);
1416 		break;
1417 
1418 	  case 'X':		/* load avg at which to auto-reject connections */
1419 		RefuseLA = atoi(val);
1420 		break;
1421 
1422 	  case 'y':		/* work recipient factor */
1423 		WkRecipFact = atoi(val);
1424 		break;
1425 
1426 	  case 'Y':		/* fork jobs during queue runs */
1427 		ForkQueueRuns = atobool(val);
1428 		break;
1429 
1430 	  case 'z':		/* work message class factor */
1431 		WkClassFact = atoi(val);
1432 		break;
1433 
1434 	  case 'Z':		/* work time factor */
1435 		WkTimeFact = atoi(val);
1436 		break;
1437 
1438 	  default:
1439 		break;
1440 	}
1441 	if (sticky)
1442 		setbitn(opt, StickyOpt);
1443 	return;
1444 }
1445 /*
1446 **  SETCLASS -- set a word into a class
1447 **
1448 **	Parameters:
1449 **		class -- the class to put the word in.
1450 **		word -- the word to enter
1451 **
1452 **	Returns:
1453 **		none.
1454 **
1455 **	Side Effects:
1456 **		puts the word into the symbol table.
1457 */
1458 
1459 setclass(class, word)
1460 	int class;
1461 	char *word;
1462 {
1463 	register STAB *s;
1464 
1465 	if (tTd(37, 8))
1466 		printf("setclass(%c, %s)\n", class, word);
1467 	s = stab(word, ST_CLASS, ST_ENTER);
1468 	setbitn(class, s->s_class);
1469 }
1470 /*
1471 **  MAKEMAPENTRY -- create a map entry
1472 **
1473 **	Parameters:
1474 **		line -- the config file line
1475 **
1476 **	Returns:
1477 **		TRUE if it successfully entered the map entry.
1478 **		FALSE otherwise (usually syntax error).
1479 **
1480 **	Side Effects:
1481 **		Enters the map into the dictionary.
1482 */
1483 
1484 void
1485 makemapentry(line)
1486 	char *line;
1487 {
1488 	register char *p;
1489 	char *mapname;
1490 	char *classname;
1491 	register STAB *s;
1492 	STAB *class;
1493 
1494 	for (p = line; isascii(*p) && isspace(*p); p++)
1495 		continue;
1496 	if (!(isascii(*p) && isalnum(*p)))
1497 	{
1498 		syserr("readcf: config K line: no map name");
1499 		return;
1500 	}
1501 
1502 	mapname = p;
1503 	while (isascii(*++p) && isalnum(*p))
1504 		continue;
1505 	if (*p != '\0')
1506 		*p++ = '\0';
1507 	while (isascii(*p) && isspace(*p))
1508 		p++;
1509 	if (!(isascii(*p) && isalnum(*p)))
1510 	{
1511 		syserr("readcf: config K line, map %s: no map class", mapname);
1512 		return;
1513 	}
1514 	classname = p;
1515 	while (isascii(*++p) && isalnum(*p))
1516 		continue;
1517 	if (*p != '\0')
1518 		*p++ = '\0';
1519 	while (isascii(*p) && isspace(*p))
1520 		p++;
1521 
1522 	/* look up the class */
1523 	class = stab(classname, ST_MAPCLASS, ST_FIND);
1524 	if (class == NULL)
1525 	{
1526 		syserr("readcf: map %s: class %s not available", mapname, classname);
1527 		return;
1528 	}
1529 
1530 	/* enter the map */
1531 	s = stab(mapname, ST_MAP, ST_ENTER);
1532 	s->s_map.map_class = &class->s_mapclass;
1533 	s->s_map.map_mname = newstr(mapname);
1534 
1535 	if (class->s_mapclass.map_parse(&s->s_map, p))
1536 		s->s_map.map_mflags |= MF_VALID;
1537 
1538 	if (tTd(37, 5))
1539 	{
1540 		printf("map %s, class %s, flags %x, file %s,\n",
1541 			s->s_map.map_mname, s->s_map.map_class->map_cname,
1542 			s->s_map.map_mflags,
1543 			s->s_map.map_file == NULL ? "(null)" : s->s_map.map_file);
1544 		printf("\tapp %s, domain %s, rebuild %s\n",
1545 			s->s_map.map_app == NULL ? "(null)" : s->s_map.map_app,
1546 			s->s_map.map_domain == NULL ? "(null)" : s->s_map.map_domain,
1547 			s->s_map.map_rebuild == NULL ? "(null)" : s->s_map.map_rebuild);
1548 	}
1549 }
1550 /*
1551 **  SETTIMEOUTS -- parse and set timeout values
1552 **
1553 **	Parameters:
1554 **		val -- a pointer to the values.  If NULL, do initial
1555 **			settings.
1556 **
1557 **	Returns:
1558 **		none.
1559 **
1560 **	Side Effects:
1561 **		Initializes the TimeOuts structure
1562 */
1563 
1564 #define SECONDS
1565 #define MINUTES	* 60
1566 #define HOUR	* 3600
1567 
1568 settimeouts(val)
1569 	register char *val;
1570 {
1571 	register char *p;
1572 	extern time_t convtime();
1573 
1574 	if (val == NULL)
1575 	{
1576 		TimeOuts.to_initial = (time_t) 5 MINUTES;
1577 		TimeOuts.to_helo = (time_t) 5 MINUTES;
1578 		TimeOuts.to_mail = (time_t) 10 MINUTES;
1579 		TimeOuts.to_rcpt = (time_t) 1 HOUR;
1580 		TimeOuts.to_datainit = (time_t) 5 MINUTES;
1581 		TimeOuts.to_datablock = (time_t) 1 HOUR;
1582 		TimeOuts.to_datafinal = (time_t) 1 HOUR;
1583 		TimeOuts.to_rset = (time_t) 5 MINUTES;
1584 		TimeOuts.to_quit = (time_t) 2 MINUTES;
1585 		TimeOuts.to_nextcommand = (time_t) 1 HOUR;
1586 		TimeOuts.to_miscshort = (time_t) 2 MINUTES;
1587 		TimeOuts.to_ident = (time_t) 30 SECONDS;
1588 		return;
1589 	}
1590 
1591 	for (;; val = p)
1592 	{
1593 		while (isascii(*val) && isspace(*val))
1594 			val++;
1595 		if (*val == '\0')
1596 			break;
1597 		for (p = val; *p != '\0' && *p != ','; p++)
1598 			continue;
1599 		if (*p != '\0')
1600 			*p++ = '\0';
1601 
1602 		if (isascii(*val) && isdigit(*val))
1603 		{
1604 			/* old syntax -- set everything */
1605 			TimeOuts.to_mail = convtime(val, 'm');
1606 			TimeOuts.to_rcpt = TimeOuts.to_mail;
1607 			TimeOuts.to_datainit = TimeOuts.to_mail;
1608 			TimeOuts.to_datablock = TimeOuts.to_mail;
1609 			TimeOuts.to_datafinal = TimeOuts.to_mail;
1610 			TimeOuts.to_nextcommand = TimeOuts.to_mail;
1611 			continue;
1612 		}
1613 		else
1614 		{
1615 			register char *q = strchr(val, '=');
1616 			time_t to;
1617 
1618 			if (q == NULL)
1619 			{
1620 				/* syntax error */
1621 				continue;
1622 			}
1623 			*q++ = '\0';
1624 			to = convtime(q, 'm');
1625 
1626 			if (strcasecmp(val, "initial") == 0)
1627 				TimeOuts.to_initial = to;
1628 			else if (strcasecmp(val, "mail") == 0)
1629 				TimeOuts.to_mail = to;
1630 			else if (strcasecmp(val, "rcpt") == 0)
1631 				TimeOuts.to_rcpt = to;
1632 			else if (strcasecmp(val, "datainit") == 0)
1633 				TimeOuts.to_datainit = to;
1634 			else if (strcasecmp(val, "datablock") == 0)
1635 				TimeOuts.to_datablock = to;
1636 			else if (strcasecmp(val, "datafinal") == 0)
1637 				TimeOuts.to_datafinal = to;
1638 			else if (strcasecmp(val, "command") == 0)
1639 				TimeOuts.to_nextcommand = to;
1640 			else if (strcasecmp(val, "rset") == 0)
1641 				TimeOuts.to_rset = to;
1642 			else if (strcasecmp(val, "helo") == 0)
1643 				TimeOuts.to_helo = to;
1644 			else if (strcasecmp(val, "quit") == 0)
1645 				TimeOuts.to_quit = to;
1646 			else if (strcasecmp(val, "misc") == 0)
1647 				TimeOuts.to_miscshort = to;
1648 			else if (strcasecmp(val, "ident") == 0)
1649 				TimeOuts.to_ident = to;
1650 			else
1651 				syserr("settimeouts: invalid timeout %s", val);
1652 		}
1653 	}
1654 }
1655