/*
* Copyright (c) 1998-2006, 2008-2010, 2013 Proofpoint, Inc. and its suppliers.
* All rights reserved.
* Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*
*/
#include <sendmail.h>
#include <sm/sendmail.h>
#endif /* NETINET || NETINET6 */
#define SECONDS
static void settimeout __P((char *, char *, bool));
static char *extrquotstr __P((char *, char **, char *, bool *));
static void parse_class_words __P((int, char *));
/*
** READCF -- read configuration file.
**
** This routine reads the configuration file and builds the internal
** form.
**
** The file is formatted as a sequence of lines, each taken
** atomically. The first character of each line describes how
** the line is to be interpreted. The lines are:
** Dxval Define macro x to have value val.
** Cxword Put word into class x.
** Fxfile [fmt] Read file for lines to put into
** class x. Use scanf string 'fmt'
** or "%s" if not present. Fmt should
** only produce one string-valued result.
** Hname: value Define header with field-name 'name'
** and value as specified; this will be
** macro expanded immediately before
** use.
** Sn Use rewriting set n.
** Rlhs rhs Rewrite addresses that match lhs to
** be rhs.
** Mn arg=val... Define mailer. n is the internal name.
** Args specify mailer parameters.
** Oxvalue Set option x to value.
** O option value Set option (long name) to value.
** Pname=value Set precedence name to value.
** Qn arg=val... Define queue groups. n is the internal name.
** Args specify queue parameters.
** Vversioncode[/vendorcode]
** configuration syntax.
** Kmapname mapclass arguments....
** Define keyed lookup of a given class.
** Arguments are class dependent.
** Eenvar=value Set the environment value to the given value.
**
** Parameters:
** cfname -- configuration file name.
** safe -- true if this is the system config file;
** false otherwise.
** e -- the main envelope.
**
** Returns:
** none.
**
** Side Effects:
** Builds several internal tables.
*/
void
char *cfname;
bool safe;
register ENVELOPE *e;
{
char *q;
char *bp;
auto char *ep;
int nfuzzy;
char *file;
bool optional;
bool ok;
bool ismap;
int mid;
register char *p;
int bufsize;
extern unsigned char TokTypeNoC[];
LineNumber = 0;
#if STARTTLS
#ifdef SSL_OP_NO_SSLv2
#endif
#ifdef SSL_OP_NO_TICKET
#endif
;
#endif /* STARTTLS */
if (DontLockReadFiles)
sff |= SFF_NOLOCK;
{
syserr("cannot open");
}
{
syserr("cannot fstat");
}
{
syserr("not a plain file");
}
{
"%s: WARNING: dangerous write permissions\n",
FileName);
if (LogLevel > 0)
"%s: WARNING: dangerous write permissions",
FileName);
}
#if XLA
xla_zero();
#endif /* XLA */
{
char *nbp;
if (bp[0] == '#')
{
continue;
}
/* do macro expansion mappings */
/* interpret this line */
errno = 0;
switch (bp[0])
{
case '\0':
case '#': /* comment */
break;
case 'R': /* rewriting rule */
if (ruleset < 0)
{
break;
}
continue;
if (*p == '\0')
{
break;
}
/* allocate space for the rule header */
{
}
else
{
}
/* expand and save the LHS */
*p = '\0';
true);
nfuzzy = 0;
{
register char **ap;
/* count the number of fuzzy matches in LHS */
{
char *botch;
switch (ap[0][0] & 0377)
{
case MATCHZANY:
case MATCHANY:
case MATCHONE:
case MATCHCLASS:
case MATCHNCLASS:
nfuzzy++;
break;
case MATCHREPL:
botch = "$1-$9";
break;
case CANONUSER:
botch = "$:";
break;
case CALLSUBR:
botch = "$>";
break;
case CONDIF:
botch = "$?";
break;
case CONDFI:
botch = "$.";
break;
case HOSTBEGIN:
botch = "$[";
break;
case HOSTEND:
botch = "$]";
break;
case LOOKUPBEGIN:
botch = "$(";
break;
case LOOKUPEND:
botch = "$)";
break;
}
syserr("Inappropriate use of %s on LHS",
botch);
}
}
else
{
syserr("R line: null LHS");
}
{
syserr("R line: too many wildcards");
}
/* expand and save the RHS */
while (*++p == '\t')
continue;
q = p;
while (*p != '\0' && *p != '\t')
p++;
*p = '\0';
true);
{
register char **ap;
int nexttoken;
#endif /* _FFR_EXTRA_MAP_CHECK */
bool inmap;
/* check no out-of-bounds replacements */
nfuzzy += '0';
inmap = false;
args = 0;
endtoken = 0;
{
char *botch;
switch (ap[0][0] & 0377)
{
case MATCHREPL:
{
syserr("replacement $%c out of bounds",
ap[0][1]);
}
break;
case MATCHZANY:
botch = "$*";
break;
case MATCHANY:
botch = "$+";
break;
case MATCHONE:
botch = "$-";
break;
case MATCHCLASS:
botch = "$=";
break;
case MATCHNCLASS:
botch = "$~";
break;
case CANONHOST:
if (!inmap)
break;
if (++args >= MAX_MAP_ARGS)
syserr("too many arguments for map lookup");
break;
case HOSTBEGIN:
/* FALLTHROUGH */
case LOOKUPBEGIN:
/* see above... */
if (inmap)
syserr("cannot nest map lookups");
inmap = true;
args = 0;
{
syserr("syntax error in map lookup");
break;
}
{
syserr("missing map name for lookup");
break;
}
{
syserr("syntax error in map lookup");
break;
}
break;
{
syserr("missing key name for lookup");
break;
}
#endif /* _FFR_EXTRA_MAP_CHECK */
break;
case HOSTEND:
case LOOKUPEND:
break;
inmap = false;
endtoken = 0;
break;
#if 0
/*
** This doesn't work yet as there are maps defined *after* the cf
** is read such as host, user, and alias. So for now, it's removed.
** When it comes back, the RELEASE_NOTES entry will be:
** Emit warnings for unknown maps when reading the .cf file. Based on
** patch from Robert Harker of Harker Systems.
*/
case LOOKUPBEGIN:
/*
** Got a database lookup,
** check if map is defined.
*/
{
(void) sm_io_fprintf(smioout,
"Warning: %s: line %d: map %s not found\n",
ep);
}
break;
#endif /* 0 */
}
syserr("Inappropriate use of %s on RHS",
botch);
}
if (inmap)
syserr("missing map closing token");
}
else
{
syserr("R line: null RHS");
}
break;
case 'S': /* select rewriting set */
if (ruleset < 0)
break;
{
(void) sm_io_fprintf(smioout,
"WARNING: Ruleset %s has multiple definitions\n",
&bp[1]);
sm_dprintf("WARNING: Ruleset %s has multiple definitions\n",
&bp[1]);
}
break;
case 'D': /* macro definition */
if (mid == 0)
break;
break;
case 'H': /* required header line */
break;
case 'C': /* word class */
case 'T': /* trusted user (set class `t') */
if (bp[0] == 'C')
{
if (mid == 0)
break;
p = exbuf;
}
else
{
mid = 't';
p = &bp[1];
}
while (*p != '\0')
{
register char *wd;
char delim;
p++;
wd = p;
p++;
delim = *p;
*p = '\0';
if (wd[0] != '\0')
*p = delim;
}
break;
case 'F': /* word class from file */
if (mid == 0)
break;
p++;
if (p[0] == '-' && p[1] == 'o')
{
optional = true;
while (*p != '\0' &&
p++;
p++;
}
else
optional = false;
/* check if [key]@map:spec */
ismap = false;
if (!SM_IS_DIR_DELIM(*p) &&
*p != '|' &&
{
q++;
/* look for @LDAP or @map: in string */
if (strcmp(q, "LDAP") == 0 ||
(*q != ':' &&
ismap = true;
}
if (ismap)
{
/* use entire spec */
file = p;
}
else
{
if (!ok)
{
syserr("illegal filename '%s'", p);
break;
}
}
p = "%s";
else
{
p = q;
if (*p == '\0')
p = "%s";
else
{
*p = '\0';
continue;
}
}
break;
#if XLA
case 'L': /* extended load average description */
break;
#endif /* XLA */
#if defined(SUN_EXTENSIONS) && defined(SUN_LOOKUP_MACRO)
case 'L': /* lookup macro */
case 'G': /* lookup class */
/* reserved for Sun -- NIS+ database lookup */
if (VendorCode != VENDOR_SUN)
goto badline;
sun_lg_config_line(bp, e);
break;
#endif /* defined(SUN_EXTENSIONS) && defined(SUN_LOOKUP_MACRO) */
case 'M': /* define mailer */
break;
case 'O': /* set option */
break;
case 'P': /* set precedence */
if (NumPriorities >= MAXPRIORITIES)
{
break;
}
continue;
if (*p == '\0')
goto badline;
*p = '\0';
break;
case 'Q': /* define queue */
break;
case 'V': /* configuration syntax version */
continue;
{
syserr("invalid argument to V line: \"%.20s\"",
&bp[1]);
break;
}
/*
** Do heuristic tweaking for back compatibility.
*/
if (ConfigLevel >= 5)
{
/* level 5 configs have short name in $w */
p = macvalue('w', e);
{
*p = '\0';
macvalue('w', e));
}
}
if (ConfigLevel >= 6)
{
ColonOkInAddr = false;
}
/*
** Look for vendor code.
*/
if (*ep++ == '/')
{
/* extract vendor code */
p++;
*p = '\0';
syserr("invalid V line vendor code: \"%s\"",
ep);
}
break;
case 'K':
(void) makemapentry(exbuf);
break;
case 'E':
if (p != NULL)
*p++ = '\0';
break;
case 'X': /* mail filter */
#if MILTER
#else /* MILTER */
"Warning: Filter usage ('X') requires Milter support (-DMILTER)\n");
#endif /* MILTER */
break;
default:
}
}
if (sm_io_error(cf))
{
syserr("I/O read error");
}
/* initialize host maps from local service tables */
inithostmaps();
/* initialize daemon (if not defined yet) */
initdaemon();
/* determine if we need to do special name-server frotz */
{
int nmaps;
UseNameServer = false;
{
register int mapno;
mapno++)
{
UseNameServer = true;
}
}
}
}
/*
** TRANSLATE_DOLLARS -- convert $x into internal form
**
** Actually does all appropriate pre-processing of a config line
** to turn it into internal form.
**
** Parameters:
** ibp -- the buffer to translate.
** obp -- where to put the translation; may be the same as obp
** bsp -- a pointer to the size of obp; will be updated if
** the buffer needs to be replaced.
**
** Returns:
** The buffer pointer; may differ from obp if the expansion
** is larger then *bsp, in which case this will point to
** malloc()ed memory which must be free()d by the caller.
*/
char *
char *ibp;
char *obp;
int *bsp;
{
register char *p;
auto char *ep;
char *bp;
{
sm_dprintf("translate_dollars(");
sm_dprintf(")\n");
}
for (p = bp; *p != '\0'; p++)
{
{
register char *e;
switch (*--p & 0377)
{
case MACROEXPAND:
/* it's from $# -- let it go through */
p++;
break;
case '\\':
/* it's backslash escaped */
break;
default:
/* delete leading white space */
*p != '\n' && p > bp)
{
p--;
}
(void) sm_strlcpy(p, e, strlen(p));
else
*p-- = '\0';
break;
}
continue;
}
if (*p != '$' || p[1] == '\0')
continue;
if (p[1] == '$')
{
/* actual dollar sign.... */
continue;
}
/* convert to macro expansion character */
*p++ = MACROEXPAND;
/* special handling for $=, $~, $&, and $? */
if (*p == '=' || *p == '~' || *p == '&' || *p == '?')
p++;
/* convert macro name to code */
*p = macid_parse(p, &ep);
if (ep != p + 1)
}
/* strip trailing white space from the line */
*p = '\0';
{
sm_dprintf(" translate_dollars => ");
sm_dprintf("\n");
}
return bp;
}
/*
** TOOMANY -- signal too many of some option
**
** Parameters:
** id -- the id of the error line
** maxcnt -- the maximum possible values
**
** Returns:
** none.
**
** Side Effects:
** gives a syserr.
*/
static void
int id;
int maxcnt;
{
}
/*
** FILECLASS -- read members of a class from a file
**
** Parameters:
** class -- class to define.
** filename -- name of file to read.
** fmt -- scanf string to use for match.
** ismap -- if set, this is a map lookup.
** safe -- if set, this is a safe read.
** optional -- if set, it is not an error for the file to
** not exist.
**
** Returns:
** none
**
** Side Effects:
** puts all lines in filename that match a scanf into
** the named class.
*/
/*
** Break up the match into words and add to class.
*/
static void
int class;
char *line;
{
{
register char *q;
/* strip leading spaces */
line++;
if (*line == '\0')
break;
/* find the end of the word */
q = line;
line++;
if (*line != '\0')
*line++ = '\0';
/* enter the word in the symbol table */
}
}
static void
int class;
char *filename;
char *fmt;
bool ismap;
bool safe;
bool optional;
{
SM_FILE_T *f;
long sff;
register char *p;
if (*filename == '\0')
{
syserr("fileclass: missing file name");
return;
}
else if (ismap)
{
int status = 0;
char *key;
char *mn;
/* skip past key */
{
/* should not happen */
syserr("fileclass: bogus map specification");
return;
}
/* skip past '@' */
*p++ = '\0';
cl = p;
#if LDAPMAP
{
int n;
char *lc;
/* Get $j */
if (jbuf[0] == '\0')
{
sizeof(jbuf));
}
/* impose the default schema */
lc = "";
else
{
}
cl = "ldap";
"-k (&(objectClass=sendmailMTAClass)(sendmailMTAClassName=%s)(|(sendmailMTACluster=%s)(sendmailMTAHost=%s))) -v sendmailMTAClassValue,sendmailMTAClassSearch:FILTER:sendmailMTAClass,sendmailMTAClassURL:URL:sendmailMTAClass",
if (n >= sizeof(buf))
{
syserr("fileclass: F{%s}: Default LDAP string too long",
mn);
return;
}
}
else
#endif /* LDAPMAP */
{
{
syserr("fileclass: F{%s}: missing map class",
mn);
return;
}
*spec++ ='\0';
}
/* set up map structure */
{
syserr("fileclass: F{%s}: class %s not available",
return;
}
sm_dprintf("fileclass: F{%s}: map class %s, key %s, spec %s\n",
/* parse map spec */
{
/* map_parse() showed the error already */
return;
}
/* open map */
{
}
else
{
if (!optional &&
syserr("fileclass: F{%s}: map open failed",
mn);
return;
}
/* lookup */
{
if (!optional)
syserr("fileclass: F{%s}: map lookup failed",
mn);
p = NULL;
}
/* use the results */
if (p != NULL)
parse_class_words(class, p);
/* close map */
return;
}
else if (filename[0] == '|')
{
auto int fd;
int i;
i = 0;
argv[i++] = p;
if (pid < 0)
f = NULL;
else
}
else
{
pid = -1;
sff = SFF_REGONLY;
sff |= SFF_SAFEDIRPATH;
sff |= SFF_NOWLINK;
if (safe)
sff |= SFF_OPENASROOT;
else if (RealUid == 0)
sff |= SFF_ROOTOK;
if (DontLockReadFiles)
sff |= SFF_NOLOCK;
}
if (f == NULL)
{
if (!optional)
return;
}
{
#if SCANF
#endif /* SCANF */
if (buf[0] == '#')
continue;
#if SCANF
continue;
p = wordbuf;
#else /* SCANF */
p = buf;
#endif /* SCANF */
parse_class_words(class, p);
/*
** If anything else is added here,
** check if the '@' map case above
** needs the code as well.
*/
}
(void) sm_io_close(f, SM_TIME_DEFAULT);
if (pid > 0)
}
/*
** MAKEMAILER -- define a new mailer.
**
** Parameters:
** line -- description of mailer. This is in labeled
** fields. The fields are:
** A -- the argv for this mailer
** C -- the character set for MIME conversions
** D -- the directory to run in
** E -- the eol string
** F -- the flags associated with the mailer
** L -- the maximum line length
** M -- the maximum message size
** N -- the niceness at which to run
** P -- the path to the mailer
** Q -- the queue group for the mailer
** R -- the recipient rewriting set
** S -- the sender rewriting set
** T -- the mailer type (for DSNs)
** U -- the uid to run as
** W -- the time to wait at the end
** m -- maximum messages per connection
** r -- maximum number of recipients per message
** / -- new root directory
** The first word is the canonical name of the mailer.
**
** Returns:
** none.
**
** Side Effects:
** enters the mailer into the mailer table.
*/
void
char *line;
{
register char *p;
register struct mailer *m;
register STAB *s;
int i;
char fcode;
auto char *endp;
/* allocate a mailer and set up defaults */
memset((char *) m, '\0', sizeof(*m));
errno = 0; /* avoid bogus error text */
/* collect the mailer name */
for (p = line;
p++)
continue;
if (*p != '\0')
*p++ = '\0';
if (line[0] == '\0')
{
syserr("name required for mailer");
return;
}
/* now scan through and assign info from the fields */
while (*p != '\0')
{
auto char *delimptr;
while (*p != '\0' &&
p++;
/* p now points to field code */
fcode = *p;
while (*p != '\0' && *p != '=' && *p != ',')
p++;
if (*p++ != '=')
{
return;
}
p++;
/* p now points to the field body */
/* install the field into the mailer struct */
switch (fcode)
{
case 'P': /* pathname */
if (*p != '\0') /* error is issued below */
break;
case 'F': /* flags */
for (; *p != '\0'; p++)
{
{
if (*p == M_INTERNAL)
"WARNING: mailer=%s, flag=%c deprecated",
m->m_name, *p);
#endif /* _FFR_DEPRECATE_MAILER_FLAG_I */
}
}
break;
case 'S': /* sender rewriting ruleset */
case 'R': /* recipient rewriting ruleset */
if (i < 0)
return;
if (fcode == 'S')
m->m_sh_rwset = m->m_se_rwset = i;
else
m->m_rh_rwset = m->m_re_rwset = i;
p = endp;
if (*p++ == '/')
{
if (i < 0)
return;
if (fcode == 'S')
m->m_sh_rwset = i;
else
m->m_rh_rwset = i;
}
break;
case 'E': /* end of line string */
if (*p == '\0')
syserr("mailer %s: null end-of-line string",
m->m_name);
else
break;
case 'A': /* argument vector */
if (*p != '\0') /* error is issued below */
break;
case 'M': /* maximum message size */
break;
case 'm': /* maximum messages per connection */
m->m_maxdeliveries = atoi(p);
break;
case 'r': /* max recipient per envelope */
break;
case 'L': /* maximum line length */
m->m_linelimit = atoi(p);
if (m->m_linelimit < 0)
m->m_linelimit = 0;
break;
case 'N': /* run niceness */
break;
case 'D': /* working directory */
if (*p == '\0')
syserr("mailer %s: null working directory",
m->m_name);
else
break;
case 'C': /* default charset */
if (*p == '\0')
else
m->m_defcharset = newstr(p);
break;
case 'Q': /* queue for this mailer */
if (*p == '\0')
{
break;
}
if (s == NULL)
syserr("mailer %s: unknown queue %s",
m->m_name, p);
else
break;
case 'T': /* MTA-Name/Address/Diagnostic types */
/* extract MTA name type; default to "dns" */
if (p != NULL)
{
*p++ = '\0';
if (*p == '\0')
p = NULL;
}
if (*m->m_mtatype == '\0')
m->m_mtatype = "dns";
/* extract address type; default to "rfc822" */
m->m_addrtype = p;
if (p != NULL)
p = strchr(p, '/');
if (p != NULL)
{
*p++ = '\0';
if (*p == '\0')
p = NULL;
}
m->m_addrtype = "rfc822";
/* extract diagnostic type; default to "smtp" */
m->m_diagtype = p;
m->m_diagtype = "smtp";
break;
case 'U': /* user id */
{
char *q = p;
while (*p != '\0' && isascii(*p) &&
p++;
*p++ = '\0';
if (*p != '\0')
*p++ = '\0';
if (*q == '\0')
{
syserr("mailer %s: null user name",
m->m_name);
break;
}
pw = sm_getpwnam(q);
{
syserr("readcf: mailer U= flag: unknown user %s", q);
break;
}
else
{
}
}
else
{
auto char *q;
p = q;
p++;
if (*p != '\0')
p++;
}
p++;
if (*p == '\0')
break;
{
char *q = p;
p++;
*p++ = '\0';
if (*q == '\0')
{
syserr("mailer %s: null group name",
m->m_name);
break;
}
{
syserr("readcf: mailer U= flag: unknown group %s", q);
break;
}
else
}
else
{
}
break;
case 'W': /* wait timeout */
break;
case '/': /* new root directory */
if (*p == '\0')
syserr("mailer %s: null root directory",
m->m_name);
else
break;
default:
syserr("M%s: unknown mailer equate %c=",
break;
}
p = delimptr;
}
#if !HASRRESVPORT
{
"M%s: Warning: F=%c set on system that doesn't support rresvport()\n",
m->m_name, M_SECURE_PORT);
}
#endif /* !HASRRESVPORT */
#if !HASNICE
if (m->m_nice != 0)
{
"M%s: Warning: N= set on system that doesn't support nice()\n",
m->m_name);
}
#endif /* !HASNICE */
/* do some rationality checking */
{
return;
}
{
return;
}
if (nextmailer >= MAXMAILERS)
{
return;
}
if (m->m_maxrcpt <= 0)
m->m_maxrcpt = DEFAULT_MAX_RCPT;
/* do some heuristic cleanup for back compatibility */
{
if (m->m_linelimit == 0)
m->m_linelimit = SMTPLINELIM;
if (ConfigLevel < 2)
}
{
return;
}
{
/* Use the second argument for host or path to socket */
{
syserr("M%s: too few parameters for %s mailer",
return;
}
#if NETUNIX
#endif /* NETUNIX */
)
{
"M%s: Warning: first argument in %s mailer must be %s\n",
#if NETUNIX
"TCP or FILE"
#else /* NETUNIX */
"TCP"
#endif /* NETUNIX */
);
}
m->m_mtatype = "dns";
if (m->m_addrtype == NULL)
m->m_addrtype = "rfc822";
if (m->m_diagtype == NULL)
{
m->m_diagtype = "x-unix";
else
m->m_diagtype = "smtp";
}
}
{
/* Use the second argument for filename */
{
syserr("M%s: too %s parameters for [FILE] mailer",
m->m_name,
return;
}
{
syserr("M%s: first argument in [FILE] mailer must be FILE",
m->m_name);
return;
}
}
{
char **pp;
/* default for SMTP is \r\n; use \n for local delivery */
{
for (p = *pp; *p != '\0'; )
{
break;
}
if (*p != '\0')
break;
}
m->m_eol = "\r\n";
else
m->m_eol = "\n";
}
/* enter the mailer into the symbol table */
{
}
else
{
i = nextmailer++;
}
m->m_mno = i;
}
/*
** MUNCHSTRING -- translate a string into internal form.
**
** Parameters:
** p -- the string to munch.
** delimptr -- if non-NULL, set to the pointer of the
** field delimiter character.
** delim -- the delimiter for the field.
**
** Returns:
** the munched string.
**
** Side Effects:
** the munched string is a local static buffer.
** it must be copied before the function is called again.
*/
char *
register char *p;
char **delimptr;
int delim;
{
register char *q;
bool backslash = false;
bool quotemode = false;
{
if (backslash)
{
/* everything is roughly literal */
backslash = false;
switch (*p)
{
case 'r': /* carriage return */
*q++ = '\r';
continue;
case 'n': /* newline */
*q++ = '\n';
continue;
case 'f': /* form feed */
*q++ = '\f';
continue;
case 'b': /* backspace */
*q++ = '\b';
continue;
}
*q++ = *p;
}
else
{
if (*p == '\\')
backslash = true;
else if (*p == '"')
*q++ = *p;
else
break;
}
}
*delimptr = p;
*q++ = '\0';
return buf;
}
/*
** EXTRQUOTSTR -- extract a (quoted) string.
**
** This routine deals with quoted (") strings and escaped
** spaces (\\ ).
**
** Parameters:
** p -- source string.
** delimptr -- if non-NULL, set to the pointer of the
** field delimiter character.
** delimbuf -- delimiters for the field.
** st -- if non-NULL, store the return value (whether the
** string was correctly quoted) here.
**
** Returns:
** the extracted string.
**
** Side Effects:
** the returned string is a local static buffer.
** it must be copied before the function is called again.
*/
static char *
register char *p;
char **delimptr;
char *delimbuf;
bool *st;
{
register char *q;
bool backslash = false;
bool quotemode = false;
{
if (backslash)
{
backslash = false;
if (*p != ' ')
*q++ = '\\';
}
if (*p == '\\')
backslash = true;
else if (*p == '"')
else if (quotemode ||
*q++ = *p;
else
break;
}
*delimptr = p;
*q++ = '\0';
return buf;
}
/*
** MAKEARGV -- break up a string into words
**
** Parameters:
** p -- the string to break up.
**
** Returns:
** a char **argv (dynamically allocated)
**
** Side Effects:
** munges p.
*/
static char **
makeargv(p)
register char *p;
{
char *q;
int i;
char **avp;
/* take apart the words */
i = 0;
while (*p != '\0' && i < MAXPV)
{
q = p;
p++;
*p++ = '\0';
}
/* now make a copy of the argv */
return avp;
}
/*
** PRINTRULES -- print rewrite rules (for debugging)
**
** Parameters:
** none.
**
** Returns:
** none.
**
** Side Effects:
** prints rewrite rules.
*/
void
{
register int ruleset;
{
continue;
{
sm_dprintf("\nLHS:");
sm_dprintf("RHS:");
}
}
}
/*
** PRINTMAILER -- print mailer structure (for debugging)
**
** Parameters:
** fp -- output file
** m -- the mailer to print
**
** Returns:
** none.
*/
void
register MAILER *m;
{
int j;
m->m_mailer);
m->m_se_rwset);
else
RuleSetNames[m->m_se_rwset]);
m->m_sh_rwset);
else
RuleSetNames[m->m_sh_rwset]);
m->m_re_rwset);
else
RuleSetNames[m->m_re_rwset]);
m->m_rh_rwset);
else
RuleSetNames[m->m_rh_rwset]);
for (j = '\0'; j <= '\177'; j++)
m->m_linelimit);
if (m->m_defcharset != NULL)
m->m_defcharset);
? "<undefined>" : m->m_mtatype,
m->m_addrtype == NULL
? "<undefined>" : m->m_addrtype,
m->m_diagtype == NULL
? "<undefined>" : m->m_diagtype);
{
char **a = m->m_argv;
while (*a != NULL)
{
if (a != m->m_argv)
" ");
}
}
}
/*
** SETOPTION -- set global processing option
**
** Parameters:
** opt -- option name.
** val -- option value (as a text string).
** safe -- set if this came from a configuration file.
** Some options (if set from the command line) will
** reset the user id to avoid security problems.
** sticky -- if set, don't let other setoptions override
** this value.
** e -- the main envelope.
**
** Returns:
** none.
**
** Side Effects:
** Sets options as implied by the arguments.
*/
#if NAMED_BIND
static struct resolverflags
{
} 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 },
# ifdef RES_USE_INET6
{ "use_inet6", RES_USE_INET6 },
# endif /* RES_USE_INET6 */
{ "true", 0 }, /* avoid error on old syntax */
{ NULL, 0 }
};
#endif /* NAMED_BIND */
static struct optioninfo
{
} OptionTab[] =
{
#if defined(SUN_EXTENSIONS) && defined(REMOTE_MODE)
#endif /* defined(SUN_EXTENSIONS) && defined(REMOTE_MODE) */
/* no long name, just here to avoid problems in setoption */
/* no long name, just here to avoid problems in setoption */
#endif /* _FFR_DONTLOCKFILESFORREAD_OPTION */
#endif /* _FFR_MAX_FORWARD_ENTRIES */
#else /* _FFR_ALLOW_SASLINFO */
#endif /* _FFR_ALLOW_SASLINFO */
#if _FFR_TLS_1
#endif /* _FFR_TLS_1 */
#if _FFR_CRLPATH
#endif /* _FFR_CRLPATH */
#if _FFR_MEMSTAT
#endif /* _FFR_MEMSTAT */
#if _FFR_MSG_ACCEPT
#endif /* _FFR_MSG_ACCEPT */
#endif /* _FFR_QUEUE_RUN_PARANOIA */
# if !ALLOW_255
# endif /* !ALLOW_255 */
#endif /* _FFR_EIGHT_BIT_ADDR_OK */
#endif /* _FFR_ADDR_TYPE_MODES */
#endif /* _FFR_BADRCPT_SHUTDOWN */
#if STARTTLS && _FFR_TLS_1
#endif /* STARTTLS && _FFR_TLS_1 */
#if _FFR_EXPDELAY
#endif /* _FFR_EXPDELAY */
#endif /* _FFR_RCPTTHROTDELAY */
#endif
#if STARTTLS && _FFR_FIPSMODE
#endif /* STARTTLS && _FFR_FIPSMODE */
#endif /* _FFR_REJECT_NUL_BYTE */
};
#if STARTTLS && _FFR_TLS_1
static struct ssl_options
{
} SSL_Option[] =
{
/* Workaround for bugs are turned on by default (as well as some others) */
#ifdef SSL_OP_MICROSOFT_SESS_ID_BUG
{ "SSL_OP_MICROSOFT_SESS_ID_BUG", SSL_OP_MICROSOFT_SESS_ID_BUG },
#endif
{ "SSL_OP_NETSCAPE_CHALLENGE_BUG", SSL_OP_NETSCAPE_CHALLENGE_BUG },
#endif
#ifdef SSL_OP_LEGACY_SERVER_CONNECT
{ "SSL_OP_LEGACY_SERVER_CONNECT", SSL_OP_LEGACY_SERVER_CONNECT },
#endif
{ "SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG", SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG },
#endif
{ "SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG", SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG },
#endif
{ "SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER", SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER },
#endif
{ "SSL_OP_MSIE_SSLV2_RSA_PADDING", SSL_OP_MSIE_SSLV2_RSA_PADDING },
#endif
{ "SSL_OP_SSLEAY_080_CLIENT_DH_BUG", SSL_OP_SSLEAY_080_CLIENT_DH_BUG },
#endif
#ifdef SSL_OP_TLS_D5_BUG
{ "SSL_OP_TLS_D5_BUG", SSL_OP_TLS_D5_BUG },
#endif
#ifdef SSL_OP_TLS_BLOCK_PADDING_BUG
{ "SSL_OP_TLS_BLOCK_PADDING_BUG", SSL_OP_TLS_BLOCK_PADDING_BUG },
#endif
{ "SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS", SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS },
#endif
#ifdef SSL_OP_ALL
{ "SSL_OP_ALL", SSL_OP_ALL },
#endif
#ifdef SSL_OP_NO_QUERY_MTU
{ "SSL_OP_NO_QUERY_MTU", SSL_OP_NO_QUERY_MTU },
#endif
#ifdef SSL_OP_COOKIE_EXCHANGE
{ "SSL_OP_COOKIE_EXCHANGE", SSL_OP_COOKIE_EXCHANGE },
#endif
#ifdef SSL_OP_NO_TICKET
{ "SSL_OP_NO_TICKET", SSL_OP_NO_TICKET },
#endif
#ifdef SSL_OP_CISCO_ANYCONNECT
{ "SSL_OP_CISCO_ANYCONNECT", SSL_OP_CISCO_ANYCONNECT },
#endif
{ "SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION", SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION },
#endif
#ifdef SSL_OP_NO_COMPRESSION
{ "SSL_OP_NO_COMPRESSION", SSL_OP_NO_COMPRESSION },
#endif
{ "SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION", SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION },
#endif
#ifdef SSL_OP_SINGLE_ECDH_USE
{ "SSL_OP_SINGLE_ECDH_USE", SSL_OP_SINGLE_ECDH_USE },
#endif
#ifdef SSL_OP_SINGLE_DH_USE
{ "SSL_OP_SINGLE_DH_USE", SSL_OP_SINGLE_DH_USE },
#endif
#ifdef SSL_OP_EPHEMERAL_RSA
{ "SSL_OP_EPHEMERAL_RSA", SSL_OP_EPHEMERAL_RSA },
#endif
{ "SSL_OP_CIPHER_SERVER_PREFERENCE", SSL_OP_CIPHER_SERVER_PREFERENCE },
#endif
#ifdef SSL_OP_TLS_ROLLBACK_BUG
{ "SSL_OP_TLS_ROLLBACK_BUG", SSL_OP_TLS_ROLLBACK_BUG },
#endif
#ifdef SSL_OP_NO_SSLv2
{ "SSL_OP_NO_SSLv2", SSL_OP_NO_SSLv2 },
#endif
#ifdef SSL_OP_NO_SSLv3
{ "SSL_OP_NO_SSLv3", SSL_OP_NO_SSLv3 },
#endif
#ifdef SSL_OP_NO_TLSv1
{ "SSL_OP_NO_TLSv1", SSL_OP_NO_TLSv1 },
#endif
#ifdef SSL_OP_NO_TLSv1_2
{ "SSL_OP_NO_TLSv1_2", SSL_OP_NO_TLSv1_2 },
#endif
#ifdef SSL_OP_NO_TLSv1_1
{ "SSL_OP_NO_TLSv1_1", SSL_OP_NO_TLSv1_1 },
#endif
#ifdef SSL_OP_PKCS1_CHECK_1
{ "SSL_OP_PKCS1_CHECK_1", SSL_OP_PKCS1_CHECK_1 },
#endif
#ifdef SSL_OP_PKCS1_CHECK_2
{ "SSL_OP_PKCS1_CHECK_2", SSL_OP_PKCS1_CHECK_2 },
#endif
#ifdef SSL_OP_NETSCAPE_CA_DN_BUG
{ "SSL_OP_NETSCAPE_CA_DN_BUG", SSL_OP_NETSCAPE_CA_DN_BUG },
#endif
{ "SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG", SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG },
#endif
#ifdef SSL_OP_CRYPTOPRO_TLSEXT_BUG
{ "SSL_OP_CRYPTOPRO_TLSEXT_BUG", SSL_OP_CRYPTOPRO_TLSEXT_BUG },
#endif
{ NULL, 0 }
};
#endif /* STARTTLS && _FFR_TLS_1 */
/* set a string option by expanding the value and assigning it */
/* WARNING this belongs ONLY into a case statement! */
break
void
int opt;
char *val;
bool safe;
bool sticky;
register ENVELOPE *e;
{
register char *p;
register struct optioninfo *o;
char *subopt;
int mid;
auto char *ep;
extern bool Warn_Q_option;
extern unsigned int SubmitMode;
#endif /* _FFR_ALLOW_SASLINFO */
#if STARTTLS || SM_CONF_SHM
char *newval;
#endif /* STARTTLS || SM_CONF_SHM */
#if STARTTLS && _FFR_TLS_1
#endif /* STARTTLS && _FFR_TLS_1 */
errno = 0;
if (opt == ' ')
{
/* full word options */
if (p == NULL)
while (*--p == ' ')
continue;
while (*++p == ' ')
*p = '\0';
if (p == val)
{
syserr("readcf: null option name");
return;
}
if (*p == '=')
*p++ = '\0';
while (*p == ' ')
p++;
*subopt++ = '\0';
{
continue;
{
/* completely specified -- this must be it */
break;
}
break;
sel = o;
}
o = sel;
{
return;
}
{
syserr("readcf: ambiguous option name %s (matches %s and %s)",
return;
}
{
Verbose = 1;
message("Option %s used as abbreviation for %s",
}
val = p;
}
else
{
{
break;
}
{
return;
}
}
{
sm_dprintf("setoption: %s does not support suboptions, ignoring .%s\n",
}
{
"setoption %s (%c)%s%s=" :
"setoption %s (0x%x)%s%s=",
}
/*
** See if this option is preset for us.
*/
{
sm_dprintf(" (ignored)\n");
return;
}
/*
** Check to see if this option can be specified by this user.
*/
safe = true;
{
{
int dp;
sm_dprintf(" (unsafe)");
dp = drop_privileges(true);
}
}
sm_dprintf("\n");
switch (opt & 0xff)
{
case '7': /* force seven-bit input */
break;
case '8': /* handling of 8-bit input */
#if MIME8TO7
switch (*val)
{
case 'p': /* pass 8 bit, convert MIME */
break;
case 'm': /* convert 8-bit, convert MIME */
break;
case 's': /* strict adherence */
break;
# if 0
case 'r': /* reject 8-bit, don't convert MIME */
MimeMode = 0;
break;
case 'j': /* "just send 8" */
break;
case 'a': /* encode 8 bit if available */
break;
case 'c': /* convert 8 bit to MIME, never 7 bit */
break;
# endif /* 0 */
default:
}
#else /* MIME8TO7 */
"Warning: Option: %s requires MIME8TO7 support\n",
OPTNAME);
#endif /* MIME8TO7 */
break;
case 'A': /* set default alias file */
if (val[0] == '\0')
{
char *al;
}
else
break;
case 'a': /* look N minutes for "@:@" in alias file */
if (val[0] == '\0')
else
break;
case 'B': /* substitution for blank character */
if (SpaceSub == '\0')
SpaceSub = ' ';
break;
if (p != NULL)
{
*p++ = '\0';
MaxMessageSize = atol(p);
}
break;
case 'c': /* don't connect to "expensive" mailers */
break;
case 'C': /* checkpoint every N addresses */
break;
case 'd': /* delivery mode */
switch (*val)
{
case '\0':
break;
case SM_QUEUE: /* queue only */
case SM_DEFER: /* queue only and defer map lookups */
case SM_DELIVER: /* do everything */
case SM_FORK: /* fork after verification */
#if _FFR_DM_ONE
/* deliver first TA in background, then queue */
case SM_DM_ONE:
#endif /* _FFR_DM_ONE */
set_delivery_mode(*val, e);
break;
default:
}
break;
if (*val != '\0')
break;
case 'e': /* set error processing mode */
switch (*val)
{
case EM_QUIET: /* be silent about it */
case EM_MAIL: /* mail back */
case EM_BERKNET: /* do berknet error processing */
case EM_WRITE: /* write back (or mail) */
case EM_PRINT: /* print errors normally (default) */
e->e_errormode = *val;
break;
}
break;
case 'F': /* file mode */
break;
case 'f': /* save Unix-style From lines on front */
break;
case 'G': /* match recipients against GECOS field */
break;
case 'g': /* default gid */
else
{
DefGid = -1;
syserr("readcf: option %c: unknown group %s",
else
}
break;
case 'H': /* help file */
if (val[0] == '\0')
{
}
else
{
}
break;
case 'h': /* maximum hop count */
break;
case 'I': /* use internet domain name server */
#if NAMED_BIND
for (p = val; *p != 0; )
{
bool clearmode;
char *q;
while (*p == ' ')
p++;
if (*p == '\0')
break;
clearmode = false;
if (*p == '-')
clearmode = true;
else if (*p != '+')
p--;
p++;
q = p;
p++;
if (*p != '\0')
*p++ = '\0';
if (sm_strcasecmp(q, "HasWildcardMX") == 0)
{
continue;
}
if (sm_strcasecmp(q, "WorkAroundBrokenAAAA") == 0)
{
continue;
}
{
break;
}
syserr("readcf: I option value %s unrecognized", q);
else if (clearmode)
else
}
sm_dprintf("_res.options = %x, HasWildcardMX = %d\n",
#else /* NAMED_BIND */
usrerr("name server (I option) specified but BIND not compiled in");
#endif /* NAMED_BIND */
break;
case 'i': /* ignore dot lines in message */
break;
case 'j': /* send errors in MIME (RFC 1341) format */
break;
case 'J': /* .forward search path */
break;
case 'k': /* connection cache size */
if (MaxMciCache < 0)
MaxMciCache = 0;
break;
case 'K': /* connection cache timeout */
break;
case 'l': /* use Errors-To: header */
break;
case 'L': /* log level */
break;
case 'M': /* define macro */
sticky = false;
if (mid == 0)
break;
if (!safe)
break;
case 'm': /* send to me too */
break;
case 'n': /* validate RHS in newaliases */
break;
/* 'N' available -- was "net name" */
case 'O': /* daemon options */
if (!setdaemonoptions(val))
break;
case 'o': /* assume old style headers */
else
break;
case 'p': /* select privacy level */
p = val;
for (;;)
{
extern struct prival PrivacyValues[];
p++;
if (*p == '\0')
break;
val = p;
p++;
if (*p != '\0')
*p++ = '\0';
{
break;
}
else
}
sticky = false;
break;
case 'P': /* postmaster copy address for returned mail */
break;
case 'q': /* slope of queue only function */
break;
case 'Q': /* queue directory */
if (val[0] == '\0')
{
QueueDir = "mqueue";
}
else
{
}
Warn_Q_option = true;
break;
case 'R': /* don't prune routes */
break;
case 'r': /* read timeout */
else
break;
case 'S': /* status file */
if (val[0] == '\0')
{
}
else
{
}
break;
case 's': /* be super safe, even if expensive */
#if MILTER
#else /* MILTER */
"Warning: SuperSafe=PostMilter requires Milter support (-DMILTER)\n");
#endif /* MILTER */
else
break;
case 'T': /* queue timeout */
if (p != NULL)
{
*p++ = '\0';
}
break;
case 't': /* time zone name */
break;
case 'U': /* location of user database */
break;
case 'u': /* set default uid */
for (p = val; *p != '\0'; p++)
{
if (*p == '/' || *p == ':')
# else /* _FFR_DOTTED_USERNAMES */
if (*p == '.' || *p == '/' || *p == ':')
# endif /* _FFR_DOTTED_USERNAMES */
{
*p++ = '\0';
break;
}
}
{
setdefuser();
}
else
{
DefUid = -1;
{
break;
}
else
{
}
}
# ifdef UID_MAX
{
syserr("readcf: option u: uid value (%ld) > UID_MAX (%ld); ignored",
break;
}
# endif /* UID_MAX */
/* handle the group if it is there */
if (*p == '\0')
break;
val = p;
goto g_opt;
case 'V': /* fallback MX host */
if (val[0] != '\0')
break;
case 'v': /* run in verbose mode */
break;
case 'w': /* if we are best MX, try host directly */
break;
/* 'W' available -- was wizard password */
case 'x': /* load avg at which to auto-queue msgs */
break;
case 'X': /* load avg at which to auto-reject connections */
break;
case O_DELAY_LA: /* load avg at which to delay connections */
break;
case 'y': /* work recipient factor */
break;
case 'Y': /* fork jobs during queue runs */
break;
case 'z': /* work message class factor */
break;
case 'Z': /* work time factor */
break;
/* coordinate this with makequeue() */
#endif /* _FFR_QUEUE_GROUP_SORTORDER */
case O_QUEUESORTORD: /* queue sorting order */
switch (*val)
{
case 'f': /* File Name */
case 'F':
break;
case 'h': /* Host first */
case 'H':
break;
case 'm': /* Modification time */
case 'M':
break;
case 'p': /* Priority order */
case 'P':
break;
case 't': /* Submission time */
case 'T':
break;
case 'r': /* Random */
case 'R':
break;
#if _FFR_RHS
case 's': /* Shuffled host name */
case 'S':
break;
#endif /* _FFR_RHS */
case 'n': /* none */
case 'N':
break;
default:
}
break;
case O_HOSTSFILE: /* pathname of /etc/hosts file */
break;
case O_MQA: /* minimum queue age between deliveries */
break;
#if _FFR_EXPDELAY
case O_MAX_QUEUE_AGE:
break;
#endif /* _FFR_EXPDELAY */
case O_DEFCHARSET: /* default character set for mimefying */
break;
case O_SSFILE: /* service switch file */
break;
case O_DIALDELAY: /* delay for dial-on-demand operation */
break;
case O_NORCPTACTION: /* what to do if no recipient */
else
break;
case O_SAFEFILEENV: /* chroot() environ for writing to files */
if (*val == '\0')
break;
/* strip trailing slashes */
while (p >= val && *p == '/')
*p-- = '\0';
if (*val == '\0')
break;
break;
case O_MAXMSGSIZE: /* maximum message size */
break;
case O_COLONOKINADDR: /* old style handling of colon addresses */
break;
case O_MAXQUEUERUN: /* max # of jobs in a single queue run */
break;
case O_MAXCHILDREN: /* max # of children of daemon */
break;
case O_MAXQUEUECHILDREN: /* max # of children of daemon */
break;
case O_MAXRUNNERSPERQUEUE: /* max # runners in a queue group */
break;
case O_NICEQUEUERUN: /* nice queue runs */
#if !HASNICE
"Warning: NiceQueueRun set on system that doesn't support nice()\n");
#endif /* !HASNICE */
/* XXX do we want to check the range? > 0 ? */
break;
case O_SHMKEY: /* shared memory key */
#if SM_CONF_SHM
#else /* SM_CONF_SHM */
"Warning: Option: %s requires shared memory support (-DSM_CONF_SHM)\n",
OPTNAME);
#endif /* SM_CONF_SHM */
break;
case O_SHMKEYFILE: /* shared memory key file */
#if SM_CONF_SHM
#else /* SM_CONF_SHM */
"Warning: Option: %s requires shared memory support (-DSM_CONF_SHM)\n",
OPTNAME);
break;
#endif /* SM_CONF_SHM */
case O_MAXFORWARD: /* max # of forward entries */
break;
#endif /* _FFR_MAX_FORWARD_ENTRIES */
case O_KEEPCNAMES: /* don't expand CNAME records */
break;
case O_MUSTQUOTE: /* must quote these characters in phrases */
else
"Warning: MustQuoteChars too long, ignored.\n");
break;
case O_SMTPGREETING: /* SMTP greeting message (old $e macro) */
break;
case O_UNIXFROM: /* UNIX From_ line (old $l macro) */
break;
case O_OPCHARS: /* operator characters (old $o macro) */
if (OperatorChars != NULL)
"Warning: OperatorChars is being redefined.\n It should only be set before ruleset definitions.\n");
break;
case O_DONTINITGRPS: /* don't call initgroups(3) */
break;
case O_SLFH: /* make sure from fits on one line */
break;
case O_ABH: /* allow HELO commands with syntax errors */
break;
case O_CONNTHROT: /* connection rate throttle */
break;
case O_UGW: /* group writable files are unsafe */
{
}
break;
case O_DBLBOUNCE: /* address to which to send double bounces */
break;
case O_HSDIR: /* persistent host status directory */
if (val[0] != '\0')
{
}
break;
case O_SINGTHREAD: /* single thread deliveries (requires hsdir) */
break;
case O_RUNASUSER: /* run bulk of code as this user */
for (p = val; *p != '\0'; p++)
{
if (*p == '/' || *p == ':')
# else /* _FFR_DOTTED_USERNAMES */
if (*p == '.' || *p == '/' || *p == ':')
# endif /* _FFR_DOTTED_USERNAMES */
{
*p++ = '\0';
break;
}
}
{
if (can_setuid)
}
else
{
{
break;
}
else if (can_setuid)
{
if (*p == '\0')
}
else if (UseMSP && *p == '\0')
"WARNING: RunAsUser for MSP ignored, check group ids (egid=%d, want=%d)\n",
(int) EffGid,
}
# ifdef UID_MAX
{
syserr("readcf: option RunAsUser: uid value (%ld) > UID_MAX (%ld); ignored",
break;
}
# endif /* UID_MAX */
if (*p != '\0')
{
{
else if (UseMSP)
(void) sm_io_fprintf(smioout,
"WARNING: RunAsUser for MSP ignored, check group ids (egid=%d, want=%d)\n",
(int) EffGid,
(int) runasgid);
}
else
{
syserr("readcf: option RunAsUser: unknown group %s",
p);
else if (UseMSP)
(void) sm_io_fprintf(smioout,
"WARNING: RunAsUser for MSP ignored, check group ids (egid=%d, want=%d)\n",
(int) EffGid,
}
}
sm_dprintf("readcf: RunAsUser = %d:%d\n",
break;
case O_DSN_RRT:
break;
case O_PIDFILE:
break;
case O_DONTBLAMESENDMAIL:
p = val;
for (;;)
{
extern struct dbsval DontBlameSendmailValues[];
p++;
if (*p == '\0')
break;
val = p;
p++;
if (*p != '\0')
*p++ = '\0';
for (dbs = DontBlameSendmailValues;
{
break;
}
else
}
sticky = false;
break;
case O_DPI:
else
break;
case O_MAXRCPT:
break;
case O_RCPTTHROT:
break;
case O_RCPTTHROTDELAY:
break;
#endif /* _FFR_RCPTTHROTDELAY */
case O_DEADLETTER:
break;
case O_DONTLOCK:
break;
#endif /* _FFR_DONTLOCKFILESFORREAD_OPTION */
case O_MAXALIASRCSN:
break;
case O_CNCTONLYTO:
/* XXX should probably use gethostbyname */
# if NETINET6
else
# endif /* NETINET6 */
# if NETINET
{
}
# endif /* NETINET */
{
syserr("readcf: option ConnectOnlyTo: invalid IP address %s",
val);
break;
}
#endif /* NETINET || NETINET6 */
break;
case O_TRUSTUSER:
# if !HASFCHOWN && !defined(_FFR_DROP_TRUSTUSER_WARNING)
if (!UseMSP)
"readcf: option TrustedUser may cause problems on systems\n which do not support fchown() if UseMSP is not set.\n");
# endif /* !HASFCHOWN && !defined(_FFR_DROP_TRUSTUSER_WARNING) */
else
{
TrustedUid = 0;
{
break;
}
else
}
# ifdef UID_MAX
if (TrustedUid > UID_MAX)
{
syserr("readcf: option TrustedUser: uid value (%ld) > UID_MAX (%ld)",
(long) TrustedUid, (long) UID_MAX);
TrustedUid = 0;
}
# endif /* UID_MAX */
break;
case O_MAXMIMEHDRLEN:
if (p != NULL)
*p++ = '\0';
if (p != NULL && *p != '\0')
MaxMimeFieldLength = atoi(p);
else
if (MaxMimeHeaderLength <= 0)
MaxMimeHeaderLength = 0;
else if (MaxMimeHeaderLength < 128)
"Warning: MaxMimeHeaderLength: header length limit set lower than 128\n");
if (MaxMimeFieldLength <= 0)
MaxMimeFieldLength = 0;
else if (MaxMimeFieldLength < 40)
"Warning: MaxMimeHeaderLength: field length limit set lower than 40\n");
/*
** Headers field values now include leading space, so let's
** adjust the values to be "backward compatible".
*/
if (MaxMimeHeaderLength > 0)
if (MaxMimeFieldLength > 0)
break;
case O_CONTROLSOCKET:
break;
case O_MAXHDRSLEN:
if (MaxHeadersLength > 0 &&
"Warning: MaxHeadersLength: headers length limit set lower than %d\n",
(MAXHDRSLEN / 2));
break;
case O_PROCTITLEPREFIX:
break;
#if SASL
case O_SASLINFO:
# if _FFR_ALLOW_SASLINFO
/*
** Allow users to select their own authinfo file
** under certain circumstances, otherwise just ignore
** the option. If the option isn't ignored, several
** commands don't work very well, e.g., mailq.
** However, this is not a "perfect" solution.
** If mail is queued, the authentication info
** will not be used in subsequent delivery attempts.
** If we really want to support this, then it has
** to be stored in the queue file.
*/
break;
# endif /* _FFR_ALLOW_SASLINFO */
break;
case O_SASLMECH:
if (AuthMechanisms != NULL)
if (*val != '\0')
else
break;
case O_SASLREALM:
if (*val != '\0')
else
break;
case O_SASLOPTS:
{
switch (*val)
{
case 'A':
break;
case 'a':
break;
case 'c':
break;
case 'd':
break;
case 'f':
break;
# if SASL >= 20101
case 'm':
break;
# endif /* SASL >= 20101 */
case 'p':
break;
case 'y':
break;
case ' ': /* ignore */
case '\t': /* ignore */
case ',': /* ignore */
break;
default:
"Warning: Option: %s unknown parameter '%c'\n",
? *val : '?');
break;
}
++val;
++val;
}
break;
case O_SASLBITS:
break;
#else /* SASL */
case O_SASLINFO:
case O_SASLMECH:
case O_SASLREALM:
case O_SASLOPTS:
case O_SASLBITS:
"Warning: Option: %s requires SASL support (-DSASL)\n",
OPTNAME);
break;
#endif /* SASL */
#if STARTTLS
case O_SRVCERTFILE:
case O_SRVKEYFILE:
case O_CLTCERTFILE:
case O_CLTKEYFILE:
case O_CACERTFILE:
case O_CACERTPATH:
case O_DHPARAMS:
# if _FFR_TLS_1
case O_DHPARAMS5:
case O_CIPHERLIST:
case O_SRV_SSL_OPTIONS:
case O_CLT_SSL_OPTIONS:
if (pssloptions == NULL)
for (p = val; *p != 0; )
{
bool clearmode;
char *q;
while (*p == ' ')
p++;
if (*p == '\0')
break;
clearmode = false;
if (*p == '-' || *p == '+')
clearmode = *p++ == '-';
q = p;
p++;
if (*p != '\0')
*p++ = '\0';
for (sslopts = SSL_Option;
{
break;
}
{
errno = 0;
syserr("readcf: %s option value %s unrecognized",
o->o_name, q);
}
else if (clearmode)
else
}
pssloptions = NULL;
break;
# endif /* _FFR_TLS_1 */
case O_CRLFILE:
# if OPENSSL_VERSION_NUMBER > 0x00907000L
# else /* OPENSSL_VERSION_NUMBER > 0x00907000L */
"Warning: Option: %s requires at least OpenSSL 0.9.7\n",
OPTNAME);
break;
# endif /* OPENSSL_VERSION_NUMBER > 0x00907000L */
# if _FFR_CRLPATH
case O_CRLPATH:
# if OPENSSL_VERSION_NUMBER > 0x00907000L
# else /* OPENSSL_VERSION_NUMBER > 0x00907000L */
"Warning: Option: %s requires at least OpenSSL 0.9.7\n",
OPTNAME);
break;
# endif /* OPENSSL_VERSION_NUMBER > 0x00907000L */
# endif /* _FFR_CRLPATH */
/*
** This doesn't work well for some options, e.g., no server cert,
** but fine for others.
**
** XXX Some people may want different certs per server.
**
** See also srvfeatures()
*/
case O_TLS_SRV_OPTS:
{
switch (*val)
{
case 'V':
break;
# if _FFR_TLS_1
/*
** Server without a cert? That works only if
** AnonDH is enabled as cipher, which is not in the
** default list. Hence the CipherList option must
** be available. Moreover: which clients support this
** besides sendmail with this setting?
*/
case 'C':
break;
# endif /* _FFR_TLS_1 */
case ' ': /* ignore */
case '\t': /* ignore */
case ',': /* ignore */
break;
default:
"Warning: Option: %s unknown parameter '%c'\n",
? *val : '?');
break;
}
++val;
++val;
}
break;
case O_RANDFILE:
break;
#else /* STARTTLS */
case O_SRVCERTFILE:
case O_SRVKEYFILE:
case O_CLTCERTFILE:
case O_CLTKEYFILE:
case O_CACERTFILE:
case O_CACERTPATH:
case O_DHPARAMS:
# if _FFR_TLS_1
case O_DHPARAMS5:
case O_CIPHERLIST:
# endif /* _FFR_TLS_1 */
case O_CRLFILE:
# if _FFR_CRLPATH
case O_CRLPATH:
# endif /* _FFR_CRLPATH */
case O_RANDFILE:
"Warning: Option: %s requires TLS support\n",
OPTNAME);
break;
#endif /* STARTTLS */
#if STARTTLS && _FFR_FIPSMODE
case O_FIPSMODE:
break;
#endif /* STARTTLS && _FFR_FIPSMODE */
case O_CLIENTPORT:
break;
case O_DF_BUFSIZE:
break;
case O_XF_BUFSIZE:
break;
case O_LDAPDEFAULTSPEC:
#if LDAPMAP
#else /* LDAPMAP */
"Warning: Option: %s requires LDAP support (-DLDAPMAP)\n",
OPTNAME);
#endif /* LDAPMAP */
break;
case O_INPUTMILTER:
#if MILTER
#else /* MILTER */
"Warning: Option: %s requires Milter support (-DMILTER)\n",
OPTNAME);
#endif /* MILTER */
break;
case O_MILTER:
#if MILTER
#else /* MILTER */
"Warning: Option: %s requires Milter support (-DMILTER)\n",
OPTNAME);
#endif /* MILTER */
break;
case O_QUEUE_FILE_MODE: /* queue file mode */
break;
case O_DLVR_MIN: /* deliver by minimum time */
break;
/* modifiers {daemon_flags} for direct submissions */
case O_DIRECTSUBMODIFIERS:
{
BITMAP256 m; /* ignored */
extern ENVELOPE BlankEnvelope;
macid("{daemon_flags}"),
getmodifiers(val, m));
}
break;
case O_FASTSPLIT:
break;
case O_MBDB:
break;
case O_MSQ:
break;
case O_SOFTBOUNCE:
break;
case O_REJECTLOGINTERVAL: /* time btwn log msgs while refusing */
break;
case O_REQUIRES_DIR_FSYNC:
#else /* REQUIRES_DIR_FSYNC */
/* silently ignored... required for cf file option */
#endif /* REQUIRES_DIR_FSYNC */
break;
break;
case O_FALLBACKSMARTHOST: /* fallback smart host */
if (val[0] != '\0')
break;
case O_HELONAME:
break;
#if _FFR_MEMSTAT
case O_REFUSELOWMEM:
break;
case O_QUEUELOWMEM:
break;
case O_MEMRESOURCE:
break;
#endif /* _FFR_MEMSTAT */
case O_MAXNOOPCOMMANDS:
break;
#if _FFR_MSG_ACCEPT
case O_MSG_ACCEPT:
break;
#endif /* _FFR_MSG_ACCEPT */
case O_CHK_Q_RUNNERS:
break;
#endif /* _FFR_QUEUE_RUN_PARANOIA */
case O_EIGHT_BIT_ADDR_OK:
break;
#endif /* _FFR_EIGHT_BIT_ADDR_OK */
case O_ADDR_TYPE_MODES:
break;
#endif /* _FFR_ADDR_TYPE_MODES */
case O_RCPTSHUTD:
break;
case O_RCPTSHUTDG:
break;
#endif /* _FFR_BADRCPT_SHUTDOWN */
case O_REJECTNUL:
break;
#endif /* _FFR_REJECT_NUL_BYTE */
default:
{
else
}
break;
}
/*
** Options with suboptions are responsible for taking care
** of sticky-ness (e.g., that a command line setting is kept
** when reading in the sendmail.cf file). This has to be done
** when the suboptions are parsed since each suboption must be
** sticky, not the root option.
*/
}
/*
** SETCLASS -- set a string into a class
**
** Parameters:
** class -- the class to put the string in.
** str -- the string to enter
**
** Returns:
** none.
**
** Side Effects:
** puts the word into the symbol table.
*/
void
int class;
char *str;
{
register STAB *s;
{
int mid;
str++;
if (mid == 0)
return;
sm_dprintf("setclass(%s, $=%s)\n",
}
else
{
}
}
/*
** MAKEMAPENTRY -- create a map entry
**
** Parameters:
** line -- the config file line
**
** Returns:
** A pointer to the map that has been created.
** NULL if there was a syntax error.
**
** Side Effects:
** Enters the map into the dictionary.
*/
MAP *
char *line;
{
register char *p;
char *mapname;
char *classname;
register STAB *s;
continue;
{
syserr("readcf: config K line: no map name");
return NULL;
}
mapname = p;
continue;
if (*p != '\0')
*p++ = '\0';
p++;
{
return NULL;
}
classname = p;
continue;
if (*p != '\0')
*p++ = '\0';
p++;
/* look up the class */
{
return NULL;
}
/* enter the map */
{
sm_dprintf("map %s, class %s, flags %lx, file %s,\n",
sm_dprintf("\tapp %s, domain %s, rebuild %s\n",
s->s_map.map_rebuild);
}
return &s->s_map;
}
/*
** STRTORWSET -- convert string to rewriting set number
**
** Parameters:
** p -- the pointer to the string to decode.
** endp -- if set, store the trailing delimiter here.
** stabmode -- ST_ENTER to create this entry, ST_FIND if
** it must already exist.
**
** Returns:
** The appropriate ruleset number.
** -1 if it is not valid (error already printed)
*/
int
char *p;
char **endp;
int stabmode;
{
int ruleset;
p++;
if (!isascii(*p))
{
syserr("invalid ruleset name: \"%.20s\"", p);
return -1;
}
if (isdigit(*p))
{
{
syserr("bad ruleset %d (%d max)",
ruleset = -1;
}
}
else
{
STAB *s;
char delim;
char *q = NULL;
q = p;
p++;
{
/* no valid characters */
syserr("invalid ruleset name: \"%.20s\"", q);
return -1;
}
*p++ = '\0';
delim = *p;
if (delim != '\0')
*p = '\0';
if (delim != '\0')
*p = delim;
if (s == NULL)
return -1;
{
continue;
{
syserr("bad ruleset definition \"%s\" (number required after `=')", q);
ruleset = -1;
}
else
{
{
syserr("bad ruleset number %d in \"%s\" (%d max)",
ruleset = -1;
}
}
}
else
{
*endp = p;
if (s->s_ruleset >= 0)
{
syserr("%s: too many named rulesets (%d max)",
q, MAXRWSETS / 2);
ruleset = -1;
}
}
if (s->s_ruleset >= 0 &&
ruleset >= 0 &&
{
syserr("%s: ruleset changed value (old %d, new %d)",
}
else if (ruleset >= 0)
{
}
{
char *h = NULL;
*h = '\0';
*h = delim; /* put back delim */
}
}
return ruleset;
}
/*
** SETTIMEOUT -- set an individual timeout
**
** Parameters:
** name -- the name of the timeout.
** val -- the value of the timeout.
** sticky -- if set, don't let other setoptions override
** this value.
**
** Returns:
** none.
*/
/* set if Timeout sub-option is stuck */
static struct timeoutinfo
{
} TimeOutTab[] =
{
{ "initial", TO_INITIAL },
{ "mail", TO_MAIL },
{ "rcpt", TO_RCPT },
{ "datainit", TO_DATAINIT },
{ "datablock", TO_DATABLOCK },
{ "datafinal", TO_DATAFINAL },
{ "command", TO_COMMAND },
{ "rset", TO_RSET },
{ "helo", TO_HELO },
{ "quit", TO_QUIT },
{ "misc", TO_MISC },
{ "ident", TO_IDENT },
{ "fileopen", TO_FILEOPEN },
{ "connect", TO_CONNECT },
{ "iconnect", TO_ICONNECT },
{ "queuewarn", TO_QUEUEWARN },
{ "queuewarn.*", TO_QUEUEWARN },
{ "queuewarn.normal", TO_QUEUEWARN_NORMAL },
{ "queuewarn.urgent", TO_QUEUEWARN_URGENT },
{ "queuewarn.non-urgent", TO_QUEUEWARN_NON_URGENT },
{ "queuereturn", TO_QUEUERETURN },
{ "queuereturn.*", TO_QUEUERETURN },
{ "queuereturn.normal", TO_QUEUERETURN_NORMAL },
{ "queuereturn.urgent", TO_QUEUERETURN_URGENT },
{ "queuereturn.non-urgent", TO_QUEUERETURN_NON_URGENT },
{ "hoststatus", TO_HOSTSTATUS },
{ "resolver.retrans", TO_RESOLVER_RETRANS },
{ "resolver.retrans.normal", TO_RESOLVER_RETRANS_NORMAL },
{ "resolver.retrans.first", TO_RESOLVER_RETRANS_FIRST },
{ "resolver.retry", TO_RESOLVER_RETRY },
{ "resolver.retry.normal", TO_RESOLVER_RETRY_NORMAL },
{ "resolver.retry.first", TO_RESOLVER_RETRY_FIRST },
{ "control", TO_CONTROL },
{ "lhlo", TO_LHLO },
{ "auth", TO_AUTH },
{ "starttls", TO_STARTTLS },
{ "aconnect", TO_ACONNECT },
{ "queuewarn.dsn", TO_QUEUEWARN_DSN },
{ "queuereturn.dsn", TO_QUEUERETURN_DSN },
{ NULL, 0 },
};
static void
char *name;
char *val;
bool sticky;
{
int i, addopts;
{
break;
}
{
errno = 0; /* avoid bogus error text */
return;
}
/*
** See if this option is preset for us.
*/
{
sm_dprintf(" (ignored)\n");
return;
}
sm_dprintf("\n");
addopts = 0;
{
case TO_INITIAL:
break;
case TO_MAIL:
break;
case TO_RCPT:
break;
case TO_DATAINIT:
break;
case TO_DATABLOCK:
break;
case TO_DATAFINAL:
break;
case TO_COMMAND:
break;
case TO_RSET:
break;
case TO_HELO:
break;
case TO_QUIT:
break;
case TO_MISC:
break;
case TO_IDENT:
break;
case TO_FILEOPEN:
break;
case TO_CONNECT:
break;
case TO_ICONNECT:
break;
case TO_ACONNECT:
break;
case TO_QUEUEWARN:
addopts = 2;
break;
case TO_QUEUEWARN_NORMAL:
break;
case TO_QUEUEWARN_URGENT:
break;
case TO_QUEUEWARN_NON_URGENT:
break;
case TO_QUEUEWARN_DSN:
break;
case TO_QUEUERETURN:
addopts = 2;
break;
case TO_QUEUERETURN_NORMAL:
break;
case TO_QUEUERETURN_URGENT:
break;
break;
case TO_QUEUERETURN_DSN:
break;
case TO_HOSTSTATUS:
break;
case TO_RESOLVER_RETRANS:
addopts = 2;
break;
case TO_RESOLVER_RETRY:
addopts = 2;
break;
break;
case TO_RESOLVER_RETRY_NORMAL:
break;
break;
case TO_RESOLVER_RETRY_FIRST:
break;
case TO_CONTROL:
break;
case TO_LHLO:
break;
#if SASL
case TO_AUTH:
break;
#endif /* SASL */
#if STARTTLS
case TO_STARTTLS:
break;
#endif /* STARTTLS */
default:
break;
}
if (sticky)
{
for (i = 0; i <= addopts; i++)
}
}
/*
** INITTIMEOUTS -- parse and set timeout values
**
** Parameters:
** val -- a pointer to the values. If NULL, do initial
** settings.
** sticky -- if set, don't let other setoptions override
** this suboption value.
**
** Returns:
** none.
**
** Side Effects:
** Initializes the TimeOuts structure
*/
void
register char *val;
bool sticky;
{
register char *p;
{
#if IDENTPROTO
#else /* IDENTPROTO */
#endif /* IDENTPROTO */
#if SASL
#endif /* SASL */
#if STARTTLS
#endif /* STARTTLS */
{
sm_dprintf("Timeouts:\n");
sm_dprintf(" connect = %ld\n",
(long) TimeOuts.to_connect);
sm_dprintf(" aconnect = %ld\n",
(long) TimeOuts.to_aconnect);
sm_dprintf(" initial = %ld\n",
(long) TimeOuts.to_initial);
sm_dprintf(" datainit = %ld\n",
(long) TimeOuts.to_datainit);
sm_dprintf(" datablock = %ld\n",
(long) TimeOuts.to_datablock);
sm_dprintf(" datafinal = %ld\n",
(long) TimeOuts.to_datafinal);
sm_dprintf(" nextcommand = %ld\n",
(long) TimeOuts.to_nextcommand);
sm_dprintf(" miscshort = %ld\n",
(long) TimeOuts.to_miscshort);
sm_dprintf(" fileopen = %ld\n",
(long) TimeOuts.to_fileopen);
sm_dprintf(" lhlo = %ld\n",
sm_dprintf(" control = %ld\n",
(long) TimeOuts.to_control);
}
return;
}
for (;; val = p)
{
val++;
if (*val == '\0')
break;
continue;
if (*p != '\0')
*p++ = '\0';
{
/* old syntax -- set everything */
if (sticky)
{
}
continue;
}
else
{
{
/* syntax error */
continue;
}
*q++ = '\0';
}
}
}