1295Seric /* 23313Seric ** SENDMAIL.H -- Global definitions for sendmail. 3295Seric */ 4295Seric 5295Seric 6295Seric 74371Seric # ifdef _DEFINE 84371Seric # define EXTERN 95194Seric # ifndef lint 10*5983Seric static char SmailSccsId[] = "@(#)sendmail.h 3.62 02/27/82"; 115194Seric # endif lint 124371Seric # else _DEFINE 134371Seric # define EXTERN extern 144371Seric # endif _DEFINE 15295Seric 164183Seric # include <stdio.h> 174183Seric # include <ctype.h> 181390Seric # include "useful.h" 191390Seric 20295Seric /* 214284Seric ** Configuration constants. 224284Seric ** There shouldn't be much need to change these.... 23295Seric */ 24295Seric 254374Seric # define MAXLINE 256 /* max line length */ 264374Seric # define MAXNAME 128 /* max length of a name */ 274374Seric # define MAXFIELD 2500 /* max total length of a hdr field */ 284374Seric # define MAXPV 40 /* max # of parms to mailers */ 294374Seric # define MAXHOP 30 /* max value of HopCount */ 304384Seric # define MAXATOM 30 /* max atoms per address */ 314374Seric # define MAXMAILERS 10 /* maximum mailers known to system */ 324374Seric # define SPACESUB ('.'|0200) /* substitution for <lwsp> */ 33295Seric 344167Seric extern char Arpa_Info[]; /* the message number for Arpanet info */ 35295Seric 36295Seric 37295Seric 383190Seric 394162Seric 404167Seric 41295Seric /* 423190Seric ** Address structure. 433190Seric ** Addresses are stored internally in this structure. 443190Seric */ 453190Seric 463190Seric struct address 473190Seric { 483190Seric char *q_paddr; /* the printname for the address */ 493190Seric char *q_user; /* user name */ 503190Seric char *q_host; /* host name */ 514597Seric struct mailer *q_mailer; /* mailer to use */ 523190Seric short q_rmailer; /* real mailer (before mapping) */ 534149Seric u_short q_flags; /* status flags, see below */ 544213Seric short q_uid; /* user-id of receiver (if known) */ 554398Seric short q_gid; /* group-id of receiver (if known) */ 564079Seric char *q_home; /* home dir (local mailer only) */ 574995Seric char *q_fullname; /* full name if known */ 584995Seric struct address *q_next; /* chain */ 594995Seric struct address *q_alias; /* address this results from */ 605034Seric struct address *q_tchain; /* temporary use chain */ 614987Seric time_t q_timeout; /* timeout for this address */ 623190Seric }; 633190Seric 643190Seric typedef struct address ADDRESS; 653190Seric 663190Seric # define QDONTSEND 000001 /* don't send to this address */ 674068Seric # define QBADADDR 000002 /* this address is verified bad */ 684403Seric # define QGOODUID 000004 /* the q_uid q_gid fields are good */ 694422Seric # define QPRIMARY 000010 /* set from argv */ 704624Seric # define QQUEUEUP 000020 /* queue for later transmission */ 713190Seric 723190Seric 733190Seric 743190Seric 753190Seric 763190Seric /* 77295Seric ** Mailer definition structure. 78295Seric ** Every mailer known to the system is declared in this 79295Seric ** structure. It defines the pathname of the mailer, some 80295Seric ** flags associated with it, and the argument vector to 811390Seric ** pass to it. The flags are defined in conf.c 82295Seric ** 834171Seric ** The argument vector is expanded before actual use. All 844171Seric ** words except the first are passed through the macro 854171Seric ** processor. 86295Seric */ 87295Seric 88295Seric struct mailer 89295Seric { 903190Seric char *m_name; /* symbolic name of this mailer */ 91295Seric char *m_mailer; /* pathname of the mailer to use */ 924149Seric u_long m_flags; /* status flags, see below */ 93295Seric short m_badstat; /* the status code to use on unknown error */ 944438Seric short m_mno; /* mailer number internally */ 952899Seric char *m_from; /* pattern for From: header */ 963049Seric char **m_argv; /* template argument vector */ 97295Seric }; 98295Seric 994100Seric typedef struct mailer MAILER; 1004100Seric 1015601Seric /* bits for m_flags */ 1025601Seric # define M_FOPT 000000001 /* mailer takes picky -f flag */ 1035601Seric # define M_ROPT 000000002 /* mailer takes picky -r flag */ 1045601Seric # define M_QUIET 000000004 /* don't print error on bad status */ 1055601Seric # define M_RESTR 000000010 /* must be daemon to execute */ 1065601Seric # define M_NHDR 000000020 /* don't insert From line */ 1075601Seric # define M_LOCAL 000000040 /* delivery is to this host */ 1085601Seric # define M_STRIPQ 000000100 /* strip quote chars from user/host */ 1095601Seric # define M_MUSER 000000200 /* can handle multiple users at once */ 1105601Seric # define M_NEEDFROM 000000400 /* need arpa-style From: line */ 1115601Seric # define M_NEEDDATE 000001000 /* need arpa-style Date: line */ 1125601Seric # define M_MSGID 000002000 /* need Message-Id: field */ 1135601Seric # define M_USR_UPPER 000010000 /* preserve user case distinction */ 1145601Seric # define M_HST_UPPER 000020000 /* preserve host case distinction */ 1155601Seric # define M_FULLNAME 000040000 /* want Full-Name field */ 1165601Seric # define M_UGLYUUCP 000100000 /* this wants an ugly UUCP from line */ 1175904Seric # define M_EXPENSIVE 000200000 /* it costs to use this mailer.... */ 118295Seric 1194317Seric # define M_ARPAFMT (M_NEEDDATE|M_NEEDFROM|M_MSGID) 1202899Seric 1214597Seric EXTERN MAILER *Mailer[MAXMAILERS+1]; 122295Seric 1234597Seric EXTERN MAILER *LocalMailer; /* ptr to local mailer */ 1244597Seric EXTERN MAILER *ProgMailer; /* ptr to program mailer */ 125295Seric 126295Seric 1272899Seric /* 1282899Seric ** Header structure. 1292899Seric ** This structure is used internally to store header items. 1302899Seric */ 131295Seric 1322899Seric struct header 1332899Seric { 1342899Seric char *h_field; /* the name of the field */ 1352899Seric char *h_value; /* the value of that field */ 1362899Seric struct header *h_link; /* the next header */ 1374149Seric u_short h_flags; /* status bits, see below */ 1384149Seric u_long h_mflags; /* m_flags bits needed */ 1392899Seric }; 140295Seric 1412899Seric typedef struct header HDR; 1422899Seric 1434371Seric EXTERN HDR *Header; /* head of header list */ 1442899Seric 145295Seric /* 1462899Seric ** Header information structure. 1472899Seric ** Defined in conf.c, this struct declares the header fields 1482899Seric ** that have some magic meaning. 1492899Seric */ 1502899Seric 1512899Seric struct hdrinfo 1522899Seric { 1532899Seric char *hi_field; /* the name of the field */ 1544149Seric u_short hi_flags; /* status bits, see below */ 1554149Seric u_short hi_mflags; /* m_flags needed for this field */ 1562899Seric }; 1572899Seric 1582899Seric extern struct hdrinfo HdrInfo[]; 1592899Seric 1602899Seric /* bits for h_flags and hi_flags */ 1613060Seric # define H_EOH 00001 /* this field terminates header */ 1625918Seric # define H_RCPT 00002 /* contains recipient addresses */ 1632899Seric # define H_DEFAULT 00004 /* if another value is found, drop this */ 1642899Seric # define H_USED 00010 /* indicates that this has been output */ 1653386Seric # define H_CHECK 00020 /* check h_mflags against m_flags */ 1663390Seric # define H_ACHECK 00040 /* ditto, but always (not just default) */ 1674149Seric # define H_FORCE 00100 /* force this field, even if default */ 1684222Seric # define H_ADDR 00200 /* this field contains addresses */ 1692899Seric 1702899Seric 1714624Seric 1723153Seric /* 1734624Seric ** Work queue. 1744624Seric */ 1754624Seric 1764624Seric struct work 1774624Seric { 1784624Seric char *w_name; /* name of control file */ 1795034Seric long w_pri; /* priority of message, see below */ 1804624Seric struct work *w_next; /* next in queue */ 1814624Seric }; 1824624Seric 1834624Seric typedef struct work WORK; 1844624Seric 1854624Seric EXTERN WORK *WorkQ; /* queue of things to be done */ 1864624Seric 1874624Seric 1884624Seric /* 1894624Seric ** Message priorities. 1904633Seric ** Priorities > 0 should be preemptive. 1915034Seric ** 1925034Seric ** MsgPriority is the number of bytes in the message adjusted 1935034Seric ** by the message priority and the amount of time the message 1945034Seric ** has been sitting around. Each priority point is worth 1955034Seric ** WKPRIFACT bytes of message, and each time we reprocess a 1965034Seric ** message the size gets reduced by WKTIMEFACT. 1974624Seric */ 1984624Seric 1994633Seric # define PRI_ALERT 20 2004633Seric # define PRI_QUICK 10 2015034Seric # define PRI_FIRSTCL 3 2025034Seric # define PRI_NORMAL 0 2034633Seric # define PRI_SECONDCL -10 2044633Seric # define PRI_THIRDCL -20 2054624Seric 2065034Seric # define WKPRIFACT 1800 /* bytes each pri point is worth */ 2075034Seric # define WKTIMEFACT 400 /* bytes each time unit is worth */ 2084624Seric 2095034Seric EXTERN long MsgPriority; /* adjusted priority of this message */ 2104624Seric 2114624Seric 2125034Seric 2134624Seric /* 2143153Seric ** Rewrite rules. 2153153Seric */ 2162899Seric 2173153Seric struct rewrite 2183153Seric { 2193153Seric char **r_lhs; /* pattern match */ 2203153Seric char **r_rhs; /* substitution value */ 2213153Seric struct rewrite *r_next;/* next in chain */ 2223153Seric }; 2232899Seric 2244090Seric extern struct rewrite *RewriteRules[]; 2253153Seric 2264060Seric # define MATCHANY '\020' /* match one or more tokens */ 2274060Seric # define MATCHONE '\021' /* match exactly one token */ 2284060Seric # define MATCHCLASS '\022' /* match one token in a class */ 2294467Seric # define MATCHREPL '\023' /* replacement on RHS for above */ 2303153Seric 2313153Seric # define CANONNET '\025' /* canonical net, next token */ 2323153Seric # define CANONHOST '\026' /* canonical host, next token */ 2333153Seric # define CANONUSER '\027' /* canonical user, next N tokens */ 2343153Seric 2353153Seric 2363153Seric 2374056Seric /* 2384056Seric ** Symbol table definitions 2394056Seric */ 2403153Seric 2414056Seric struct symtab 2424056Seric { 2434056Seric char *s_name; /* name to be entered */ 2444100Seric char s_type; /* general type (see below) */ 2454056Seric struct symtab *s_next; /* pointer to next in chain */ 2464100Seric union 2474100Seric { 2484100Seric long sv_class; /* bit-map of word classes */ 2494100Seric ADDRESS *sv_addr; /* pointer to address header */ 2504100Seric MAILER *sv_mailer; /* pointer to mailer */ 2514100Seric char *sv_alias; /* alias */ 2524100Seric } s_value; 2534056Seric }; 2544056Seric 2554056Seric typedef struct symtab STAB; 2564056Seric 2574100Seric /* symbol types */ 2584100Seric # define ST_UNDEF 0 /* undefined type */ 2594100Seric # define ST_CLASS 1 /* class map */ 2604100Seric # define ST_ADDRESS 2 /* an address in parsed format */ 2614100Seric # define ST_MAILER 3 /* a mailer header */ 2624100Seric # define ST_ALIAS 4 /* an alias */ 2634100Seric 2644100Seric # define s_class s_value.sv_class 2655976Seric # define s_address s_value.sv_addr 2664100Seric # define s_mailer s_value.sv_mailer 2674100Seric # define s_alias s_value.sv_alias 2684100Seric 2694056Seric extern STAB *stab(); 2704056Seric 2714056Seric /* opcodes to stab */ 2724056Seric # define ST_FIND 0 /* find entry */ 2734056Seric # define ST_ENTER 1 /* enter if not there */ 2744056Seric 2754056Seric 2764056Seric 2774056Seric 2782899Seric /* 2794284Seric ** Statistics structure. 2804284Seric */ 2814284Seric 2824284Seric struct statistics 2834284Seric { 2844284Seric time_t stat_itime; /* file initialization time */ 2854284Seric short stat_size; /* size of this structure */ 2864284Seric long stat_nf[MAXMAILERS]; /* # msgs from each mailer */ 2874284Seric long stat_bf[MAXMAILERS]; /* kbytes from each mailer */ 2884284Seric long stat_nt[MAXMAILERS]; /* # msgs to each mailer */ 2894284Seric long stat_bt[MAXMAILERS]; /* kbytes to each mailer */ 2904284Seric }; 2914284Seric 2924371Seric EXTERN struct statistics Stat; 2934284Seric extern long kbytes(); /* for _bf, _bt */ 2944284Seric 2954284Seric 2964284Seric 2974284Seric 2984284Seric /* 299295Seric ** Global variables. 300295Seric */ 301295Seric 3024371Seric EXTERN bool FromFlag; /* if set, "From" person is explicit */ 3034371Seric EXTERN bool MailBack; /* mail back response on error */ 3044371Seric EXTERN bool BerkNet; /* called from BerkNet */ 3054371Seric EXTERN bool WriteBack; /* write back response on error */ 3064371Seric EXTERN bool NoAlias; /* if set, don't do any aliasing */ 3074371Seric EXTERN bool ForceMail; /* if set, mail even if already got a copy */ 3084371Seric EXTERN bool MeToo; /* send to the sender also */ 3094371Seric EXTERN bool IgnrDot; /* don't let dot end messages */ 3104371Seric EXTERN bool SaveFrom; /* save leading "From" lines */ 3114371Seric EXTERN bool Verbose; /* set if blow-by-blow desired */ 3124371Seric EXTERN bool GrabTo; /* if set, get recipients from msg */ 3134371Seric EXTERN bool DontSend; /* mark recipients as QDONTSEND */ 3144371Seric EXTERN bool NoReturn; /* don't return letter to sender */ 3154537Seric EXTERN bool Daemon; /* running as a daemon */ 3164553Seric EXTERN bool Smtp; /* using SMTP over connection */ 3174553Seric EXTERN bool SuprErrs; /* set if we are suppressing errors */ 3184624Seric EXTERN bool QueueUp; /* queue this message for future xmission */ 3194624Seric EXTERN bool QueueRun; /* currently running something from the queue */ 3204711Seric EXTERN bool HoldErrs; /* only output errors to transcript */ 3214711Seric EXTERN bool ArpaMode; /* set if running arpanet protocol */ 3225703Seric EXTERN bool ForkOff; /* fork after initial verification */ 3235703Seric EXTERN bool OldStyle; /* spaces (not commas) delimit addresses */ 3245904Seric EXTERN bool NoConnect; /* don't connect to non-local mailers */ 325*5983Seric EXTERN bool RetReceipt; /* give a return receipt if delivery occurs */ 326*5983Seric EXTERN bool SendReceipt; /* actually send a receipt back */ 3274624Seric extern time_t TimeOut; /* time until timeout */ 3284553Seric EXTERN FILE *InChannel; /* input connection */ 3294553Seric EXTERN FILE *OutChannel; /* output connection */ 3304553Seric EXTERN FILE *TempFile; /* mail temp file */ 3314711Seric EXTERN FILE *Xscript; /* mail transcript file */ 3324537Seric EXTERN int RealUid; /* when Daemon, real uid of caller */ 3334537Seric EXTERN int RealGid; /* when Daemon, real gid of caller */ 3345703Seric extern int DefUid; /* default uid to run as */ 3355703Seric extern int DefGid; /* default gid to run as */ 3364371Seric EXTERN int OldUmask; /* umask when sendmail starts up */ 3374371Seric EXTERN int Debug; /* debugging level */ 3384371Seric EXTERN int Errors; /* set if errors */ 3394371Seric EXTERN int ExitStat; /* exit status code */ 3404553Seric EXTERN int HopCount; /* hop count */ 3414553Seric EXTERN int AliasLevel; /* depth of aliasing */ 3424624Seric EXTERN time_t QueueIntvl; /* intervals between running the queue */ 3434553Seric EXTERN char *OrigFrom; /* the From: line read from the message */ 3444553Seric EXTERN char *To; /* the target person */ 3454553Seric EXTERN char *HostName; /* name of this host for SMTP messages */ 3464624Seric EXTERN char *InFileName; /* input file name */ 3474624Seric EXTERN char *Transcript; /* the transcript file name */ 3484624Seric extern char *XcriptFile; /* template for Transcript */ 3494624Seric extern char *AliasFile; /* location of alias file */ 3504624Seric extern char *ConfFile; /* location of configuration file */ 3514624Seric extern char *StatFile; /* location of statistics summary */ 3524624Seric extern char *QueueDir; /* location of queue directory */ 3534371Seric EXTERN ADDRESS From; /* the person it is from */ 3545000Seric EXTERN ADDRESS *SendQueue; /* list of message recipients */ 3554553Seric EXTERN long MsgSize; /* size of the message in bytes */ 3564624Seric EXTERN time_t CurTime; /* time of this message */ 357295Seric 358295Seric 359295Seric # include <sysexits.h> 360295Seric 361295Seric # define setstat(s) { if (ExitStat == EX_OK) ExitStat = s; } 3624085Seric 3634085Seric 3644085Seric /* useful functions */ 3654085Seric 3664085Seric extern char *newstr(); 3674085Seric extern ADDRESS *parse(); 3684085Seric extern char *xalloc(); 3694085Seric extern char *expand(); 3704085Seric extern bool sameaddr(); 371