122709Sdist /* 222709Sdist ** Sendmail 322709Sdist ** Copyright (c) 1983 Eric P. Allman 422709Sdist ** Berkeley, California 522709Sdist ** 622709Sdist ** Copyright (c) 1983 Regents of the University of California. 722709Sdist ** All rights reserved. The Berkeley software License Agreement 822709Sdist ** specifies the terms and conditions for redistribution. 922709Sdist */ 1022709Sdist 1122709Sdist #ifndef lint 12*23111Seric static char SccsId[] = "@(#)readcf.c 5.3 (Berkeley) 06/08/85"; 1322709Sdist #endif not lint 1422709Sdist 153313Seric # include "sendmail.h" 163308Seric 173308Seric /* 183308Seric ** READCF -- read control file. 193308Seric ** 203308Seric ** This routine reads the control file and builds the internal 213308Seric ** form. 223308Seric ** 234432Seric ** The file is formatted as a sequence of lines, each taken 244432Seric ** atomically. The first character of each line describes how 254432Seric ** the line is to be interpreted. The lines are: 264432Seric ** Dxval Define macro x to have value val. 274432Seric ** Cxword Put word into class x. 284432Seric ** Fxfile [fmt] Read file for lines to put into 294432Seric ** class x. Use scanf string 'fmt' 304432Seric ** or "%s" if not present. Fmt should 314432Seric ** only produce one string-valued result. 324432Seric ** Hname: value Define header with field-name 'name' 334432Seric ** and value as specified; this will be 344432Seric ** macro expanded immediately before 354432Seric ** use. 364432Seric ** Sn Use rewriting set n. 374432Seric ** Rlhs rhs Rewrite addresses that match lhs to 384432Seric ** be rhs. 398252Seric ** Mn p f s r a Define mailer. n - internal name, 408252Seric ** p - pathname, f - flags, s - rewriting 418252Seric ** ruleset for sender, s - rewriting ruleset 428252Seric ** for recipients, a - argument vector. 438252Seric ** Oxvalue Set option x to value. 448252Seric ** Pname=value Set precedence name to value. 454432Seric ** 463308Seric ** Parameters: 473308Seric ** cfname -- control file name. 483308Seric ** 493308Seric ** Returns: 503308Seric ** none. 513308Seric ** 523308Seric ** Side Effects: 533308Seric ** Builds several internal tables. 543308Seric */ 553308Seric 5621066Seric readcf(cfname) 573308Seric char *cfname; 583308Seric { 593308Seric FILE *cf; 608547Seric int ruleset = 0; 618547Seric char *q; 628547Seric char **pv; 639350Seric struct rewrite *rwp = NULL; 643308Seric char buf[MAXLINE]; 653308Seric register char *p; 663308Seric extern char **prescan(); 673308Seric extern char **copyplist(); 685909Seric char exbuf[MAXLINE]; 6916915Seric char pvpbuf[PSBUFSIZE]; 709350Seric extern char *fgetfolded(); 7110709Seric extern char *munchstring(); 723308Seric 733308Seric cf = fopen(cfname, "r"); 743308Seric if (cf == NULL) 753308Seric { 763308Seric syserr("cannot open %s", cfname); 773308Seric exit(EX_OSFILE); 783308Seric } 793308Seric 809381Seric FileName = cfname; 818056Seric LineNumber = 0; 827854Seric while (fgetfolded(buf, sizeof buf, cf) != NULL) 833308Seric { 8416157Seric /* map $ into \001 (ASCII SOH) for macro expansion */ 8516157Seric for (p = buf; *p != '\0'; p++) 8616157Seric { 8716157Seric if (*p != '$') 8816157Seric continue; 8916157Seric 9016157Seric if (p[1] == '$') 9116157Seric { 9216157Seric /* actual dollar sign.... */ 93*23111Seric (void) strcpy(p, p + 1); 9416157Seric continue; 9516157Seric } 9616157Seric 9716157Seric /* convert to macro expansion character */ 9816157Seric *p = '\001'; 9916157Seric } 10016157Seric 10116157Seric /* interpret this line */ 1023308Seric switch (buf[0]) 1033308Seric { 1043308Seric case '\0': 1053308Seric case '#': /* comment */ 1063308Seric break; 1073308Seric 1083308Seric case 'R': /* rewriting rule */ 1093308Seric for (p = &buf[1]; *p != '\0' && *p != '\t'; p++) 1103308Seric continue; 1113308Seric 1123308Seric if (*p == '\0') 1135909Seric { 1149381Seric syserr("invalid rewrite line \"%s\"", buf); 1155909Seric break; 1165909Seric } 1175909Seric 1185909Seric /* allocate space for the rule header */ 1195909Seric if (rwp == NULL) 1205909Seric { 1215909Seric RewriteRules[ruleset] = rwp = 1225909Seric (struct rewrite *) xalloc(sizeof *rwp); 1235909Seric } 1243308Seric else 1253308Seric { 1265909Seric rwp->r_next = (struct rewrite *) xalloc(sizeof *rwp); 1275909Seric rwp = rwp->r_next; 1285909Seric } 1295909Seric rwp->r_next = NULL; 1303308Seric 1315909Seric /* expand and save the LHS */ 1325909Seric *p = '\0'; 1336991Seric expand(&buf[1], exbuf, &exbuf[sizeof exbuf], CurEnv); 13416915Seric rwp->r_lhs = prescan(exbuf, '\t', pvpbuf); 1355909Seric if (rwp->r_lhs != NULL) 1365909Seric rwp->r_lhs = copyplist(rwp->r_lhs, TRUE); 1375909Seric 1385909Seric /* expand and save the RHS */ 1395909Seric while (*++p == '\t') 1405909Seric continue; 1417231Seric q = p; 1427231Seric while (*p != '\0' && *p != '\t') 1437231Seric p++; 1447231Seric *p = '\0'; 1457231Seric expand(q, exbuf, &exbuf[sizeof exbuf], CurEnv); 14616915Seric rwp->r_rhs = prescan(exbuf, '\t', pvpbuf); 1475909Seric if (rwp->r_rhs != NULL) 1485909Seric rwp->r_rhs = copyplist(rwp->r_rhs, TRUE); 1493308Seric break; 1503308Seric 1514072Seric case 'S': /* select rewriting set */ 1524072Seric ruleset = atoi(&buf[1]); 1538056Seric if (ruleset >= MAXRWSETS || ruleset < 0) 1548056Seric { 1559381Seric syserr("bad ruleset %d (%d max)", ruleset, MAXRWSETS); 1568056Seric ruleset = 0; 1578056Seric } 1584072Seric rwp = NULL; 1594072Seric break; 1604072Seric 1613308Seric case 'D': /* macro definition */ 16210709Seric define(buf[1], newstr(munchstring(&buf[2])), CurEnv); 1633308Seric break; 1643308Seric 1653387Seric case 'H': /* required header line */ 1664088Seric (void) chompheader(&buf[1], TRUE); 1673387Seric break; 1683387Seric 1694061Seric case 'C': /* word class */ 1704432Seric case 'F': /* word class from file */ 1714432Seric /* read list of words from argument or file */ 1724432Seric if (buf[0] == 'F') 1734432Seric { 1744432Seric /* read from file */ 1754432Seric for (p = &buf[2]; *p != '\0' && !isspace(*p); p++) 1764432Seric continue; 1774432Seric if (*p == '\0') 1784432Seric p = "%s"; 1794432Seric else 1804432Seric { 1814432Seric *p = '\0'; 1824432Seric while (isspace(*++p)) 1834432Seric continue; 1844432Seric } 18510687Seric fileclass(buf[1], &buf[2], p); 1864432Seric break; 1874432Seric } 1884061Seric 1894432Seric /* scan the list of words and set class for all */ 1904061Seric for (p = &buf[2]; *p != '\0'; ) 1914061Seric { 1924061Seric register char *wd; 1934061Seric char delim; 1944061Seric 1954061Seric while (*p != '\0' && isspace(*p)) 1964061Seric p++; 1974061Seric wd = p; 1984061Seric while (*p != '\0' && !isspace(*p)) 1994061Seric p++; 2004061Seric delim = *p; 2014061Seric *p = '\0'; 2024061Seric if (wd[0] != '\0') 20310687Seric setclass(buf[1], wd); 2044061Seric *p = delim; 2054061Seric } 2064061Seric break; 2074061Seric 2084096Seric case 'M': /* define mailer */ 20921066Seric makemailer(&buf[1]); 2104096Seric break; 2114096Seric 2128252Seric case 'O': /* set option */ 21321755Seric setoption(buf[1], &buf[2], TRUE, FALSE); 2148252Seric break; 2158252Seric 2168252Seric case 'P': /* set precedence */ 2178252Seric if (NumPriorities >= MAXPRIORITIES) 2188252Seric { 2198547Seric toomany('P', MAXPRIORITIES); 2208252Seric break; 2218252Seric } 2229381Seric for (p = &buf[1]; *p != '\0' && *p != '=' && *p != '\t'; p++) 2238252Seric continue; 2248252Seric if (*p == '\0') 2258252Seric goto badline; 2268252Seric *p = '\0'; 2278252Seric Priorities[NumPriorities].pri_name = newstr(&buf[1]); 2288252Seric Priorities[NumPriorities].pri_val = atoi(++p); 2298252Seric NumPriorities++; 2308252Seric break; 2318252Seric 2328547Seric case 'T': /* trusted user(s) */ 2338547Seric p = &buf[1]; 2348547Seric while (*p != '\0') 2358547Seric { 2368547Seric while (isspace(*p)) 2378547Seric p++; 2388547Seric q = p; 2398547Seric while (*p != '\0' && !isspace(*p)) 2408547Seric p++; 2418547Seric if (*p != '\0') 2428547Seric *p++ = '\0'; 2438547Seric if (*q == '\0') 2448547Seric continue; 2458547Seric for (pv = TrustedUsers; *pv != NULL; pv++) 2468547Seric continue; 2478547Seric if (pv >= &TrustedUsers[MAXTRUST]) 2488547Seric { 2498547Seric toomany('T', MAXTRUST); 2508547Seric break; 2518547Seric } 2528547Seric *pv = newstr(q); 2538547Seric } 2548547Seric break; 2558547Seric 2563308Seric default: 2574061Seric badline: 2589381Seric syserr("unknown control line \"%s\"", buf); 2593308Seric } 2603308Seric } 2619381Seric FileName = NULL; 2624096Seric } 2634096Seric /* 2648547Seric ** TOOMANY -- signal too many of some option 2658547Seric ** 2668547Seric ** Parameters: 2678547Seric ** id -- the id of the error line 2688547Seric ** maxcnt -- the maximum possible values 2698547Seric ** 2708547Seric ** Returns: 2718547Seric ** none. 2728547Seric ** 2738547Seric ** Side Effects: 2748547Seric ** gives a syserr. 2758547Seric */ 2768547Seric 2778547Seric toomany(id, maxcnt) 2788547Seric char id; 2798547Seric int maxcnt; 2808547Seric { 2819381Seric syserr("too many %c lines, %d max", id, maxcnt); 2828547Seric } 2838547Seric /* 2844432Seric ** FILECLASS -- read members of a class from a file 2854432Seric ** 2864432Seric ** Parameters: 2874432Seric ** class -- class to define. 2884432Seric ** filename -- name of file to read. 2894432Seric ** fmt -- scanf string to use for match. 2904432Seric ** 2914432Seric ** Returns: 2924432Seric ** none 2934432Seric ** 2944432Seric ** Side Effects: 2954432Seric ** 2964432Seric ** puts all lines in filename that match a scanf into 2974432Seric ** the named class. 2984432Seric */ 2994432Seric 3004432Seric fileclass(class, filename, fmt) 3014432Seric int class; 3024432Seric char *filename; 3034432Seric char *fmt; 3044432Seric { 3054432Seric register FILE *f; 3064432Seric char buf[MAXLINE]; 3074432Seric 3084432Seric f = fopen(filename, "r"); 3094432Seric if (f == NULL) 3104432Seric { 3114432Seric syserr("cannot open %s", filename); 3124432Seric return; 3134432Seric } 3144432Seric 3154432Seric while (fgets(buf, sizeof buf, f) != NULL) 3164432Seric { 3174432Seric register STAB *s; 3184432Seric char wordbuf[MAXNAME+1]; 3194432Seric 3204432Seric if (sscanf(buf, fmt, wordbuf) != 1) 3214432Seric continue; 3224432Seric s = stab(wordbuf, ST_CLASS, ST_ENTER); 32310687Seric setbitn(class, s->s_class); 3244432Seric } 3254432Seric 3264627Seric (void) fclose(f); 3274432Seric } 3284432Seric /* 3294096Seric ** MAKEMAILER -- define a new mailer. 3304096Seric ** 3314096Seric ** Parameters: 33210327Seric ** line -- description of mailer. This is in labeled 33310327Seric ** fields. The fields are: 33410327Seric ** P -- the path to the mailer 33510327Seric ** F -- the flags associated with the mailer 33610327Seric ** A -- the argv for this mailer 33710327Seric ** S -- the sender rewriting set 33810327Seric ** R -- the recipient rewriting set 33910327Seric ** E -- the eol string 34010327Seric ** The first word is the canonical name of the mailer. 3414096Seric ** 3424096Seric ** Returns: 3434096Seric ** none. 3444096Seric ** 3454096Seric ** Side Effects: 3464096Seric ** enters the mailer into the mailer table. 3474096Seric */ 3483308Seric 34921066Seric makemailer(line) 3504096Seric char *line; 3514096Seric { 3524096Seric register char *p; 3538067Seric register struct mailer *m; 3548067Seric register STAB *s; 3558067Seric int i; 35610327Seric char fcode; 3574096Seric extern int NextMailer; 35810327Seric extern char **makeargv(); 35910327Seric extern char *munchstring(); 36010327Seric extern char *DelimChar; 36110701Seric extern long atol(); 3624096Seric 36310327Seric /* allocate a mailer and set up defaults */ 36410327Seric m = (struct mailer *) xalloc(sizeof *m); 36510327Seric bzero((char *) m, sizeof *m); 36610327Seric m->m_mno = NextMailer; 36710327Seric m->m_eol = "\n"; 36810327Seric 36910327Seric /* collect the mailer name */ 37010327Seric for (p = line; *p != '\0' && *p != ',' && !isspace(*p); p++) 37110327Seric continue; 37210327Seric if (*p != '\0') 37310327Seric *p++ = '\0'; 37410327Seric m->m_name = newstr(line); 37510327Seric 37610327Seric /* now scan through and assign info from the fields */ 37710327Seric while (*p != '\0') 37810327Seric { 37910327Seric while (*p != '\0' && (*p == ',' || isspace(*p))) 38010327Seric p++; 38110327Seric 38210327Seric /* p now points to field code */ 38310327Seric fcode = *p; 38410327Seric while (*p != '\0' && *p != '=' && *p != ',') 38510327Seric p++; 38610327Seric if (*p++ != '=') 38710327Seric { 38810327Seric syserr("`=' expected"); 38910327Seric return; 39010327Seric } 39110327Seric while (isspace(*p)) 39210327Seric p++; 39310327Seric 39410327Seric /* p now points to the field body */ 39510327Seric p = munchstring(p); 39610327Seric 39710327Seric /* install the field into the mailer struct */ 39810327Seric switch (fcode) 39910327Seric { 40010327Seric case 'P': /* pathname */ 40110327Seric m->m_mailer = newstr(p); 40210327Seric break; 40310327Seric 40410327Seric case 'F': /* flags */ 40510687Seric for (; *p != '\0'; p++) 40610687Seric setbitn(*p, m->m_flags); 40710327Seric break; 40810327Seric 40910327Seric case 'S': /* sender rewriting ruleset */ 41010327Seric case 'R': /* recipient rewriting ruleset */ 41110327Seric i = atoi(p); 41210327Seric if (i < 0 || i >= MAXRWSETS) 41310327Seric { 41410327Seric syserr("invalid rewrite set, %d max", MAXRWSETS); 41510327Seric return; 41610327Seric } 41710327Seric if (fcode == 'S') 41810327Seric m->m_s_rwset = i; 41910327Seric else 42010327Seric m->m_r_rwset = i; 42110327Seric break; 42210327Seric 42310327Seric case 'E': /* end of line string */ 42410327Seric m->m_eol = newstr(p); 42510327Seric break; 42610327Seric 42710327Seric case 'A': /* argument vector */ 42810327Seric m->m_argv = makeargv(p); 42910327Seric break; 43010701Seric 43110701Seric case 'M': /* maximum message size */ 43210701Seric m->m_maxsize = atol(p); 43310701Seric break; 43410327Seric } 43510327Seric 43610327Seric p = DelimChar; 43710327Seric } 43810327Seric 43910327Seric /* now store the mailer away */ 4404096Seric if (NextMailer >= MAXMAILERS) 4414096Seric { 4429381Seric syserr("too many mailers defined (%d max)", MAXMAILERS); 4434096Seric return; 4444096Seric } 44510327Seric Mailer[NextMailer++] = m; 44610327Seric s = stab(m->m_name, ST_MAILER, ST_ENTER); 44710327Seric s->s_mailer = m; 44810327Seric } 44910327Seric /* 45010327Seric ** MUNCHSTRING -- translate a string into internal form. 45110327Seric ** 45210327Seric ** Parameters: 45310327Seric ** p -- the string to munch. 45410327Seric ** 45510327Seric ** Returns: 45610327Seric ** the munched string. 45710327Seric ** 45810327Seric ** Side Effects: 45910327Seric ** Sets "DelimChar" to point to the string that caused us 46010327Seric ** to stop. 46110327Seric */ 4624096Seric 46310327Seric char * 46410327Seric munchstring(p) 46510327Seric register char *p; 46610327Seric { 46710327Seric register char *q; 46810327Seric bool backslash = FALSE; 46910327Seric bool quotemode = FALSE; 47010327Seric static char buf[MAXLINE]; 47110327Seric extern char *DelimChar; 4724096Seric 47310327Seric for (q = buf; *p != '\0'; p++) 4744096Seric { 47510327Seric if (backslash) 47610327Seric { 47710327Seric /* everything is roughly literal */ 47810357Seric backslash = FALSE; 47910327Seric switch (*p) 48010327Seric { 48110327Seric case 'r': /* carriage return */ 48210327Seric *q++ = '\r'; 48310327Seric continue; 48410327Seric 48510327Seric case 'n': /* newline */ 48610327Seric *q++ = '\n'; 48710327Seric continue; 48810327Seric 48910327Seric case 'f': /* form feed */ 49010327Seric *q++ = '\f'; 49110327Seric continue; 49210327Seric 49310327Seric case 'b': /* backspace */ 49410327Seric *q++ = '\b'; 49510327Seric continue; 49610327Seric } 49710327Seric *q++ = *p; 49810327Seric } 49910327Seric else 50010327Seric { 50110327Seric if (*p == '\\') 50210327Seric backslash = TRUE; 50310327Seric else if (*p == '"') 50410327Seric quotemode = !quotemode; 50510327Seric else if (quotemode || *p != ',') 50610327Seric *q++ = *p; 50710327Seric else 50810327Seric break; 50910327Seric } 5104096Seric } 5114096Seric 51210327Seric DelimChar = p; 51310327Seric *q++ = '\0'; 51410327Seric return (buf); 51510327Seric } 51610327Seric /* 51710327Seric ** MAKEARGV -- break up a string into words 51810327Seric ** 51910327Seric ** Parameters: 52010327Seric ** p -- the string to break up. 52110327Seric ** 52210327Seric ** Returns: 52310327Seric ** a char **argv (dynamically allocated) 52410327Seric ** 52510327Seric ** Side Effects: 52610327Seric ** munges p. 52710327Seric */ 5284096Seric 52910327Seric char ** 53010327Seric makeargv(p) 53110327Seric register char *p; 53210327Seric { 53310327Seric char *q; 53410327Seric int i; 53510327Seric char **avp; 53610327Seric char *argv[MAXPV + 1]; 53710327Seric 53810327Seric /* take apart the words */ 53910327Seric i = 0; 54010327Seric while (*p != '\0' && i < MAXPV) 5414096Seric { 54210327Seric q = p; 54310327Seric while (*p != '\0' && !isspace(*p)) 54410327Seric p++; 54510327Seric while (isspace(*p)) 54610327Seric *p++ = '\0'; 54710327Seric argv[i++] = newstr(q); 5484096Seric } 54910327Seric argv[i++] = NULL; 5504096Seric 55110327Seric /* now make a copy of the argv */ 55210327Seric avp = (char **) xalloc(sizeof *avp * i); 55316893Seric bcopy((char *) argv, (char *) avp, sizeof *avp * i); 55410327Seric 55510327Seric return (avp); 5563308Seric } 5573308Seric /* 5583308Seric ** PRINTRULES -- print rewrite rules (for debugging) 5593308Seric ** 5603308Seric ** Parameters: 5613308Seric ** none. 5623308Seric ** 5633308Seric ** Returns: 5643308Seric ** none. 5653308Seric ** 5663308Seric ** Side Effects: 5673308Seric ** prints rewrite rules. 5683308Seric */ 5693308Seric 5704319Seric # ifdef DEBUG 5714319Seric 5723308Seric printrules() 5733308Seric { 5743308Seric register struct rewrite *rwp; 5754072Seric register int ruleset; 5763308Seric 5774072Seric for (ruleset = 0; ruleset < 10; ruleset++) 5783308Seric { 5794072Seric if (RewriteRules[ruleset] == NULL) 5804072Seric continue; 5818067Seric printf("\n----Rule Set %d:", ruleset); 5823308Seric 5834072Seric for (rwp = RewriteRules[ruleset]; rwp != NULL; rwp = rwp->r_next) 5843308Seric { 5858067Seric printf("\nLHS:"); 5868067Seric printav(rwp->r_lhs); 5878067Seric printf("RHS:"); 5888067Seric printav(rwp->r_rhs); 5893308Seric } 5903308Seric } 5913308Seric } 5924319Seric 5934319Seric # endif DEBUG 5944096Seric /* 5958256Seric ** SETOPTION -- set global processing option 5968256Seric ** 5978256Seric ** Parameters: 5988256Seric ** opt -- option name. 5998256Seric ** val -- option value (as a text string). 60021755Seric ** safe -- set if this came from a configuration file. 60121755Seric ** Some options (if set from the command line) will 60221755Seric ** reset the user id to avoid security problems. 6038269Seric ** sticky -- if set, don't let other setoptions override 6048269Seric ** this value. 6058256Seric ** 6068256Seric ** Returns: 6078256Seric ** none. 6088256Seric ** 6098256Seric ** Side Effects: 6108256Seric ** Sets options as implied by the arguments. 6118256Seric */ 6128256Seric 61310687Seric static BITMAP StickyOpt; /* set if option is stuck */ 61410687Seric extern char *WizWord; /* the stored wizard password */ 61516143Seric extern char *NetName; /* name of home (local) network */ 6168269Seric 61721755Seric setoption(opt, val, safe, sticky) 6188256Seric char opt; 6198256Seric char *val; 62021755Seric bool safe; 6218269Seric bool sticky; 6228256Seric { 6238265Seric extern bool atobool(); 62412633Seric extern time_t convtime(); 62514879Seric extern int QueueLA; 62614879Seric extern int RefuseLA; 62717474Seric extern bool trusteduser(); 62817474Seric extern char *username(); 6298256Seric 6308256Seric # ifdef DEBUG 6318256Seric if (tTd(37, 1)) 6329341Seric printf("setoption %c=%s", opt, val); 6338256Seric # endif DEBUG 6348256Seric 6358256Seric /* 6368269Seric ** See if this option is preset for us. 6378256Seric */ 6388256Seric 63910687Seric if (bitnset(opt, StickyOpt)) 6408269Seric { 6418269Seric # ifdef DEBUG 6429341Seric if (tTd(37, 1)) 6439341Seric printf(" (ignored)\n"); 6448269Seric # endif DEBUG 6458269Seric return; 6468269Seric } 6478269Seric 64821755Seric /* 64921755Seric ** Check to see if this option can be specified by this user. 65021755Seric */ 65121755Seric 65221755Seric if (!safe && getruid()) 65321755Seric safe = TRUE; 65421755Seric if (!safe && index("deiLmorsv", opt) == NULL) 65521755Seric { 65621755Seric # ifdef DEBUG 65721755Seric if (tTd(37, 1)) 65821755Seric printf(" (unsafe)"); 65921755Seric # endif DEBUG 66021755Seric if (getruid() != geteuid()) 66121755Seric { 66221755Seric printf("(Resetting uid)\n"); 663*23111Seric (void) setgid(getgid()); 664*23111Seric (void) setuid(getuid()); 66521755Seric } 66621755Seric } 66717985Seric #ifdef DEBUG 66821755Seric else if (tTd(37, 1)) 66917985Seric printf("\n"); 67017985Seric #endif DEBUG 6718269Seric 6728256Seric switch (opt) 6738256Seric { 6748256Seric case 'A': /* set default alias file */ 6759381Seric if (val[0] == '\0') 6768269Seric AliasFile = "aliases"; 6779381Seric else 6789381Seric AliasFile = newstr(val); 6798256Seric break; 6808256Seric 68117474Seric case 'a': /* look N minutes for "@:@" in alias file */ 68217474Seric if (val[0] == '\0') 68317474Seric SafeAlias = 5; 68417474Seric else 68517474Seric SafeAlias = atoi(val); 68617474Seric break; 68717474Seric 68816843Seric case 'B': /* substitution for blank character */ 68916843Seric SpaceSub = val[0]; 69016843Seric if (SpaceSub == '\0') 69116843Seric SpaceSub = ' '; 69216843Seric break; 69316843Seric 6949284Seric case 'c': /* don't connect to "expensive" mailers */ 6959381Seric NoConnect = atobool(val); 6969284Seric break; 6979284Seric 6989284Seric case 'd': /* delivery mode */ 6999284Seric switch (*val) 7008269Seric { 7019284Seric case '\0': 7029284Seric SendMode = SM_DELIVER; 7038269Seric break; 7048269Seric 70510755Seric case SM_QUEUE: /* queue only */ 70610755Seric #ifndef QUEUE 70710755Seric syserr("need QUEUE to set -odqueue"); 70810755Seric #endif QUEUE 70910755Seric /* fall through..... */ 71010755Seric 7119284Seric case SM_DELIVER: /* do everything */ 7129284Seric case SM_FORK: /* fork after verification */ 7139284Seric SendMode = *val; 7148269Seric break; 7158269Seric 7168269Seric default: 7179284Seric syserr("Unknown delivery mode %c", *val); 7188269Seric exit(EX_USAGE); 7198269Seric } 7208269Seric break; 7218269Seric 7229146Seric case 'D': /* rebuild alias database as needed */ 7239381Seric AutoRebuild = atobool(val); 7249146Seric break; 7259146Seric 7268269Seric case 'e': /* set error processing mode */ 7278269Seric switch (*val) 7288269Seric { 7299381Seric case EM_QUIET: /* be silent about it */ 7309381Seric case EM_MAIL: /* mail back */ 7319381Seric case EM_BERKNET: /* do berknet error processing */ 7329381Seric case EM_WRITE: /* write back (or mail) */ 7338269Seric HoldErrs = TRUE; 7349381Seric /* fall through... */ 7358269Seric 7369381Seric case EM_PRINT: /* print errors normally (default) */ 7379381Seric ErrorMode = *val; 7388269Seric break; 7398269Seric } 7408269Seric break; 7418269Seric 7429049Seric case 'F': /* file mode */ 74317975Seric FileMode = atooct(val) & 0777; 7449049Seric break; 7459049Seric 7468269Seric case 'f': /* save Unix-style From lines on front */ 7479381Seric SaveFrom = atobool(val); 7488269Seric break; 7498269Seric 7508256Seric case 'g': /* default gid */ 75117474Seric DefGid = atoi(val); 7528256Seric break; 7538256Seric 7548256Seric case 'H': /* help file */ 7559381Seric if (val[0] == '\0') 7568269Seric HelpFile = "sendmail.hf"; 7579381Seric else 7589381Seric HelpFile = newstr(val); 7598256Seric break; 7608256Seric 7618269Seric case 'i': /* ignore dot lines in message */ 7629381Seric IgnrDot = atobool(val); 7638269Seric break; 7648269Seric 7658256Seric case 'L': /* log level */ 7669381Seric LogLevel = atoi(val); 7678256Seric break; 7688256Seric 7698269Seric case 'M': /* define macro */ 7709381Seric define(val[0], newstr(&val[1]), CurEnv); 77116878Seric sticky = FALSE; 7728269Seric break; 7738269Seric 7748269Seric case 'm': /* send to me too */ 7759381Seric MeToo = atobool(val); 7768269Seric break; 7778269Seric 77816143Seric # ifdef DAEMON 77916143Seric case 'N': /* home (local?) network name */ 78016143Seric NetName = newstr(val); 78116143Seric break; 78216143Seric # endif DAEMON 78316143Seric 7848269Seric case 'o': /* assume old style headers */ 7859381Seric if (atobool(val)) 7869341Seric CurEnv->e_flags |= EF_OLDSTYLE; 7879341Seric else 7889341Seric CurEnv->e_flags &= ~EF_OLDSTYLE; 7898269Seric break; 7908269Seric 7918256Seric case 'Q': /* queue directory */ 7929381Seric if (val[0] == '\0') 7938269Seric QueueDir = "mqueue"; 7949381Seric else 7959381Seric QueueDir = newstr(val); 7968256Seric break; 7978256Seric 7988256Seric case 'r': /* read timeout */ 7999381Seric ReadTimeout = convtime(val); 8008256Seric break; 8018256Seric 8028256Seric case 'S': /* status file */ 8039381Seric if (val[0] == '\0') 8048269Seric StatFile = "sendmail.st"; 8059381Seric else 8069381Seric StatFile = newstr(val); 8078256Seric break; 8088256Seric 8098265Seric case 's': /* be super safe, even if expensive */ 8109381Seric SuperSafe = atobool(val); 8118256Seric break; 8128256Seric 8138256Seric case 'T': /* queue timeout */ 8149381Seric TimeOut = convtime(val); 8158256Seric break; 8168256Seric 8178265Seric case 't': /* time zone name */ 8188265Seric # ifdef V6 8199381Seric StdTimezone = newstr(val); 8209381Seric DstTimezone = index(StdTimeZone, ','); 8218265Seric if (DstTimezone == NULL) 8229381Seric syserr("bad time zone spec"); 8239381Seric else 8249381Seric *DstTimezone++ = '\0'; 8258265Seric # endif V6 8268265Seric break; 8278265Seric 8288256Seric case 'u': /* set default uid */ 82917474Seric DefUid = atoi(val); 8308256Seric break; 8318256Seric 8328269Seric case 'v': /* run in verbose mode */ 8339381Seric Verbose = atobool(val); 8348256Seric break; 8358256Seric 8368544Seric # ifdef DEBUG 8378544Seric case 'W': /* set the wizards password */ 83817474Seric WizWord = newstr(val); 8398544Seric break; 8408544Seric # endif DEBUG 8418544Seric 84214879Seric case 'x': /* load avg at which to auto-queue msgs */ 84314879Seric QueueLA = atoi(val); 84414879Seric break; 84514879Seric 84614879Seric case 'X': /* load avg at which to auto-reject connections */ 84714879Seric RefuseLA = atoi(val); 84814879Seric break; 84914879Seric 8508256Seric default: 8518256Seric break; 8528256Seric } 85316878Seric if (sticky) 85416878Seric setbitn(opt, StickyOpt); 8559188Seric return; 8568256Seric } 85710687Seric /* 85810687Seric ** SETCLASS -- set a word into a class 85910687Seric ** 86010687Seric ** Parameters: 86110687Seric ** class -- the class to put the word in. 86210687Seric ** word -- the word to enter 86310687Seric ** 86410687Seric ** Returns: 86510687Seric ** none. 86610687Seric ** 86710687Seric ** Side Effects: 86810687Seric ** puts the word into the symbol table. 86910687Seric */ 87010687Seric 87110687Seric setclass(class, word) 87210687Seric int class; 87310687Seric char *word; 87410687Seric { 87510687Seric register STAB *s; 87610687Seric 87710687Seric s = stab(word, ST_CLASS, ST_ENTER); 87810687Seric setbitn(class, s->s_class); 87910687Seric } 880