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