sendmail.h revision 3ee0e49223f178da635734759b9167f924321ff0
/*
* Copyright (c) 1998-2006 Sendmail, 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.
*/
/*
** SENDMAIL.H -- MTA-specific definitions for sendmail.
*/
#ifndef _SENDMAIL_H
# define _SENDMAIL_H 1
#pragma ident "%Z%%M% %I% %E% SMI"
#ifndef MILTER
#endif /* MILTER */
#ifdef _DEFINE
# define EXTERN
#else /* _DEFINE */
# define EXTERN extern
#endif /* _DEFINE */
#include <unistd.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <setjmp.h>
#include <string.h>
#include <time.h>
# ifdef EX_OK
# endif /* EX_OK */
#include "sendmail/sendmail.h"
/* profiling? */
#if MONCONTROL
# define SM_PROF(x) moncontrol(x)
#else /* MONCONTROL */
# define SM_PROF(x)
#endif /* MONCONTROL */
#ifdef _DEFINE
# ifndef lint
# endif /* ! lint */
#endif /* _DEFINE */
#include "bf.h"
#include "timers.h"
#include <sm/errstring.h>
#include <sm/sysexits.h>
#ifdef LOG
# include <syslog.h>
#endif /* LOG */
# endif /* NETINET || NETINET6 || NETUNIX || NETISO || NETNS || NETX25 */
# if NETUNIX
# endif /* NETUNIX */
# endif /* NETINET || NETINET6 */
# if NETINET6
/*
** There is no standard yet for IPv6 includes.
** Specify OS specific implementation in conf.h
*/
# endif /* NETINET6 */
# if NETISO
# endif /* NETISO */
# if NETNS
# endif /* NETNS */
# if NETX25
# endif /* NETX25 */
# if NAMED_BIND
# ifdef NOERROR
# endif /* NOERROR */
# include <resolv.h>
# else /* NAMED_BIND */
# define SM_SET_H_ERRNO(err)
# endif /* NAMED_BIND */
# if HESIOD
# include <hesiod.h>
# if !defined(HES_ER_OK) || defined(HESIOD_INTERFACES)
# define HESIOD_INIT /* support for the new interface */
# endif /* !defined(HES_ER_OK) || defined(HESIOD_INTERFACES) */
# endif /* HESIOD */
#if STARTTLS
# if !TLS_NO_RSA
# define RSA_KEYLENGTH 512
# endif /* !TLS_NO_RSA */
#endif /* STARTTLS */
#if SASL /* include the sasl include files if we have them */
# include <sasl/saslutil.h>
# else /* SASL == 2 || SASL >= 20000 */
# include <sasl.h>
# include <saslutil.h>
# endif /* SASL == 2 || SASL >= 20000 */
# define SASL SASL_VERSION
# else /* SASL == 1 || SASL == 2 */
# if SASL != SASL_VERSION
ERROR README: -DSASL (SASL) does not agree with the version of the CYRUS_SASL library (SASL_VERSION)
# endif /* SASL != SASL_VERSION */
# endif /* SASL == 1 || SASL == 2 */
# else /* defined(SASL_VERSION_MAJOR) && defined(SASL_VERSION_MINOR) && defined(SASL_VERSION_STEP) */
# if SASL == 1
# endif /* SASL == 1 */
# endif /* defined(SASL_VERSION_MAJOR) && defined(SASL_VERSION_MINOR) && defined(SASL_VERSION_STEP) */
#endif /* SASL */
/*
** Following are "sort of" configuration constants, but they should
** be pretty solid on most architectures today. They have to be
** file also define them. In all cases, we can't use sizeof because
** some systems (e.g., Crays) always treat everything as being at
** least 64 bits.
*/
#ifndef INADDRSZ
#endif /* ! INADDRSZ */
#ifndef IN6ADDRSZ
#endif /* ! IN6ADDRSZ */
#ifndef INT16SZ
#endif /* ! INT16SZ */
#ifndef INT32SZ
#endif /* ! INT32SZ */
#ifndef INADDR_LOOPBACK
#endif /* ! INADDR_LOOPBACK */
/*
*/
#ifndef INADDR_NONE
# define INADDR_NONE 0xffffffff
#endif /* ! INADDR_NONE */
/* (f)open() modes for queue files */
# define QF_O_EXTRA 0
/*
** An 'argument class' describes the storage allocation status
** of an object pointed to by an argument to a function.
*/
typedef enum
{
A_HEAP, /* the storage was allocated by malloc, and the
* ownership of the storage is ceded by the caller
* to the called function. */
A_TEMP, /* The storage is temporary, and is only guaranteed
* to be valid for the duration of the function call. */
A_PERM /* The storage is 'permanent': this might mean static
* storage, or rpool storage. */
} ARGCLASS_T;
/* forward references for prototypes */
/*
** Address structure.
** Addresses are stored internally in this structure.
*/
struct address
{
char *q_paddr; /* the printname for the address */
char *q_user; /* user name */
char *q_ruser; /* real user name, or NULL if q_user */
char *q_host; /* host name */
unsigned long q_flags; /* status flags, see below */
char *q_home; /* home dir (local mailer only) */
char *q_fullname; /* full name if known */
char *q_owner; /* owner of q_alias */
#if PIPELINING
#endif /* PIPELINING */
char *q_finalrcpt; /* Final-Recipient: DSN header */
char *q_orcpt; /* ORCPT parameter from RCPT TO: line */
char *q_status; /* status code for DSNs */
char *q_rstatus; /* remote status message for DSNs */
char *q_statmta; /* MTA generating q_rstatus */
short q_state; /* address state, see below */
char *q_signature; /* MX-based sorting value */
int q_qgrp; /* index into queue groups */
int q_qdir; /* queue directory inside group */
char *q_message; /* error message */
};
/* bit values for q_flags */
/* values for q_state */
#define QS_OK 0 /* address ok (for now)/not yet tried */
/*
** Notice: all of the following values are variations of QS_DONTSEND.
** If new states are added, they must be inserted in the proper place!
** See the macro definition of QS_IS_DEAD() down below.
*/
/* address state testing primitives */
#define QS_IS_SENT(s) ((s) == QS_SENT)
#define QS_IS_BADADDR(s) ((s) == QS_BADADDR)
#define QS_IS_QUEUEUP(s) ((s) == QS_QUEUEUP)
#define QS_IS_RETRY(s) ((s) == QS_RETRY)
#define QS_IS_VERIFIED(s) ((s) == QS_VERIFIED)
#define QS_IS_EXPANDED(s) ((s) == QS_EXPANDED)
#define QS_IS_REMOVED(s) ((s) == QS_REMOVED)
#define QS_IS_UNDELIVERED(s) ((s) == QS_OK || \
(s) == QS_QUEUEUP || \
(s) == QS_RETRY || \
(s) == QS_VERIFIED)
#define QS_IS_UNMARKED(s) ((s) == QS_OK || \
(s) == QS_RETRY)
#define QS_IS_SENDABLE(s) ((s) == QS_OK || \
(s) == QS_QUEUEUP || \
(s) == QS_RETRY)
#define QS_IS_ATTEMPTED(s) ((s) == QS_QUEUEUP || \
(s) == QS_RETRY || \
(s) == QS_SENT)
#define QS_IS_DEAD(s) ((s) >= QS_DONTSEND)
/* functions */
extern bool invalidaddr __P((char *, char *, bool));
ENVELOPE *, bool));
#if MILTER
#endif /* MILTER */
/* macro to simplify the common call to rewrite() */
/*
** Mailer definition structure.
** Every mailer known to the system is declared in this
** structure. It defines the pathname of the mailer, some
** flags associated with it, and the argument vector to
** pass to it. The flags are defined in conf.c
**
** The argument vector is expanded before actual use. All
** words except the first are passed through the macro
** processor.
*/
struct mailer
{
char *m_name; /* symbolic name of this mailer */
char *m_mailer; /* pathname of the mailer to use */
char *m_mtatype; /* type of this MTA */
char *m_addrtype; /* type for addresses */
char *m_diagtype; /* type for diagnostics */
short m_mno; /* mailer number internally */
short m_nice; /* niceness to run at (mostly for prog) */
char **m_argv; /* template argument vector */
short m_sh_rwset; /* rewrite set: sender header addresses */
short m_se_rwset; /* rewrite set: sender envelope addresses */
short m_rh_rwset; /* rewrite set: recipient header addresses */
short m_re_rwset; /* rewrite set: recipient envelope addresses */
char *m_eol; /* end of line string */
long m_maxsize; /* size limit on message to this mailer */
int m_linelimit; /* max # characters per line */
int m_maxdeliveries; /* max deliveries per mailer connection */
char *m_execdir; /* directory to chdir to before execv */
char *m_rootdir; /* directory to chroot to before execv */
char *m_defcharset; /* default character set */
int m_maxrcpt; /* max recipients per envelope client-side */
short m_qgrp; /* queue group for this mailer */
};
/* bits for m_flags */
/* 'D' CF: include Date: */
/* 'F' CF: include From: or Resent-From: */
/* 'M' CF: include Message-Id: */
/* 'P' CF: include Return-Path: */
/* 'V' UIUC: !-relativize all addresses */
/* 'x' CF: include Full-Name: */
/* functions */
extern void initerrmailers __P((void));
extern void makemailer __P((char *));
extern void runqueueevent __P((int));
extern bool checkqueuerunner __P((void));
#endif /* _FFR_QUEUE_RUN_PARANOIA */
/*
** Queue group definition structure.
** Every queue group known to the system is declared in this structure.
** It defines the basic pathname of the queue group, some flags
** associated with it, and the argument vector to pass to it.
*/
struct qpaths_s
{
char *qp_name; /* name of queue dir, relative path */
short qp_subdirs; /* use subdirs? */
short qp_fsysidx; /* file system index of this directory */
# if SM_CONF_SHM
int qp_idx; /* index into array for queue information */
# endif /* SM_CONF_SHM */
};
struct queuegrp
{
char *qg_name; /* symbolic name of this queue group */
/*
** For now this is the same across all queue groups.
** Otherwise we have to play around with chdir().
*/
char *qg_qdir; /* common component of queue directory */
short qg_index; /* queue number internally, index in Queue[] */
int qg_maxqrun; /* max # of jobs in 1 queuerun */
int qg_numqueues; /* number of queues in this queue */
/*
** qg_queueintvl == 0 denotes that no individual value is used.
** Whatever accesses this must deal with "<= 0" as
** "not set, use appropriate default".
*/
short qg_nice; /* niceness for queue run */
int qg_wgrp; /* Assigned to this work group */
int qg_maxlist; /* max items in work queue for this group */
int qg_curnum; /* current number of queue for queue runs */
int qg_maxrcpt; /* max recipients per envelope, 0==no limit */
short qg_sortorder; /* how do we sort this queuerun */
#endif /* _FFR_QUEUE_GROUP_SORTORDER */
#if 0
long qg_wkrcptfact; /* multiplier for # recipients -> priority */
long qg_qfactor; /* slope of queue function */
bool qg_doqueuerun; /* XXX flag is it time to do a queuerun */
#endif /* 0 */
};
/* bits for qg_flags (XXX: unused as of now) */
extern void filesys_update __P((void));
#if _FFR_ANY_FREE_FS
extern bool filesys_free __P((long));
#endif /* _FFR_ANY_FREE_FS */
#if SASL
/*
** SASL
*/
/* lines in authinfo file or index into SASL_AI_T */
# define SASL_WRONG (-1)
# define SASL_USER 0 /* authorization id (user) */
/*
** Current mechanism; this is just used to convey information between
** invocation of SASL callback functions.
** It must be last in the list, because it's not allocated by us
** and hence we don't free() it.
*/
# define SASL_MECH 6
/* authenticated? */
# define SASL_NOT_AUTH 0 /* not authenticated */
/* SASL options */
# if SASL >= 20101
# else /* SASL >= 20101 */
# if (SASL_SEC_NOPLAINTEXT & SASL_SEC_MASK) == 0 || \
(SASL_SEC_NOACTIVE & SASL_SEC_MASK) == 0 || \
(SASL_SEC_NODICTIONARY & SASL_SEC_MASK) == 0 || \
(SASL_SEC_FORWARD_SECRECY & SASL_SEC_MASK) == 0 || \
(SASL_SEC_NOANONYMOUS & SASL_SEC_MASK) == 0 || \
(SASL_SEC_PASS_CREDENTIALS & SASL_SEC_MASK) == 0
# endif /* SASL_SEC_NOPLAINTEXT & SASL_SEC_MASK) == 0 ... */
# endif /* SASL >= 20101 */
/* functions */
extern char *iteminlist __P((char *, char *, char *));
# if SASL >= 20000
extern int proxy_policy __P((sasl_conn_t *, void *, const char *, unsigned, const char *, unsigned, const char *, unsigned, struct propctx *));
# else /* SASL >= 20000 */
extern int proxy_policy __P((void *, const char *, const char *, const char **, const char **));
# if SASL > 10515
extern int safesaslfile __P((void *, char *, int));
# else /* SASL > 10515 */
extern int safesaslfile __P((void *, char *));
# endif /* SASL > 10515 */
# endif /* SASL >= 20000 */
extern void stop_sasl_client __P((void));
/* structure to store authinfo */
typedef char *SASL_AI_T[SASL_ENTRIES];
#endif /* SASL */
/*
** Structure to store macros.
*/
typedef struct
{
} MACROS_T;
/*
** Information about currently open connections to mailers, or to
** hosts that we have looked up recently.
*/
#define MCI struct mailer_con_info
{
unsigned long mci_flags; /* flag bits, see below */
short mci_errno; /* error number on last connection */
short mci_herrno; /* h_errno from last DNS lookup */
short mci_exitstat; /* exit status from last connection */
short mci_state; /* SMTP state */
int mci_deliveries; /* delivery attempts for connection */
long mci_maxsize; /* max size this server will accept */
char *mci_phase; /* SMTP phase string */
char *mci_host; /* host name */
char *mci_status; /* DSN status to be copied to addrs */
char *mci_rstatus; /* SMTP status to be copied to addrs */
char *mci_heloname; /* name to use as HELO arg */
long mci_min_by; /* minimum DELIVERBY */
bool mci_retryrcpt; /* tempfail for at least one rcpt */
char *mci_tolist; /* list of valid recipients */
#if PIPELINING
int mci_okrcpts; /* number of valid recipients */
#endif /* PIPELINING */
#if SASL
bool mci_sasl_auth; /* authenticated? */
int mci_sasl_string_len;
char *mci_sasl_string; /* sasl reply string */
char *mci_saslcap; /* SASL list of mechanisms */
#endif /* SASL */
#if STARTTLS
#endif /* STARTTLS */
};
/* flag bits */
/* 0x00000002 unused, was MCIF_TEMP */
/* 0x00000100 unused, was MCIF_MULTSTAT: MAIL11V3: handles MULT status */
#if STARTTLS
#define MCIF_EXTENS (MCIF_EXPN | MCIF_SIZE | MCIF_8BITMIME | MCIF_DSN | MCIF_8BITOK | MCIF_AUTH | MCIF_ENHSTAT | MCIF_TLS)
#else /* STARTTLS */
#define MCIF_EXTENS (MCIF_EXPN | MCIF_SIZE | MCIF_8BITMIME | MCIF_DSN | MCIF_8BITOK | MCIF_AUTH | MCIF_ENHSTAT)
#endif /* STARTTLS */
#endif /* _FFR_IGNORE_EXT_ON_HELO */
/* states */
#define MCIS_CLOSED 0 /* no traffic on this connection */
/* functions */
extern int mci_print_persistent __P((char *, char *));
extern int mci_purge_persistent __P((char *, char *));
extern int mci_traverse_persistent __P((int (*)(), char *));
/*
** Header structure.
** This structure is used internally to store header items.
*/
struct header
{
char *h_field; /* the name of the field */
char *h_value; /* the value of that field */
unsigned char h_macro; /* include header if macro defined */
unsigned long h_flags; /* status bits, see below */
};
/*
** Header information structure.
** Defined in conf.c, this struct declares the header fields
** that have some magic meaning.
*/
struct hdrinfo
{
char *hi_field; /* the name of the field */
unsigned long hi_flags; /* status bits, see below */
char *hi_ruleset; /* validity check ruleset */
};
/* bits for h_flags and hi_flags */
/* bits for chompheader() */
/* functions */
extern void setupheaders __P((void));
/*
** Performance monitoring
*/
{
};
/*
** Envelope structure.
** This structure defines the message itself. There is usually
** only one of these -- for the message that we originally read
** and which is our primary interest -- but other envelopes can
** be generated during processing. For example, error messages
** will have their own envelope.
*/
struct envelope
{
long e_msgpriority; /* adjusted priority of this message */
char *e_to; /* (list of) target person(s) */
char *e_sender; /* e_from.q_paddr w comments stripped */
char **e_fromdomain; /* the domain part of the sender */
/*
** Overflow detection is based on < 0, so don't change this
** to unsigned. We don't use unsigned and == ULONG_MAX because
** some libc's don't have strtoul(), see mail_esmtp_args().
*/
long e_msgsize; /* size of the message in bytes */
char *e_msgid; /* message id (for logging) */
unsigned long e_flags; /* flags, see below */
int e_nrcpts; /* number of recipients */
short e_class; /* msg class (priority, junk, etc.) */
short e_hopcount; /* number of times processed */
short e_nsent; /* number of sends since checkpoint */
short e_sendmode; /* message send mode */
short e_errormode; /* error return mode */
short e_timeoutclass; /* message timeout class */
/* function to put header of message */
/* function to put body of message */
char *e_bodytype; /* type of message body */
char *e_id; /* code for this entry in queue */
int e_qgrp; /* queue group (index into queues) */
int e_qdir; /* index into queue directories */
int e_dfqgrp; /* data file queue group index */
int e_dfqdir; /* data file queue directory index */
int e_xfqgrp; /* queue group (index into queues) */
int e_xfqdir; /* index into queue directories (xf) */
char *e_message; /* error message; readonly; NULL, or
* static storage, or allocated from
* e_rpool */
char *e_statmsg; /* stat msg (changes per delivery).
* readonly. NULL or allocated from
* e_rpool. */
char *e_quarmsg; /* why envelope is quarantined */
char e_qfletter; /* queue file letter on disk */
char *e_msgboundary; /* MIME-style message part boundary */
char *e_origrcpt; /* original recipient (one only) */
char *e_envid; /* envelope id from MAIL FROM: line */
char *e_status; /* DSN status for this message */
int e_ntries; /* number of delivery attempts */
char *e_auth_param; /* readonly; NULL or static storage or
* allocated from e_rpool */
long e_deliver_by; /* deliver by */
int e_dlvr_flag; /* deliver by flag */
};
/* values for e_flags */
#define DLVR_NOTIFY 0x01
#define DLVR_RETURN 0x02
#define DLVR_TRACE 0x10
#define IS_DLVR_BY(e) ((e)->e_dlvr_flag != 0)
#define BODYTYPE_NONE (0)
#define BODYTYPE_7BIT (1)
#define BODYTYPE_8BITMIME (2)
#define BODYTYPE_ILLEGAL (-1)
extern ENVELOPE BlankEnvelope;
/* functions */
/*
** Message priority classes.
**
** The message class is read directly from the Priority: header
** field in the message.
**
** CurEnv->e_msgpriority is the number of bytes in the message plus
** the creation time (so that jobs ``tend'' to be ordered correctly),
** adjusted by the message class, the number of recipients, and the
** amount of time the message has been sitting around. This number
** is used to order the queue. Higher values mean LOWER priority.
**
** Each priority class point is worth WkClassFact priority points;
** each recipient is worth WkRecipFact priority points. Each time
** we reprocess a message the priority is adjusted by WkTimeFact.
** WkTimeFact should normally decrease the priority so that jobs
** that have historically failed will be run later; thanks go to
** Jay Lepreau at Utah for pointing out the error in my thinking.
**
** The "class" is this number, unadjusted by the age or size of
** this message. Classes with negative representations will have
** error messages thrown away if they are not local.
*/
struct priority
{
char *pri_name; /* external name of priority */
int pri_val; /* internal value for same */
};
/*
** Rewrite rules.
*/
struct rewrite
{
char **r_lhs; /* pattern match */
char **r_rhs; /* substitution value */
int r_line; /* rule line in sendmail.cf */
};
/*
** Special characters in rewriting rules.
** These are used internally only.
** The COND* rules are actually used in macros rather than in
** rewriting rules, but are given here because they
** cannot conflict.
*/
/* left hand side items */
/* right hand side items */
/* conditionals in macros */
/* bracket characters for host name lookup */
/* bracket characters for generalized lookup */
/* macro substitution character */
/* to make the code clearer */
/* external <==> internal mapping table */
struct metamac
{
char metaname; /* external code (after $) */
unsigned char metaval; /* internal code (as above) */
};
/* values for macros with external names only */
/* functions */
#if SM_HEAP_CHECK
extern void
int _id,
char *_value,
char *_file,
int _line,
int _group));
#else /* SM_HEAP_CHECK */
extern void
int _id,
char *_value));
#endif /* SM_HEAP_CHECK */
extern int macid_parse __P((char *, char **));
extern int strtorwset __P((char *, char **, int));
extern void translate_dollars __P((char *));
extern bool wordinclass __P((char *, int));
/*
** Name canonification short circuit.
**
** If the name server for a host is down, the process of trying to
** canonify the name can hang. This is similar to (but alas, not
** identical to) looking up the name for delivery. This stab type
** caches the result of the name server lookup so we don't hang
** multiple times.
*/
#define NAMECANON struct _namecanon
{
short nc_errno; /* cached errno */
short nc_herrno; /* cached h_errno */
short nc_stat; /* cached exit status code */
short nc_flags; /* flag bits */
char *nc_cname; /* the canonical name */
};
/* values for nc_flags */
/* hostsignature structure */
struct hostsig_t
{
char *hs_sig; /* hostsignature */
};
/* functions */
extern bool getcanonname __P((char *, int, bool, int *));
extern int getfallbackmxrr __P((char *));
/*
** Mapping functions
**
** These allow arbitrary mappings in the config file. The idea
** (albeit not the implementation) comes from IDA sendmail.
*/
/*
** An actual map.
*/
{
char *map_mname; /* name of this map */
long map_mflags; /* flags, see below */
char *map_file; /* the (nominal) filename */
char *map_keycolnm; /* key column name */
char *map_valcolnm; /* value column name */
unsigned char map_keycolno; /* key column number */
unsigned char map_valcolno; /* value column number */
char map_coldelim; /* column delimiter */
char map_spacesub; /* spacesub */
char *map_app; /* to append to successful matches */
char *map_tapp; /* to append to "tempfail" matches */
char *map_domain; /* the (nominal) NIS domain */
char *map_rebuild; /* program to run to do auto-rebuild */
int map_retry; /* # of retries for map accesses */
int map_lockfd; /* auxiliary lock file descriptor */
short map_specificity; /* specificity of aliases */
};
/* bit values for map_mflags */
/* 0x00004000 */
{ \
return NULL; \
}
/* indices for map_actions */
#define MA_NOTFOUND 0 /* member map returned "not found" */
/* macros to handle MapTempFail */
#define RESET_MAPTEMPFAIL MapTempFail = 0
/*
** The class of a map -- essentially the functions to call
*/
{
char *map_cname; /* name of this map class */
char *map_ext; /* extension for database file */
short map_cflags; /* flag bits, see below */
/* argument parsing function */
/* lookup function */
/* store function */
/* open function */
/* close function */
};
/* bit values for map_cflags */
/* functions */
#if NETINFO
extern char *ni_propval __P((char *, char *, char *, char *, int));
#endif /* NETINFO */
#if USERDB
extern void _udbx_close __P((void));
#endif /* USERDB */
/*
** LDAP related items
*/
#if LDAPMAP
/* struct defining LDAP Auth Methods */
struct lamvalues
{
char *lam_name; /* name of LDAP auth method */
int lam_code; /* numeric code */
};
/* struct defining LDAP Alias Dereferencing */
struct ladvalues
{
char *lad_name; /* name of LDAP alias dereferencing method */
int lad_code; /* numeric code */
};
/* struct defining LDAP Search Scope */
struct lssvalues
{
char *lss_name; /* name of LDAP search scope */
int lss_code; /* numeric code */
};
/* functions */
extern void ldapmap_set_defaults __P((char *));
#endif /* LDAPMAP */
/*
** PH related items
*/
#if PH_MAP
# include <phclient.h>
struct ph_map_struct
{
char *ph_servers; /* list of ph servers */
char *ph_field_list; /* list of fields to search for match */
int ph_fastclose; /* send "quit" command on close */
};
typedef struct ph_map_struct PH_MAP_STRUCT;
#endif /* PH_MAP */
/*
** Regular UNIX sockaddrs are too small to handle ISO addresses, so
** we are forced to declare a supertype here.
*/
union bigsockaddr
{
# if NETUNIX
# endif /* NETUNIX */
# if NETINET
# endif /* NETINET */
# if NETINET6
# endif /* NETINET6 */
# if NETISO
# endif /* NETISO */
# if NETNS
# endif /* NETNS */
# if NETX25
# endif /* NETX25 */
};
# define SOCKADDR union bigsockaddr
/* functions */
# if NETINET6
extern int anynet_pton __P((int, const char *, void *));
# endif /* NETINET6 */
# if SASL >= 20000
# endif /* SASL >= 20000 */
#endif /* NETINET || NETINET6 || NETUNIX || NETISO || NETNS || NETX25 */
/*
** Process List (proclist)
*/
#ifndef PROC_LIST_SEG
#endif /* ! PROC_LIST_SEG */
/* process types */
#define PROC_NONE 0
#define PROC_DAEMON 1
#define PROC_DAEMON_CHILD 2
#define PROC_QUEUE 3
#define PROC_QUEUE_CHILD 3
#define PROC_CONTROL 4
#define PROC_CONTROL_CHILD 5
/* functions */
extern void proc_list_clear __P((void));
extern void proc_list_probe __P((void));
extern void proc_list_signal __P((int, int));
/*
** Symbol table definitions
*/
struct symtab
{
char *s_name; /* name to be entered */
short s_symtype; /* general type (see below) */
union
{
char *sv_alias; /* alias */
int sv_macro; /* macro name => id mapping */
int sv_ruleset; /* ruleset index */
#if LDAPMAP
#endif /* LDAPMAP */
#if SOCKETMAP
#endif /* SOCKETMAP */
#if MILTER
#endif /* MILTER */
} s_value;
};
/* symbol types */
#define ST_UNDEF 0 /* undefined type */
#if LDAPMAP
#endif /* LDAPMAP */
#if MILTER
#endif /* MILTER */
#if SOCKETMAP
#endif /* SOCKETMAP */
/* This entry must be last */
#if LDAPMAP
#endif /* LDAPMAP */
#if SOCKETMAP
#endif /* SOCKETMAP */
#if MILTER
#endif /* MILTER */
/* opcodes to stab */
#define ST_FIND 0 /* find entry */
/* functions */
/*
** Operation, send, error, and MIME modes
**
** The operation mode describes the basic operation of sendmail.
** This can be set from the command line, and is "send mail" by
** default.
**
** The send mode tells how to send mail. It can be set in the
** configuration file. Its setting determines how quickly the
** mail will be delivered versus the load on your system. If the
** -v (verbose) flag is given, it will be forced to SM_DELIVER
** mode.
**
** The error mode tells how to return errors.
*/
/* Note: see also include/sendmail/pathnames.h: GET_CLIENT_CF */
/* values for e_sendmode -- send modes */
#if _FFR_DM_ONE
#endif /* _FFR_DM_ONE */
/* used only as a parameter to sendall */
/* functions */
/* values for e_errormode -- error handling modes */
/* bit values for MimeMode */
/* how to handle messages without any recipient addresses */
#define NRA_NO_ACTION 0 /* just leave it as is */
/* flags to putxline */
#define PXLF_NOTHINGSPECIAL 0 /* no special mapping */
/*
** Privacy flags
** These are bit values for the PrivacyFlags word.
*/
#define PRIV_PUBLIC 0 /* what have I got to hide? */
#endif /* _FFR_PRIV_NOACTUALRECIPIENT */
/* don't give no info, anyway, anyhow */
#define PRIV_GOAWAY 0x0000ffff
/* struct defining such things */
struct prival
{
char *pv_name; /* name of privacy flag */
unsigned long pv_flag; /* numeric level */
};
/*
** Flags passed to remotename, parseaddr, allocaddr, and buildaddr.
*/
#define RF_COPYNONE 0
/*
** Flags passed to rscheck
*/
/*
** Flags passed to mime8to7 and putheader.
*/
#define M87F_OUTER 0 /* outer context */
/* functions */
/*
** Flags passed to returntosender.
*/
#define RTSF_NO_BODY 0 /* send headers only */
/* functions */
/*
** Mail Filters (milter)
*/
/*
** 32-bit type used by milter
** (needed by libmilter even if MILTER isn't defined)
*/
#if MILTER
# define SMFTO_WRITE 0 /* Timeout for sending information */
struct milter
{
char *mf_name; /* filter name */
char *mf_conn; /* connection info */
int mf_sock; /* connected socket */
char mf_state; /* state of filter */
};
/* MTA flags */
/* states */
EXTERN char *InputFilterList;
EXTERN int MilterLogLevel;
/* functions */
extern void setup_daemon_milters __P((void));
#endif /* MILTER */
/*
** Vendor codes
**
** Vendors can customize sendmail to add special behaviour,
** generally for back compatibility. Ideally, this should
** be set up in the .cf file using the "V" command. However,
** it's quite reasonable for some vendors to want the default
** be their old version; this can be set using
** -DVENDOR_DEFAULT=VENDOR_xxx
** in the Makefile.
**
** Vendors should apply to sendmail@sendmail.org for
** unique vendor codes.
*/
/* prototypes for vendor-specific hook routines */
/*
** Terminal escape codes.
**
** To make debugging output clearer.
*/
struct termescape
{
char *te_rv_on; /* turn reverse-video on */
char *te_rv_off; /* turn reverse-video off */
};
/*
** Additional definitions
*/
/*
** d_flags, see daemon.c
** general rule: lower case: required, upper case: No
*/
#if STARTTLS
/*
** TLS
*/
/* what to do in the TLS initialization */
/* require server cert */
TLS_I_KEY_UNR | TLS_I_KEY_OUNR | \
TLS_I_CERTP_EX | TLS_I_CERTF_EX | \
/* server requirements */
/* client requirements */
#define TLS_AUTH_OK 0
#define TLS_AUTH_NO 1
#define TLS_AUTH_FAIL (-1)
/* functions */
extern bool init_tls_library __P((void));
extern bool initclttls __P((bool));
extern bool initsrvtls __P((bool));
# if _FFR_TLS_1
# endif /* _FFR_TLS_1 */
#if _FFR_CRLPATH
#endif /* _FFR_CRLPATH */
#endif /* STARTTLS */
/*
** Queue related items
*/
/* queue file names */
#define ANYQFL_LETTER '?'
#define QUARQF_LETTER 'h'
#define DATAFL_LETTER 'd'
#define XSCRPT_LETTER 'x'
#define NORMQF_LETTER 'q'
#define NEWQFL_LETTER 't'
# define TEMPQF_LETTER 'T'
# define LOSEQF_LETTER 'Q'
/* queue sort order */
#define QSO_BYPRIORITY 0 /* sort by message priority */
#if _FFR_RHS
#endif /* _FFR_RHS */
#define ISVALIDQGRP(x) ((x) >= 0) /* valid queue group? */
#define ISVALIDQDIR(x) ((x) >= 0) /* valid queue directory? */
/* SuperSafe values */
#define SAFE_NO 0 /* no fsync(): don't use... */
/* QueueMode bits */
#define QM_NORMAL ' '
#define QM_QUARANTINE 'Q'
#define QM_LOST 'L'
/* Queue Run Limitations */
struct queue_char
{
char *queue_match; /* string to match */
bool queue_negate; /* or not match, if set */
struct queue_char *queue_next;
};
/* run_work_group() flags */
#define RWG_NONE 0x0000
#define RWG_FORK 0x0001
#define RWG_VERBOSE 0x0002
#define RWG_PERSISTENT 0x0004
#define RWG_FORCE 0x0008
#define RWG_RUNALL 0x0010
typedef struct queue_char QUEUE_CHAR;
/* functions */
extern void cleanup_queues __P((void));
extern bool doqueuerun __P((void));
extern char *qid_printqueue __P((int, int));
extern void quarantine_queue __P((char *, int));
extern bool run_work_group __P((int, int));
extern void setup_queues __P((bool));
extern void sync_queue_time __P((void));
extern void init_qid_alg __P((void));
extern int print_single_queue __P((int, int));
#else /* REQUIRES_DIR_FSYNC */
#endif /* REQUIRES_DIR_FSYNC */
/*
** Timeouts
**
** Indicated values are the MINIMUM per RFC 1123 section 5.3.2.
*/
EXTERN struct
{
/* RFC 1123-specified timeouts [minimum value] */
/* following timeouts are not mentioned in RFC 1123 */
#if SASL
#endif /* SASL */
#if STARTTLS
#endif /* STARTTLS */
/* following are per message */
} TimeOuts;
/* timeout classes for return and warning timeouts */
#define TOC_NORMAL 0 /* normal delivery */
/* resolver timeout specifiers */
#define RES_TO_FIRST 0 /* first attempt */
/* functions */
extern void inittimeouts __P((char *, bool));
/*
** Interface probing
*/
#define DPI_PROBENONE 0 /* Don't probe any interfaces */
/*
** Trace information
*/
/* macros for debugging flags */
/* variables */
/*
** Miscellaneous information.
*/
/*
** The "no queue id" queue id for sm_syslog
*/
#define NOQID "*~*"
/* use id or NOQID (to avoid NOQUEUE in logfile) */
/*
** Some in-line functions
*/
/* set exit status */
#define setstat(s) { \
ExitStat = s; \
}
#define STRUCTCOPY(s, d) d = s
/* free a pointer if it isn't NULL and set it to NULL */
#define SM_FREE_CLR(p) \
if ((p) != NULL) \
{ \
sm_free(p); \
(p) = NULL; \
} \
else
/*
** Update a permanent string variable with a new value.
** The old value is freed, the new value is strdup'ed.
**
** We use sm_pstrdup_x to duplicate the string because it raises
** an exception on error, and because it allocates "permanent storage"
** which is not expected to be freed before process exit.
** The latter is important for memory leak analysis.
**
** If an exception occurs while strdup'ing the new value,
** then the variable remains set to the old value.
** That's why the strdup must occur before we free the old value.
**
** The macro uses a do loop so that this idiom will work:
** if (...)
** PSTRSET(var, val1);
** else
** PSTRSET(var, val2);
*/
do \
{ \
} while (0)
#define _CHECK_RESTART \
do \
{ \
if (ShutdownRequest != NULL) \
shutdown_daemon(); \
else if (RestartRequest != NULL) \
restart_daemon(); \
else if (RestartWorkGroup) \
} while (0)
# define CHECK_RESTART _CHECK_RESTART
/* reply types (text in SmtpMsgBuffer) */
#define XS_DEFAULT 0
#define XS_STARTTLS 1
#define XS_AUTH 2
/*
** Global variables.
*/
#endif /* _FFR_QUEUE_RUN_PARANOIA */
#if !defined(_USE_SUN_NSSWITCH_) && !defined(_USE_DEC_SVC_CONF_)
#endif /* !defined(_USE_SUN_NSSWITCH_) && !defined(_USE_DEC_SVC_CONF_) */
#endif /* REQUIRES_DIR_FSYNC */
#if _FFR_SOFT_BOUNCE
#endif /* _FFR_SOFT_BOUNCE */
#if _FFR_MSG_ACCEPT
#endif /* _FFR_MSG_ACCEPT */
EXTERN int NoRecipientAction;
#if SM_CONF_SHM
EXTERN int *PNumFileSys;
# define NumFileSys (*PNumFileSys)
# else /* SM_CONF_SHM */
# endif /* SM_CONF_SHM */
#if _FFR_MEMSTAT
#endif /* _FFR_MEMSTAT */
#if SM_CONF_SHM
# if _FFR_SELECT_SHM
# endif /* _FFR_SELECT_SHM */
#endif /* SM_CONF_SHM */
#if _FFR_HELONAME
#endif /* _FFR_HELONAME */
extern char *Mbdb; /* mailbox database type */
#if HESIOD
EXTERN void *HesiodContext;
#endif /* HESIOD */
/*
** Declarations of useful functions
*/
/* Transcript file */
/* error related */
extern void buffer_errors __P((void));
extern void flush_errors __P((bool));
/* alias file */
/* logging */
extern void logdelivery __P((MAILER *, MCI *, char *, const char *, ADDRESS *, time_t, ENVELOPE *));
/* SMTP */
extern void giveresponse __P((int, char *, MAILER *, MCI *, ADDRESS *, time_t, ENVELOPE *, ADDRESS *));
extern int reply __P((MAILER *, MCI *, ENVELOPE *, time_t, void (*)__P((char *, bool, MAILER *, MCI *, ENVELOPE *)), char **, int));
#if SASL
#endif /* SASL */
#define ISSMTPREPLY(c) (ISSMTPCODE(c) && \
(c[3] == ' ' || c[3] == '-' || c[3] == '\0'))
/* delivery */
/* stats */
#define STATS_NORMAL 'n'
#define STATS_QUARANTINE 'q'
#define STATS_REJECT 'r'
#define STATS_CONNECT 'c'
extern void clearstats __P((void));
/* control socket */
extern void closecontrolsocket __P((bool));
extern void clrcontrol __P((void));
extern int opencontrolsocket __P((void));
#if MILTER
/* milter functions */
extern void milter_setup __P((char *));
extern void milter_set_option __P((char *, char *, bool));
extern bool milter_can_delrcpts __P((void));
#endif /* MILTER */
extern int blocksignal __P((int));
extern int check_bodytype __P((char *));
extern void buildfname __P((char *, char *, char *, int));
extern bool chkclientmodifiers __P((int));
extern bool chkdaemonmodifiers __P((int));
#ifdef XDEBUG
extern void checkfd012 __P((char *));
extern void checkfdopen __P((int, char *));
#endif /* XDEBUG */
extern void cleanstrcpy __P((char *, char *, int));
#if SM_CONF_SHM
extern void cleanup_shm __P((bool));
#endif /* SM_CONF_SHM */
extern void close_sendmail_pid __P((void));
extern void copy_class __P((int, int));
extern char *denlstring __P((char *, bool, bool));
#endif /* _FFR_CONTROL_MSTAT */
extern bool dns_getcanonname __P((char *, int, bool, int *, int *));
extern int drop_privileges __P((bool));
extern int dsntoexitstat __P((char *));
extern char *find_character __P((char *, int));
extern long freediskspace __P((char *, long *));
#if NETINET6 && NEEDSGETIPNODE
#endif /* NETINET6 && NEEDSGETIPNODE */
extern char *get_column __P((char *, int, int, char *, int));
extern char *getauthinfo __P((int, bool *));
extern void initdaemon __P((void));
extern void inithostmaps __P((void));
extern void initsetproctitle __P((int, char **, char **));
extern void load_if_names __P((void));
extern void makeworkgroups __P((void));
extern void mark_work_group_restart __P((int, int));
extern char * munchstring __P((char *, char **, int));
#if NISPLUS
#endif /* NISPLUS */
extern bool path_is_dir __P((char *, bool));
extern void printopenfds __P((bool));
extern void printqueue __P((void));
extern void printrules __P((void));
extern int releasesignal __P((int));
extern void resetlimits __P((void));
extern void restart_daemon __P((void));
extern void restart_marked_work_groups __P((void));
extern bool rfc822_string __P((char *));
extern void seed_random __P((void));
extern void setclientoptions __P((char *));
extern bool setdaemonoptions __P((char *));
extern void setdefuser __P((void));
extern void set_op_mode __P((int));
extern void sm_setuserenv __P((const char *, const char *));
extern char *shorten_hostname __P((char []));
extern void shutdown_daemon __P((void));
extern void stop_sendmail __P((void));
extern void stripbackslash __P((char *));
extern bool strreplnonprt __P((char *, int));
extern bool strcontainedin __P((bool, char *, char *));
extern int switch_map_find __P((char *, char *[], short []));
extern bool transienterror __P((int));
#endif /* _FFR_BESTMX_BETTER_TRUNCATION || _FFR_DNSMAP_MULTI */
#if !HASUNSETENV
#endif /* !HASUNSETENV */
/* update file system information: +/- some blocks */
#if SM_CONF_SHM
#else /* SM_CONF_SHM */
#endif /* SM_CONF_SHM */
extern bool usershellok __P((char *, char *));
#if SM_HEAP_CHECK
extern char *xalloc_tagged __P((int, char*, int));
#else /* SM_HEAP_CHECK */
#endif /* SM_HEAP_CHECK */
extern char *xuntextify __P((char *));
#endif /* ! _SENDMAIL_H */