1295Seric /* 23313Seric ** SENDMAIL.H -- Global definitions for sendmail. 3295Seric */ 4295Seric 5295Seric 6295Seric 74371Seric # ifdef _DEFINE 84371Seric # define EXTERN 9*4711Seric static char SmailSccsId[] = "@(#)sendmail.h 3.52 10/31/81"; 104371Seric # else _DEFINE 114371Seric # define EXTERN extern 124371Seric # endif _DEFINE 13295Seric 144624Seric # ifndef major 154624Seric # include <sys/types.h> 164624Seric # endif major 174183Seric # include <stdio.h> 184183Seric # include <ctype.h> 191390Seric # include "useful.h" 201390Seric 21295Seric /* 224284Seric ** Configuration constants. 234284Seric ** There shouldn't be much need to change these.... 24295Seric */ 25295Seric 264374Seric # define MAXLINE 256 /* max line length */ 274374Seric # define MAXNAME 128 /* max length of a name */ 284374Seric # define MAXFIELD 2500 /* max total length of a hdr field */ 294374Seric # define MAXPV 40 /* max # of parms to mailers */ 304374Seric # define MAXHOP 30 /* max value of HopCount */ 314384Seric # define MAXATOM 30 /* max atoms per address */ 324374Seric # define MAXMAILERS 10 /* maximum mailers known to system */ 334374Seric # define SPACESUB ('.'|0200) /* substitution for <lwsp> */ 34295Seric 354167Seric extern char Arpa_Info[]; /* the message number for Arpanet info */ 36295Seric 37295Seric 38295Seric 393190Seric 404162Seric 414167Seric 42295Seric /* 433190Seric ** Address structure. 443190Seric ** Addresses are stored internally in this structure. 453190Seric */ 463190Seric 473190Seric struct address 483190Seric { 493190Seric char *q_paddr; /* the printname for the address */ 503190Seric char *q_user; /* user name */ 513190Seric char *q_host; /* host name */ 524597Seric struct mailer *q_mailer; /* mailer to use */ 533190Seric short q_rmailer; /* real mailer (before mapping) */ 544149Seric u_short q_flags; /* status flags, see below */ 554213Seric short q_uid; /* user-id of receiver (if known) */ 564398Seric short q_gid; /* group-id of receiver (if known) */ 574079Seric char *q_home; /* home dir (local mailer only) */ 583190Seric struct address *q_next; /* chain */ 594398Seric struct address *q_alias; /* address this results from */ 604624Seric time_t q_timeout; /* timeout for this address */ 613190Seric }; 623190Seric 633190Seric typedef struct address ADDRESS; 643190Seric 653190Seric # define QDONTSEND 000001 /* don't send to this address */ 664068Seric # define QBADADDR 000002 /* this address is verified bad */ 674403Seric # define QGOODUID 000004 /* the q_uid q_gid fields are good */ 684422Seric # define QPRIMARY 000010 /* set from argv */ 694624Seric # define QQUEUEUP 000020 /* queue for later transmission */ 703190Seric 713190Seric 723190Seric 733190Seric 743190Seric 753190Seric /* 76295Seric ** Mailer definition structure. 77295Seric ** Every mailer known to the system is declared in this 78295Seric ** structure. It defines the pathname of the mailer, some 79295Seric ** flags associated with it, and the argument vector to 801390Seric ** pass to it. The flags are defined in conf.c 81295Seric ** 822899Seric ** The host map is a list of lists of strings. Within each 832899Seric ** list, any host is mapped to the last host in the list. 842899Seric ** This allows multiple names, as well as doing clever 852899Seric ** mail grouping in point-to-point networks. Note: this 862899Seric ** is only used internally, so the apparent host is still 872899Seric ** kept around. 882899Seric ** 894171Seric ** The argument vector is expanded before actual use. All 904171Seric ** words except the first are passed through the macro 914171Seric ** processor. 92295Seric */ 93295Seric 94295Seric struct mailer 95295Seric { 963190Seric char *m_name; /* symbolic name of this mailer */ 97295Seric char *m_mailer; /* pathname of the mailer to use */ 984149Seric u_long m_flags; /* status flags, see below */ 99295Seric short m_badstat; /* the status code to use on unknown error */ 1004438Seric short m_mno; /* mailer number internally */ 1012899Seric char *m_from; /* pattern for From: header */ 1023049Seric char **m_argv; /* template argument vector */ 1033190Seric ADDRESS *m_sendq; /* list of addresses to send to */ 104295Seric }; 105295Seric 1064100Seric typedef struct mailer MAILER; 1074100Seric 1082899Seric # define M_FOPT 000001 /* mailer takes picky -f flag */ 1092899Seric # define M_ROPT 000002 /* mailer takes picky -r flag */ 1102899Seric # define M_QUIET 000004 /* don't print error on bad status */ 1112899Seric # define M_RESTR 000010 /* must be daemon to execute */ 1123190Seric # define M_NHDR 000020 /* don't insert From line */ 1134192Seric # define M_LOCAL 000040 /* delivery is to this host */ 1142899Seric # define M_STRIPQ 000100 /* strip quote characters from user/host */ 1153190Seric # define M_MUSER 000200 /* mailer can handle multiple users at once */ 1162899Seric # define M_NEEDFROM 000400 /* need arpa-style From: line */ 1172899Seric # define M_NEEDDATE 001000 /* need arpa-style Date: line */ 1182899Seric # define M_MSGID 002000 /* need Message-Id: field */ 1193153Seric # define M_USR_UPPER 010000 /* preserve user case distinction */ 1203153Seric # define M_HST_UPPER 020000 /* preserve host case distinction */ 1213390Seric # define M_FULLNAME 040000 /* want Full-Name field */ 122295Seric 1234317Seric # define M_ARPAFMT (M_NEEDDATE|M_NEEDFROM|M_MSGID) 1242899Seric 1254597Seric EXTERN MAILER *Mailer[MAXMAILERS+1]; 126295Seric 1274597Seric EXTERN MAILER *LocalMailer; /* ptr to local mailer */ 1284597Seric EXTERN MAILER *ProgMailer; /* ptr to program mailer */ 129295Seric 130295Seric 1312899Seric /* 1322899Seric ** Header structure. 1332899Seric ** This structure is used internally to store header items. 1342899Seric */ 135295Seric 1362899Seric struct header 1372899Seric { 1382899Seric char *h_field; /* the name of the field */ 1392899Seric char *h_value; /* the value of that field */ 1402899Seric struct header *h_link; /* the next header */ 1414149Seric u_short h_flags; /* status bits, see below */ 1424149Seric u_long h_mflags; /* m_flags bits needed */ 1432899Seric }; 144295Seric 1452899Seric typedef struct header HDR; 1462899Seric 1474371Seric EXTERN HDR *Header; /* head of header list */ 1482899Seric 149295Seric /* 1502899Seric ** Header information structure. 1512899Seric ** Defined in conf.c, this struct declares the header fields 1522899Seric ** that have some magic meaning. 1532899Seric */ 1542899Seric 1552899Seric struct hdrinfo 1562899Seric { 1572899Seric char *hi_field; /* the name of the field */ 1584149Seric u_short hi_flags; /* status bits, see below */ 1594149Seric u_short hi_mflags; /* m_flags needed for this field */ 1602899Seric }; 1612899Seric 1622899Seric extern struct hdrinfo HdrInfo[]; 1632899Seric 1642899Seric /* bits for h_flags and hi_flags */ 1653060Seric # define H_EOH 00001 /* this field terminates header */ 1662899Seric # define H_DEFAULT 00004 /* if another value is found, drop this */ 1672899Seric # define H_USED 00010 /* indicates that this has been output */ 1683386Seric # define H_CHECK 00020 /* check h_mflags against m_flags */ 1693390Seric # define H_ACHECK 00040 /* ditto, but always (not just default) */ 1704149Seric # define H_FORCE 00100 /* force this field, even if default */ 1714222Seric # define H_ADDR 00200 /* this field contains addresses */ 1722899Seric 1732899Seric 1744624Seric 1753153Seric /* 1764624Seric ** Work queue. 1774624Seric */ 1784624Seric 1794624Seric struct work 1804624Seric { 1814624Seric char *w_name; /* name of control file */ 1824624Seric short w_pri; /* priority of message, see below */ 1834624Seric long w_size; /* length of data file */ 1844624Seric struct work *w_next; /* next in queue */ 1854624Seric }; 1864624Seric 1874624Seric typedef struct work WORK; 1884624Seric 1894624Seric EXTERN WORK *WorkQ; /* queue of things to be done */ 1904624Seric 1914624Seric 1924624Seric /* 1934624Seric ** Message priorities. 1944633Seric ** Priorities > 0 should be preemptive. 1954624Seric */ 1964624Seric 1974633Seric # define PRI_ALERT 20 1984633Seric # define PRI_QUICK 10 1994633Seric # define PRI_FIRSTCL 0 2004633Seric # define PRI_NORMAL -4 2014633Seric # define PRI_SECONDCL -10 2024633Seric # define PRI_THIRDCL -20 2034624Seric 2044624Seric EXTERN int MsgPriority; /* priority of this message */ 2054624Seric 2064624Seric 2074624Seric 2084624Seric /* 2093153Seric ** Rewrite rules. 2103153Seric */ 2112899Seric 2123153Seric struct rewrite 2133153Seric { 2143153Seric char **r_lhs; /* pattern match */ 2153153Seric char **r_rhs; /* substitution value */ 2163153Seric struct rewrite *r_next;/* next in chain */ 2173153Seric }; 2182899Seric 2194090Seric extern struct rewrite *RewriteRules[]; 2203153Seric 2214060Seric # define MATCHANY '\020' /* match one or more tokens */ 2224060Seric # define MATCHONE '\021' /* match exactly one token */ 2234060Seric # define MATCHCLASS '\022' /* match one token in a class */ 2244467Seric # define MATCHREPL '\023' /* replacement on RHS for above */ 2253153Seric 2263153Seric # define CANONNET '\025' /* canonical net, next token */ 2273153Seric # define CANONHOST '\026' /* canonical host, next token */ 2283153Seric # define CANONUSER '\027' /* canonical user, next N tokens */ 2293153Seric 2303153Seric 2313153Seric 2324056Seric /* 2334056Seric ** Symbol table definitions 2344056Seric */ 2353153Seric 2364056Seric struct symtab 2374056Seric { 2384056Seric char *s_name; /* name to be entered */ 2394100Seric char s_type; /* general type (see below) */ 2404056Seric struct symtab *s_next; /* pointer to next in chain */ 2414100Seric union 2424100Seric { 2434100Seric long sv_class; /* bit-map of word classes */ 2444100Seric ADDRESS *sv_addr; /* pointer to address header */ 2454100Seric MAILER *sv_mailer; /* pointer to mailer */ 2464100Seric char *sv_alias; /* alias */ 2474100Seric } s_value; 2484056Seric }; 2494056Seric 2504056Seric typedef struct symtab STAB; 2514056Seric 2524100Seric /* symbol types */ 2534100Seric # define ST_UNDEF 0 /* undefined type */ 2544100Seric # define ST_CLASS 1 /* class map */ 2554100Seric # define ST_ADDRESS 2 /* an address in parsed format */ 2564100Seric # define ST_MAILER 3 /* a mailer header */ 2574100Seric # define ST_ALIAS 4 /* an alias */ 2584100Seric 2594100Seric # define s_class s_value.sv_class 2604100Seric # define s_addr s_value.sv_addr 2614100Seric # define s_mailer s_value.sv_mailer 2624100Seric # define s_alias s_value.sv_alias 2634100Seric 2644056Seric extern STAB *stab(); 2654056Seric 2664056Seric /* opcodes to stab */ 2674056Seric # define ST_FIND 0 /* find entry */ 2684056Seric # define ST_ENTER 1 /* enter if not there */ 2694056Seric 2704056Seric 2714056Seric 2724056Seric 2732899Seric /* 2744284Seric ** Statistics structure. 2754284Seric */ 2764284Seric 2774284Seric struct statistics 2784284Seric { 2794284Seric time_t stat_itime; /* file initialization time */ 2804284Seric short stat_size; /* size of this structure */ 2814284Seric long stat_nf[MAXMAILERS]; /* # msgs from each mailer */ 2824284Seric long stat_bf[MAXMAILERS]; /* kbytes from each mailer */ 2834284Seric long stat_nt[MAXMAILERS]; /* # msgs to each mailer */ 2844284Seric long stat_bt[MAXMAILERS]; /* kbytes to each mailer */ 2854284Seric }; 2864284Seric 2874371Seric EXTERN struct statistics Stat; 2884284Seric extern long kbytes(); /* for _bf, _bt */ 2894284Seric 2904284Seric 2914284Seric 2924284Seric 2934284Seric /* 294295Seric ** Global variables. 295295Seric */ 296295Seric 2974371Seric EXTERN bool FromFlag; /* if set, "From" person is explicit */ 2984371Seric EXTERN bool MailBack; /* mail back response on error */ 2994371Seric EXTERN bool BerkNet; /* called from BerkNet */ 3004371Seric EXTERN bool WriteBack; /* write back response on error */ 3014371Seric EXTERN bool NoAlias; /* if set, don't do any aliasing */ 3024371Seric EXTERN bool ForceMail; /* if set, mail even if already got a copy */ 3034371Seric EXTERN bool MeToo; /* send to the sender also */ 3044371Seric EXTERN bool IgnrDot; /* don't let dot end messages */ 3054371Seric EXTERN bool SaveFrom; /* save leading "From" lines */ 3064371Seric EXTERN bool Verbose; /* set if blow-by-blow desired */ 3074371Seric EXTERN bool GrabTo; /* if set, get recipients from msg */ 3084371Seric EXTERN bool DontSend; /* mark recipients as QDONTSEND */ 3094371Seric EXTERN bool NoReturn; /* don't return letter to sender */ 3104537Seric EXTERN bool Daemon; /* running as a daemon */ 3114553Seric EXTERN bool Smtp; /* using SMTP over connection */ 3124553Seric EXTERN bool SuprErrs; /* set if we are suppressing errors */ 3134624Seric EXTERN bool QueueUp; /* queue this message for future xmission */ 3144624Seric EXTERN bool QueueRun; /* currently running something from the queue */ 315*4711Seric EXTERN bool HoldErrs; /* only output errors to transcript */ 316*4711Seric EXTERN bool ArpaMode; /* set if running arpanet protocol */ 3174624Seric extern time_t TimeOut; /* time until timeout */ 3184553Seric EXTERN FILE *InChannel; /* input connection */ 3194553Seric EXTERN FILE *OutChannel; /* output connection */ 3204553Seric EXTERN FILE *TempFile; /* mail temp file */ 321*4711Seric EXTERN FILE *Xscript; /* mail transcript file */ 3224537Seric EXTERN int RealUid; /* when Daemon, real uid of caller */ 3234537Seric EXTERN int RealGid; /* when Daemon, real gid of caller */ 3244371Seric EXTERN int OldUmask; /* umask when sendmail starts up */ 3254371Seric EXTERN int Debug; /* debugging level */ 3264371Seric EXTERN int Errors; /* set if errors */ 3274371Seric EXTERN int ExitStat; /* exit status code */ 3284553Seric EXTERN int HopCount; /* hop count */ 3294553Seric EXTERN int AliasLevel; /* depth of aliasing */ 3304624Seric EXTERN time_t QueueIntvl; /* intervals between running the queue */ 3314553Seric EXTERN char *OrigFrom; /* the From: line read from the message */ 3324553Seric EXTERN char *To; /* the target person */ 3334553Seric EXTERN char *HostName; /* name of this host for SMTP messages */ 3344624Seric EXTERN char *InFileName; /* input file name */ 3354624Seric EXTERN char *Transcript; /* the transcript file name */ 3364624Seric extern char *XcriptFile; /* template for Transcript */ 3374624Seric extern char *AliasFile; /* location of alias file */ 3384624Seric extern char *ConfFile; /* location of configuration file */ 3394624Seric extern char *StatFile; /* location of statistics summary */ 3404624Seric extern char *QueueDir; /* location of queue directory */ 3414371Seric EXTERN ADDRESS From; /* the person it is from */ 3424553Seric EXTERN long MsgSize; /* size of the message in bytes */ 3434624Seric EXTERN time_t CurTime; /* time of this message */ 344295Seric 345295Seric 346295Seric # include <sysexits.h> 347295Seric 348295Seric # define setstat(s) { if (ExitStat == EX_OK) ExitStat = s; } 3494085Seric 3504085Seric 3514085Seric /* useful functions */ 3524085Seric 3534085Seric extern char *newstr(); 3544085Seric extern ADDRESS *parse(); 3554085Seric extern char *xalloc(); 3564085Seric extern char *expand(); 3574085Seric extern bool sameaddr(); 358