13313Seric # include "sendmail.h" 23308Seric 3*9350Seric SCCSID(@(#)readcf.c 3.47 11/24/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; 57*9350Seric struct rewrite *rwp = NULL; 583308Seric char buf[MAXLINE]; 593308Seric register char *p; 603308Seric extern char **prescan(); 613308Seric extern char **copyplist(); 625909Seric char exbuf[MAXLINE]; 63*9350Seric 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 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 { 878056Seric syserr("line %d: invalid rewrite line \"%s\"", 888056Seric LineNumber, 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 { 1298056Seric syserr("readcf: line %d: bad ruleset %d (%d max)", 1308056Seric LineNumber, ruleset, MAXRWSETS); 1318056Seric ruleset = 0; 1328056Seric } 1334072Seric rwp = NULL; 1344072Seric break; 1354072Seric 1363308Seric case 'D': /* macro definition */ 1373308Seric define(buf[1], newstr(&buf[2])); 1383308Seric break; 1393308Seric 1403387Seric case 'H': /* required header line */ 1414088Seric (void) chompheader(&buf[1], TRUE); 1423387Seric break; 1433387Seric 1444061Seric case 'C': /* word class */ 1454432Seric case 'F': /* word class from file */ 1464061Seric class = buf[1]; 1474061Seric if (!isalpha(class)) 1484061Seric goto badline; 1494061Seric if (isupper(class)) 1504061Seric class -= 'A'; 1514061Seric else 1524061Seric class -= 'a'; 1534432Seric 1544432Seric /* read list of words from argument or file */ 1554432Seric if (buf[0] == 'F') 1564432Seric { 1574432Seric /* read from file */ 1584432Seric for (p = &buf[2]; *p != '\0' && !isspace(*p); p++) 1594432Seric continue; 1604432Seric if (*p == '\0') 1614432Seric p = "%s"; 1624432Seric else 1634432Seric { 1644432Seric *p = '\0'; 1654432Seric while (isspace(*++p)) 1664432Seric continue; 1674432Seric } 1684432Seric fileclass(class, &buf[2], p); 1694432Seric break; 1704432Seric } 1714061Seric 1724432Seric /* scan the list of words and set class for all */ 1734061Seric for (p = &buf[2]; *p != '\0'; ) 1744061Seric { 1754061Seric register char *wd; 1764061Seric char delim; 1774061Seric register STAB *s; 1784061Seric 1794061Seric while (*p != '\0' && isspace(*p)) 1804061Seric p++; 1814061Seric wd = p; 1824061Seric while (*p != '\0' && !isspace(*p)) 1834061Seric p++; 1844061Seric delim = *p; 1854061Seric *p = '\0'; 1864061Seric if (wd[0] != '\0') 1874061Seric { 1884103Seric s = stab(wd, ST_CLASS, ST_ENTER); 1896275Seric s->s_class |= 1L << class; 1904061Seric } 1914061Seric *p = delim; 1924061Seric } 1934061Seric break; 1944061Seric 1954096Seric case 'M': /* define mailer */ 1964217Seric makemailer(&buf[1], safe); 1974096Seric break; 1984096Seric 1998252Seric case 'O': /* set option */ 2008269Seric setoption(buf[1], &buf[2], safe, FALSE); 2018252Seric break; 2028252Seric 2038252Seric case 'P': /* set precedence */ 2048252Seric if (NumPriorities >= MAXPRIORITIES) 2058252Seric { 2068547Seric toomany('P', MAXPRIORITIES); 2078252Seric break; 2088252Seric } 2098252Seric for (p = &buf[1]; *p != '\0' && *p != '='; p++) 2108252Seric continue; 2118252Seric if (*p == '\0') 2128252Seric goto badline; 2138252Seric *p = '\0'; 2148252Seric Priorities[NumPriorities].pri_name = newstr(&buf[1]); 2158252Seric Priorities[NumPriorities].pri_val = atoi(++p); 2168252Seric NumPriorities++; 2178252Seric break; 2188252Seric 2198547Seric case 'T': /* trusted user(s) */ 2208547Seric p = &buf[1]; 2218547Seric while (*p != '\0') 2228547Seric { 2238547Seric while (isspace(*p)) 2248547Seric p++; 2258547Seric q = p; 2268547Seric while (*p != '\0' && !isspace(*p)) 2278547Seric p++; 2288547Seric if (*p != '\0') 2298547Seric *p++ = '\0'; 2308547Seric if (*q == '\0') 2318547Seric continue; 2328547Seric for (pv = TrustedUsers; *pv != NULL; pv++) 2338547Seric continue; 2348547Seric if (pv >= &TrustedUsers[MAXTRUST]) 2358547Seric { 2368547Seric toomany('T', MAXTRUST); 2378547Seric break; 2388547Seric } 2398547Seric *pv = newstr(q); 2408547Seric } 2418547Seric break; 2428547Seric 2433308Seric default: 2444061Seric badline: 2458056Seric syserr("readcf: line %d: unknown control line \"%s\"", 2468056Seric LineNumber, buf); 2473308Seric } 2483308Seric } 2494096Seric } 2504096Seric /* 2518547Seric ** TOOMANY -- signal too many of some option 2528547Seric ** 2538547Seric ** Parameters: 2548547Seric ** id -- the id of the error line 2558547Seric ** maxcnt -- the maximum possible values 2568547Seric ** 2578547Seric ** Returns: 2588547Seric ** none. 2598547Seric ** 2608547Seric ** Side Effects: 2618547Seric ** gives a syserr. 2628547Seric */ 2638547Seric 2648547Seric toomany(id, maxcnt) 2658547Seric char id; 2668547Seric int maxcnt; 2678547Seric { 2688547Seric syserr("readcf: line %d: too many %c lines, %d max", 2698547Seric LineNumber, id, maxcnt); 2708547Seric } 2718547Seric /* 2724432Seric ** FILECLASS -- read members of a class from a file 2734432Seric ** 2744432Seric ** Parameters: 2754432Seric ** class -- class to define. 2764432Seric ** filename -- name of file to read. 2774432Seric ** fmt -- scanf string to use for match. 2784432Seric ** 2794432Seric ** Returns: 2804432Seric ** none 2814432Seric ** 2824432Seric ** Side Effects: 2834432Seric ** 2844432Seric ** puts all lines in filename that match a scanf into 2854432Seric ** the named class. 2864432Seric */ 2874432Seric 2884432Seric fileclass(class, filename, fmt) 2894432Seric int class; 2904432Seric char *filename; 2914432Seric char *fmt; 2924432Seric { 2934432Seric register FILE *f; 2944432Seric char buf[MAXLINE]; 2954432Seric 2964432Seric f = fopen(filename, "r"); 2974432Seric if (f == NULL) 2984432Seric { 2994432Seric syserr("cannot open %s", filename); 3004432Seric return; 3014432Seric } 3024432Seric 3034432Seric while (fgets(buf, sizeof buf, f) != NULL) 3044432Seric { 3054432Seric register STAB *s; 3064432Seric char wordbuf[MAXNAME+1]; 3074432Seric 3084432Seric if (sscanf(buf, fmt, wordbuf) != 1) 3094432Seric continue; 3104432Seric s = stab(wordbuf, ST_CLASS, ST_ENTER); 3116275Seric s->s_class |= 1L << class; 3124432Seric } 3134432Seric 3144627Seric (void) fclose(f); 3154432Seric } 3164432Seric /* 3174096Seric ** MAKEMAILER -- define a new mailer. 3184096Seric ** 3194096Seric ** Parameters: 3204096Seric ** line -- description of mailer. This is in tokens 3214096Seric ** separated by white space. The fields are: 3224096Seric ** * the name of the mailer, as refered to 3234096Seric ** in the rewriting rules. 3244096Seric ** * the pathname of the program to fork to 3254096Seric ** execute it. 3264096Seric ** * the options needed by this program. 3274096Seric ** * the macro string needed to translate 3284096Seric ** a local "from" name to one that can be 3294096Seric ** returned to this machine. 3304096Seric ** * the argument vector (a series of parameters). 3314217Seric ** safe -- set if this is a safe configuration file. 3324096Seric ** 3334096Seric ** Returns: 3344096Seric ** none. 3354096Seric ** 3364096Seric ** Side Effects: 3374096Seric ** enters the mailer into the mailer table. 3384096Seric */ 3393308Seric 3404096Seric # define SETWORD \ 3414096Seric { \ 3424096Seric while (*p != '\0' && isspace(*p)) \ 3434096Seric p++; \ 3444096Seric q = p; \ 3454096Seric while (*p != '\0' && !isspace(*p)) \ 3464096Seric p++; \ 3474096Seric if (*p != '\0') \ 3484096Seric *p++ = '\0'; \ 3494096Seric } 3504096Seric 3514217Seric makemailer(line, safe) 3524096Seric char *line; 3534217Seric bool safe; 3544096Seric { 3554096Seric register char *p; 3564096Seric register char *q; 3578067Seric register struct mailer *m; 3588067Seric register STAB *s; 3598067Seric int i; 3604096Seric char *mname; 3614096Seric char *mpath; 3624627Seric u_long mopts; 3638067Seric short mrset, msset; 3648067Seric char *margv[MAXPV + 1]; 3654627Seric extern u_long mfencode(); 3664096Seric extern int NextMailer; 3674096Seric 3684096Seric if (NextMailer >= MAXMAILERS) 3694096Seric { 3708056Seric syserr("readcf: line %d: too many mailers defined (%d max)", 3718056Seric LineNumber, 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 { 3928056Seric syserr("readcf: line %d: invalid M line in configuration file", 3938056Seric LineNumber); 3944096Seric return; 3954096Seric } 3968067Seric if (msset >= MAXRWSETS || mrset >= MAXRWSETS) 3978067Seric { 3988067Seric syserr("readcf: line %d: invalid rewrite set, %d max", 3998067Seric LineNumber, MAXRWSETS); 4008067Seric return; 4018067Seric } 4024096Seric 4034096Seric /* allocate a mailer */ 4044096Seric m = (struct mailer *) xalloc(sizeof *m); 4054096Seric m->m_name = newstr(mname); 4064096Seric m->m_mailer = newstr(mpath); 4074096Seric m->m_flags = mopts; 4088067Seric m->m_r_rwset = mrset; 4098067Seric m->m_s_rwset = msset; 4104096Seric m->m_badstat = EX_UNAVAILABLE; 4114439Seric m->m_mno = NextMailer; 4124096Seric Mailer[NextMailer++] = m; 4134096Seric 4144096Seric /* collect the argument vector */ 4154096Seric for (i = 0; i < MAXPV - 1 && *p != '\0'; i++) 4164096Seric { 4174096Seric SETWORD; 4184096Seric margv[i] = newstr(q); 4194096Seric } 4204096Seric margv[i++] = NULL; 4214096Seric 4224096Seric /* save the argv */ 4237009Seric m->m_argv = (char **) xalloc(sizeof margv[0] * i); 4244096Seric bmove((char *) margv, (char *) m->m_argv, sizeof margv[0] * i); 4254439Seric s = stab(m->m_name, ST_MAILER, ST_ENTER); 4264439Seric s->s_mailer = m; 4273308Seric } 4283308Seric /* 4293308Seric ** PRINTRULES -- print rewrite rules (for debugging) 4303308Seric ** 4313308Seric ** Parameters: 4323308Seric ** none. 4333308Seric ** 4343308Seric ** Returns: 4353308Seric ** none. 4363308Seric ** 4373308Seric ** Side Effects: 4383308Seric ** prints rewrite rules. 4393308Seric */ 4403308Seric 4414319Seric # ifdef DEBUG 4424319Seric 4433308Seric printrules() 4443308Seric { 4453308Seric register struct rewrite *rwp; 4464072Seric register int ruleset; 4473308Seric 4484072Seric for (ruleset = 0; ruleset < 10; ruleset++) 4493308Seric { 4504072Seric if (RewriteRules[ruleset] == NULL) 4514072Seric continue; 4528067Seric printf("\n----Rule Set %d:", ruleset); 4533308Seric 4544072Seric for (rwp = RewriteRules[ruleset]; rwp != NULL; rwp = rwp->r_next) 4553308Seric { 4568067Seric printf("\nLHS:"); 4578067Seric printav(rwp->r_lhs); 4588067Seric printf("RHS:"); 4598067Seric printav(rwp->r_rhs); 4603308Seric } 4613308Seric } 4623308Seric } 4634319Seric 4644319Seric # endif DEBUG 4654096Seric /* 4664627Seric ** MFENCODE -- crack mailer options 4674096Seric ** 4684096Seric ** These options modify the functioning of the mailer 4694096Seric ** from the configuration table. 4704096Seric ** 4714096Seric ** Parameters: 4724096Seric ** p -- pointer to vector of options. 4734096Seric ** 4744096Seric ** Returns: 4754096Seric ** option list in binary. 4764096Seric ** 4774096Seric ** Side Effects: 4784096Seric ** none. 4794096Seric */ 4804096Seric 4814096Seric struct optlist 4824096Seric { 4834096Seric char opt_name; /* external name of option */ 4846275Seric u_long opt_value; /* internal name of option */ 4854096Seric }; 4864096Seric struct optlist OptList[] = 4874096Seric { 4884096Seric 'f', M_FOPT, 4894096Seric 'r', M_ROPT, 4904096Seric 'q', M_QUIET, 4914096Seric 'S', M_RESTR, 4924096Seric 'n', M_NHDR, 4934197Seric 'l', M_LOCAL, 4944096Seric 's', M_STRIPQ, 4954096Seric 'm', M_MUSER, 4964096Seric 'F', M_NEEDFROM, 4974096Seric 'D', M_NEEDDATE, 4984096Seric 'M', M_MSGID, 4994096Seric 'u', M_USR_UPPER, 5004096Seric 'h', M_HST_UPPER, 5014096Seric 'x', M_FULLNAME, 5024096Seric 'A', M_ARPAFMT, 5035601Seric 'U', M_UGLYUUCP, 5045906Seric 'e', M_EXPENSIVE, 5056983Seric 'X', M_FULLSMTP, 5068182Seric 'C', M_CANONICAL, 5079315Seric 'I', M_INTERNAL, 5084319Seric '\0', 0 5094096Seric }; 5104096Seric 5114627Seric u_long 5124627Seric mfencode(p) 5134096Seric register char *p; 5144096Seric { 5154096Seric register struct optlist *o; 5164627Seric register u_long opts = 0; 5174096Seric 5184096Seric while (*p != '\0') 5194096Seric { 5204096Seric for (o = OptList; o->opt_name != '\0' && o->opt_name != *p; o++) 5214096Seric continue; 5224096Seric if (o->opt_name == '\0') 5234096Seric syserr("bad mailer option %c", *p); 5244096Seric opts |= o->opt_value; 5254096Seric p++; 5264096Seric } 5274096Seric return (opts); 5284096Seric } 5294627Seric /* 5304627Seric ** MFDECODE -- decode mailer flags into external form. 5314627Seric ** 5324627Seric ** Parameters: 5334627Seric ** flags -- value of flags to decode. 5344627Seric ** f -- file to write them onto. 5354627Seric ** 5364627Seric ** Returns: 5374627Seric ** none. 5384627Seric ** 5394627Seric ** Side Effects: 5404627Seric ** none. 5414627Seric */ 5424627Seric 5434627Seric mfdecode(flags, f) 5444627Seric u_long flags; 5454627Seric FILE *f; 5464627Seric { 5474627Seric register struct optlist *o; 5484627Seric 5494627Seric putc('?', f); 5504627Seric for (o = OptList; o->opt_name != '\0'; o++) 5514627Seric { 5524627Seric if ((o->opt_value & flags) == o->opt_value) 5534627Seric { 5544627Seric flags &= ~o->opt_value; 5554627Seric putc(o->opt_name, f); 5564627Seric } 5574627Seric } 5584627Seric putc('?', f); 5594627Seric } 5608256Seric /* 5618256Seric ** SETOPTION -- set global processing option 5628256Seric ** 5638256Seric ** Parameters: 5648256Seric ** opt -- option name. 5658256Seric ** val -- option value (as a text string). 5668269Seric ** safe -- if set, this came from a system configuration file. 5678269Seric ** sticky -- if set, don't let other setoptions override 5688269Seric ** this value. 5698256Seric ** 5708256Seric ** Returns: 5718256Seric ** none. 5728256Seric ** 5738256Seric ** Side Effects: 5748256Seric ** Sets options as implied by the arguments. 5758256Seric */ 5768256Seric 5778544Seric static int StickyOpt[128 / sizeof (int)]; /* set if option is stuck */ 5788544Seric extern char *WizWord; /* the stored wizard password */ 5798269Seric 5808269Seric setoption(opt, val, safe, sticky) 5818256Seric char opt; 5828256Seric char *val; 5838269Seric bool safe; 5848269Seric bool sticky; 5858256Seric { 5868256Seric time_t tval; 5878256Seric int ival; 5888265Seric bool bval; 5898269Seric int smask; 5908269Seric int sindex; 5918265Seric extern bool atobool(); 5928256Seric 5938256Seric # ifdef DEBUG 5948256Seric if (tTd(37, 1)) 5959341Seric printf("setoption %c=%s", opt, val); 5968256Seric # endif DEBUG 5978256Seric 5988256Seric /* 5998269Seric ** See if this option is preset for us. 6008256Seric */ 6018256Seric 6028269Seric sindex = opt; 6038269Seric smask = 1 << (sindex % sizeof (int)); 6048269Seric sindex /= sizeof (int); 6058269Seric if (bitset(smask, StickyOpt[sindex])) 6068269Seric { 6078269Seric # ifdef DEBUG 6089341Seric if (tTd(37, 1)) 6099341Seric printf(" (ignored)\n"); 6108269Seric # endif DEBUG 6118269Seric return; 6128269Seric } 6139341Seric #ifdef DEBUG 6149341Seric else if (tTd(37, 1)) 6159341Seric printf("\n"); 6169341Seric #endif DEBUG 6178269Seric if (sticky) 6188269Seric StickyOpt[sindex] |= smask; 6198269Seric 6208269Seric if (getruid() == 0) 6218269Seric safe = TRUE; 6228269Seric 6238269Seric /* 6248269Seric ** Encode this option as appropriate. 6258269Seric */ 6268269Seric 6278256Seric if (index("rT", opt) != NULL) 6288256Seric tval = convtime(val); 6298256Seric else if (index("gLu", opt) != NULL) 6308256Seric ival = atoi(val); 6319049Seric else if (index("F", opt) != NULL) 6329049Seric ival = atooct(val); 6339146Seric else if (index("acDfimosv", opt) != NULL) 6348265Seric bval = atobool(val); 6358269Seric else if (index("be", opt) != NULL) 6368269Seric /* do nothing */ ; 6378256Seric else if (val[0] == '\0') 6388256Seric val = ""; 6398256Seric else 6408256Seric val = newstr(val); 6418256Seric 6428256Seric /* 6438256Seric ** Now do the actual assignment. 6448256Seric */ 6458256Seric 6468256Seric switch (opt) 6478256Seric { 6488256Seric case 'A': /* set default alias file */ 6498256Seric AliasFile = val; 6508269Seric if (AliasFile[0] == '\0') 6518269Seric AliasFile = "aliases"; 6528256Seric break; 6538256Seric 6548931Seric case 'a': /* look for "@:@" in alias file */ 6558931Seric SafeAlias = bval; 6568931Seric break; 6578931Seric 6589284Seric case 'c': /* don't connect to "expensive" mailers */ 6599284Seric NoConnect = bval; 6609284Seric break; 6619284Seric 6629284Seric case 'd': /* delivery mode */ 6639284Seric switch (*val) 6648269Seric { 6659284Seric case '\0': 6669284Seric SendMode = SM_DELIVER; 6678269Seric break; 6688269Seric 6699284Seric case SM_DELIVER: /* do everything */ 6709284Seric case SM_FORK: /* fork after verification */ 6719284Seric case SM_QUEUE: /* queue only */ 6729284Seric SendMode = *val; 6738269Seric break; 6748269Seric 6758269Seric default: 6769284Seric syserr("Unknown delivery mode %c", *val); 6778269Seric exit(EX_USAGE); 6788269Seric } 6798269Seric break; 6808269Seric 6819146Seric case 'D': /* rebuild alias database as needed */ 6829146Seric AutoRebuild = bval; 6839146Seric break; 6849146Seric 6858269Seric case 'e': /* set error processing mode */ 6868269Seric switch (*val) 6878269Seric { 6888269Seric case 'p': /* print errors normally */ 6898269Seric break; /* (default) */ 6908269Seric 6918269Seric case 'q': /* be silent about it */ 6928269Seric (void) freopen("/dev/null", "w", stdout); 6938269Seric break; 6948269Seric 6958269Seric case 'm': /* mail back */ 6968269Seric MailBack = TRUE; 6978269Seric HoldErrs = TRUE; 6988269Seric break; 6998269Seric 7008269Seric case 'e': /* do berknet error processing */ 7018269Seric BerkNet = TRUE; 7028269Seric HoldErrs = TRUE; 7038269Seric break; 7048269Seric 7058269Seric case 'w': /* write back (or mail) */ 7068269Seric WriteBack = TRUE; 7078269Seric HoldErrs = TRUE; 7088269Seric break; 7098269Seric } 7108269Seric break; 7118269Seric 7129049Seric case 'F': /* file mode */ 7139049Seric FileMode = ival; 7149049Seric break; 7159049Seric 7168269Seric case 'f': /* save Unix-style From lines on front */ 7178269Seric SaveFrom = bval; 7188269Seric break; 7198269Seric 7208256Seric case 'g': /* default gid */ 7219105Seric if (safe) 7229105Seric DefGid = ival; 7238256Seric break; 7248256Seric 7258256Seric case 'H': /* help file */ 7268256Seric HelpFile = val; 7278269Seric if (HelpFile[0] == '\0') 7288269Seric HelpFile = "sendmail.hf"; 7298256Seric break; 7308256Seric 7318269Seric case 'i': /* ignore dot lines in message */ 7328269Seric IgnrDot = bval; 7338269Seric break; 7348269Seric 7358256Seric case 'L': /* log level */ 7368256Seric LogLevel = ival; 7378256Seric break; 7388256Seric 7398269Seric case 'M': /* define macro */ 7408269Seric define(val[0], &val[1]); 7418269Seric break; 7428269Seric 7438269Seric case 'm': /* send to me too */ 7448269Seric MeToo = bval; 7458269Seric break; 7468269Seric 7478269Seric case 'o': /* assume old style headers */ 7489341Seric if (bval) 7499341Seric CurEnv->e_flags |= EF_OLDSTYLE; 7509341Seric else 7519341Seric CurEnv->e_flags &= ~EF_OLDSTYLE; 7528269Seric break; 7538269Seric 7548256Seric case 'Q': /* queue directory */ 7558256Seric QueueDir = val; 7568269Seric if (QueueDir[0] == '\0') 7578269Seric QueueDir = "mqueue"; 7588256Seric break; 7598256Seric 7608256Seric case 'r': /* read timeout */ 7618256Seric ReadTimeout = tval; 7628256Seric break; 7638256Seric 7648256Seric case 'S': /* status file */ 7658256Seric StatFile = val; 7668269Seric if (StatFile[0] == '\0') 7678269Seric StatFile = "sendmail.st"; 7688256Seric break; 7698256Seric 7708265Seric case 's': /* be super safe, even if expensive */ 7718265Seric SuperSafe = bval; 7728256Seric break; 7738256Seric 7748256Seric case 'T': /* queue timeout */ 7758256Seric TimeOut = tval; 7768256Seric break; 7778256Seric 7788265Seric case 't': /* time zone name */ 7798265Seric # ifdef V6 7808265Seric StdTimezone = val; 7818265Seric DstTimezone = index(val, ','); 7828265Seric if (DstTimezone == NULL) 7838265Seric goto syntax; 7848265Seric *DstTimezone++ = '\0'; 7858265Seric # endif V6 7868265Seric break; 7878265Seric 7888256Seric case 'u': /* set default uid */ 7899105Seric if (safe) 7909105Seric DefUid = ival; 7918256Seric break; 7928256Seric 7938269Seric case 'v': /* run in verbose mode */ 7948269Seric Verbose = bval; 7958256Seric break; 7968256Seric 7978544Seric # ifdef DEBUG 7988544Seric case 'W': /* set the wizards password */ 7999105Seric if (safe) 8009105Seric WizWord = val; 8018544Seric break; 8028544Seric # endif DEBUG 8038544Seric 8048256Seric default: 8058256Seric break; 8068256Seric } 8079188Seric return; 8089188Seric 8099188Seric syntax: 8109188Seric syserr("setoption: line %d: syntax error on \"%c%s\"", 8119188Seric LineNumber, opt, val); 8128256Seric } 813