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*24944Seric static char SccsId[] = "@(#)readcf.c 5.3.1.1 (Berkeley) 09/19/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. 39*24944Seric ** Mn arg=val... Define mailer. n is the internal name. 40*24944Seric ** Args specify mailer parameters. 418252Seric ** Oxvalue Set option x to value. 428252Seric ** Pname=value Set precedence name to value. 434432Seric ** 443308Seric ** Parameters: 453308Seric ** cfname -- control file name. 463308Seric ** 473308Seric ** Returns: 483308Seric ** none. 493308Seric ** 503308Seric ** Side Effects: 513308Seric ** Builds several internal tables. 523308Seric */ 533308Seric 5421066Seric readcf(cfname) 553308Seric char *cfname; 563308Seric { 573308Seric FILE *cf; 588547Seric int ruleset = 0; 598547Seric char *q; 608547Seric char **pv; 619350Seric struct rewrite *rwp = NULL; 623308Seric char buf[MAXLINE]; 633308Seric register char *p; 643308Seric extern char **prescan(); 653308Seric extern char **copyplist(); 665909Seric char exbuf[MAXLINE]; 6716915Seric char pvpbuf[PSBUFSIZE]; 689350Seric extern char *fgetfolded(); 6910709Seric extern char *munchstring(); 703308Seric 713308Seric cf = fopen(cfname, "r"); 723308Seric if (cf == NULL) 733308Seric { 743308Seric syserr("cannot open %s", cfname); 753308Seric exit(EX_OSFILE); 763308Seric } 773308Seric 789381Seric FileName = cfname; 798056Seric LineNumber = 0; 807854Seric while (fgetfolded(buf, sizeof buf, cf) != NULL) 813308Seric { 8216157Seric /* map $ into \001 (ASCII SOH) for macro expansion */ 8316157Seric for (p = buf; *p != '\0'; p++) 8416157Seric { 8516157Seric if (*p != '$') 8616157Seric continue; 8716157Seric 8816157Seric if (p[1] == '$') 8916157Seric { 9016157Seric /* actual dollar sign.... */ 9123111Seric (void) strcpy(p, p + 1); 9216157Seric continue; 9316157Seric } 9416157Seric 9516157Seric /* convert to macro expansion character */ 9616157Seric *p = '\001'; 9716157Seric } 9816157Seric 9916157Seric /* interpret this line */ 1003308Seric switch (buf[0]) 1013308Seric { 1023308Seric case '\0': 1033308Seric case '#': /* comment */ 1043308Seric break; 1053308Seric 1063308Seric case 'R': /* rewriting rule */ 1073308Seric for (p = &buf[1]; *p != '\0' && *p != '\t'; p++) 1083308Seric continue; 1093308Seric 1103308Seric if (*p == '\0') 1115909Seric { 1129381Seric syserr("invalid rewrite line \"%s\"", buf); 1135909Seric break; 1145909Seric } 1155909Seric 1165909Seric /* allocate space for the rule header */ 1175909Seric if (rwp == NULL) 1185909Seric { 1195909Seric RewriteRules[ruleset] = rwp = 1205909Seric (struct rewrite *) xalloc(sizeof *rwp); 1215909Seric } 1223308Seric else 1233308Seric { 1245909Seric rwp->r_next = (struct rewrite *) xalloc(sizeof *rwp); 1255909Seric rwp = rwp->r_next; 1265909Seric } 1275909Seric rwp->r_next = NULL; 1283308Seric 1295909Seric /* expand and save the LHS */ 1305909Seric *p = '\0'; 1316991Seric expand(&buf[1], exbuf, &exbuf[sizeof exbuf], CurEnv); 13216915Seric rwp->r_lhs = prescan(exbuf, '\t', pvpbuf); 1335909Seric if (rwp->r_lhs != NULL) 1345909Seric rwp->r_lhs = copyplist(rwp->r_lhs, TRUE); 1355909Seric 1365909Seric /* expand and save the RHS */ 1375909Seric while (*++p == '\t') 1385909Seric continue; 1397231Seric q = p; 1407231Seric while (*p != '\0' && *p != '\t') 1417231Seric p++; 1427231Seric *p = '\0'; 1437231Seric expand(q, exbuf, &exbuf[sizeof exbuf], CurEnv); 14416915Seric rwp->r_rhs = prescan(exbuf, '\t', pvpbuf); 1455909Seric if (rwp->r_rhs != NULL) 1465909Seric rwp->r_rhs = copyplist(rwp->r_rhs, TRUE); 1473308Seric break; 1483308Seric 1494072Seric case 'S': /* select rewriting set */ 1504072Seric ruleset = atoi(&buf[1]); 1518056Seric if (ruleset >= MAXRWSETS || ruleset < 0) 1528056Seric { 1539381Seric syserr("bad ruleset %d (%d max)", ruleset, MAXRWSETS); 1548056Seric ruleset = 0; 1558056Seric } 1564072Seric rwp = NULL; 1574072Seric break; 1584072Seric 1593308Seric case 'D': /* macro definition */ 16010709Seric define(buf[1], newstr(munchstring(&buf[2])), CurEnv); 1613308Seric break; 1623308Seric 1633387Seric case 'H': /* required header line */ 1644088Seric (void) chompheader(&buf[1], TRUE); 1653387Seric break; 1663387Seric 1674061Seric case 'C': /* word class */ 1684432Seric case 'F': /* word class from file */ 1694432Seric /* read list of words from argument or file */ 1704432Seric if (buf[0] == 'F') 1714432Seric { 1724432Seric /* read from file */ 1734432Seric for (p = &buf[2]; *p != '\0' && !isspace(*p); p++) 1744432Seric continue; 1754432Seric if (*p == '\0') 1764432Seric p = "%s"; 1774432Seric else 1784432Seric { 1794432Seric *p = '\0'; 1804432Seric while (isspace(*++p)) 1814432Seric continue; 1824432Seric } 18310687Seric fileclass(buf[1], &buf[2], p); 1844432Seric break; 1854432Seric } 1864061Seric 1874432Seric /* scan the list of words and set class for all */ 1884061Seric for (p = &buf[2]; *p != '\0'; ) 1894061Seric { 1904061Seric register char *wd; 1914061Seric char delim; 1924061Seric 1934061Seric while (*p != '\0' && isspace(*p)) 1944061Seric p++; 1954061Seric wd = p; 1964061Seric while (*p != '\0' && !isspace(*p)) 1974061Seric p++; 1984061Seric delim = *p; 1994061Seric *p = '\0'; 2004061Seric if (wd[0] != '\0') 20110687Seric setclass(buf[1], wd); 2024061Seric *p = delim; 2034061Seric } 2044061Seric break; 2054061Seric 2064096Seric case 'M': /* define mailer */ 20721066Seric makemailer(&buf[1]); 2084096Seric break; 2094096Seric 2108252Seric case 'O': /* set option */ 21121755Seric setoption(buf[1], &buf[2], TRUE, FALSE); 2128252Seric break; 2138252Seric 2148252Seric case 'P': /* set precedence */ 2158252Seric if (NumPriorities >= MAXPRIORITIES) 2168252Seric { 2178547Seric toomany('P', MAXPRIORITIES); 2188252Seric break; 2198252Seric } 2209381Seric for (p = &buf[1]; *p != '\0' && *p != '=' && *p != '\t'; p++) 2218252Seric continue; 2228252Seric if (*p == '\0') 2238252Seric goto badline; 2248252Seric *p = '\0'; 2258252Seric Priorities[NumPriorities].pri_name = newstr(&buf[1]); 2268252Seric Priorities[NumPriorities].pri_val = atoi(++p); 2278252Seric NumPriorities++; 2288252Seric break; 2298252Seric 2308547Seric case 'T': /* trusted user(s) */ 2318547Seric p = &buf[1]; 2328547Seric while (*p != '\0') 2338547Seric { 2348547Seric while (isspace(*p)) 2358547Seric p++; 2368547Seric q = p; 2378547Seric while (*p != '\0' && !isspace(*p)) 2388547Seric p++; 2398547Seric if (*p != '\0') 2408547Seric *p++ = '\0'; 2418547Seric if (*q == '\0') 2428547Seric continue; 2438547Seric for (pv = TrustedUsers; *pv != NULL; pv++) 2448547Seric continue; 2458547Seric if (pv >= &TrustedUsers[MAXTRUST]) 2468547Seric { 2478547Seric toomany('T', MAXTRUST); 2488547Seric break; 2498547Seric } 2508547Seric *pv = newstr(q); 2518547Seric } 2528547Seric break; 2538547Seric 2543308Seric default: 2554061Seric badline: 2569381Seric syserr("unknown control line \"%s\"", buf); 2573308Seric } 2583308Seric } 2599381Seric FileName = NULL; 2604096Seric } 2614096Seric /* 2628547Seric ** TOOMANY -- signal too many of some option 2638547Seric ** 2648547Seric ** Parameters: 2658547Seric ** id -- the id of the error line 2668547Seric ** maxcnt -- the maximum possible values 2678547Seric ** 2688547Seric ** Returns: 2698547Seric ** none. 2708547Seric ** 2718547Seric ** Side Effects: 2728547Seric ** gives a syserr. 2738547Seric */ 2748547Seric 2758547Seric toomany(id, maxcnt) 2768547Seric char id; 2778547Seric int maxcnt; 2788547Seric { 2799381Seric syserr("too many %c lines, %d max", id, maxcnt); 2808547Seric } 2818547Seric /* 2824432Seric ** FILECLASS -- read members of a class from a file 2834432Seric ** 2844432Seric ** Parameters: 2854432Seric ** class -- class to define. 2864432Seric ** filename -- name of file to read. 2874432Seric ** fmt -- scanf string to use for match. 2884432Seric ** 2894432Seric ** Returns: 2904432Seric ** none 2914432Seric ** 2924432Seric ** Side Effects: 2934432Seric ** 2944432Seric ** puts all lines in filename that match a scanf into 2954432Seric ** the named class. 2964432Seric */ 2974432Seric 2984432Seric fileclass(class, filename, fmt) 2994432Seric int class; 3004432Seric char *filename; 3014432Seric char *fmt; 3024432Seric { 3034432Seric register FILE *f; 3044432Seric char buf[MAXLINE]; 3054432Seric 3064432Seric f = fopen(filename, "r"); 3074432Seric if (f == NULL) 3084432Seric { 3094432Seric syserr("cannot open %s", filename); 3104432Seric return; 3114432Seric } 3124432Seric 3134432Seric while (fgets(buf, sizeof buf, f) != NULL) 3144432Seric { 3154432Seric register STAB *s; 3164432Seric char wordbuf[MAXNAME+1]; 3174432Seric 3184432Seric if (sscanf(buf, fmt, wordbuf) != 1) 3194432Seric continue; 3204432Seric s = stab(wordbuf, ST_CLASS, ST_ENTER); 32110687Seric setbitn(class, s->s_class); 3224432Seric } 3234432Seric 3244627Seric (void) fclose(f); 3254432Seric } 3264432Seric /* 3274096Seric ** MAKEMAILER -- define a new mailer. 3284096Seric ** 3294096Seric ** Parameters: 33010327Seric ** line -- description of mailer. This is in labeled 33110327Seric ** fields. The fields are: 33210327Seric ** P -- the path to the mailer 33310327Seric ** F -- the flags associated with the mailer 33410327Seric ** A -- the argv for this mailer 33510327Seric ** S -- the sender rewriting set 33610327Seric ** R -- the recipient rewriting set 33710327Seric ** E -- the eol string 33810327Seric ** The first word is the canonical name of the mailer. 3394096Seric ** 3404096Seric ** Returns: 3414096Seric ** none. 3424096Seric ** 3434096Seric ** Side Effects: 3444096Seric ** enters the mailer into the mailer table. 3454096Seric */ 3463308Seric 34721066Seric makemailer(line) 3484096Seric char *line; 3494096Seric { 3504096Seric register char *p; 3518067Seric register struct mailer *m; 3528067Seric register STAB *s; 3538067Seric int i; 35410327Seric char fcode; 3554096Seric extern int NextMailer; 35610327Seric extern char **makeargv(); 35710327Seric extern char *munchstring(); 35810327Seric extern char *DelimChar; 35910701Seric extern long atol(); 3604096Seric 36110327Seric /* allocate a mailer and set up defaults */ 36210327Seric m = (struct mailer *) xalloc(sizeof *m); 36310327Seric bzero((char *) m, sizeof *m); 36410327Seric m->m_mno = NextMailer; 36510327Seric m->m_eol = "\n"; 36610327Seric 36710327Seric /* collect the mailer name */ 36810327Seric for (p = line; *p != '\0' && *p != ',' && !isspace(*p); p++) 36910327Seric continue; 37010327Seric if (*p != '\0') 37110327Seric *p++ = '\0'; 37210327Seric m->m_name = newstr(line); 37310327Seric 37410327Seric /* now scan through and assign info from the fields */ 37510327Seric while (*p != '\0') 37610327Seric { 37710327Seric while (*p != '\0' && (*p == ',' || isspace(*p))) 37810327Seric p++; 37910327Seric 38010327Seric /* p now points to field code */ 38110327Seric fcode = *p; 38210327Seric while (*p != '\0' && *p != '=' && *p != ',') 38310327Seric p++; 38410327Seric if (*p++ != '=') 38510327Seric { 38610327Seric syserr("`=' expected"); 38710327Seric return; 38810327Seric } 38910327Seric while (isspace(*p)) 39010327Seric p++; 39110327Seric 39210327Seric /* p now points to the field body */ 39310327Seric p = munchstring(p); 39410327Seric 39510327Seric /* install the field into the mailer struct */ 39610327Seric switch (fcode) 39710327Seric { 39810327Seric case 'P': /* pathname */ 39910327Seric m->m_mailer = newstr(p); 40010327Seric break; 40110327Seric 40210327Seric case 'F': /* flags */ 40310687Seric for (; *p != '\0'; p++) 40410687Seric setbitn(*p, m->m_flags); 40510327Seric break; 40610327Seric 40710327Seric case 'S': /* sender rewriting ruleset */ 40810327Seric case 'R': /* recipient rewriting ruleset */ 40910327Seric i = atoi(p); 41010327Seric if (i < 0 || i >= MAXRWSETS) 41110327Seric { 41210327Seric syserr("invalid rewrite set, %d max", MAXRWSETS); 41310327Seric return; 41410327Seric } 41510327Seric if (fcode == 'S') 41610327Seric m->m_s_rwset = i; 41710327Seric else 41810327Seric m->m_r_rwset = i; 41910327Seric break; 42010327Seric 42110327Seric case 'E': /* end of line string */ 42210327Seric m->m_eol = newstr(p); 42310327Seric break; 42410327Seric 42510327Seric case 'A': /* argument vector */ 42610327Seric m->m_argv = makeargv(p); 42710327Seric break; 42810701Seric 42910701Seric case 'M': /* maximum message size */ 43010701Seric m->m_maxsize = atol(p); 43110701Seric break; 43210327Seric } 43310327Seric 43410327Seric p = DelimChar; 43510327Seric } 43610327Seric 43710327Seric /* now store the mailer away */ 4384096Seric if (NextMailer >= MAXMAILERS) 4394096Seric { 4409381Seric syserr("too many mailers defined (%d max)", MAXMAILERS); 4414096Seric return; 4424096Seric } 44310327Seric Mailer[NextMailer++] = m; 44410327Seric s = stab(m->m_name, ST_MAILER, ST_ENTER); 44510327Seric s->s_mailer = m; 44610327Seric } 44710327Seric /* 44810327Seric ** MUNCHSTRING -- translate a string into internal form. 44910327Seric ** 45010327Seric ** Parameters: 45110327Seric ** p -- the string to munch. 45210327Seric ** 45310327Seric ** Returns: 45410327Seric ** the munched string. 45510327Seric ** 45610327Seric ** Side Effects: 45710327Seric ** Sets "DelimChar" to point to the string that caused us 45810327Seric ** to stop. 45910327Seric */ 4604096Seric 46110327Seric char * 46210327Seric munchstring(p) 46310327Seric register char *p; 46410327Seric { 46510327Seric register char *q; 46610327Seric bool backslash = FALSE; 46710327Seric bool quotemode = FALSE; 46810327Seric static char buf[MAXLINE]; 46910327Seric extern char *DelimChar; 4704096Seric 47110327Seric for (q = buf; *p != '\0'; p++) 4724096Seric { 47310327Seric if (backslash) 47410327Seric { 47510327Seric /* everything is roughly literal */ 47610357Seric backslash = FALSE; 47710327Seric switch (*p) 47810327Seric { 47910327Seric case 'r': /* carriage return */ 48010327Seric *q++ = '\r'; 48110327Seric continue; 48210327Seric 48310327Seric case 'n': /* newline */ 48410327Seric *q++ = '\n'; 48510327Seric continue; 48610327Seric 48710327Seric case 'f': /* form feed */ 48810327Seric *q++ = '\f'; 48910327Seric continue; 49010327Seric 49110327Seric case 'b': /* backspace */ 49210327Seric *q++ = '\b'; 49310327Seric continue; 49410327Seric } 49510327Seric *q++ = *p; 49610327Seric } 49710327Seric else 49810327Seric { 49910327Seric if (*p == '\\') 50010327Seric backslash = TRUE; 50110327Seric else if (*p == '"') 50210327Seric quotemode = !quotemode; 50310327Seric else if (quotemode || *p != ',') 50410327Seric *q++ = *p; 50510327Seric else 50610327Seric break; 50710327Seric } 5084096Seric } 5094096Seric 51010327Seric DelimChar = p; 51110327Seric *q++ = '\0'; 51210327Seric return (buf); 51310327Seric } 51410327Seric /* 51510327Seric ** MAKEARGV -- break up a string into words 51610327Seric ** 51710327Seric ** Parameters: 51810327Seric ** p -- the string to break up. 51910327Seric ** 52010327Seric ** Returns: 52110327Seric ** a char **argv (dynamically allocated) 52210327Seric ** 52310327Seric ** Side Effects: 52410327Seric ** munges p. 52510327Seric */ 5264096Seric 52710327Seric char ** 52810327Seric makeargv(p) 52910327Seric register char *p; 53010327Seric { 53110327Seric char *q; 53210327Seric int i; 53310327Seric char **avp; 53410327Seric char *argv[MAXPV + 1]; 53510327Seric 53610327Seric /* take apart the words */ 53710327Seric i = 0; 53810327Seric while (*p != '\0' && i < MAXPV) 5394096Seric { 54010327Seric q = p; 54110327Seric while (*p != '\0' && !isspace(*p)) 54210327Seric p++; 54310327Seric while (isspace(*p)) 54410327Seric *p++ = '\0'; 54510327Seric argv[i++] = newstr(q); 5464096Seric } 54710327Seric argv[i++] = NULL; 5484096Seric 54910327Seric /* now make a copy of the argv */ 55010327Seric avp = (char **) xalloc(sizeof *avp * i); 55116893Seric bcopy((char *) argv, (char *) avp, sizeof *avp * i); 55210327Seric 55310327Seric return (avp); 5543308Seric } 5553308Seric /* 5563308Seric ** PRINTRULES -- print rewrite rules (for debugging) 5573308Seric ** 5583308Seric ** Parameters: 5593308Seric ** none. 5603308Seric ** 5613308Seric ** Returns: 5623308Seric ** none. 5633308Seric ** 5643308Seric ** Side Effects: 5653308Seric ** prints rewrite rules. 5663308Seric */ 5673308Seric 5684319Seric # ifdef DEBUG 5694319Seric 5703308Seric printrules() 5713308Seric { 5723308Seric register struct rewrite *rwp; 5734072Seric register int ruleset; 5743308Seric 5754072Seric for (ruleset = 0; ruleset < 10; ruleset++) 5763308Seric { 5774072Seric if (RewriteRules[ruleset] == NULL) 5784072Seric continue; 5798067Seric printf("\n----Rule Set %d:", ruleset); 5803308Seric 5814072Seric for (rwp = RewriteRules[ruleset]; rwp != NULL; rwp = rwp->r_next) 5823308Seric { 5838067Seric printf("\nLHS:"); 5848067Seric printav(rwp->r_lhs); 5858067Seric printf("RHS:"); 5868067Seric printav(rwp->r_rhs); 5873308Seric } 5883308Seric } 5893308Seric } 5904319Seric 5914319Seric # endif DEBUG 5924096Seric /* 5938256Seric ** SETOPTION -- set global processing option 5948256Seric ** 5958256Seric ** Parameters: 5968256Seric ** opt -- option name. 5978256Seric ** val -- option value (as a text string). 59821755Seric ** safe -- set if this came from a configuration file. 59921755Seric ** Some options (if set from the command line) will 60021755Seric ** reset the user id to avoid security problems. 6018269Seric ** sticky -- if set, don't let other setoptions override 6028269Seric ** this value. 6038256Seric ** 6048256Seric ** Returns: 6058256Seric ** none. 6068256Seric ** 6078256Seric ** Side Effects: 6088256Seric ** Sets options as implied by the arguments. 6098256Seric */ 6108256Seric 61110687Seric static BITMAP StickyOpt; /* set if option is stuck */ 61210687Seric extern char *WizWord; /* the stored wizard password */ 61316143Seric extern char *NetName; /* name of home (local) network */ 6148269Seric 61521755Seric setoption(opt, val, safe, sticky) 6168256Seric char opt; 6178256Seric char *val; 61821755Seric bool safe; 6198269Seric bool sticky; 6208256Seric { 6218265Seric extern bool atobool(); 62212633Seric extern time_t convtime(); 62314879Seric extern int QueueLA; 62414879Seric extern int RefuseLA; 62517474Seric extern bool trusteduser(); 62617474Seric extern char *username(); 6278256Seric 6288256Seric # ifdef DEBUG 6298256Seric if (tTd(37, 1)) 6309341Seric printf("setoption %c=%s", opt, val); 6318256Seric # endif DEBUG 6328256Seric 6338256Seric /* 6348269Seric ** See if this option is preset for us. 6358256Seric */ 6368256Seric 63710687Seric if (bitnset(opt, StickyOpt)) 6388269Seric { 6398269Seric # ifdef DEBUG 6409341Seric if (tTd(37, 1)) 6419341Seric printf(" (ignored)\n"); 6428269Seric # endif DEBUG 6438269Seric return; 6448269Seric } 6458269Seric 64621755Seric /* 64721755Seric ** Check to see if this option can be specified by this user. 64821755Seric */ 64921755Seric 65021755Seric if (!safe && getruid()) 65121755Seric safe = TRUE; 65221755Seric if (!safe && index("deiLmorsv", opt) == NULL) 65321755Seric { 65421755Seric # ifdef DEBUG 65521755Seric if (tTd(37, 1)) 65621755Seric printf(" (unsafe)"); 65721755Seric # endif DEBUG 65821755Seric if (getruid() != geteuid()) 65921755Seric { 66021755Seric printf("(Resetting uid)\n"); 66123111Seric (void) setgid(getgid()); 66223111Seric (void) setuid(getuid()); 66321755Seric } 66421755Seric } 66517985Seric #ifdef DEBUG 66621755Seric else if (tTd(37, 1)) 66717985Seric printf("\n"); 66817985Seric #endif DEBUG 6698269Seric 6708256Seric switch (opt) 6718256Seric { 6728256Seric case 'A': /* set default alias file */ 6739381Seric if (val[0] == '\0') 6748269Seric AliasFile = "aliases"; 6759381Seric else 6769381Seric AliasFile = newstr(val); 6778256Seric break; 6788256Seric 67917474Seric case 'a': /* look N minutes for "@:@" in alias file */ 68017474Seric if (val[0] == '\0') 68117474Seric SafeAlias = 5; 68217474Seric else 68317474Seric SafeAlias = atoi(val); 68417474Seric break; 68517474Seric 68616843Seric case 'B': /* substitution for blank character */ 68716843Seric SpaceSub = val[0]; 68816843Seric if (SpaceSub == '\0') 68916843Seric SpaceSub = ' '; 69016843Seric break; 69116843Seric 6929284Seric case 'c': /* don't connect to "expensive" mailers */ 6939381Seric NoConnect = atobool(val); 6949284Seric break; 6959284Seric 696*24944Seric case 'C': /* checkpoint after N connections */ 697*24944Seric CheckPointLimit = atoi(val); 698*24944Seric break; 699*24944Seric 7009284Seric case 'd': /* delivery mode */ 7019284Seric switch (*val) 7028269Seric { 7039284Seric case '\0': 7049284Seric SendMode = SM_DELIVER; 7058269Seric break; 7068269Seric 70710755Seric case SM_QUEUE: /* queue only */ 70810755Seric #ifndef QUEUE 70910755Seric syserr("need QUEUE to set -odqueue"); 71010755Seric #endif QUEUE 71110755Seric /* fall through..... */ 71210755Seric 7139284Seric case SM_DELIVER: /* do everything */ 7149284Seric case SM_FORK: /* fork after verification */ 7159284Seric SendMode = *val; 7168269Seric break; 7178269Seric 7188269Seric default: 7199284Seric syserr("Unknown delivery mode %c", *val); 7208269Seric exit(EX_USAGE); 7218269Seric } 7228269Seric break; 7238269Seric 7249146Seric case 'D': /* rebuild alias database as needed */ 7259381Seric AutoRebuild = atobool(val); 7269146Seric break; 7279146Seric 7288269Seric case 'e': /* set error processing mode */ 7298269Seric switch (*val) 7308269Seric { 7319381Seric case EM_QUIET: /* be silent about it */ 7329381Seric case EM_MAIL: /* mail back */ 7339381Seric case EM_BERKNET: /* do berknet error processing */ 7349381Seric case EM_WRITE: /* write back (or mail) */ 7358269Seric HoldErrs = TRUE; 7369381Seric /* fall through... */ 7378269Seric 7389381Seric case EM_PRINT: /* print errors normally (default) */ 7399381Seric ErrorMode = *val; 7408269Seric break; 7418269Seric } 7428269Seric break; 7438269Seric 7449049Seric case 'F': /* file mode */ 74517975Seric FileMode = atooct(val) & 0777; 7469049Seric break; 7479049Seric 7488269Seric case 'f': /* save Unix-style From lines on front */ 7499381Seric SaveFrom = atobool(val); 7508269Seric break; 7518269Seric 7528256Seric case 'g': /* default gid */ 75317474Seric DefGid = atoi(val); 7548256Seric break; 7558256Seric 7568256Seric case 'H': /* help file */ 7579381Seric if (val[0] == '\0') 7588269Seric HelpFile = "sendmail.hf"; 7599381Seric else 7609381Seric HelpFile = newstr(val); 7618256Seric break; 7628256Seric 7638269Seric case 'i': /* ignore dot lines in message */ 7649381Seric IgnrDot = atobool(val); 7658269Seric break; 7668269Seric 7678256Seric case 'L': /* log level */ 7689381Seric LogLevel = atoi(val); 7698256Seric break; 7708256Seric 7718269Seric case 'M': /* define macro */ 7729381Seric define(val[0], newstr(&val[1]), CurEnv); 77316878Seric sticky = FALSE; 7748269Seric break; 7758269Seric 7768269Seric case 'm': /* send to me too */ 7779381Seric MeToo = atobool(val); 7788269Seric break; 7798269Seric 78016143Seric # ifdef DAEMON 78116143Seric case 'N': /* home (local?) network name */ 78216143Seric NetName = newstr(val); 78316143Seric break; 78416143Seric # endif DAEMON 78516143Seric 7868269Seric case 'o': /* assume old style headers */ 7879381Seric if (atobool(val)) 7889341Seric CurEnv->e_flags |= EF_OLDSTYLE; 7899341Seric else 7909341Seric CurEnv->e_flags &= ~EF_OLDSTYLE; 7918269Seric break; 7928269Seric 793*24944Seric case 'P': /* postmaster copy address for returned mail */ 794*24944Seric PostMasterCopy = newstr(val); 795*24944Seric break; 796*24944Seric 797*24944Seric case 'q': /* slope of queue only function */ 798*24944Seric QueueFactor = atoi(val); 799*24944Seric break; 800*24944Seric 8018256Seric case 'Q': /* queue directory */ 8029381Seric if (val[0] == '\0') 8038269Seric QueueDir = "mqueue"; 8049381Seric else 8059381Seric QueueDir = newstr(val); 8068256Seric break; 8078256Seric 8088256Seric case 'r': /* read timeout */ 8099381Seric ReadTimeout = convtime(val); 8108256Seric break; 8118256Seric 8128256Seric case 'S': /* status file */ 8139381Seric if (val[0] == '\0') 8148269Seric StatFile = "sendmail.st"; 8159381Seric else 8169381Seric StatFile = newstr(val); 8178256Seric break; 8188256Seric 8198265Seric case 's': /* be super safe, even if expensive */ 8209381Seric SuperSafe = atobool(val); 8218256Seric break; 8228256Seric 8238256Seric case 'T': /* queue timeout */ 8249381Seric TimeOut = convtime(val); 8258256Seric break; 8268256Seric 8278265Seric case 't': /* time zone name */ 8288265Seric # ifdef V6 8299381Seric StdTimezone = newstr(val); 8309381Seric DstTimezone = index(StdTimeZone, ','); 8318265Seric if (DstTimezone == NULL) 8329381Seric syserr("bad time zone spec"); 8339381Seric else 8349381Seric *DstTimezone++ = '\0'; 8358265Seric # endif V6 8368265Seric break; 8378265Seric 8388256Seric case 'u': /* set default uid */ 83917474Seric DefUid = atoi(val); 8408256Seric break; 8418256Seric 8428269Seric case 'v': /* run in verbose mode */ 8439381Seric Verbose = atobool(val); 8448256Seric break; 8458256Seric 8468544Seric # ifdef DEBUG 8478544Seric case 'W': /* set the wizards password */ 84817474Seric WizWord = newstr(val); 8498544Seric break; 8508544Seric # endif DEBUG 8518544Seric 85214879Seric case 'x': /* load avg at which to auto-queue msgs */ 85314879Seric QueueLA = atoi(val); 85414879Seric break; 85514879Seric 85614879Seric case 'X': /* load avg at which to auto-reject connections */ 85714879Seric RefuseLA = atoi(val); 85814879Seric break; 85914879Seric 8608256Seric default: 8618256Seric break; 8628256Seric } 86316878Seric if (sticky) 86416878Seric setbitn(opt, StickyOpt); 8659188Seric return; 8668256Seric } 86710687Seric /* 86810687Seric ** SETCLASS -- set a word into a class 86910687Seric ** 87010687Seric ** Parameters: 87110687Seric ** class -- the class to put the word in. 87210687Seric ** word -- the word to enter 87310687Seric ** 87410687Seric ** Returns: 87510687Seric ** none. 87610687Seric ** 87710687Seric ** Side Effects: 87810687Seric ** puts the word into the symbol table. 87910687Seric */ 88010687Seric 88110687Seric setclass(class, word) 88210687Seric int class; 88310687Seric char *word; 88410687Seric { 88510687Seric register STAB *s; 88610687Seric 88710687Seric s = stab(word, ST_CLASS, ST_ENTER); 88810687Seric setbitn(class, s->s_class); 88910687Seric } 890