fix wildcard MX handling (option W no longer needed); fix
[unix-history] / usr / src / usr.sbin / sendmail / src / readcf.c
index 3a2a77c..5032821 100644 (file)
@@ -1,18 +1,33 @@
 /*
 /*
-**  Sendmail
-**  Copyright (c) 1983  Eric P. Allman
-**  Berkeley, California
-**
-**  Copyright (c) 1983 Regents of the University of California.
-**  All rights reserved.  The Berkeley software License Agreement
-**  specifies the terms and conditions for redistribution.
-*/
+ * Copyright (c) 1983 Eric P. Allman
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * %sccs.include.redist.c%
+ */
 
 #ifndef lint
 
 #ifndef lint
-static char    SccsId[] = "@(#)readcf.c        5.4 (Berkeley) %G%";
-#endif not lint
+static char sccsid[] = "@(#)readcf.c   6.6 (Berkeley) %G%";
+#endif /* not lint */
 
 # include "sendmail.h"
 
 # include "sendmail.h"
+# include <sys/stat.h>
+# include <unistd.h>
+#ifdef NAMED_BIND
+# include <arpa/nameser.h>
+# include <resolv.h>
+#endif
+
+/* System 5 compatibility */
+#ifndef S_ISREG
+#define S_ISREG(foo)   ((foo & S_IFREG) == S_IFREG)
+#endif
+#ifndef S_IWGRP
+#define S_IWGRP                020
+#endif
+#ifndef S_IWOTH
+#define S_IWOTH                002
+#endif
 
 /*
 **  READCF -- read control file.
 
 /*
 **  READCF -- read control file.
@@ -40,9 +55,16 @@ static char  SccsId[] = "@(#)readcf.c        5.4 (Berkeley) %G%";
 **                             Args specify mailer parameters.
 **             Oxvalue         Set option x to value.
 **             Pname=value     Set precedence name to value.
 **                             Args specify mailer parameters.
 **             Oxvalue         Set option x to value.
 **             Pname=value     Set precedence name to value.
+**             Vversioncode    Version level of configuration syntax.
+**             Kmapname mapclass arguments....
+**                             Define keyed lookup of a given class.
+**                             Arguments are class dependent.
 **
 **     Parameters:
 **             cfname -- control file name.
 **
 **     Parameters:
 **             cfname -- control file name.
+**             safe -- TRUE if this is the system config file;
+**                     FALSE otherwise.
+**             e -- the main envelope.
 **
 **     Returns:
 **             none.
 **
 **     Returns:
 **             none.
@@ -53,35 +75,103 @@ static char        SccsId[] = "@(#)readcf.c        5.4 (Berkeley) %G%";
 
 readcf(cfname)
        char *cfname;
 
 readcf(cfname)
        char *cfname;
+       bool safe;
+       register ENVELOPE *e;
 {
        FILE *cf;
        int ruleset = 0;
        char *q;
        char **pv;
        struct rewrite *rwp = NULL;
 {
        FILE *cf;
        int ruleset = 0;
        char *q;
        char **pv;
        struct rewrite *rwp = NULL;
+       char *bp;
+       int nfuzzy;
        char buf[MAXLINE];
        register char *p;
        extern char **prescan();
        extern char **copyplist();
        char buf[MAXLINE];
        register char *p;
        extern char **prescan();
        extern char **copyplist();
+       struct stat statb;
        char exbuf[MAXLINE];
        char pvpbuf[PSBUFSIZE];
        extern char *fgetfolded();
        extern char *munchstring();
        char exbuf[MAXLINE];
        char pvpbuf[PSBUFSIZE];
        extern char *fgetfolded();
        extern char *munchstring();
+       extern void makemapentry();
+
+       FileName = cfname;
+       LineNumber = 0;
 
        cf = fopen(cfname, "r");
        if (cf == NULL)
        {
 
        cf = fopen(cfname, "r");
        if (cf == NULL)
        {
-               syserr("cannot open %s", cfname);
+               syserr("cannot open");
                exit(EX_OSFILE);
        }
 
                exit(EX_OSFILE);
        }
 
-       FileName = cfname;
-       LineNumber = 0;
-       while (fgetfolded(buf, sizeof buf, cf) != NULL)
+       if (fstat(fileno(cf), &statb) < 0)
+       {
+               syserr("cannot fstat");
+               exit(EX_OSFILE);
+       }
+
+       if (!S_ISREG(statb.st_mode))
        {
        {
+               syserr("not a plain file");
+               exit(EX_OSFILE);
+       }
+
+       if (OpMode != MD_TEST && bitset(S_IWGRP|S_IWOTH, statb.st_mode))
+       {
+               if (OpMode == MD_DAEMON || OpMode == MD_FREEZE)
+                       fprintf(stderr, "%s: WARNING: dangerous write permissions\n",
+                               FileName);
+#ifdef LOG
+               if (LogLevel > 0)
+                       syslog(LOG_CRIT, "%s: WARNING: dangerous write permissions",
+                               FileName);
+#endif
+       }
+
+       while ((bp = fgetfolded(buf, sizeof buf, cf)) != NULL)
+       {
+               if (bp[0] == '#')
+               {
+                       if (bp != buf)
+                               free(bp);
+                       continue;
+               }
+
                /* map $ into \001 (ASCII SOH) for macro expansion */
                /* map $ into \001 (ASCII SOH) for macro expansion */
-               for (p = buf; *p != '\0'; p++)
+               for (p = bp; *p != '\0'; p++)
                {
                {
+                       if (*p == '#' && p > bp && ConfigLevel >= 3)
+                       {
+                               /* this is an on-line comment */
+                               register char *e;
+
+                               switch (*--p)
+                               {
+                                 case '\001':
+                                       /* it's from $# -- let it go through */
+                                       p++;
+                                       break;
+
+                                 case '\\':
+                                       /* it's backslash escaped */
+                                       (void) strcpy(p, p + 1);
+                                       break;
+
+                                 default:
+                                       /* delete preceeding white space */
+                                       while (isspace(*p) && p > bp)
+                                               p--;
+                                       if ((e = strchr(++p, '\n')) != NULL)
+                                               (void) strcpy(p, e);
+                                       else
+                                               p[0] = p[1] = '\0';
+                                       break;
+                               }
+                               continue;
+                       }
+
                        if (*p != '$')
                                continue;
 
                        if (*p != '$')
                                continue;
 
@@ -97,19 +187,19 @@ readcf(cfname)
                }
 
                /* interpret this line */
                }
 
                /* interpret this line */
-               switch (buf[0])
+               switch (bp[0])
                {
                  case '\0':
                  case '#':             /* comment */
                        break;
 
                  case 'R':             /* rewriting rule */
                {
                  case '\0':
                  case '#':             /* comment */
                        break;
 
                  case 'R':             /* rewriting rule */
-                       for (p = &buf[1]; *p != '\0' && *p != '\t'; p++)
+                       for (p = &bp[1]; *p != '\0' && *p != '\t'; p++)
                                continue;
 
                        if (*p == '\0')
                        {
                                continue;
 
                        if (*p == '\0')
                        {
-                               syserr("invalid rewrite line \"%s\"", buf);
+                               syserr("invalid rewrite line \"%s\"", bp);
                                break;
                        }
 
                                break;
                        }
 
@@ -128,11 +218,32 @@ readcf(cfname)
 
                        /* expand and save the LHS */
                        *p = '\0';
 
                        /* expand and save the LHS */
                        *p = '\0';
-                       expand(&buf[1], exbuf, &exbuf[sizeof exbuf], CurEnv);
+                       expand(&bp[1], exbuf, &exbuf[sizeof exbuf], e);
                        rwp->r_lhs = prescan(exbuf, '\t', pvpbuf);
                        rwp->r_lhs = prescan(exbuf, '\t', pvpbuf);
+                       nfuzzy = 0;
                        if (rwp->r_lhs != NULL)
                        if (rwp->r_lhs != NULL)
+                       {
+                               register char **ap;
+
                                rwp->r_lhs = copyplist(rwp->r_lhs, TRUE);
 
                                rwp->r_lhs = copyplist(rwp->r_lhs, TRUE);
 
+                               /* count the number of fuzzy matches in LHS */
+                               for (ap = rwp->r_lhs; *ap != NULL; ap++)
+                               {
+                                       switch (**ap)
+                                       {
+                                         case MATCHZANY:
+                                         case MATCHANY:
+                                         case MATCHONE:
+                                         case MATCHCLASS:
+                                         case MATCHNCLASS:
+                                               nfuzzy++;
+                                       }
+                               }
+                       }
+                       else
+                               syserr("R line: null LHS");
+
                        /* expand and save the RHS */
                        while (*++p == '\t')
                                continue;
                        /* expand and save the RHS */
                        while (*++p == '\t')
                                continue;
@@ -140,14 +251,33 @@ readcf(cfname)
                        while (*p != '\0' && *p != '\t')
                                p++;
                        *p = '\0';
                        while (*p != '\0' && *p != '\t')
                                p++;
                        *p = '\0';
-                       expand(q, exbuf, &exbuf[sizeof exbuf], CurEnv);
+                       expand(q, exbuf, &exbuf[sizeof exbuf], e);
                        rwp->r_rhs = prescan(exbuf, '\t', pvpbuf);
                        if (rwp->r_rhs != NULL)
                        rwp->r_rhs = prescan(exbuf, '\t', pvpbuf);
                        if (rwp->r_rhs != NULL)
+                       {
+                               register char **ap;
+
                                rwp->r_rhs = copyplist(rwp->r_rhs, TRUE);
                                rwp->r_rhs = copyplist(rwp->r_rhs, TRUE);
+
+                               /* check no out-of-bounds replacements */
+                               nfuzzy += '0';
+                               for (ap = rwp->r_rhs; *ap != NULL; ap++)
+                               {
+                                       if (**ap != MATCHREPL)
+                                               continue;
+                                       if ((*ap)[1] <= '0' || (*ap)[1] > nfuzzy)
+                                       {
+                                               syserr("replacement $%c out of bounds",
+                                                       (*ap)[1]);
+                                       }
+                               }
+                       }
+                       else
+                               syserr("R line: null RHS");
                        break;
 
                  case 'S':             /* select rewriting set */
                        break;
 
                  case 'S':             /* select rewriting set */
-                       ruleset = atoi(&buf[1]);
+                       ruleset = atoi(&bp[1]);
                        if (ruleset >= MAXRWSETS || ruleset < 0)
                        {
                                syserr("bad ruleset %d (%d max)", ruleset, MAXRWSETS);
                        if (ruleset >= MAXRWSETS || ruleset < 0)
                        {
                                syserr("bad ruleset %d (%d max)", ruleset, MAXRWSETS);
@@ -157,20 +287,20 @@ readcf(cfname)
                        break;
 
                  case 'D':             /* macro definition */
                        break;
 
                  case 'D':             /* macro definition */
-                       define(buf[1], newstr(munchstring(&buf[2])), CurEnv);
+                       define(bp[1], newstr(munchstring(&bp[2])), e);
                        break;
 
                  case 'H':             /* required header line */
                        break;
 
                  case 'H':             /* required header line */
-                       (void) chompheader(&buf[1], TRUE);
+                       (void) chompheader(&bp[1], TRUE, e);
                        break;
 
                  case 'C':             /* word class */
                  case 'F':             /* word class from file */
                        /* read list of words from argument or file */
                        break;
 
                  case 'C':             /* word class */
                  case 'F':             /* word class from file */
                        /* read list of words from argument or file */
-                       if (buf[0] == 'F')
+                       if (bp[0] == 'F')
                        {
                                /* read from file */
                        {
                                /* read from file */
-                               for (p = &buf[2]; *p != '\0' && !isspace(*p); p++)
+                               for (p = &bp[2]; *p != '\0' && !isspace(*p); p++)
                                        continue;
                                if (*p == '\0')
                                        p = "%s";
                                        continue;
                                if (*p == '\0')
                                        p = "%s";
@@ -180,12 +310,12 @@ readcf(cfname)
                                        while (isspace(*++p))
                                                continue;
                                }
                                        while (isspace(*++p))
                                                continue;
                                }
-                               fileclass(buf[1], &buf[2], p);
+                               fileclass(bp[1], &bp[2], p, safe);
                                break;
                        }
 
                        /* scan the list of words and set class for all */
                                break;
                        }
 
                        /* scan the list of words and set class for all */
-                       for (p = &buf[2]; *p != '\0'; )
+                       for (p = &bp[2]; *p != '\0'; )
                        {
                                register char *wd;
                                char delim;
                        {
                                register char *wd;
                                char delim;
@@ -198,7 +328,7 @@ readcf(cfname)
                                delim = *p;
                                *p = '\0';
                                if (wd[0] != '\0')
                                delim = *p;
                                *p = '\0';
                                if (wd[0] != '\0')
-                                       setclass(buf[1], wd);
+                                       setclass(bp[1], wd);
                                *p = delim;
                        }
                        break;
                                *p = delim;
                        }
                        break;
@@ -217,18 +347,18 @@ readcf(cfname)
                                toomany('P', MAXPRIORITIES);
                                break;
                        }
                                toomany('P', MAXPRIORITIES);
                                break;
                        }
-                       for (p = &buf[1]; *p != '\0' && *p != '=' && *p != '\t'; p++)
+                       for (p = &bp[1]; *p != '\0' && *p != '=' && *p != '\t'; p++)
                                continue;
                        if (*p == '\0')
                                goto badline;
                        *p = '\0';
                                continue;
                        if (*p == '\0')
                                goto badline;
                        *p = '\0';
-                       Priorities[NumPriorities].pri_name = newstr(&buf[1]);
+                       Priorities[NumPriorities].pri_name = newstr(&bp[1]);
                        Priorities[NumPriorities].pri_val = atoi(++p);
                        NumPriorities++;
                        break;
 
                  case 'T':             /* trusted user(s) */
                        Priorities[NumPriorities].pri_val = atoi(++p);
                        NumPriorities++;
                        break;
 
                  case 'T':             /* trusted user(s) */
-                       p = &buf[1];
+                       p = &bp[1];
                        while (*p != '\0')
                        {
                                while (isspace(*p))
                        while (*p != '\0')
                        {
                                while (isspace(*p))
@@ -251,12 +381,37 @@ readcf(cfname)
                        }
                        break;
 
                        }
                        break;
 
+                 case 'V':             /* configuration syntax version */
+                       ConfigLevel = atoi(&bp[1]);
+                       break;
+
+                 case 'K':
+                       makemapentry(&bp[1]);
+                       break;
+
                  default:
                  badline:
                  default:
                  badline:
-                       syserr("unknown control line \"%s\"", buf);
+                       syserr("unknown control line \"%s\"", bp);
                }
                }
+               if (bp != buf)
+                       free(bp);
+       }
+       if (ferror(cf))
+       {
+               syserr("I/O read error", cfname);
+               exit(EX_OSFILE);
        }
        }
+       fclose(cf);
        FileName = NULL;
        FileName = NULL;
+
+       if (stab("host", ST_MAP, ST_FIND) == NULL)
+       {
+               /* user didn't initialize: set up host map */
+               strcpy(buf, "host host");
+               if (ConfigLevel >= 2)
+                       strcat(buf, " -a.");
+               makemapentry(buf);
+       }
 }
 \f/*
 **  TOOMANY -- signal too many of some option
 }
 \f/*
 **  TOOMANY -- signal too many of some option
@@ -295,30 +450,77 @@ toomany(id, maxcnt)
 **                     the named class.
 */
 
 **                     the named class.
 */
 
-fileclass(class, filename, fmt)
+fileclass(class, filename, fmt, safe)
        int class;
        char *filename;
        char *fmt;
        int class;
        char *filename;
        char *fmt;
+       bool safe;
 {
 {
-       register FILE *f;
+       FILE *f;
+       struct stat stbuf;
        char buf[MAXLINE];
 
        char buf[MAXLINE];
 
+       if (stat(filename, &stbuf) < 0)
+       {
+               syserr("fileclass: cannot stat %s", filename);
+               return;
+       }
+       if (!S_ISREG(stbuf.st_mode))
+       {
+               syserr("fileclass: %s not a regular file", filename);
+               return;
+       }
+       if (!safe && access(filename, R_OK) < 0)
+       {
+               syserr("fileclass: access denied on %s", filename);
+               return;
+       }
        f = fopen(filename, "r");
        if (f == NULL)
        {
        f = fopen(filename, "r");
        if (f == NULL)
        {
-               syserr("cannot open %s", filename);
+               syserr("fileclass: cannot open %s", filename);
                return;
        }
 
        while (fgets(buf, sizeof buf, f) != NULL)
        {
                register STAB *s;
                return;
        }
 
        while (fgets(buf, sizeof buf, f) != NULL)
        {
                register STAB *s;
+               register char *p;
+# ifdef SCANF
                char wordbuf[MAXNAME+1];
 
                if (sscanf(buf, fmt, wordbuf) != 1)
                        continue;
                char wordbuf[MAXNAME+1];
 
                if (sscanf(buf, fmt, wordbuf) != 1)
                        continue;
-               s = stab(wordbuf, ST_CLASS, ST_ENTER);
-               setbitn(class, s->s_class);
+               p = wordbuf;
+# else /* SCANF */
+               p = buf;
+# endif /* SCANF */
+
+               /*
+               **  Break up the match into words.
+               */
+
+               while (*p != '\0')
+               {
+                       register char *q;
+
+                       /* strip leading spaces */
+                       while (isspace(*p))
+                               p++;
+                       if (*p == '\0')
+                               break;
+
+                       /* find the end of the word */
+                       q = p;
+                       while (*p != '\0' && !isspace(*p))
+                               p++;
+                       if (*p != '\0')
+                               *p++ = '\0';
+
+                       /* enter the word in the symbol table */
+                       s = stab(q, ST_CLASS, ST_ENTER);
+                       setbitn(class, s->s_class);
+               }
        }
 
        (void) fclose(f);
        }
 
        (void) fclose(f);
@@ -361,7 +563,6 @@ makemailer(line)
        /* allocate a mailer and set up defaults */
        m = (struct mailer *) xalloc(sizeof *m);
        bzero((char *) m, sizeof *m);
        /* allocate a mailer and set up defaults */
        m = (struct mailer *) xalloc(sizeof *m);
        bzero((char *) m, sizeof *m);
-       m->m_mno = NextMailer;
        m->m_eol = "\n";
 
        /* collect the mailer name */
        m->m_eol = "\n";
 
        /* collect the mailer name */
@@ -383,7 +584,7 @@ makemailer(line)
                        p++;
                if (*p++ != '=')
                {
                        p++;
                if (*p++ != '=')
                {
-                       syserr("`=' expected");
+                       syserr("mailer %s: `=' expected", m->m_name);
                        return;
                }
                while (isspace(*p))
                        return;
                }
                while (isspace(*p))
@@ -401,7 +602,8 @@ makemailer(line)
 
                  case 'F':             /* flags */
                        for (; *p != '\0'; p++)
 
                  case 'F':             /* flags */
                        for (; *p != '\0'; p++)
-                               setbitn(*p, m->m_flags);
+                               if (!isspace(*p))
+                                       setbitn(*p, m->m_flags);
                        break;
 
                  case 'S':             /* sender rewriting ruleset */
                        break;
 
                  case 'S':             /* sender rewriting ruleset */
@@ -429,20 +631,42 @@ makemailer(line)
                  case 'M':             /* maximum message size */
                        m->m_maxsize = atol(p);
                        break;
                  case 'M':             /* maximum message size */
                        m->m_maxsize = atol(p);
                        break;
+
+                 case 'L':             /* maximum line length */
+                       m->m_linelimit = atoi(p);
+                       break;
                }
 
                p = DelimChar;
        }
 
                }
 
                p = DelimChar;
        }
 
-       /* now store the mailer away */
+       /* do some heuristic cleanup for back compatibility */
+       if (bitnset(M_LIMITS, m->m_flags))
+       {
+               if (m->m_linelimit == 0)
+                       m->m_linelimit = SMTPLINELIM;
+               if (ConfigLevel < 2)
+                       setbitn(M_7BITS, m->m_flags);
+       }
+
        if (NextMailer >= MAXMAILERS)
        {
                syserr("too many mailers defined (%d max)", MAXMAILERS);
                return;
        }
        if (NextMailer >= MAXMAILERS)
        {
                syserr("too many mailers defined (%d max)", MAXMAILERS);
                return;
        }
-       Mailer[NextMailer++] = m;
+
        s = stab(m->m_name, ST_MAILER, ST_ENTER);
        s = stab(m->m_name, ST_MAILER, ST_ENTER);
-       s->s_mailer = m;
+       if (s->s_mailer != NULL)
+       {
+               i = s->s_mailer->m_mno;
+               free(s->s_mailer);
+       }
+       else
+       {
+               i = NextMailer++;
+       }
+       Mailer[i] = s->s_mailer = m;
+       m->m_mno = i;
 }
 \f/*
 **  MUNCHSTRING -- translate a string into internal form.
 }
 \f/*
 **  MUNCHSTRING -- translate a string into internal form.
@@ -565,8 +789,6 @@ makeargv(p)
 **             prints rewrite rules.
 */
 
 **             prints rewrite rules.
 */
 
-# ifdef DEBUG
-
 printrules()
 {
        register struct rewrite *rwp;
 printrules()
 {
        register struct rewrite *rwp;
@@ -588,7 +810,6 @@ printrules()
        }
 }
 
        }
 }
 
-# endif DEBUG
 \f/*
 **  SETOPTION -- set global processing option
 **
 \f/*
 **  SETOPTION -- set global processing option
 **
@@ -606,14 +827,36 @@ printrules()
 */
 
 static BITMAP  StickyOpt;              /* set if option is stuck */
 */
 
 static BITMAP  StickyOpt;              /* set if option is stuck */
-extern char    *WizWord;               /* the stored wizard password */
-extern char    *NetName;               /* name of home (local) network */
+
+
+#ifdef NAMED_BIND
+
+struct resolverflags
+{
+       char    *rf_name;       /* name of the flag */
+       long    rf_bits;        /* bits to set/clear */
+} ResolverFlags[] =
+{
+       "debug",        RES_DEBUG,
+       "aaonly",       RES_AAONLY,
+       "usevc",        RES_USEVC,
+       "primary",      RES_PRIMARY,
+       "igntc",        RES_IGNTC,
+       "recurse",      RES_RECURSE,
+       "defnames",     RES_DEFNAMES,
+       "stayopen",     RES_STAYOPEN,
+       "dnsrch",       RES_DNSRCH,
+       NULL,           0
+};
+
+#endif
 
 setoption(opt, val, sticky)
        char opt;
        char *val;
        bool sticky;
 {
 
 setoption(opt, val, sticky)
        char opt;
        char *val;
        bool sticky;
 {
+       register char *p;
        extern bool atobool();
        extern time_t convtime();
        extern int QueueLA;
        extern bool atobool();
        extern time_t convtime();
        extern int QueueLA;
@@ -621,10 +864,8 @@ setoption(opt, val, sticky)
        extern bool trusteduser();
        extern char *username();
 
        extern bool trusteduser();
        extern char *username();
 
-# ifdef DEBUG
        if (tTd(37, 1))
                printf("setoption %c=%s", opt, val);
        if (tTd(37, 1))
                printf("setoption %c=%s", opt, val);
-# endif DEBUG
 
        /*
        **  See if this option is preset for us.
 
        /*
        **  See if this option is preset for us.
@@ -632,20 +873,20 @@ setoption(opt, val, sticky)
 
        if (bitnset(opt, StickyOpt))
        {
 
        if (bitnset(opt, StickyOpt))
        {
-# ifdef DEBUG
                if (tTd(37, 1))
                        printf(" (ignored)\n");
                if (tTd(37, 1))
                        printf(" (ignored)\n");
-# endif DEBUG
                return;
        }
 
                return;
        }
 
-#ifdef DEBUG
        if (tTd(37, 1))
                printf("\n");
        if (tTd(37, 1))
                printf("\n");
-#endif DEBUG
 
        switch (opt)
        {
 
        switch (opt)
        {
+         case '8':             /* allow eight-bit input */
+               EightBit = atobool(val);
+               break;
+
          case 'A':             /* set default alias file */
                if (val[0] == '\0')
                        AliasFile = "aliases";
          case 'A':             /* set default alias file */
                if (val[0] == '\0')
                        AliasFile = "aliases";
@@ -670,8 +911,8 @@ setoption(opt, val, sticky)
                NoConnect = atobool(val);
                break;
 
                NoConnect = atobool(val);
                break;
 
-         case 'C':             /* checkpoint after N connections */
-               CheckPointLimit = atoi(val);
+         case 'C':             /* checkpoint every N addresses */
+               CheckpointInterval = atoi(val);
                break;
 
          case 'd':             /* delivery mode */
                break;
 
          case 'd':             /* delivery mode */
@@ -684,7 +925,7 @@ setoption(opt, val, sticky)
                  case SM_QUEUE:        /* queue only */
 #ifndef QUEUE
                        syserr("need QUEUE to set -odqueue");
                  case SM_QUEUE:        /* queue only */
 #ifndef QUEUE
                        syserr("need QUEUE to set -odqueue");
-#endif QUEUE
+#endif /* QUEUE */
                        /* fall through..... */
 
                  case SM_DELIVER:      /* do everything */
                        /* fall through..... */
 
                  case SM_DELIVER:      /* do everything */
@@ -702,6 +943,11 @@ setoption(opt, val, sticky)
                AutoRebuild = atobool(val);
                break;
 
                AutoRebuild = atobool(val);
                break;
 
+         case 'E':             /* error message header/header file */
+               if (*val != '\0')
+                       ErrMsgFile = newstr(val);
+               break;
+
          case 'e':             /* set error processing mode */
                switch (*val)
                {
          case 'e':             /* set error processing mode */
                switch (*val)
                {
@@ -726,6 +972,10 @@ setoption(opt, val, sticky)
                SaveFrom = atobool(val);
                break;
 
                SaveFrom = atobool(val);
                break;
 
+         case 'G':             /* match recipients against GECOS field */
+               MatchGecos = atobool(val);
+               break;
+
          case 'g':             /* default gid */
                DefGid = atoi(val);
                break;
          case 'g':             /* default gid */
                DefGid = atoi(val);
                break;
@@ -737,10 +987,69 @@ setoption(opt, val, sticky)
                        HelpFile = newstr(val);
                break;
 
                        HelpFile = newstr(val);
                break;
 
+         case 'h':             /* maximum hop count */
+               MaxHopCount = atoi(val);
+               break;
+
+         case 'I':             /* use internet domain name server */
+#ifdef NAMED_BIND
+               UseNameServer = TRUE;
+               for (p = val; *p != 0; )
+               {
+                       bool clearmode;
+                       char *q;
+                       struct resolverflags *rfp;
+
+                       while (*p == ' ')
+                               p++;
+                       if (*p == '\0')
+                               break;
+                       clearmode = FALSE;
+                       if (*p == '-')
+                               clearmode = TRUE;
+                       else if (*p != '+')
+                               p--;
+                       p++;
+                       q = p;
+                       while (*p != '\0' && !isspace(*p))
+                               p++;
+                       if (*p != '\0')
+                               *p++ = '\0';
+                       for (rfp = ResolverFlags; rfp->rf_name != NULL; rfp++)
+                       {
+                               if (strcasecmp(q, rfp->rf_name) == 0)
+                                       break;
+                       }
+                       if (clearmode)
+                               _res.options &= ~rfp->rf_bits;
+                       else
+                               _res.options |= rfp->rf_bits;
+               }
+               if (tTd(8, 2))
+                       printf("_res.options = %x\n", _res.options);
+#else
+               usrerr("name server (I option) specified but BIND not compiled in");
+#endif
+               break;
+
          case 'i':             /* ignore dot lines in message */
                IgnrDot = atobool(val);
                break;
 
          case 'i':             /* ignore dot lines in message */
                IgnrDot = atobool(val);
                break;
 
+         case 'J':             /* .forward search path */
+               ForwardPath = newstr(val);
+               break;
+
+         case 'k':             /* connection cache size */
+               MaxMciCache = atoi(val);
+               if (MaxMciCache < 0)
+                       MaxMciCache = 0;
+               break;
+
+         case 'K':             /* connection cache timeout */
+               MciCacheTimeout = convtime(val);
+               break;
+
          case 'L':             /* log level */
                LogLevel = atoi(val);
                break;
          case 'L':             /* log level */
                LogLevel = atoi(val);
                break;
@@ -754,11 +1063,9 @@ setoption(opt, val, sticky)
                MeToo = atobool(val);
                break;
 
                MeToo = atobool(val);
                break;
 
-# ifdef DAEMON
-         case 'N':             /* home (local?) network name */
-               NetName = newstr(val);
+         case 'n':             /* validate RHS in newaliases */
+               CheckAliases = atobool(val);
                break;
                break;
-# endif DAEMON
 
          case 'o':             /* assume old style headers */
                if (atobool(val))
 
          case 'o':             /* assume old style headers */
                if (atobool(val))
@@ -802,30 +1109,22 @@ setoption(opt, val, sticky)
                break;
 
          case 't':             /* time zone name */
                break;
 
          case 't':             /* time zone name */
-# ifdef V6
-               StdTimezone = newstr(val);
-               DstTimezone = index(StdTimeZone, ',');
-               if (DstTimezone == NULL)
-                       syserr("bad time zone spec");
-               else
-                       *DstTimezone++ = '\0';
-# endif V6
+               TimeZoneSpec = newstr(val);
+               break;
+
+         case 'U':             /* location of user database */
+               UdbSpec = newstr(val);
                break;
 
          case 'u':             /* set default uid */
                DefUid = atoi(val);
                break;
 
          case 'u':             /* set default uid */
                DefUid = atoi(val);
+               setdefuser();
                break;
 
          case 'v':             /* run in verbose mode */
                Verbose = atobool(val);
                break;
 
                break;
 
          case 'v':             /* run in verbose mode */
                Verbose = atobool(val);
                break;
 
-# ifdef DEBUG
-         case 'W':             /* set the wizards password */
-               WizWord = newstr(val);
-               break;
-# endif DEBUG
-
          case 'x':             /* load avg at which to auto-queue msgs */
                QueueLA = atoi(val);
                break;
          case 'x':             /* load avg at which to auto-queue msgs */
                QueueLA = atoi(val);
                break;
@@ -834,6 +1133,22 @@ setoption(opt, val, sticky)
                RefuseLA = atoi(val);
                break;
 
                RefuseLA = atoi(val);
                break;
 
+         case 'y':             /* work recipient factor */
+               WkRecipFact = atoi(val);
+               break;
+
+         case 'Y':             /* fork jobs during queue runs */
+               ForkQueueRuns = atobool(val);
+               break;
+
+         case 'z':             /* work message class factor */
+               WkClassFact = atoi(val);
+               break;
+
+         case 'Z':             /* work time factor */
+               WkTimeFact = atoi(val);
+               break;
+
          default:
                break;
        }
          default:
                break;
        }
@@ -861,6 +1176,75 @@ setclass(class, word)
 {
        register STAB *s;
 
 {
        register STAB *s;
 
+       if (tTd(37, 8))
+               printf("%s added to class %c\n", word, class);
        s = stab(word, ST_CLASS, ST_ENTER);
        setbitn(class, s->s_class);
 }
        s = stab(word, ST_CLASS, ST_ENTER);
        setbitn(class, s->s_class);
 }
+\f/*
+**  MAKEMAPENTRY -- create a map entry
+**
+**     Parameters:
+**             line -- the config file line
+**
+**     Returns:
+**             TRUE if it successfully entered the map entry.
+**             FALSE otherwise (usually syntax error).
+**
+**     Side Effects:
+**             Enters the map into the dictionary.
+*/
+
+void
+makemapentry(line)
+       char *line;
+{
+       register char *p;
+       char *mapname;
+       char *classname;
+       register STAB *map;
+       STAB *class;
+
+       for (p = line; isspace(*p); p++)
+               continue;
+       if (!isalnum(*p))
+       {
+               syserr("readcf: config K line: no map name");
+               return;
+       }
+
+       mapname = p;
+       while (isalnum(*++p))
+               continue;
+       if (*p != '\0')
+               *p++ = '\0';
+       while (isspace(*p))
+               p++;
+       if (!isalnum(*p))
+       {
+               syserr("readcf: config K line, map %s: no map class", mapname);
+               return;
+       }
+       classname = p;
+       while (isalnum(*++p))
+               continue;
+       if (*p != '\0')
+               *p++ = '\0';
+       while (isspace(*p))
+               p++;
+
+       /* look up the class */
+       class = stab(classname, ST_MAPCLASS, ST_FIND);
+       if (class == NULL)
+       {
+               syserr("readcf: map %s: class %s not available", mapname, classname);
+               return;
+       }
+
+       /* enter the map */
+       map = stab(mapname, ST_MAP, ST_ENTER);
+       map->s_map.map_class = &class->s_mapclass;
+
+       if ((*class->s_mapclass.map_init)(&map->s_map, mapname, p))
+               map->s_map.map_flags |= MF_VALID;
+}