13313Seric # include "sendmail.h"
23308Seric 
3*9381Seric SCCSID(@(#)readcf.c	3.48		11/28/82);
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 class;
548547Seric 	int ruleset = 0;
558547Seric 	char *q;
568547Seric 	char **pv;
579350Seric 	struct rewrite *rwp = NULL;
583308Seric 	char buf[MAXLINE];
593308Seric 	register char *p;
603308Seric 	extern char **prescan();
613308Seric 	extern char **copyplist();
625909Seric 	char exbuf[MAXLINE];
639350Seric 	extern char *fgetfolded();
643308Seric 
653308Seric 	cf = fopen(cfname, "r");
663308Seric 	if (cf == NULL)
673308Seric 	{
683308Seric 		syserr("cannot open %s", cfname);
693308Seric 		exit(EX_OSFILE);
703308Seric 	}
713308Seric 
72*9381Seric 	FileName = cfname;
738056Seric 	LineNumber = 0;
747854Seric 	while (fgetfolded(buf, sizeof buf, cf) != NULL)
753308Seric 	{
763308Seric 		switch (buf[0])
773308Seric 		{
783308Seric 		  case '\0':
793308Seric 		  case '#':		/* comment */
803308Seric 			break;
813308Seric 
823308Seric 		  case 'R':		/* rewriting rule */
833308Seric 			for (p = &buf[1]; *p != '\0' && *p != '\t'; p++)
843308Seric 				continue;
853308Seric 
863308Seric 			if (*p == '\0')
875909Seric 			{
88*9381Seric 				syserr("invalid rewrite line \"%s\"", buf);
895909Seric 				break;
905909Seric 			}
915909Seric 
925909Seric 			/* allocate space for the rule header */
935909Seric 			if (rwp == NULL)
945909Seric 			{
955909Seric 				RewriteRules[ruleset] = rwp =
965909Seric 					(struct rewrite *) xalloc(sizeof *rwp);
975909Seric 			}
983308Seric 			else
993308Seric 			{
1005909Seric 				rwp->r_next = (struct rewrite *) xalloc(sizeof *rwp);
1015909Seric 				rwp = rwp->r_next;
1025909Seric 			}
1035909Seric 			rwp->r_next = NULL;
1043308Seric 
1055909Seric 			/* expand and save the LHS */
1065909Seric 			*p = '\0';
1076991Seric 			expand(&buf[1], exbuf, &exbuf[sizeof exbuf], CurEnv);
1085909Seric 			rwp->r_lhs = prescan(exbuf, '\t');
1095909Seric 			if (rwp->r_lhs != NULL)
1105909Seric 				rwp->r_lhs = copyplist(rwp->r_lhs, TRUE);
1115909Seric 
1125909Seric 			/* expand and save the RHS */
1135909Seric 			while (*++p == '\t')
1145909Seric 				continue;
1157231Seric 			q = p;
1167231Seric 			while (*p != '\0' && *p != '\t')
1177231Seric 				p++;
1187231Seric 			*p = '\0';
1197231Seric 			expand(q, exbuf, &exbuf[sizeof exbuf], CurEnv);
1205909Seric 			rwp->r_rhs = prescan(exbuf, '\t');
1215909Seric 			if (rwp->r_rhs != NULL)
1225909Seric 				rwp->r_rhs = copyplist(rwp->r_rhs, TRUE);
1233308Seric 			break;
1243308Seric 
1254072Seric 		  case 'S':		/* select rewriting set */
1264072Seric 			ruleset = atoi(&buf[1]);
1278056Seric 			if (ruleset >= MAXRWSETS || ruleset < 0)
1288056Seric 			{
129*9381Seric 				syserr("bad ruleset %d (%d max)", ruleset, MAXRWSETS);
1308056Seric 				ruleset = 0;
1318056Seric 			}
1324072Seric 			rwp = NULL;
1334072Seric 			break;
1344072Seric 
1353308Seric 		  case 'D':		/* macro definition */
136*9381Seric 			define(buf[1], newstr(&buf[2]), CurEnv);
1373308Seric 			break;
1383308Seric 
1393387Seric 		  case 'H':		/* required header line */
1404088Seric 			(void) chompheader(&buf[1], TRUE);
1413387Seric 			break;
1423387Seric 
1434061Seric 		  case 'C':		/* word class */
1444432Seric 		  case 'F':		/* word class from file */
1454061Seric 			class = buf[1];
1464061Seric 			if (!isalpha(class))
147*9381Seric 			{
148*9381Seric 				syserr("illegal class name %c", class);
149*9381Seric 				break;
150*9381Seric 			}
1514061Seric 			if (isupper(class))
1524061Seric 				class -= 'A';
1534061Seric 			else
1544061Seric 				class -= 'a';
1554432Seric 
1564432Seric 			/* read list of words from argument or file */
1574432Seric 			if (buf[0] == 'F')
1584432Seric 			{
1594432Seric 				/* read from file */
1604432Seric 				for (p = &buf[2]; *p != '\0' && !isspace(*p); p++)
1614432Seric 					continue;
1624432Seric 				if (*p == '\0')
1634432Seric 					p = "%s";
1644432Seric 				else
1654432Seric 				{
1664432Seric 					*p = '\0';
1674432Seric 					while (isspace(*++p))
1684432Seric 						continue;
1694432Seric 				}
1704432Seric 				fileclass(class, &buf[2], p);
1714432Seric 				break;
1724432Seric 			}
1734061Seric 
1744432Seric 			/* scan the list of words and set class for all */
1754061Seric 			for (p = &buf[2]; *p != '\0'; )
1764061Seric 			{
1774061Seric 				register char *wd;
1784061Seric 				char delim;
1794061Seric 				register STAB *s;
1804061Seric 
1814061Seric 				while (*p != '\0' && isspace(*p))
1824061Seric 					p++;
1834061Seric 				wd = p;
1844061Seric 				while (*p != '\0' && !isspace(*p))
1854061Seric 					p++;
1864061Seric 				delim = *p;
1874061Seric 				*p = '\0';
1884061Seric 				if (wd[0] != '\0')
1894061Seric 				{
1904103Seric 					s = stab(wd, ST_CLASS, ST_ENTER);
1916275Seric 					s->s_class |= 1L << class;
1924061Seric 				}
1934061Seric 				*p = delim;
1944061Seric 			}
1954061Seric 			break;
1964061Seric 
1974096Seric 		  case 'M':		/* define mailer */
1984217Seric 			makemailer(&buf[1], safe);
1994096Seric 			break;
2004096Seric 
2018252Seric 		  case 'O':		/* set option */
2028269Seric 			setoption(buf[1], &buf[2], safe, FALSE);
2038252Seric 			break;
2048252Seric 
2058252Seric 		  case 'P':		/* set precedence */
2068252Seric 			if (NumPriorities >= MAXPRIORITIES)
2078252Seric 			{
2088547Seric 				toomany('P', MAXPRIORITIES);
2098252Seric 				break;
2108252Seric 			}
211*9381Seric 			for (p = &buf[1]; *p != '\0' && *p != '=' && *p != '\t'; p++)
2128252Seric 				continue;
2138252Seric 			if (*p == '\0')
2148252Seric 				goto badline;
2158252Seric 			*p = '\0';
2168252Seric 			Priorities[NumPriorities].pri_name = newstr(&buf[1]);
2178252Seric 			Priorities[NumPriorities].pri_val = atoi(++p);
2188252Seric 			NumPriorities++;
2198252Seric 			break;
2208252Seric 
2218547Seric 		  case 'T':		/* trusted user(s) */
2228547Seric 			p = &buf[1];
2238547Seric 			while (*p != '\0')
2248547Seric 			{
2258547Seric 				while (isspace(*p))
2268547Seric 					p++;
2278547Seric 				q = p;
2288547Seric 				while (*p != '\0' && !isspace(*p))
2298547Seric 					p++;
2308547Seric 				if (*p != '\0')
2318547Seric 					*p++ = '\0';
2328547Seric 				if (*q == '\0')
2338547Seric 					continue;
2348547Seric 				for (pv = TrustedUsers; *pv != NULL; pv++)
2358547Seric 					continue;
2368547Seric 				if (pv >= &TrustedUsers[MAXTRUST])
2378547Seric 				{
2388547Seric 					toomany('T', MAXTRUST);
2398547Seric 					break;
2408547Seric 				}
2418547Seric 				*pv = newstr(q);
2428547Seric 			}
2438547Seric 			break;
2448547Seric 
2453308Seric 		  default:
2464061Seric 		  badline:
247*9381Seric 			syserr("unknown control line \"%s\"", buf);
2483308Seric 		}
2493308Seric 	}
250*9381Seric 	FileName = NULL;
2514096Seric }
2524096Seric /*
2538547Seric **  TOOMANY -- signal too many of some option
2548547Seric **
2558547Seric **	Parameters:
2568547Seric **		id -- the id of the error line
2578547Seric **		maxcnt -- the maximum possible values
2588547Seric **
2598547Seric **	Returns:
2608547Seric **		none.
2618547Seric **
2628547Seric **	Side Effects:
2638547Seric **		gives a syserr.
2648547Seric */
2658547Seric 
2668547Seric toomany(id, maxcnt)
2678547Seric 	char id;
2688547Seric 	int maxcnt;
2698547Seric {
270*9381Seric 	syserr("too many %c lines, %d max", id, maxcnt);
2718547Seric }
2728547Seric /*
2734432Seric **  FILECLASS -- read members of a class from a file
2744432Seric **
2754432Seric **	Parameters:
2764432Seric **		class -- class to define.
2774432Seric **		filename -- name of file to read.
2784432Seric **		fmt -- scanf string to use for match.
2794432Seric **
2804432Seric **	Returns:
2814432Seric **		none
2824432Seric **
2834432Seric **	Side Effects:
2844432Seric **
2854432Seric **		puts all lines in filename that match a scanf into
2864432Seric **			the named class.
2874432Seric */
2884432Seric 
2894432Seric fileclass(class, filename, fmt)
2904432Seric 	int class;
2914432Seric 	char *filename;
2924432Seric 	char *fmt;
2934432Seric {
2944432Seric 	register FILE *f;
2954432Seric 	char buf[MAXLINE];
2964432Seric 
2974432Seric 	f = fopen(filename, "r");
2984432Seric 	if (f == NULL)
2994432Seric 	{
3004432Seric 		syserr("cannot open %s", filename);
3014432Seric 		return;
3024432Seric 	}
3034432Seric 
3044432Seric 	while (fgets(buf, sizeof buf, f) != NULL)
3054432Seric 	{
3064432Seric 		register STAB *s;
3074432Seric 		char wordbuf[MAXNAME+1];
3084432Seric 
3094432Seric 		if (sscanf(buf, fmt, wordbuf) != 1)
3104432Seric 			continue;
3114432Seric 		s = stab(wordbuf, ST_CLASS, ST_ENTER);
3126275Seric 		s->s_class |= 1L << class;
3134432Seric 	}
3144432Seric 
3154627Seric 	(void) fclose(f);
3164432Seric }
3174432Seric /*
3184096Seric **  MAKEMAILER -- define a new mailer.
3194096Seric **
3204096Seric **	Parameters:
3214096Seric **		line -- description of mailer.  This is in tokens
3224096Seric **			separated by white space.  The fields are:
3234096Seric **			* the name of the mailer, as refered to
3244096Seric **			  in the rewriting rules.
3254096Seric **			* the pathname of the program to fork to
3264096Seric **			  execute it.
3274096Seric **			* the options needed by this program.
3284096Seric **			* the macro string needed to translate
3294096Seric **			  a local "from" name to one that can be
3304096Seric **			  returned to this machine.
3314096Seric **			* the argument vector (a series of parameters).
3324217Seric **		safe -- set if this is a safe configuration file.
3334096Seric **
3344096Seric **	Returns:
3354096Seric **		none.
3364096Seric **
3374096Seric **	Side Effects:
3384096Seric **		enters the mailer into the mailer table.
3394096Seric */
3403308Seric 
3414096Seric # define SETWORD \
3424096Seric 		{ \
3434096Seric 			while (*p != '\0' && isspace(*p)) \
3444096Seric 				p++; \
3454096Seric 			q = p; \
3464096Seric 			while (*p != '\0' && !isspace(*p)) \
3474096Seric 				p++; \
3484096Seric 			if (*p != '\0') \
3494096Seric 				*p++ = '\0'; \
3504096Seric 		}
3514096Seric 
3524217Seric makemailer(line, safe)
3534096Seric 	char *line;
3544217Seric 	bool safe;
3554096Seric {
3564096Seric 	register char *p;
3574096Seric 	register char *q;
3588067Seric 	register struct mailer *m;
3598067Seric 	register STAB *s;
3608067Seric 	int i;
3614096Seric 	char *mname;
3624096Seric 	char *mpath;
3634627Seric 	u_long mopts;
3648067Seric 	short mrset, msset;
3658067Seric 	char *margv[MAXPV + 1];
3664627Seric 	extern u_long mfencode();
3674096Seric 	extern int NextMailer;
3684096Seric 
3694096Seric 	if (NextMailer >= MAXMAILERS)
3704096Seric 	{
371*9381Seric 		syserr("too many mailers defined (%d max)", MAXMAILERS);
3724096Seric 		return;
3734096Seric 	}
3744096Seric 
3754096Seric 	/* collect initial information */
3764096Seric 	p = line;
3774096Seric 	SETWORD;
3784096Seric 	mname = q;
3794096Seric 	SETWORD;
3804096Seric 	mpath = q;
3814096Seric 	SETWORD;
3824627Seric 	mopts = mfencode(q);
3834217Seric 	if (!safe)
3844217Seric 		mopts &= ~M_RESTR;
3854096Seric 	SETWORD;
3868067Seric 	msset = atoi(q);
3878067Seric 	SETWORD;
3888067Seric 	mrset = atoi(q);
3894096Seric 
3904096Seric 	if (*p == '\0')
3914096Seric 	{
392*9381Seric 		syserr("invalid M line in configuration file");
3934096Seric 		return;
3944096Seric 	}
3958067Seric 	if (msset >= MAXRWSETS || mrset >= MAXRWSETS)
3968067Seric 	{
3978067Seric 		syserr("readcf: line %d: invalid rewrite set, %d max",
3988067Seric 			LineNumber, MAXRWSETS);
3998067Seric 		return;
4008067Seric 	}
4014096Seric 
4024096Seric 	/* allocate a mailer */
4034096Seric 	m = (struct mailer *) xalloc(sizeof *m);
4044096Seric 	m->m_name = newstr(mname);
4054096Seric 	m->m_mailer = newstr(mpath);
4064096Seric 	m->m_flags = mopts;
4078067Seric 	m->m_r_rwset = mrset;
4088067Seric 	m->m_s_rwset = msset;
4094439Seric 	m->m_mno = NextMailer;
4104096Seric 	Mailer[NextMailer++] = m;
4114096Seric 
4124096Seric 	/* collect the argument vector */
4134096Seric 	for (i = 0; i < MAXPV - 1 && *p != '\0'; i++)
4144096Seric 	{
4154096Seric 		SETWORD;
4164096Seric 		margv[i] = newstr(q);
4174096Seric 	}
4184096Seric 	margv[i++] = NULL;
4194096Seric 
4204096Seric 	/* save the argv */
4217009Seric 	m->m_argv = (char **) xalloc(sizeof margv[0] * i);
4224096Seric 	bmove((char *) margv, (char *) m->m_argv, sizeof margv[0] * i);
4234439Seric 	s = stab(m->m_name, ST_MAILER, ST_ENTER);
4244439Seric 	s->s_mailer = m;
4253308Seric }
4263308Seric /*
4273308Seric **  PRINTRULES -- print rewrite rules (for debugging)
4283308Seric **
4293308Seric **	Parameters:
4303308Seric **		none.
4313308Seric **
4323308Seric **	Returns:
4333308Seric **		none.
4343308Seric **
4353308Seric **	Side Effects:
4363308Seric **		prints rewrite rules.
4373308Seric */
4383308Seric 
4394319Seric # ifdef DEBUG
4404319Seric 
4413308Seric printrules()
4423308Seric {
4433308Seric 	register struct rewrite *rwp;
4444072Seric 	register int ruleset;
4453308Seric 
4464072Seric 	for (ruleset = 0; ruleset < 10; ruleset++)
4473308Seric 	{
4484072Seric 		if (RewriteRules[ruleset] == NULL)
4494072Seric 			continue;
4508067Seric 		printf("\n----Rule Set %d:", ruleset);
4513308Seric 
4524072Seric 		for (rwp = RewriteRules[ruleset]; rwp != NULL; rwp = rwp->r_next)
4533308Seric 		{
4548067Seric 			printf("\nLHS:");
4558067Seric 			printav(rwp->r_lhs);
4568067Seric 			printf("RHS:");
4578067Seric 			printav(rwp->r_rhs);
4583308Seric 		}
4593308Seric 	}
4603308Seric }
4614319Seric 
4624319Seric # endif DEBUG
4634096Seric /*
4644627Seric **  MFENCODE -- crack mailer options
4654096Seric **
4664096Seric **	These options modify the functioning of the mailer
4674096Seric **	from the configuration table.
4684096Seric **
4694096Seric **	Parameters:
4704096Seric **		p -- pointer to vector of options.
4714096Seric **
4724096Seric **	Returns:
4734096Seric **		option list in binary.
4744096Seric **
4754096Seric **	Side Effects:
4764096Seric **		none.
4774096Seric */
4784096Seric 
4794096Seric struct optlist
4804096Seric {
4814096Seric 	char	opt_name;	/* external name of option */
4826275Seric 	u_long	opt_value;	/* internal name of option */
4834096Seric };
4844096Seric struct optlist	OptList[] =
4854096Seric {
4864096Seric 	'f',	M_FOPT,
4874096Seric 	'r',	M_ROPT,
488*9381Seric 	'P',	M_RPATH,
4894096Seric 	'S',	M_RESTR,
4904096Seric 	'n',	M_NHDR,
4914197Seric 	'l',	M_LOCAL,
4924096Seric 	's',	M_STRIPQ,
4934096Seric 	'm',	M_MUSER,
4944096Seric 	'F',	M_NEEDFROM,
4954096Seric 	'D',	M_NEEDDATE,
4964096Seric 	'M',	M_MSGID,
4974096Seric 	'u',	M_USR_UPPER,
4984096Seric 	'h',	M_HST_UPPER,
4994096Seric 	'x',	M_FULLNAME,
5004096Seric 	'A',	M_ARPAFMT,
5015601Seric 	'U',	M_UGLYUUCP,
5025906Seric 	'e',	M_EXPENSIVE,
5036983Seric 	'X',	M_FULLSMTP,
5048182Seric 	'C',	M_CANONICAL,
5059315Seric 	'I',	M_INTERNAL,
5064319Seric 	'\0',	0
5074096Seric };
5084096Seric 
5094627Seric u_long
5104627Seric mfencode(p)
5114096Seric 	register char *p;
5124096Seric {
5134096Seric 	register struct optlist *o;
5144627Seric 	register u_long opts = 0;
5154096Seric 
5164096Seric 	while (*p != '\0')
5174096Seric 	{
5184096Seric 		for (o = OptList; o->opt_name != '\0' && o->opt_name != *p; o++)
5194096Seric 			continue;
5204096Seric 		if (o->opt_name == '\0')
5214096Seric 			syserr("bad mailer option %c", *p);
5224096Seric 		opts |= o->opt_value;
5234096Seric 		p++;
5244096Seric 	}
5254096Seric 	return (opts);
5264096Seric }
5274627Seric /*
5284627Seric **  MFDECODE -- decode mailer flags into external form.
5294627Seric **
5304627Seric **	Parameters:
5314627Seric **		flags -- value of flags to decode.
5324627Seric **		f -- file to write them onto.
5334627Seric **
5344627Seric **	Returns:
5354627Seric **		none.
5364627Seric **
5374627Seric **	Side Effects:
5384627Seric **		none.
5394627Seric */
5404627Seric 
5414627Seric mfdecode(flags, f)
5424627Seric 	u_long flags;
5434627Seric 	FILE *f;
5444627Seric {
5454627Seric 	register struct optlist *o;
5464627Seric 
5474627Seric 	putc('?', f);
5484627Seric 	for (o = OptList; o->opt_name != '\0'; o++)
5494627Seric 	{
5504627Seric 		if ((o->opt_value & flags) == o->opt_value)
5514627Seric 		{
5524627Seric 			flags &= ~o->opt_value;
5534627Seric 			putc(o->opt_name, f);
5544627Seric 		}
5554627Seric 	}
5564627Seric 	putc('?', f);
5574627Seric }
5588256Seric /*
5598256Seric **  SETOPTION -- set global processing option
5608256Seric **
5618256Seric **	Parameters:
5628256Seric **		opt -- option name.
5638256Seric **		val -- option value (as a text string).
5648269Seric **		safe -- if set, this came from a system configuration file.
5658269Seric **		sticky -- if set, don't let other setoptions override
5668269Seric **			this value.
5678256Seric **
5688256Seric **	Returns:
5698256Seric **		none.
5708256Seric **
5718256Seric **	Side Effects:
5728256Seric **		Sets options as implied by the arguments.
5738256Seric */
5748256Seric 
5758544Seric static int	StickyOpt[128 / sizeof (int)];	/* set if option is stuck */
5768544Seric extern char	*WizWord;			/* the stored wizard password */
5778269Seric 
5788269Seric setoption(opt, val, safe, sticky)
5798256Seric 	char opt;
5808256Seric 	char *val;
5818269Seric 	bool safe;
5828269Seric 	bool sticky;
5838256Seric {
5848269Seric 	int smask;
5858269Seric 	int sindex;
5868265Seric 	extern bool atobool();
5878256Seric 
5888256Seric # ifdef DEBUG
5898256Seric 	if (tTd(37, 1))
5909341Seric 		printf("setoption %c=%s", opt, val);
5918256Seric # endif DEBUG
5928256Seric 
5938256Seric 	/*
5948269Seric 	**  See if this option is preset for us.
5958256Seric 	*/
5968256Seric 
5978269Seric 	sindex = opt;
5988269Seric 	smask = 1 << (sindex % sizeof (int));
5998269Seric 	sindex /= sizeof (int);
6008269Seric 	if (bitset(smask, StickyOpt[sindex]))
6018269Seric 	{
6028269Seric # ifdef DEBUG
6039341Seric 		if (tTd(37, 1))
6049341Seric 			printf(" (ignored)\n");
6058269Seric # endif DEBUG
6068269Seric 		return;
6078269Seric 	}
6089341Seric #ifdef DEBUG
6099341Seric 	else if (tTd(37, 1))
6109341Seric 		printf("\n");
6119341Seric #endif DEBUG
6128269Seric 	if (sticky)
6138269Seric 		StickyOpt[sindex] |= smask;
6148269Seric 
6158269Seric 	if (getruid() == 0)
6168269Seric 		safe = TRUE;
6178269Seric 
6188256Seric 	switch (opt)
6198256Seric 	{
6208256Seric 	  case 'A':		/* set default alias file */
621*9381Seric 		if (val[0] == '\0')
6228269Seric 			AliasFile = "aliases";
623*9381Seric 		else
624*9381Seric 			AliasFile = newstr(val);
6258256Seric 		break;
6268256Seric 
6278931Seric 	  case 'a':		/* look for "@:@" in alias file */
628*9381Seric 		SafeAlias = atobool(val);
6298931Seric 		break;
6308931Seric 
6319284Seric 	  case 'c':		/* don't connect to "expensive" mailers */
632*9381Seric 		NoConnect = atobool(val);
6339284Seric 		break;
6349284Seric 
6359284Seric 	  case 'd':		/* delivery mode */
6369284Seric 		switch (*val)
6378269Seric 		{
6389284Seric 		  case '\0':
6399284Seric 			SendMode = SM_DELIVER;
6408269Seric 			break;
6418269Seric 
6429284Seric 		  case SM_DELIVER:	/* do everything */
6439284Seric 		  case SM_FORK:		/* fork after verification */
6449284Seric 		  case SM_QUEUE:	/* queue only */
6459284Seric 			SendMode = *val;
6468269Seric 			break;
6478269Seric 
6488269Seric 		  default:
6499284Seric 			syserr("Unknown delivery mode %c", *val);
6508269Seric 			exit(EX_USAGE);
6518269Seric 		}
6528269Seric 		break;
6538269Seric 
6549146Seric 	  case 'D':		/* rebuild alias database as needed */
655*9381Seric 		AutoRebuild = atobool(val);
6569146Seric 		break;
6579146Seric 
6588269Seric 	  case 'e':		/* set error processing mode */
6598269Seric 		switch (*val)
6608269Seric 		{
661*9381Seric 		  case EM_QUIET:	/* be silent about it */
6628269Seric 			(void) freopen("/dev/null", "w", stdout);
663*9381Seric 			/* fall through... */
6648269Seric 
665*9381Seric 		  case EM_MAIL:		/* mail back */
666*9381Seric 		  case EM_BERKNET:	/* do berknet error processing */
667*9381Seric 		  case EM_WRITE:	/* write back (or mail) */
6688269Seric 			HoldErrs = TRUE;
669*9381Seric 			/* fall through... */
6708269Seric 
671*9381Seric 		  case EM_PRINT:	/* print errors normally (default) */
672*9381Seric 			ErrorMode = *val;
6738269Seric 			break;
6748269Seric 		}
6758269Seric 		break;
6768269Seric 
6779049Seric 	  case 'F':		/* file mode */
678*9381Seric 		FileMode = atooct(val);
6799049Seric 		break;
6809049Seric 
6818269Seric 	  case 'f':		/* save Unix-style From lines on front */
682*9381Seric 		SaveFrom = atobool(val);
6838269Seric 		break;
6848269Seric 
6858256Seric 	  case 'g':		/* default gid */
6869105Seric 		if (safe)
687*9381Seric 			DefGid = atoi(val);
6888256Seric 		break;
6898256Seric 
6908256Seric 	  case 'H':		/* help file */
691*9381Seric 		if (val[0] == '\0')
6928269Seric 			HelpFile = "sendmail.hf";
693*9381Seric 		else
694*9381Seric 			HelpFile = newstr(val);
6958256Seric 		break;
6968256Seric 
6978269Seric 	  case 'i':		/* ignore dot lines in message */
698*9381Seric 		IgnrDot = atobool(val);
6998269Seric 		break;
7008269Seric 
7018256Seric 	  case 'L':		/* log level */
702*9381Seric 		LogLevel = atoi(val);
7038256Seric 		break;
7048256Seric 
7058269Seric 	  case 'M':		/* define macro */
706*9381Seric 		define(val[0], newstr(&val[1]), CurEnv);
7078269Seric 		break;
7088269Seric 
7098269Seric 	  case 'm':		/* send to me too */
710*9381Seric 		MeToo = atobool(val);
7118269Seric 		break;
7128269Seric 
7138269Seric 	  case 'o':		/* assume old style headers */
714*9381Seric 		if (atobool(val))
7159341Seric 			CurEnv->e_flags |= EF_OLDSTYLE;
7169341Seric 		else
7179341Seric 			CurEnv->e_flags &= ~EF_OLDSTYLE;
7188269Seric 		break;
7198269Seric 
7208256Seric 	  case 'Q':		/* queue directory */
721*9381Seric 		if (val[0] == '\0')
7228269Seric 			QueueDir = "mqueue";
723*9381Seric 		else
724*9381Seric 			QueueDir = newstr(val);
7258256Seric 		break;
7268256Seric 
7278256Seric 	  case 'r':		/* read timeout */
728*9381Seric 		ReadTimeout = convtime(val);
7298256Seric 		break;
7308256Seric 
7318256Seric 	  case 'S':		/* status file */
732*9381Seric 		if (val[0] == '\0')
7338269Seric 			StatFile = "sendmail.st";
734*9381Seric 		else
735*9381Seric 			StatFile = newstr(val);
7368256Seric 		break;
7378256Seric 
7388265Seric 	  case 's':		/* be super safe, even if expensive */
739*9381Seric 		SuperSafe = atobool(val);
7408256Seric 		break;
7418256Seric 
7428256Seric 	  case 'T':		/* queue timeout */
743*9381Seric 		TimeOut = convtime(val);
7448256Seric 		break;
7458256Seric 
7468265Seric 	  case 't':		/* time zone name */
7478265Seric # ifdef V6
748*9381Seric 		StdTimezone = newstr(val);
749*9381Seric 		DstTimezone = index(StdTimeZone, ',');
7508265Seric 		if (DstTimezone == NULL)
751*9381Seric 			syserr("bad time zone spec");
752*9381Seric 		else
753*9381Seric 			*DstTimezone++ = '\0';
7548265Seric # endif V6
7558265Seric 		break;
7568265Seric 
7578256Seric 	  case 'u':		/* set default uid */
7589105Seric 		if (safe)
759*9381Seric 			DefUid = atoi(val);
7608256Seric 		break;
7618256Seric 
7628269Seric 	  case 'v':		/* run in verbose mode */
763*9381Seric 		Verbose = atobool(val);
7648256Seric 		break;
7658256Seric 
7668544Seric # ifdef DEBUG
7678544Seric 	  case 'W':		/* set the wizards password */
7689105Seric 		if (safe)
769*9381Seric 			WizWord = newstr(val);
7708544Seric 		break;
7718544Seric # endif DEBUG
7728544Seric 
7738256Seric 	  default:
7748256Seric 		break;
7758256Seric 	}
7769188Seric 	return;
7778256Seric }
778