fix bogus implementation of name overflow limiting
[unix-history] / usr / src / usr.sbin / sendmail / src / sendmail.h
index 6816ba3..6354cce 100644 (file)
@@ -1,11 +1,11 @@
 /*
  * Copyright (c) 1983 Eric P. Allman
 /*
  * Copyright (c) 1983 Eric P. Allman
- * Copyright (c) 1988 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)sendmail.h  6.38 (Berkeley) %G%
+ *     @(#)sendmail.h  8.29 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -15,8 +15,8 @@
 # ifdef _DEFINE
 # define EXTERN
 # ifndef lint
 # ifdef _DEFINE
 # define EXTERN
 # ifndef lint
-static char SmailSccsId[] =    "@(#)sendmail.h 6.38            %G%";
-# endif lint
+static char SmailSccsId[] =    "@(#)sendmail.h 8.29            %G%";
+# endif
 # else /*  _DEFINE */
 # define EXTERN extern
 # endif /* _DEFINE */
 # else /*  _DEFINE */
 # define EXTERN extern
 # endif /* _DEFINE */
@@ -31,7 +31,6 @@ static char SmailSccsId[] =   "@(#)sendmail.h 6.38            %G%";
 # include <string.h>
 # include <time.h>
 # include <errno.h>
 # include <string.h>
 # include <time.h>
 # include <errno.h>
-# include <sys/types.h>
 
 # include "conf.h"
 # include "conf.h"
 
 # include "conf.h"
 # include "conf.h"
@@ -44,12 +43,21 @@ static char SmailSccsId[] = "@(#)sendmail.h 6.38            %G%";
 # ifdef DAEMON
 # include <sys/socket.h>
 # endif
 # ifdef DAEMON
 # include <sys/socket.h>
 # endif
+# ifdef NETUNIX
+# include <sys/un.h>
+# endif
 # ifdef NETINET
 # include <netinet/in.h>
 # endif
 # ifdef NETISO
 # include <netiso/iso.h>
 # endif
 # ifdef NETINET
 # include <netinet/in.h>
 # endif
 # ifdef NETISO
 # include <netiso/iso.h>
 # endif
+# ifdef NETNS
+# include <netns/ns.h>
+# endif
+# ifdef NETX25
+# include <netccitt/x25.h>
+# endif
 
 
 
 
 
 
@@ -128,6 +136,9 @@ typedef struct address ADDRESS;
 # define QNOTREMOTE    000100  /* not an address for remote forwarding */
 # define QSELFREF      000200  /* this address references itself */
 # define QVERIFIED     000400  /* verified, but not expanded */
 # define QNOTREMOTE    000100  /* not an address for remote forwarding */
 # define QSELFREF      000200  /* this address references itself */
 # define QVERIFIED     000400  /* verified, but not expanded */
+# define QREPORT       001000  /* report this address in return message */
+
+# define NULLADDR      ((ADDRESS *) NULL)
 # define QPSEUDO       000040  /* only on the list for verification */
 \f/*
 **  Mailer definition structure.
 # define QPSEUDO       000040  /* only on the list for verification */
 \f/*
 **  Mailer definition structure.
@@ -155,11 +166,14 @@ struct mailer
        char    *m_eol;         /* end of line string */
        long    m_maxsize;      /* size limit on message to this mailer */
        int     m_linelimit;    /* max # characters per line */
        char    *m_eol;         /* end of line string */
        long    m_maxsize;      /* size limit on message to this mailer */
        int     m_linelimit;    /* max # characters per line */
+       char    *m_execdir;     /* directory to chdir to before execv */
 };
 
 typedef struct mailer  MAILER;
 
 /* bits for m_flags */
 };
 
 typedef struct mailer  MAILER;
 
 /* bits for m_flags */
+# define M_ESMTP       'a'     /* run Extended SMTP protocol */
+# define M_BLANKEND    'b'     /* ensure blank line at end of message */
 # define M_NOCOMMENT   'c'     /* don't include comment part of address */
 # define M_CANONICAL   'C'     /* make addresses canonical "u@dom" */
                /*      'D'     /* CF: include Date: */
 # define M_NOCOMMENT   'c'     /* don't include comment part of address */
 # define M_CANONICAL   'C'     /* make addresses canonical "u@dom" */
                /*      'D'     /* CF: include Date: */
@@ -167,15 +181,16 @@ typedef struct mailer     MAILER;
 # define M_ESCFROM     'E'     /* escape From lines to >From */
 # define M_FOPT                'f'     /* mailer takes picky -f flag */
                /*      'F'     /* CF: include From: or Resent-From: */
 # define M_ESCFROM     'E'     /* escape From lines to >From */
 # define M_FOPT                'f'     /* mailer takes picky -f flag */
                /*      'F'     /* CF: include From: or Resent-From: */
+# define M_NO_NULL_FROM        'g'     /* sender of errors should be $g */
 # define M_HST_UPPER   'h'     /* preserve host case distinction */
 # define M_HST_UPPER   'h'     /* preserve host case distinction */
-               /*      'H'     /* UIUC: MAIL11V3: preview headers */
+# define M_PREHEAD     'H'     /* MAIL11V3: preview headers */
 # define M_INTERNAL    'I'     /* SMTP to another sendmail site */
 # define M_LOCALMAILER 'l'     /* delivery is to this host */
 # define M_LIMITS      'L'     /* must enforce SMTP line limits */
 # define M_MUSER       'm'     /* can handle multiple users at once */
                /*      'M'     /* CF: include Message-Id: */
 # define M_NHDR                'n'     /* don't insert From line */
 # define M_INTERNAL    'I'     /* SMTP to another sendmail site */
 # define M_LOCALMAILER 'l'     /* delivery is to this host */
 # define M_LIMITS      'L'     /* must enforce SMTP line limits */
 # define M_MUSER       'm'     /* can handle multiple users at once */
                /*      'M'     /* CF: include Message-Id: */
 # define M_NHDR                'n'     /* don't insert From line */
-               /*      'N'     /* UIUC: MAIL11V3: DATA returns multi-status */
+# define M_MANYSTATUS  'N'     /* MAIL11V3: DATA returns multi-status */
 # define M_FROMPATH    'p'     /* use reverse-path in MAIL FROM: */
                /*      'P'     /* CF: include Return-Path: */
 # define M_ROPT                'r'     /* mailer takes picky -r flag */
 # define M_FROMPATH    'p'     /* use reverse-path in MAIL FROM: */
                /*      'P'     /* CF: include Return-Path: */
 # define M_ROPT                'r'     /* mailer takes picky -r flag */
@@ -185,6 +200,7 @@ typedef struct mailer       MAILER;
 # define M_USR_UPPER   'u'     /* preserve user case distinction */
 # define M_UGLYUUCP    'U'     /* this wants an ugly UUCP from line */
                /*      'V'     /* UIUC: !-relativize all addresses */
 # define M_USR_UPPER   'u'     /* preserve user case distinction */
 # define M_UGLYUUCP    'U'     /* this wants an ugly UUCP from line */
                /*      'V'     /* UIUC: !-relativize all addresses */
+               /*      'x'     /* CF: include Full-Name: */
 # define M_XDOT                'X'     /* use hidden-dot algorithm */
 # define M_7BITS       '7'     /* use 7-bit path */
 
 # define M_XDOT                'X'     /* use hidden-dot algorithm */
 # define M_7BITS       '7'     /* use 7-bit path */
 
@@ -246,7 +262,9 @@ extern struct hdrinfo       HdrInfo[];
 **     will have their own envelope.
 */
 
 **     will have their own envelope.
 */
 
-struct envelope
+# define ENVELOPE      struct envelope
+
+ENVELOPE
 {
        HDR             *e_header;      /* head of header list */
        long            e_msgpriority;  /* adjusted priority of this message */
 {
        HDR             *e_header;      /* head of header list */
        long            e_msgpriority;  /* adjusted priority of this message */
@@ -267,10 +285,13 @@ struct envelope
        short           e_nsent;        /* number of sends since checkpoint */
        short           e_sendmode;     /* message send mode */
        short           e_errormode;    /* error return mode */
        short           e_nsent;        /* number of sends since checkpoint */
        short           e_sendmode;     /* message send mode */
        short           e_errormode;    /* error return mode */
-       int             (*e_puthdr)();  /* function to put header of message */
-       int             (*e_putbody)(); /* function to put body of message */
+       int             (*e_puthdr)__P((FILE *, MAILER *, ENVELOPE *));
+                                       /* function to put header of message */
+       int             (*e_putbody)__P((FILE *, MAILER *, ENVELOPE *, char *));
+                                       /* function to put body of message */
        struct envelope *e_parent;      /* the message this one encloses */
        struct envelope *e_sibling;     /* the next envelope of interest */
        struct envelope *e_parent;      /* the message this one encloses */
        struct envelope *e_sibling;     /* the next envelope of interest */
+       char            *e_bodytype;    /* type of message body */
        char            *e_df;          /* location of temp file */
        FILE            *e_dfp;         /* temporary file */
        char            *e_id;          /* code for this entry in queue */
        char            *e_df;          /* location of temp file */
        FILE            *e_dfp;         /* temporary file */
        char            *e_id;          /* code for this entry in queue */
@@ -278,15 +299,15 @@ struct envelope
        FILE            *e_lockfp;      /* the lock file for this message */
        FILE            *e_qfp;         /* queue control file */
        char            *e_message;     /* error message */
        FILE            *e_lockfp;      /* the lock file for this message */
        FILE            *e_qfp;         /* queue control file */
        char            *e_message;     /* error message */
+       char            *e_statmsg;     /* stat msg (changes per delivery) */
+       char            *e_msgboundary; /* MIME-style message part boundary */
+       char            *e_origrcpt;    /* original recipient (one only) */
        char            *e_macro[128];  /* macro definitions */
 };
 
        char            *e_macro[128];  /* macro definitions */
 };
 
-typedef struct envelope        ENVELOPE;
-
 /* values for e_flags */
 #define EF_OLDSTYLE    000001          /* use spaces (not commas) in hdrs */
 #define EF_INQUEUE     000002          /* this message is fully queued */
 /* values for e_flags */
 #define EF_OLDSTYLE    000001          /* use spaces (not commas) in hdrs */
 #define EF_INQUEUE     000002          /* this message is fully queued */
-#define EF_TIMEOUT     000004          /* this message is too old */
 #define EF_CLRQUEUE    000010          /* disk copy is no longer needed */
 #define EF_SENDRECEIPT 000020          /* send a return receipt */
 #define EF_FATALERRS   000040          /* fatal errors occured */
 #define EF_CLRQUEUE    000010          /* disk copy is no longer needed */
 #define EF_SENDRECEIPT 000020          /* send a return receipt */
 #define EF_FATALERRS   000040          /* fatal errors occured */
@@ -296,6 +317,9 @@ typedef struct envelope     ENVELOPE;
 #define EF_VRFYONLY    001000          /* verify only (don't expand aliases) */
 #define EF_WARNING     002000          /* warning message has been sent */
 #define EF_QUEUERUN    004000          /* this envelope is from queue */
 #define EF_VRFYONLY    001000          /* verify only (don't expand aliases) */
 #define EF_WARNING     002000          /* warning message has been sent */
 #define EF_QUEUERUN    004000          /* this envelope is from queue */
+#define EF_GLOBALERRS  010000          /* treat errors as global */
+#define EF_PM_NOTIFY   020000          /* send return mail to postmaster */
+#define EF_METOO       040000          /* send to me too */
 
 EXTERN ENVELOPE        *CurEnv;        /* envelope currently being processed */
 \f/*
 
 EXTERN ENVELOPE        *CurEnv;        /* envelope currently being processed */
 \f/*
@@ -382,6 +406,7 @@ EXTERN struct rewrite       *RewriteRules[MAXRWSETS];
 
 /* macro substitution character */
 # define MACROEXPAND   0201    /* macro expansion */
 
 /* macro substitution character */
 # define MACROEXPAND   0201    /* macro expansion */
+# define MACRODEXPAND  0202    /* deferred macro expansion */
 
 /* to make the code clearer */
 # define MATCHZERO     CANONHOST
 
 /* to make the code clearer */
 # define MATCHZERO     CANONHOST
@@ -390,7 +415,7 @@ EXTERN struct rewrite       *RewriteRules[MAXRWSETS];
 struct metamac
 {
        char    metaname;       /* external code (after $) */
 struct metamac
 {
        char    metaname;       /* external code (after $) */
-       char    metaval;        /* internal code (as above) */
+       u_char  metaval;        /* internal code (as above) */
 };
 \f/*
 **  Information about currently open connections to mailers, or to
 };
 \f/*
 **  Information about currently open connections to mailers, or to
@@ -403,8 +428,10 @@ MCI
 {
        short           mci_flags;      /* flag bits, see below */
        short           mci_errno;      /* error number on last connection */
 {
        short           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 */
        short           mci_exitstat;   /* exit status from last connection */
        short           mci_state;      /* SMTP state */
+       long            mci_maxsize;    /* max size this server will accept */
        FILE            *mci_in;        /* input side of connection */
        FILE            *mci_out;       /* output side of connection */
        int             mci_pid;        /* process id of subordinate proc */
        FILE            *mci_in;        /* input side of connection */
        FILE            *mci_out;       /* output side of connection */
        int             mci_pid;        /* process id of subordinate proc */
@@ -416,9 +443,14 @@ MCI
 
 
 /* flag bits */
 
 
 /* flag bits */
-#define MCIF_VALID     00001           /* this entry is valid */
-#define MCIF_TEMP      00002           /* don't cache this connection */
-#define MCIF_CACHED    00004           /* currently in open cache */
+#define MCIF_VALID     000001          /* this entry is valid */
+#define MCIF_TEMP      000002          /* don't cache this connection */
+#define MCIF_CACHED    000004          /* currently in open cache */
+#define MCIF_ESMTP     000010          /* this host speaks ESMTP */
+#define MCIF_EXPN      000020          /* EXPN command supported */
+#define MCIF_SIZE      000040          /* SIZE option supported */
+#define MCIF_8BITMIME  000100          /* BODY=8BITMIME supported */
+#define MCIF_MULTSTAT  000200          /* MAIL11V3: handles MULT status */
 
 /* states */
 #define MCIS_CLOSED    0               /* no traffic on this connection */
 
 /* states */
 #define MCIS_CLOSED    0               /* no traffic on this connection */
@@ -429,48 +461,99 @@ MCI
 #define MCIS_SSD       5               /* service shutting down */
 #define MCIS_ERROR     6               /* I/O error on connection */
 \f/*
 #define MCIS_SSD       5               /* service shutting down */
 #define MCIS_ERROR     6               /* I/O error on connection */
 \f/*
-**  Mapping functions
+**  Name canonification short circuit.
 **
 **
-**     These allow arbitrary mappings in the config file.  The idea
-**     (albeit not the implementation) comes from IDA sendmail.
+**     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
 
 
-/*
-**  The class of a map -- essentially the functions to call
+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 */
+#define NCF_VALID      0x0001  /* entry valid */
+\f/*
+**  Mapping functions
+**
+**     These allow arbitrary mappings in the config file.  The idea
+**     (albeit not the implementation) comes from IDA sendmail.
 */
 
 # define MAPCLASS      struct _mapclass
 */
 
 # define MAPCLASS      struct _mapclass
-
-MAPCLASS
-{
-       bool    (*map_init)();          /* initialization function */
-       char    *(*map_lookup)();       /* lookup function */
-};
+# define MAP           struct _map
 
 
 /*
 **  An actual map.
 */
 
 
 
 /*
 **  An actual map.
 */
 
-# define MAP           struct _map
-
 MAP
 {
        MAPCLASS        *map_class;     /* the class of this map */
 MAP
 {
        MAPCLASS        *map_class;     /* the class of this map */
-       int             map_flags;      /* flags, see below */
+       char            *map_mname;     /* name of this map */
+       int             map_mflags;     /* flags, see below */
        char            *map_file;      /* the (nominal) filename */
        char            *map_file;      /* the (nominal) filename */
-       void            *map_db;        /* the open database ptr */
+       ARBPTR_T        map_db1;        /* the open database ptr */
+       ARBPTR_T        map_db2;        /* an "extra" database pointer */
        char            *map_app;       /* to append to successful matches */
        char            *map_domain;    /* the (nominal) NIS domain */
        char            *map_app;       /* to append to successful matches */
        char            *map_domain;    /* the (nominal) NIS domain */
+       char            *map_rebuild;   /* program to run to do auto-rebuild */
+       time_t          map_mtime;      /* last database modification time */
 };
 
 /* bit values for map_flags */
 };
 
 /* bit values for map_flags */
-# define MF_VALID      00001           /* this entry is valid */
-# define MF_INCLNULL   00002           /* include null byte in key */
-# define MF_OPTIONAL   00004           /* don't complain if map not found */
-# define MF_NOFOLDCASE 00010           /* don't fold case in keys */
-# define MF_MATCHONLY  00020           /* don't use the map value */
+# define MF_VALID      0x0001          /* this entry is valid */
+# define MF_INCLNULL   0x0002          /* include null byte in key */
+# define MF_OPTIONAL   0x0004          /* don't complain if map not found */
+# define MF_NOFOLDCASE 0x0008          /* don't fold case in keys */
+# define MF_MATCHONLY  0x0010          /* don't use the map value */
+# define MF_OPEN       0x0020          /* this entry is open */
+# define MF_WRITABLE   0x0040          /* open for writing */
+# define MF_ALIAS      0x0080          /* this is an alias file */
+# define MF_TRY0NULL   0x0100          /* try with no null byte */
+# define MF_TRY1NULL   0x0200          /* try with the null byte */
+# define MF_LOCKED     0x0400          /* this map is currently locked */
+# define MF_ALIASWAIT  0x0800          /* alias map in aliaswait state */
+# define MF_IMPL_HASH  0x1000          /* implicit: underlying hash database */
+# define MF_IMPL_NDBM  0x2000          /* implicit: underlying NDBM database */
+
+
+/*
+**  The class of a map -- essentially the functions to call
+*/
+
+MAPCLASS
+{
+       char    *map_cname;             /* name of this map class */
+       char    *map_ext;               /* extension for database file */
+       short   map_cflags;             /* flag bits, see below */
+       bool    (*map_parse)__P((MAP *, char *));
+                                       /* argument parsing function */
+       char    *(*map_lookup)__P((MAP *, char *, char **, int *));
+                                       /* lookup function */
+       void    (*map_store)__P((MAP *, char *, char *));
+                                       /* store function */
+       bool    (*map_open)__P((MAP *, int));
+                                       /* open function */
+       void    (*map_close)__P((MAP *));
+                                       /* close function */
+};
+
+/* bit values for map_cflags */
+#define MCF_ALIASOK    0x0001          /* can be used for aliases */
+#define MCF_ALIASONLY  0x0002          /* usable only for aliases */
+#define MCF_REBUILDABLE        0x0004          /* can rebuild alias files */
 \f/*
 **  Symbol table definitions
 */
 \f/*
 **  Symbol table definitions
 */
@@ -490,6 +573,7 @@ struct symtab
                MAP             sv_map;         /* mapping function */
                char            *sv_hostsig;    /* host signature */
                MCI             sv_mci;         /* mailer connection info */
                MAP             sv_map;         /* mapping function */
                char            *sv_hostsig;    /* host signature */
                MCI             sv_mci;         /* mailer connection info */
+               NAMECANON       sv_namecanon;   /* canonical name cache */
        }       s_value;
 };
 
        }       s_value;
 };
 
@@ -504,6 +588,7 @@ typedef struct symtab       STAB;
 # define ST_MAPCLASS   5       /* mapping function class */
 # define ST_MAP                6       /* mapping function */
 # define ST_HOSTSIG    7       /* host signature */
 # define ST_MAPCLASS   5       /* mapping function class */
 # define ST_MAP                6       /* mapping function */
 # define ST_HOSTSIG    7       /* host signature */
+# define ST_NAMECANON  8       /* cached canonical name */
 # define ST_MCI                16      /* mailer connection info (offset) */
 
 # define s_class       s_value.sv_class
 # define ST_MCI                16      /* mailer connection info (offset) */
 
 # define s_class       s_value.sv_class
@@ -512,7 +597,8 @@ typedef struct symtab       STAB;
 # define s_alias       s_value.sv_alias
 # define s_mci         s_value.sv_mci
 
 # define s_alias       s_value.sv_alias
 # define s_mci         s_value.sv_mci
 
-extern STAB    *stab();
+extern STAB            *stab __P((char *, int, int));
+extern void            stabapply __P((void (*)(STAB *, int), int));
 
 /* opcodes to stab */
 # define ST_FIND       0       /* find entry */
 
 /* opcodes to stab */
 # define ST_FIND       0       /* find entry */
@@ -529,7 +615,8 @@ extern STAB *stab();
 struct event
 {
        time_t          ev_time;        /* time of the function call */
 struct event
 {
        time_t          ev_time;        /* time of the function call */
-       int             (*ev_func)();   /* function to call */
+       int             (*ev_func)__P((int));
+                                       /* function to call */
        int             ev_arg;         /* argument to ev_func */
        int             ev_pid;         /* pid that set this event */
        struct event    *ev_link;       /* link to next item */
        int             ev_arg;         /* argument to ev_func */
        int             ev_pid;         /* pid that set this event */
        struct event    *ev_link;       /* link to next item */
@@ -583,11 +670,16 @@ EXTERN char       OpMode;         /* operation mode, see below */
 #define EM_WRITE       'w'             /* write back errors */
 #define EM_BERKNET     'e'             /* special berknet processing */
 #define EM_QUIET       'q'             /* don't print messages (stat only) */
 #define EM_WRITE       'w'             /* write back errors */
 #define EM_BERKNET     'e'             /* special berknet processing */
 #define EM_QUIET       'q'             /* don't print messages (stat only) */
+\f/*
+**  Additional definitions
+*/
 
 
-/* Offset used to ensure that name server error * codes are unique */
-#define        MAX_ERRNO       100
 
 
-/* privacy flags */
+/*
+**  Privacy flags
+**     These are bit values for the PrivacyFlags word.
+*/
+
 #define PRIV_PUBLIC            0       /* what have I got to hide? */
 #define PRIV_NEEDMAILHELO      00001   /* insist on HELO for MAIL, at least */
 #define PRIV_NEEDEXPNHELO      00002   /* insist on HELO for EXPN */
 #define PRIV_PUBLIC            0       /* what have I got to hide? */
 #define PRIV_NEEDMAILHELO      00001   /* insist on HELO for MAIL, at least */
 #define PRIV_NEEDEXPNHELO      00002   /* insist on HELO for EXPN */
@@ -595,7 +687,8 @@ EXTERN char OpMode;         /* operation mode, see below */
 #define PRIV_NOEXPN            00010   /* disallow EXPN command entirely */
 #define PRIV_NOVRFY            00020   /* disallow VRFY command entirely */
 #define PRIV_AUTHWARNINGS      00040   /* flag possible authorization probs */
 #define PRIV_NOEXPN            00010   /* disallow EXPN command entirely */
 #define PRIV_NOVRFY            00020   /* disallow VRFY command entirely */
 #define PRIV_AUTHWARNINGS      00040   /* flag possible authorization probs */
-#define PRIV_RESTRMAILQ                01000   /* restrict mailq command */
+#define PRIV_RESTRICTMAILQ     01000   /* restrict mailq command */
+#define PRIV_RESTRICTQRUN      02000   /* restrict queue run */
 #define PRIV_GOAWAY            00777   /* don't give no info, anyway, anyhow */
 
 /* struct defining such things */
 #define PRIV_GOAWAY            00777   /* don't give no info, anyway, anyhow */
 
 /* struct defining such things */
@@ -605,6 +698,29 @@ struct prival
        int     pv_flag;        /* numeric level */
 };
 
        int     pv_flag;        /* numeric level */
 };
 
+
+/*
+**  Flags passed to remotename, parseaddr, allocaddr, and buildaddr.
+*/
+
+#define RF_SENDERADDR          0001    /* this is a sender address */
+#define RF_HEADERADDR          0002    /* this is a header address */
+#define RF_CANONICAL           0004    /* strip comment information */
+#define RF_ADDDOMAIN           0010    /* OK to do domain extension */
+#define RF_COPYPARSE           0020    /* copy parsed user & host */
+#define RF_COPYPADDR           0040    /* copy print address */
+#define RF_COPYALL             (RF_COPYPARSE|RF_COPYPADDR)
+#define RF_COPYNONE            0
+
+
+/*
+**  Flags passed to safefile.
+*/
+
+#define SF_MUSTOWN             0x0001  /* user must own this file */
+#define SF_NOSLINK             0x0002  /* file cannot be a symbolic link */
+
+
 /*
 **  Regular UNIX sockaddrs are too small to handle ISO addresses, so
 **  we are forced to declare a supertype here.
 /*
 **  Regular UNIX sockaddrs are too small to handle ISO addresses, so
 **  we are forced to declare a supertype here.
@@ -613,22 +729,29 @@ struct prival
 union bigsockaddr
 {
        struct sockaddr         sa;     /* general version */
 union bigsockaddr
 {
        struct sockaddr         sa;     /* general version */
+#ifdef NETUNIX
+       struct sockaddr_un      sunix;  /* UNIX family */
+#endif
 #ifdef NETINET
        struct sockaddr_in      sin;    /* INET family */
 #endif
 #ifdef NETISO
        struct sockaddr_iso     siso;   /* ISO family */
 #endif
 #ifdef NETINET
        struct sockaddr_in      sin;    /* INET family */
 #endif
 #ifdef NETISO
        struct sockaddr_iso     siso;   /* ISO family */
 #endif
+#ifdef NETNS
+       struct sockaddr_ns      sns;    /* XNS family */
+#endif
+#ifdef NETX25
+       struct sockaddr_x25     sx25;   /* X.25 family */
+#endif
 };
 
 #define SOCKADDR       union bigsockaddr
 };
 
 #define SOCKADDR       union bigsockaddr
-
 \f/*
 **  Global variables.
 */
 
 EXTERN bool    FromFlag;       /* if set, "From" person is explicit */
 \f/*
 **  Global variables.
 */
 
 EXTERN bool    FromFlag;       /* if set, "From" person is explicit */
-EXTERN bool    NoAlias;        /* if set, don't do any aliasing */
 EXTERN bool    MeToo;          /* send to the sender also */
 EXTERN bool    IgnrDot;        /* don't let dot end messages */
 EXTERN bool    SaveFrom;       /* save leading "From" lines */
 EXTERN bool    MeToo;          /* send to the sender also */
 EXTERN bool    IgnrDot;        /* don't let dot end messages */
 EXTERN bool    SaveFrom;       /* save leading "From" lines */
@@ -642,9 +765,10 @@ EXTERN bool        SuperSafe;      /* be extra careful, even if expensive */
 EXTERN bool    ForkQueueRuns;  /* fork for each job when running the queue */
 EXTERN bool    AutoRebuild;    /* auto-rebuild the alias database as needed */
 EXTERN bool    CheckAliases;   /* parse addresses during newaliases */
 EXTERN bool    ForkQueueRuns;  /* fork for each job when running the queue */
 EXTERN bool    AutoRebuild;    /* auto-rebuild the alias database as needed */
 EXTERN bool    CheckAliases;   /* parse addresses during newaliases */
+EXTERN bool    NoAlias;        /* suppress aliasing */
 EXTERN bool    UseNameServer;  /* use internet domain name server */
 EXTERN bool    UseNameServer;  /* use internet domain name server */
-EXTERN bool    EightBit;       /* try to preserve 8-bit data */
-EXTERN int     SafeAlias;      /* minutes to wait until @:@ in alias file */
+EXTERN bool    SevenBit;       /* force 7-bit data */
+EXTERN time_t  SafeAlias;      /* interval to wait until @:@ in alias file */
 EXTERN FILE    *InChannel;     /* input connection */
 EXTERN FILE    *OutChannel;    /* output connection */
 EXTERN uid_t   RealUid;        /* when Daemon, real uid of caller */
 EXTERN FILE    *InChannel;     /* input connection */
 EXTERN FILE    *OutChannel;    /* output connection */
 EXTERN uid_t   RealUid;        /* when Daemon, real uid of caller */
@@ -664,7 +788,6 @@ EXTERN int  RefuseLA;       /* load average refusing connections are */
 EXTERN int     CurrentLA;      /* current load average */
 EXTERN long    QueueFactor;    /* slope of queue function */
 EXTERN time_t  QueueIntvl;     /* intervals between running the queue */
 EXTERN int     CurrentLA;      /* current load average */
 EXTERN long    QueueFactor;    /* slope of queue function */
 EXTERN time_t  QueueIntvl;     /* intervals between running the queue */
-EXTERN char    *AliasFile;     /* location of alias file */
 EXTERN char    *HelpFile;      /* location of SMTP help file */
 EXTERN char    *ErrMsgFile;    /* file to prepend to all error messages */
 EXTERN char    *StatFile;      /* location of statistics summary */
 EXTERN char    *HelpFile;      /* location of SMTP help file */
 EXTERN char    *ErrMsgFile;    /* file to prepend to all error messages */
 EXTERN char    *StatFile;      /* location of statistics summary */
@@ -678,30 +801,39 @@ EXTERN char       *CurHostName;   /* current host we are dealing with */
 EXTERN jmp_buf TopFrame;       /* branch-to-top-of-loop-on-error frame */
 EXTERN bool    QuickAbort;     /*  .... but only if we want a quick abort */
 EXTERN bool    LogUsrErrs;     /* syslog user errors (e.g., SMTP RCPT cmd) */
 EXTERN jmp_buf TopFrame;       /* branch-to-top-of-loop-on-error frame */
 EXTERN bool    QuickAbort;     /*  .... but only if we want a quick abort */
 EXTERN bool    LogUsrErrs;     /* syslog user errors (e.g., SMTP RCPT cmd) */
+EXTERN bool    SendMIMEErrors; /* send error messages in MIME format */
+EXTERN bool    MatchGecos;     /* look for user names in gecos field */
+EXTERN bool    UseErrorsTo;    /* use Errors-To: header (back compat) */
+EXTERN bool    TryNullMXList;  /* if we are the best MX, try host directly */
+extern bool    CheckLoopBack;  /* check for loopback on HELO packet */
+EXTERN bool    InChild;        /* true if running in an SMTP subprocess */
+EXTERN char    SpaceSub;       /* substitution for <lwsp> */
 EXTERN int     PrivacyFlags;   /* privacy flags */
 EXTERN int     PrivacyFlags;   /* privacy flags */
-extern char    *ConfFile;      /* location of configuration file [conf.c] */
-extern char    *FreezeFile;    /* location of frozen memory image [conf.c] */
+EXTERN char    *ConfFile;      /* location of configuration file [conf.c] */
 extern char    *PidFile;       /* location of proc id file [conf.c] */
 extern ADDRESS NullAddress;    /* a null (template) address [main.c] */
 extern char    *PidFile;       /* location of proc id file [conf.c] */
 extern ADDRESS NullAddress;    /* a null (template) address [main.c] */
-EXTERN char    SpaceSub;       /* substitution for <lwsp> */
 EXTERN long    WkClassFact;    /* multiplier for message class -> priority */
 EXTERN long    WkRecipFact;    /* multiplier for # of recipients -> priority */
 EXTERN long    WkTimeFact;     /* priority offset each time this job is run */
 EXTERN long    WkClassFact;    /* multiplier for message class -> priority */
 EXTERN long    WkRecipFact;    /* multiplier for # of recipients -> priority */
 EXTERN long    WkTimeFact;     /* priority offset each time this job is run */
+EXTERN char    *UdbSpec;       /* user database source spec */
+EXTERN int     MaxHopCount;    /* max # of hops until bounce */
+EXTERN int     ConfigLevel;    /* config file level */
+EXTERN char    *TimeZoneSpec;  /* override time zone specification */
+EXTERN char    *ForwardPath;   /* path to search for .forward files */
+EXTERN long    MinBlocksFree;  /* min # of blocks free on queue fs */
+EXTERN char    *FallBackMX;    /* fall back MX host */
+EXTERN long    MaxMessageSize; /* advertised max size we will accept */
 EXTERN char    *PostMasterCopy;        /* address to get errs cc's */
 EXTERN int     CheckpointInterval;     /* queue file checkpoint interval */
 EXTERN char    *PostMasterCopy;        /* address to get errs cc's */
 EXTERN int     CheckpointInterval;     /* queue file checkpoint interval */
-EXTERN char    *UdbSpec;       /* user database source spec [udbexpand.c] */
-EXTERN int     MaxHopCount;    /* number of hops until we give an error */
-EXTERN int     ConfigLevel;    /* config file level -- what does .cf expect? */
-EXTERN char    *TimeZoneSpec;  /* override time zone specification */
-EXTERN bool    MatchGecos;     /* look for user names in gecos field */
 EXTERN bool    DontPruneRoutes;        /* don't prune source routes */
 EXTERN bool    DontPruneRoutes;        /* don't prune source routes */
-EXTERN int     MaxMciCache;    /* maximum entries in MCI cache */
+extern bool    BrokenSmtpPeers;        /* peers can't handle 2-line greeting */
+EXTERN int     MaxMciCache;            /* maximum entries in MCI cache */
 EXTERN time_t  MciCacheTimeout;        /* maximum idle time on connections */
 EXTERN time_t  MciCacheTimeout;        /* maximum idle time on connections */
-EXTERN char    *ForwardPath;   /* path to search for .forward files */
-EXTERN long    MinBlocksFree;  /* minimum number of blocks free on queue fs */
 EXTERN char    *QueueLimitRecipient;   /* limit queue runs to this recipient */
 EXTERN char    *QueueLimitSender;      /* limit queue runs to this sender */
 EXTERN char    *QueueLimitId;          /* limit queue runs to this id */
 EXTERN char    *QueueLimitRecipient;   /* limit queue runs to this recipient */
 EXTERN char    *QueueLimitSender;      /* limit queue runs to this sender */
 EXTERN char    *QueueLimitId;          /* limit queue runs to this id */
+EXTERN FILE    *TrafficLogFile;        /* file in which to log all traffic */
+extern int     errno;
 
 
 /*
 
 
 /*
@@ -712,6 +844,7 @@ EXTERN char *QueueLimitId;          /* limit queue runs to this id */
 
 EXTERN struct
 {
 
 EXTERN struct
 {
+                       /* RFC 1123-specified timeouts [minimum value] */
        time_t  to_initial;     /* initial greeting timeout [5m] */
        time_t  to_mail;        /* MAIL command [5m] */
        time_t  to_rcpt;        /* RCPT command [5m] */
        time_t  to_initial;     /* initial greeting timeout [5m] */
        time_t  to_mail;        /* MAIL command [5m] */
        time_t  to_rcpt;        /* RCPT command [5m] */
@@ -724,6 +857,7 @@ EXTERN struct
        time_t  to_helo;        /* HELO command */
        time_t  to_quit;        /* QUIT command */
        time_t  to_miscshort;   /* misc short commands (NOOP, VERB, etc) */
        time_t  to_helo;        /* HELO command */
        time_t  to_quit;        /* QUIT command */
        time_t  to_miscshort;   /* misc short commands (NOOP, VERB, etc) */
+       time_t  to_ident;       /* IDENT protocol requests */
                        /* following are per message */
        time_t  to_q_return;    /* queue return timeout */
        time_t  to_q_warning;   /* queue warning timeout */
                        /* following are per message */
        time_t  to_q_return;    /* queue return timeout */
        time_t  to_q_warning;   /* queue warning timeout */
@@ -764,36 +898,53 @@ EXTERN u_char     tTdvect[100];
 **  Declarations of useful functions
 */
 
 **  Declarations of useful functions
 */
 
-#if defined(__STDC__) && defined(_FORGIVING_CC_)
-#define P(protos)      protos
-#else
-#define P(protos)      ()
-#endif
-
-extern ADDRESS *parseaddr P((char *, ADDRESS *, int, char, char **, ENVELOPE *));
-extern char    *xalloc P((int));
-extern bool    sameaddr P((ADDRESS *, ADDRESS *));
-extern FILE    *dfopen P((char *, char *));
-extern EVENT   *setevent P((time_t, int(*)(), int));
-extern char    *sfgets P((char *, int, FILE *, time_t));
-extern char    *queuename P((ENVELOPE *, char));
-extern time_t  curtime P(());
-extern bool    transienterror P((int));
-extern char    *errstring P((int));
+extern ADDRESS         *parseaddr __P((char *, ADDRESS *, int, int, char **, ENVELOPE *));
+extern char            *xalloc __P((int));
+extern bool            sameaddr __P((ADDRESS *, ADDRESS *));
+extern FILE            *dfopen __P((char *, int, int));
+extern EVENT           *setevent __P((time_t, int(*)(), int));
+extern char            *sfgets __P((char *, int, FILE *, time_t, char *));
+extern char            *queuename __P((ENVELOPE *, int));
+extern time_t          curtime __P(());
+extern bool            transienterror __P((int));
+extern const char      *errstring __P((int));
+extern void            expand __P((char *, char *, char *, ENVELOPE *));
+extern void            define __P((int, char *, ENVELOPE *));
+extern char            *macvalue __P((int, ENVELOPE *));
+extern char            **prescan __P((char *, int, char[], char **));
+extern char            *fgetfolded __P((char *, int, FILE *));
+extern ADDRESS         *recipient __P((ADDRESS *, ADDRESS **, ENVELOPE *));
+extern ENVELOPE                *newenvelope __P((ENVELOPE *, ENVELOPE *));
+extern void            dropenvelope __P((ENVELOPE *));
+extern void            clearenvelope __P((ENVELOPE *, int));
+extern char            *username __P(());
+extern MCI             *mci_get __P((char *, MAILER *));
+extern char            *pintvl __P((time_t, int));
+extern char            *map_rewrite __P((MAP *, char *, int, char **));
+extern ADDRESS         *getctladdr __P((ADDRESS *));
+extern char            *anynet_ntoa __P((SOCKADDR *));
+extern char            *remotename __P((char *, MAILER *, int, int *, ENVELOPE *));
+extern bool            shouldqueue __P((long, time_t));
+extern bool            lockfile __P((int, char *, char *, int));
+extern char            *hostsignature __P((MAILER *, char *, ENVELOPE *));
+extern void            openxscript __P((ENVELOPE *));
+extern void            closexscript __P((ENVELOPE *));
+extern sigfunc_t       setsignal __P((int, sigfunc_t));
+extern char            *shortenstring __P((char *, int));
 
 /* ellipsis is a different case though */
 #ifdef __STDC__
 
 /* ellipsis is a different case though */
 #ifdef __STDC__
-extern void    auth_warning(ENVELOPE *, char *, ...);
-extern void    syserr(char *, ...);
-extern void    usrerr(char *, ...);
-extern void    message(char *, ...);
-extern void    nmessage(char *, ...);
+extern void            auth_warning(ENVELOPE *, const char *, ...);
+extern void            syserr(const char *, ...);
+extern void            usrerr(const char *, ...);
+extern void            message(const char *, ...);
+extern void            nmessage(const char *, ...);
 #else
 #else
-extern void    auth_warning();
-extern void    syserr();
-extern void    usrerr();
-extern void    message();
-extern void    nmessage();
+extern void            auth_warning();
+extern void            syserr();
+extern void            usrerr();
+extern void            message();
+extern void            nmessage();
 #endif
 
 /*
 #endif
 
 /*