xref: /csrg-svn/usr.sbin/sendmail/src/readcf.c (revision 10687)
13313Seric # include "sendmail.h"
23308Seric 
3*10687Seric SCCSID(@(#)readcf.c	3.53		02/02/83);
43308Seric 
53308Seric /*
63308Seric **  READCF -- read control file.
73308Seric **
83308Seric **	This routine reads the control file and builds the internal
93308Seric **	form.
103308Seric **
114432Seric **	The file is formatted as a sequence of lines, each taken
124432Seric **	atomically.  The first character of each line describes how
134432Seric **	the line is to be interpreted.  The lines are:
144432Seric **		Dxval		Define macro x to have value val.
154432Seric **		Cxword		Put word into class x.
164432Seric **		Fxfile [fmt]	Read file for lines to put into
174432Seric **				class x.  Use scanf string 'fmt'
184432Seric **				or "%s" if not present.  Fmt should
194432Seric **				only produce one string-valued result.
204432Seric **		Hname: value	Define header with field-name 'name'
214432Seric **				and value as specified; this will be
224432Seric **				macro expanded immediately before
234432Seric **				use.
244432Seric **		Sn		Use rewriting set n.
254432Seric **		Rlhs rhs	Rewrite addresses that match lhs to
264432Seric **				be rhs.
278252Seric **		Mn p f s r a	Define mailer.  n - internal name,
288252Seric **				p - pathname, f - flags, s - rewriting
298252Seric **				ruleset for sender, s - rewriting ruleset
308252Seric **				for recipients, a - argument vector.
318252Seric **		Oxvalue		Set option x to value.
328252Seric **		Pname=value	Set precedence name to value.
334432Seric **
343308Seric **	Parameters:
353308Seric **		cfname -- control file name.
364217Seric **		safe -- set if this is a system configuration file.
374217Seric **			Non-system configuration files can not do
384217Seric **			certain things (e.g., leave the SUID bit on
394217Seric **			when executing mailers).
403308Seric **
413308Seric **	Returns:
423308Seric **		none.
433308Seric **
443308Seric **	Side Effects:
453308Seric **		Builds several internal tables.
463308Seric */
473308Seric 
484217Seric readcf(cfname, safe)
493308Seric 	char *cfname;
504217Seric 	bool safe;
513308Seric {
523308Seric 	FILE *cf;
538547Seric 	int ruleset = 0;
548547Seric 	char *q;
558547Seric 	char **pv;
569350Seric 	struct rewrite *rwp = NULL;
573308Seric 	char buf[MAXLINE];
583308Seric 	register char *p;
593308Seric 	extern char **prescan();
603308Seric 	extern char **copyplist();
615909Seric 	char exbuf[MAXLINE];
629350Seric 	extern char *fgetfolded();
633308Seric 
643308Seric 	cf = fopen(cfname, "r");
653308Seric 	if (cf == NULL)
663308Seric 	{
673308Seric 		syserr("cannot open %s", cfname);
683308Seric 		exit(EX_OSFILE);
693308Seric 	}
703308Seric 
719381Seric 	FileName = cfname;
728056Seric 	LineNumber = 0;
737854Seric 	while (fgetfolded(buf, sizeof buf, cf) != NULL)
743308Seric 	{
753308Seric 		switch (buf[0])
763308Seric 		{
773308Seric 		  case '\0':
783308Seric 		  case '#':		/* comment */
793308Seric 			break;
803308Seric 
813308Seric 		  case 'R':		/* rewriting rule */
823308Seric 			for (p = &buf[1]; *p != '\0' && *p != '\t'; p++)
833308Seric 				continue;
843308Seric 
853308Seric 			if (*p == '\0')
865909Seric 			{
879381Seric 				syserr("invalid rewrite line \"%s\"", buf);
885909Seric 				break;
895909Seric 			}
905909Seric 
915909Seric 			/* allocate space for the rule header */
925909Seric 			if (rwp == NULL)
935909Seric 			{
945909Seric 				RewriteRules[ruleset] = rwp =
955909Seric 					(struct rewrite *) xalloc(sizeof *rwp);
965909Seric 			}
973308Seric 			else
983308Seric 			{
995909Seric 				rwp->r_next = (struct rewrite *) xalloc(sizeof *rwp);
1005909Seric 				rwp = rwp->r_next;
1015909Seric 			}
1025909Seric 			rwp->r_next = NULL;
1033308Seric 
1045909Seric 			/* expand and save the LHS */
1055909Seric 			*p = '\0';
1066991Seric 			expand(&buf[1], exbuf, &exbuf[sizeof exbuf], CurEnv);
1075909Seric 			rwp->r_lhs = prescan(exbuf, '\t');
1085909Seric 			if (rwp->r_lhs != NULL)
1095909Seric 				rwp->r_lhs = copyplist(rwp->r_lhs, TRUE);
1105909Seric 
1115909Seric 			/* expand and save the RHS */
1125909Seric 			while (*++p == '\t')
1135909Seric 				continue;
1147231Seric 			q = p;
1157231Seric 			while (*p != '\0' && *p != '\t')
1167231Seric 				p++;
1177231Seric 			*p = '\0';
1187231Seric 			expand(q, exbuf, &exbuf[sizeof exbuf], CurEnv);
1195909Seric 			rwp->r_rhs = prescan(exbuf, '\t');
1205909Seric 			if (rwp->r_rhs != NULL)
1215909Seric 				rwp->r_rhs = copyplist(rwp->r_rhs, TRUE);
1223308Seric 			break;
1233308Seric 
1244072Seric 		  case 'S':		/* select rewriting set */
1254072Seric 			ruleset = atoi(&buf[1]);
1268056Seric 			if (ruleset >= MAXRWSETS || ruleset < 0)
1278056Seric 			{
1289381Seric 				syserr("bad ruleset %d (%d max)", ruleset, MAXRWSETS);
1298056Seric 				ruleset = 0;
1308056Seric 			}
1314072Seric 			rwp = NULL;
1324072Seric 			break;
1334072Seric 
1343308Seric 		  case 'D':		/* macro definition */
1359381Seric 			define(buf[1], newstr(&buf[2]), CurEnv);
1363308Seric 			break;
1373308Seric 
1383387Seric 		  case 'H':		/* required header line */
1394088Seric 			(void) chompheader(&buf[1], TRUE);
1403387Seric 			break;
1413387Seric 
1424061Seric 		  case 'C':		/* word class */
1434432Seric 		  case 'F':		/* word class from file */
1444432Seric 			/* read list of words from argument or file */
1454432Seric 			if (buf[0] == 'F')
1464432Seric 			{
1474432Seric 				/* read from file */
1484432Seric 				for (p = &buf[2]; *p != '\0' && !isspace(*p); p++)
1494432Seric 					continue;
1504432Seric 				if (*p == '\0')
1514432Seric 					p = "%s";
1524432Seric 				else
1534432Seric 				{
1544432Seric 					*p = '\0';
1554432Seric 					while (isspace(*++p))
1564432Seric 						continue;
1574432Seric 				}
158*10687Seric 				fileclass(buf[1], &buf[2], p);
1594432Seric 				break;
1604432Seric 			}
1614061Seric 
1624432Seric 			/* scan the list of words and set class for all */
1634061Seric 			for (p = &buf[2]; *p != '\0'; )
1644061Seric 			{
1654061Seric 				register char *wd;
1664061Seric 				char delim;
1674061Seric 				register STAB *s;
1684061Seric 
1694061Seric 				while (*p != '\0' && isspace(*p))
1704061Seric 					p++;
1714061Seric 				wd = p;
1724061Seric 				while (*p != '\0' && !isspace(*p))
1734061Seric 					p++;
1744061Seric 				delim = *p;
1754061Seric 				*p = '\0';
1764061Seric 				if (wd[0] != '\0')
177*10687Seric 					setclass(buf[1], wd);
1784061Seric 				*p = delim;
1794061Seric 			}
1804061Seric 			break;
1814061Seric 
1824096Seric 		  case 'M':		/* define mailer */
1834217Seric 			makemailer(&buf[1], safe);
1844096Seric 			break;
1854096Seric 
1868252Seric 		  case 'O':		/* set option */
1878269Seric 			setoption(buf[1], &buf[2], safe, FALSE);
1888252Seric 			break;
1898252Seric 
1908252Seric 		  case 'P':		/* set precedence */
1918252Seric 			if (NumPriorities >= MAXPRIORITIES)
1928252Seric 			{
1938547Seric 				toomany('P', MAXPRIORITIES);
1948252Seric 				break;
1958252Seric 			}
1969381Seric 			for (p = &buf[1]; *p != '\0' && *p != '=' && *p != '\t'; p++)
1978252Seric 				continue;
1988252Seric 			if (*p == '\0')
1998252Seric 				goto badline;
2008252Seric 			*p = '\0';
2018252Seric 			Priorities[NumPriorities].pri_name = newstr(&buf[1]);
2028252Seric 			Priorities[NumPriorities].pri_val = atoi(++p);
2038252Seric 			NumPriorities++;
2048252Seric 			break;
2058252Seric 
2068547Seric 		  case 'T':		/* trusted user(s) */
2078547Seric 			p = &buf[1];
2088547Seric 			while (*p != '\0')
2098547Seric 			{
2108547Seric 				while (isspace(*p))
2118547Seric 					p++;
2128547Seric 				q = p;
2138547Seric 				while (*p != '\0' && !isspace(*p))
2148547Seric 					p++;
2158547Seric 				if (*p != '\0')
2168547Seric 					*p++ = '\0';
2178547Seric 				if (*q == '\0')
2188547Seric 					continue;
2198547Seric 				for (pv = TrustedUsers; *pv != NULL; pv++)
2208547Seric 					continue;
2218547Seric 				if (pv >= &TrustedUsers[MAXTRUST])
2228547Seric 				{
2238547Seric 					toomany('T', MAXTRUST);
2248547Seric 					break;
2258547Seric 				}
2268547Seric 				*pv = newstr(q);
2278547Seric 			}
2288547Seric 			break;
2298547Seric 
2303308Seric 		  default:
2314061Seric 		  badline:
2329381Seric 			syserr("unknown control line \"%s\"", buf);
2333308Seric 		}
2343308Seric 	}
2359381Seric 	FileName = NULL;
2364096Seric }
2374096Seric /*
2388547Seric **  TOOMANY -- signal too many of some option
2398547Seric **
2408547Seric **	Parameters:
2418547Seric **		id -- the id of the error line
2428547Seric **		maxcnt -- the maximum possible values
2438547Seric **
2448547Seric **	Returns:
2458547Seric **		none.
2468547Seric **
2478547Seric **	Side Effects:
2488547Seric **		gives a syserr.
2498547Seric */
2508547Seric 
2518547Seric toomany(id, maxcnt)
2528547Seric 	char id;
2538547Seric 	int maxcnt;
2548547Seric {
2559381Seric 	syserr("too many %c lines, %d max", id, maxcnt);
2568547Seric }
2578547Seric /*
2584432Seric **  FILECLASS -- read members of a class from a file
2594432Seric **
2604432Seric **	Parameters:
2614432Seric **		class -- class to define.
2624432Seric **		filename -- name of file to read.
2634432Seric **		fmt -- scanf string to use for match.
2644432Seric **
2654432Seric **	Returns:
2664432Seric **		none
2674432Seric **
2684432Seric **	Side Effects:
2694432Seric **
2704432Seric **		puts all lines in filename that match a scanf into
2714432Seric **			the named class.
2724432Seric */
2734432Seric 
2744432Seric fileclass(class, filename, fmt)
2754432Seric 	int class;
2764432Seric 	char *filename;
2774432Seric 	char *fmt;
2784432Seric {
2794432Seric 	register FILE *f;
2804432Seric 	char buf[MAXLINE];
2814432Seric 
2824432Seric 	f = fopen(filename, "r");
2834432Seric 	if (f == NULL)
2844432Seric 	{
2854432Seric 		syserr("cannot open %s", filename);
2864432Seric 		return;
2874432Seric 	}
2884432Seric 
2894432Seric 	while (fgets(buf, sizeof buf, f) != NULL)
2904432Seric 	{
2914432Seric 		register STAB *s;
2924432Seric 		char wordbuf[MAXNAME+1];
2934432Seric 
2944432Seric 		if (sscanf(buf, fmt, wordbuf) != 1)
2954432Seric 			continue;
2964432Seric 		s = stab(wordbuf, ST_CLASS, ST_ENTER);
297*10687Seric 		setbitn(class, s->s_class);
2984432Seric 	}
2994432Seric 
3004627Seric 	(void) fclose(f);
3014432Seric }
3024432Seric /*
3034096Seric **  MAKEMAILER -- define a new mailer.
3044096Seric **
3054096Seric **	Parameters:
30610327Seric **		line -- description of mailer.  This is in labeled
30710327Seric **			fields.  The fields are:
30810327Seric **			   P -- the path to the mailer
30910327Seric **			   F -- the flags associated with the mailer
31010327Seric **			   A -- the argv for this mailer
31110327Seric **			   S -- the sender rewriting set
31210327Seric **			   R -- the recipient rewriting set
31310327Seric **			   E -- the eol string
31410327Seric **			The first word is the canonical name of the mailer.
3154217Seric **		safe -- set if this is a safe configuration file.
3164096Seric **
3174096Seric **	Returns:
3184096Seric **		none.
3194096Seric **
3204096Seric **	Side Effects:
3214096Seric **		enters the mailer into the mailer table.
3224096Seric */
3233308Seric 
3244217Seric makemailer(line, safe)
3254096Seric 	char *line;
3264217Seric 	bool safe;
3274096Seric {
3284096Seric 	register char *p;
3298067Seric 	register struct mailer *m;
3308067Seric 	register STAB *s;
3318067Seric 	int i;
33210327Seric 	char fcode;
3334096Seric 	extern int NextMailer;
33410327Seric 	extern char **makeargv();
33510327Seric 	extern char *munchstring();
33610327Seric 	extern char *DelimChar;
3374096Seric 
33810327Seric 	/* allocate a mailer and set up defaults */
33910327Seric 	m = (struct mailer *) xalloc(sizeof *m);
34010327Seric 	bzero((char *) m, sizeof *m);
34110327Seric 	m->m_mno = NextMailer;
34210327Seric 	m->m_eol = "\n";
34310327Seric 
34410327Seric 	/* collect the mailer name */
34510327Seric 	for (p = line; *p != '\0' && *p != ',' && !isspace(*p); p++)
34610327Seric 		continue;
34710327Seric 	if (*p != '\0')
34810327Seric 		*p++ = '\0';
34910327Seric 	m->m_name = newstr(line);
35010327Seric 
35110327Seric 	/* now scan through and assign info from the fields */
35210327Seric 	while (*p != '\0')
35310327Seric 	{
35410327Seric 		while (*p != '\0' && (*p == ',' || isspace(*p)))
35510327Seric 			p++;
35610327Seric 
35710327Seric 		/* p now points to field code */
35810327Seric 		fcode = *p;
35910327Seric 		while (*p != '\0' && *p != '=' && *p != ',')
36010327Seric 			p++;
36110327Seric 		if (*p++ != '=')
36210327Seric 		{
36310327Seric 			syserr("`=' expected");
36410327Seric 			return;
36510327Seric 		}
36610327Seric 		while (isspace(*p))
36710327Seric 			p++;
36810327Seric 
36910327Seric 		/* p now points to the field body */
37010327Seric 		p = munchstring(p);
37110327Seric 
37210327Seric 		/* install the field into the mailer struct */
37310327Seric 		switch (fcode)
37410327Seric 		{
37510327Seric 		  case 'P':		/* pathname */
37610327Seric 			m->m_mailer = newstr(p);
37710327Seric 			break;
37810327Seric 
37910327Seric 		  case 'F':		/* flags */
380*10687Seric 			for (; *p != '\0'; p++)
381*10687Seric 				setbitn(*p, m->m_flags);
38210327Seric 			if (!safe)
383*10687Seric 				clrbitn(M_RESTR, m->m_flags);
38410327Seric 			break;
38510327Seric 
38610327Seric 		  case 'S':		/* sender rewriting ruleset */
38710327Seric 		  case 'R':		/* recipient rewriting ruleset */
38810327Seric 			i = atoi(p);
38910327Seric 			if (i < 0 || i >= MAXRWSETS)
39010327Seric 			{
39110327Seric 				syserr("invalid rewrite set, %d max", MAXRWSETS);
39210327Seric 				return;
39310327Seric 			}
39410327Seric 			if (fcode == 'S')
39510327Seric 				m->m_s_rwset = i;
39610327Seric 			else
39710327Seric 				m->m_r_rwset = i;
39810327Seric 			break;
39910327Seric 
40010327Seric 		  case 'E':		/* end of line string */
40110327Seric 			m->m_eol = newstr(p);
40210327Seric 			break;
40310327Seric 
40410327Seric 		  case 'A':		/* argument vector */
40510327Seric 			m->m_argv = makeargv(p);
40610327Seric 			break;
40710327Seric 		}
40810327Seric 
40910327Seric 		p = DelimChar;
41010327Seric 	}
41110327Seric 
41210327Seric 	/* now store the mailer away */
4134096Seric 	if (NextMailer >= MAXMAILERS)
4144096Seric 	{
4159381Seric 		syserr("too many mailers defined (%d max)", MAXMAILERS);
4164096Seric 		return;
4174096Seric 	}
41810327Seric 	Mailer[NextMailer++] = m;
41910327Seric 	s = stab(m->m_name, ST_MAILER, ST_ENTER);
42010327Seric 	s->s_mailer = m;
42110327Seric }
42210327Seric /*
42310327Seric **  MUNCHSTRING -- translate a string into internal form.
42410327Seric **
42510327Seric **	Parameters:
42610327Seric **		p -- the string to munch.
42710327Seric **
42810327Seric **	Returns:
42910327Seric **		the munched string.
43010327Seric **
43110327Seric **	Side Effects:
43210327Seric **		Sets "DelimChar" to point to the string that caused us
43310327Seric **		to stop.
43410327Seric */
4354096Seric 
43610327Seric char *
43710327Seric munchstring(p)
43810327Seric 	register char *p;
43910327Seric {
44010327Seric 	register char *q;
44110327Seric 	bool backslash = FALSE;
44210327Seric 	bool quotemode = FALSE;
44310327Seric 	static char buf[MAXLINE];
44410327Seric 	extern char *DelimChar;
4454096Seric 
44610327Seric 	for (q = buf; *p != '\0'; p++)
4474096Seric 	{
44810327Seric 		if (backslash)
44910327Seric 		{
45010327Seric 			/* everything is roughly literal */
45110357Seric 			backslash = FALSE;
45210327Seric 			switch (*p)
45310327Seric 			{
45410327Seric 			  case 'r':		/* carriage return */
45510327Seric 				*q++ = '\r';
45610327Seric 				continue;
45710327Seric 
45810327Seric 			  case 'n':		/* newline */
45910327Seric 				*q++ = '\n';
46010327Seric 				continue;
46110327Seric 
46210327Seric 			  case 'f':		/* form feed */
46310327Seric 				*q++ = '\f';
46410327Seric 				continue;
46510327Seric 
46610327Seric 			  case 'b':		/* backspace */
46710327Seric 				*q++ = '\b';
46810327Seric 				continue;
46910327Seric 			}
47010327Seric 			*q++ = *p;
47110327Seric 		}
47210327Seric 		else
47310327Seric 		{
47410327Seric 			if (*p == '\\')
47510327Seric 				backslash = TRUE;
47610327Seric 			else if (*p == '"')
47710327Seric 				quotemode = !quotemode;
47810327Seric 			else if (quotemode || *p != ',')
47910327Seric 				*q++ = *p;
48010327Seric 			else
48110327Seric 				break;
48210327Seric 		}
4834096Seric 	}
4844096Seric 
48510327Seric 	DelimChar = p;
48610327Seric 	*q++ = '\0';
48710327Seric 	return (buf);
48810327Seric }
48910327Seric /*
49010327Seric **  MAKEARGV -- break up a string into words
49110327Seric **
49210327Seric **	Parameters:
49310327Seric **		p -- the string to break up.
49410327Seric **
49510327Seric **	Returns:
49610327Seric **		a char **argv (dynamically allocated)
49710327Seric **
49810327Seric **	Side Effects:
49910327Seric **		munges p.
50010327Seric */
5014096Seric 
50210327Seric char **
50310327Seric makeargv(p)
50410327Seric 	register char *p;
50510327Seric {
50610327Seric 	char *q;
50710327Seric 	int i;
50810327Seric 	char **avp;
50910327Seric 	char *argv[MAXPV + 1];
51010327Seric 
51110327Seric 	/* take apart the words */
51210327Seric 	i = 0;
51310327Seric 	while (*p != '\0' && i < MAXPV)
5144096Seric 	{
51510327Seric 		q = p;
51610327Seric 		while (*p != '\0' && !isspace(*p))
51710327Seric 			p++;
51810327Seric 		while (isspace(*p))
51910327Seric 			*p++ = '\0';
52010327Seric 		argv[i++] = newstr(q);
5214096Seric 	}
52210327Seric 	argv[i++] = NULL;
5234096Seric 
52410327Seric 	/* now make a copy of the argv */
52510327Seric 	avp = (char **) xalloc(sizeof *avp * i);
52610327Seric 	bmove((char *) argv, (char *) avp, sizeof *avp * i);
52710327Seric 
52810327Seric 	return (avp);
5293308Seric }
5303308Seric /*
5313308Seric **  PRINTRULES -- print rewrite rules (for debugging)
5323308Seric **
5333308Seric **	Parameters:
5343308Seric **		none.
5353308Seric **
5363308Seric **	Returns:
5373308Seric **		none.
5383308Seric **
5393308Seric **	Side Effects:
5403308Seric **		prints rewrite rules.
5413308Seric */
5423308Seric 
5434319Seric # ifdef DEBUG
5444319Seric 
5453308Seric printrules()
5463308Seric {
5473308Seric 	register struct rewrite *rwp;
5484072Seric 	register int ruleset;
5493308Seric 
5504072Seric 	for (ruleset = 0; ruleset < 10; ruleset++)
5513308Seric 	{
5524072Seric 		if (RewriteRules[ruleset] == NULL)
5534072Seric 			continue;
5548067Seric 		printf("\n----Rule Set %d:", ruleset);
5553308Seric 
5564072Seric 		for (rwp = RewriteRules[ruleset]; rwp != NULL; rwp = rwp->r_next)
5573308Seric 		{
5588067Seric 			printf("\nLHS:");
5598067Seric 			printav(rwp->r_lhs);
5608067Seric 			printf("RHS:");
5618067Seric 			printav(rwp->r_rhs);
5623308Seric 		}
5633308Seric 	}
5643308Seric }
5654319Seric 
5664319Seric # endif DEBUG
5674096Seric /*
5688256Seric **  SETOPTION -- set global processing option
5698256Seric **
5708256Seric **	Parameters:
5718256Seric **		opt -- option name.
5728256Seric **		val -- option value (as a text string).
5738269Seric **		safe -- if set, this came from a system configuration file.
5748269Seric **		sticky -- if set, don't let other setoptions override
5758269Seric **			this value.
5768256Seric **
5778256Seric **	Returns:
5788256Seric **		none.
5798256Seric **
5808256Seric **	Side Effects:
5818256Seric **		Sets options as implied by the arguments.
5828256Seric */
5838256Seric 
584*10687Seric static BITMAP	StickyOpt;		/* set if option is stuck */
585*10687Seric extern char	*WizWord;		/* the stored wizard password */
58610343Seric #ifdef DAEMON
587*10687Seric extern int	MaxConnections;		/* max simult. SMTP conns */
58810343Seric #endif DAEMON
5898269Seric 
5908269Seric setoption(opt, val, safe, sticky)
5918256Seric 	char opt;
5928256Seric 	char *val;
5938269Seric 	bool safe;
5948269Seric 	bool sticky;
5958256Seric {
5968265Seric 	extern bool atobool();
5978256Seric 
5988256Seric # ifdef DEBUG
5998256Seric 	if (tTd(37, 1))
6009341Seric 		printf("setoption %c=%s", opt, val);
6018256Seric # endif DEBUG
6028256Seric 
6038256Seric 	/*
6048269Seric 	**  See if this option is preset for us.
6058256Seric 	*/
6068256Seric 
607*10687Seric 	if (bitnset(opt, StickyOpt))
6088269Seric 	{
6098269Seric # ifdef DEBUG
6109341Seric 		if (tTd(37, 1))
6119341Seric 			printf(" (ignored)\n");
6128269Seric # endif DEBUG
6138269Seric 		return;
6148269Seric 	}
6159341Seric #ifdef DEBUG
6169341Seric 	else if (tTd(37, 1))
6179341Seric 		printf("\n");
6189341Seric #endif DEBUG
6198269Seric 	if (sticky)
620*10687Seric 		setbitn(opt, StickyOpt);
6218269Seric 
6228269Seric 	if (getruid() == 0)
6238269Seric 		safe = TRUE;
6248269Seric 
6258256Seric 	switch (opt)
6268256Seric 	{
6278256Seric 	  case 'A':		/* set default alias file */
6289381Seric 		if (val[0] == '\0')
6298269Seric 			AliasFile = "aliases";
6309381Seric 		else
6319381Seric 			AliasFile = newstr(val);
6328256Seric 		break;
6338256Seric 
6348931Seric 	  case 'a':		/* look for "@:@" in alias file */
6359381Seric 		SafeAlias = atobool(val);
6368931Seric 		break;
6378931Seric 
6389284Seric 	  case 'c':		/* don't connect to "expensive" mailers */
6399381Seric 		NoConnect = atobool(val);
6409284Seric 		break;
6419284Seric 
6429284Seric 	  case 'd':		/* delivery mode */
6439284Seric 		switch (*val)
6448269Seric 		{
6459284Seric 		  case '\0':
6469284Seric 			SendMode = SM_DELIVER;
6478269Seric 			break;
6488269Seric 
6499284Seric 		  case SM_DELIVER:	/* do everything */
6509284Seric 		  case SM_FORK:		/* fork after verification */
6519284Seric 		  case SM_QUEUE:	/* queue only */
6529284Seric 			SendMode = *val;
6538269Seric 			break;
6548269Seric 
6558269Seric 		  default:
6569284Seric 			syserr("Unknown delivery mode %c", *val);
6578269Seric 			exit(EX_USAGE);
6588269Seric 		}
6598269Seric 		break;
6608269Seric 
6619146Seric 	  case 'D':		/* rebuild alias database as needed */
6629381Seric 		AutoRebuild = atobool(val);
6639146Seric 		break;
6649146Seric 
6658269Seric 	  case 'e':		/* set error processing mode */
6668269Seric 		switch (*val)
6678269Seric 		{
6689381Seric 		  case EM_QUIET:	/* be silent about it */
6698269Seric 			(void) freopen("/dev/null", "w", stdout);
6709381Seric 			/* fall through... */
6718269Seric 
6729381Seric 		  case EM_MAIL:		/* mail back */
6739381Seric 		  case EM_BERKNET:	/* do berknet error processing */
6749381Seric 		  case EM_WRITE:	/* write back (or mail) */
6758269Seric 			HoldErrs = TRUE;
6769381Seric 			/* fall through... */
6778269Seric 
6789381Seric 		  case EM_PRINT:	/* print errors normally (default) */
6799381Seric 			ErrorMode = *val;
6808269Seric 			break;
6818269Seric 		}
6828269Seric 		break;
6838269Seric 
6849049Seric 	  case 'F':		/* file mode */
6859381Seric 		FileMode = atooct(val);
6869049Seric 		break;
6879049Seric 
6888269Seric 	  case 'f':		/* save Unix-style From lines on front */
6899381Seric 		SaveFrom = atobool(val);
6908269Seric 		break;
6918269Seric 
6928256Seric 	  case 'g':		/* default gid */
6939105Seric 		if (safe)
6949381Seric 			DefGid = atoi(val);
6958256Seric 		break;
6968256Seric 
6978256Seric 	  case 'H':		/* help file */
6989381Seric 		if (val[0] == '\0')
6998269Seric 			HelpFile = "sendmail.hf";
7009381Seric 		else
7019381Seric 			HelpFile = newstr(val);
7028256Seric 		break;
7038256Seric 
7048269Seric 	  case 'i':		/* ignore dot lines in message */
7059381Seric 		IgnrDot = atobool(val);
7068269Seric 		break;
7078269Seric 
7088256Seric 	  case 'L':		/* log level */
7099381Seric 		LogLevel = atoi(val);
7108256Seric 		break;
7118256Seric 
7128269Seric 	  case 'M':		/* define macro */
7139381Seric 		define(val[0], newstr(&val[1]), CurEnv);
7148269Seric 		break;
7158269Seric 
7168269Seric 	  case 'm':		/* send to me too */
7179381Seric 		MeToo = atobool(val);
7188269Seric 		break;
7198269Seric 
72010343Seric #ifdef DAEMON
72110343Seric 	  case 'N':		/* maximum simultaneous SMTP connections */
72210343Seric 		MaxConnections = atoi(val);
72310343Seric 		break;
72410343Seric #endif DAEMON
72510343Seric 
7268269Seric 	  case 'o':		/* assume old style headers */
7279381Seric 		if (atobool(val))
7289341Seric 			CurEnv->e_flags |= EF_OLDSTYLE;
7299341Seric 		else
7309341Seric 			CurEnv->e_flags &= ~EF_OLDSTYLE;
7318269Seric 		break;
7328269Seric 
7338256Seric 	  case 'Q':		/* queue directory */
7349381Seric 		if (val[0] == '\0')
7358269Seric 			QueueDir = "mqueue";
7369381Seric 		else
7379381Seric 			QueueDir = newstr(val);
7388256Seric 		break;
7398256Seric 
7408256Seric 	  case 'r':		/* read timeout */
7419381Seric 		ReadTimeout = convtime(val);
7428256Seric 		break;
7438256Seric 
7448256Seric 	  case 'S':		/* status file */
7459381Seric 		if (val[0] == '\0')
7468269Seric 			StatFile = "sendmail.st";
7479381Seric 		else
7489381Seric 			StatFile = newstr(val);
7498256Seric 		break;
7508256Seric 
7518265Seric 	  case 's':		/* be super safe, even if expensive */
7529381Seric 		SuperSafe = atobool(val);
7538256Seric 		break;
7548256Seric 
7558256Seric 	  case 'T':		/* queue timeout */
7569381Seric 		TimeOut = convtime(val);
7578256Seric 		break;
7588256Seric 
7598265Seric 	  case 't':		/* time zone name */
7608265Seric # ifdef V6
7619381Seric 		StdTimezone = newstr(val);
7629381Seric 		DstTimezone = index(StdTimeZone, ',');
7638265Seric 		if (DstTimezone == NULL)
7649381Seric 			syserr("bad time zone spec");
7659381Seric 		else
7669381Seric 			*DstTimezone++ = '\0';
7678265Seric # endif V6
7688265Seric 		break;
7698265Seric 
7708256Seric 	  case 'u':		/* set default uid */
7719105Seric 		if (safe)
7729381Seric 			DefUid = atoi(val);
7738256Seric 		break;
7748256Seric 
7758269Seric 	  case 'v':		/* run in verbose mode */
7769381Seric 		Verbose = atobool(val);
7778256Seric 		break;
7788256Seric 
7798544Seric # ifdef DEBUG
7808544Seric 	  case 'W':		/* set the wizards password */
7819105Seric 		if (safe)
7829381Seric 			WizWord = newstr(val);
7838544Seric 		break;
7848544Seric # endif DEBUG
7858544Seric 
7868256Seric 	  default:
7878256Seric 		break;
7888256Seric 	}
7899188Seric 	return;
7908256Seric }
791*10687Seric /*
792*10687Seric **  SETCLASS -- set a word into a class
793*10687Seric **
794*10687Seric **	Parameters:
795*10687Seric **		class -- the class to put the word in.
796*10687Seric **		word -- the word to enter
797*10687Seric **
798*10687Seric **	Returns:
799*10687Seric **		none.
800*10687Seric **
801*10687Seric **	Side Effects:
802*10687Seric **		puts the word into the symbol table.
803*10687Seric */
804*10687Seric 
805*10687Seric setclass(class, word)
806*10687Seric 	int class;
807*10687Seric 	char *word;
808*10687Seric {
809*10687Seric 	register STAB *s;
810*10687Seric 
811*10687Seric 	s = stab(word, ST_CLASS, ST_ENTER);
812*10687Seric 	setbitn(class, s->s_class);
813*10687Seric }
814