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