include is an M4 keyword and has to be quoted
[unix-history] / usr / src / usr.sbin / sendmail / src / sendmail.h
CommitLineData
aeb2545d 1/*
792e6158 2 * Copyright (c) 1983, 1995 Eric P. Allman
24634489
KB
3 * Copyright (c) 1988, 1993
4 * The Regents of the University of California. All rights reserved.
bee79b64 5 *
417f7a11 6 * %sccs.include.redist.c%
bee79b64 7 *
05b75231 8 * @(#)sendmail.h 8.133 (Berkeley) %G%
bee79b64 9 */
aeb2545d 10
b3cbe40f 11/*
96faada8 12** SENDMAIL.H -- Global definitions for sendmail.
b3cbe40f
EA
13*/
14
327272f5
EA
15# ifdef _DEFINE
16# define EXTERN
4e5e456f 17# ifndef lint
05b75231 18static char SmailSccsId[] = "@(#)sendmail.h 8.133 %G%";
6353954f 19# endif
f3d8f6d6 20# else /* _DEFINE */
327272f5 21# define EXTERN extern
f3d8f6d6 22# endif /* _DEFINE */
b3cbe40f 23
9dfbef75 24# include <unistd.h>
f3d8f6d6
EA
25# include <stddef.h>
26# include <stdlib.h>
aeb209da
EA
27# include <stdio.h>
28# include <ctype.h>
37eaaadb 29# include <setjmp.h>
f3d8f6d6
EA
30# include <string.h>
31# include <time.h>
32# include <errno.h>
3f7592f7 33# ifdef EX_OK
ff73b4e5 34# undef EX_OK /* for SVr4.2 SMP */
3f7592f7
EA
35# endif
36# include <sysexits.h>
f3d8f6d6 37
b5fd168f 38# include "conf.h"
6bf17095 39# include "conf.h"
cb590f52
EA
40# include "useful.h"
41
9678c96d 42# ifdef LOG
5031c0bb 43# include <syslog.h>
f3d8f6d6 44# endif /* LOG */
6e8a8adf 45
2e3062fe 46# ifdef DAEMON
2e3062fe 47# include <sys/socket.h>
3356c77c 48# endif
3a4fbef8
EA
49# ifdef NETUNIX
50# include <sys/un.h>
51# endif
3356c77c 52# ifdef NETINET
2e3062fe 53# include <netinet/in.h>
3356c77c
EA
54# endif
55# ifdef NETISO
56# include <netiso/iso.h>
57# endif
88e65f7c
EA
58# ifdef NETNS
59# include <netns/ns.h>
60# endif
61# ifdef NETX25
62# include <netccitt/x25.h>
63# endif
2e3062fe 64
6e8a8adf 65
a584db60
EA
66
67
6e8a8adf
EA
68/*
69** Data structure for bit maps.
70**
71** Each bit in this map can be referenced by an ascii character.
5d9e8d9a 72** This is 256 possible bits, or 32 8-bit bytes.
6e8a8adf
EA
73*/
74
5d9e8d9a 75#define BITMAPBYTES 32 /* number of bytes in a bit map */
6e8a8adf
EA
76#define BYTEBITS 8 /* number of bits in a byte */
77
78/* internal macros */
022362dd
EA
79#define _BITWORD(bit) ((bit) / (BYTEBITS * sizeof (int)))
80#define _BITBIT(bit) (1 << ((bit) % (BYTEBITS * sizeof (int))))
6e8a8adf
EA
81
82typedef int BITMAP[BITMAPBYTES / sizeof (int)];
83
84/* test bit number N */
85#define bitnset(bit, map) ((map)[_BITWORD(bit)] & _BITBIT(bit))
86
87/* set bit number N */
88#define setbitn(bit, map) (map)[_BITWORD(bit)] |= _BITBIT(bit)
89
90/* clear bit number N */
91#define clrbitn(bit, map) (map)[_BITWORD(bit)] &= ~_BITBIT(bit)
92
93/* clear an entire bit map */
cca7676f 94#define clrbitmap(map) bzero((char *) map, BITMAPBYTES)
281f3387 95\f/*
9e3c0a28
EA
96** Address structure.
97** Addresses are stored internally in this structure.
abae7b2d
EA
98**
99** Each address is on two chains and in one tree.
100** The q_next chain is used to link together addresses
101** for one mailer (and is rooted in a mailer).
102** The q_chain chain is used to maintain a list of
103** addresses originating from one call to sendto, and
104** is used primarily for printing messages.
105** The q_alias, q_sibling, and q_child tree maintains
106** a complete tree of the aliases. q_alias points to
107** the parent -- obviously, there can be several, and
108** so this points to "one" of them. Ditto for q_sibling.
9e3c0a28
EA
109*/
110
111struct address
112{
113 char *q_paddr; /* the printname for the address */
114 char *q_user; /* user name */
3fbc69d6 115 char *q_ruser; /* real user name, or NULL if q_user */
9e3c0a28 116 char *q_host; /* host name */
179c1218 117 struct mailer *q_mailer; /* mailer to use */
68d9129a 118 u_long q_flags; /* status flags, see below */
0c9a26a7
EA
119 uid_t q_uid; /* user-id of receiver (if known) */
120 gid_t q_gid; /* group-id of receiver (if known) */
4bb4503e 121 char *q_home; /* home dir (local mailer only) */
f77d50ee 122 char *q_fullname; /* full name if known */
abae7b2d 123 char *q_fullname; /* full name of this person */
abae7b2d
EA
124 struct address *q_next; /* chain */
125 struct address *q_alias; /* parent in alias tree */
126 struct address *q_sibling; /* sibling in alias tree */
127 struct address *q_child; /* child in alias tree */
9e3c0a28
EA
128};
129
130typedef struct address ADDRESS;
131
68d9129a
EA
132# define QDONTSEND 0x00000001 /* don't send to this address */
133# define QBADADDR 0x00000002 /* this address is verified bad */
134# define QGOODUID 0x00000004 /* the q_uid q_gid fields are good */
66d16835 135# define QPRIMARY 0x00000008 /* set from RCPT or argv */
68d9129a
EA
136# define QQUEUEUP 0x00000010 /* queue for later transmission */
137# define QSENT 0x00000020 /* has been successfully delivered */
138# define QNOTREMOTE 0x00000040 /* address not for remote forwarding */
139# define QSELFREF 0x00000080 /* this address references itself */
140# define QVERIFIED 0x00000100 /* verified, but not expanded */
68d9129a
EA
141# define QBOGUSSHELL 0x00000400 /* user has no valid shell listed */
142# define QUNSAFEADDR 0x00000800 /* address aquired via unsafe path */
143# define QPINGONSUCCESS 0x00001000 /* give return on successful delivery */
144# define QPINGONFAILURE 0x00002000 /* give return on failure */
145# define QPINGONDELAY 0x00004000 /* give return on message delay */
e1f691b3 146# define QHASNOTIFY 0x00008000 /* propogate notify parameter */
126c1099
EA
147# define QRELAYED 0x00010000 /* DSN: relayed to non-DSN aware sys */
148# define QEXPANDED 0x00020000 /* DSN: undergone list expansion */
149# define QDELIVERED 0x00040000 /* DSN: successful final delivery */
150# define QDELAYED 0x00080000 /* DSN: message delayed */
66d16835 151# define QTHISPASS 0x80000000 /* temp: address set this pass */
28f94061
EA
152
153# define NULLADDR ((ADDRESS *) NULL)
abae7b2d 154# define QPSEUDO 000040 /* only on the list for verification */
2654b031 155\f/*
b3cbe40f
EA
156** Mailer definition structure.
157** Every mailer known to the system is declared in this
158** structure. It defines the pathname of the mailer, some
159** flags associated with it, and the argument vector to
cb590f52 160** pass to it. The flags are defined in conf.c
b3cbe40f 161**
b8944683
EA
162** The argument vector is expanded before actual use. All
163** words except the first are passed through the macro
164** processor.
b3cbe40f
EA
165*/
166
167struct mailer
168{
d6a28dd8 169 char *m_name; /* symbolic name of this mailer */
9e3c0a28 170 char *m_mailer; /* pathname of the mailer to use */
51d448e5
EA
171 char *m_mtatype; /* type of this MTA */
172 char *m_addrtype; /* type for addresses */
173 char *m_diagtype; /* type for diagnostics */
6e8a8adf 174 BITMAP m_flags; /* status flags, see below */
b14547d5 175 short m_mno; /* mailer number internally */
246d7c84 176 short m_nice; /* niceness to run at (mostly for prog) */
6708a5e3 177 char **m_argv; /* template argument vector */
5f2e67fb
EA
178 short m_sh_rwset; /* rewrite set: sender header addresses */
179 short m_se_rwset; /* rewrite set: sender envelope addresses */
180 short m_rh_rwset; /* rewrite set: recipient header addresses */
181 short m_re_rwset; /* rewrite set: recipient envelope addresses */
b3ef02a2 182 char *m_eol; /* end of line string */
6e8a8adf 183 long m_maxsize; /* size limit on message to this mailer */
8657d05f 184 int m_linelimit; /* max # characters per line */
a9d54f84 185 char *m_execdir; /* directory to chdir to before execv */
18ec81ef
EA
186 uid_t m_uid; /* UID to run as */
187 gid_t m_gid; /* GID to run as */
3caf3b1f 188 char *m_defcharset; /* default character set */
b3cbe40f
EA
189};
190
cdb17311
EA
191typedef struct mailer MAILER;
192
5fbf3fea 193/* bits for m_flags */
4f163ea3 194# define M_ESMTP 'a' /* run Extended SMTP protocol */
2bade550 195# define M_ALIASABLE 'A' /* user can be LHS of an alias */
e9d9eee0 196# define M_BLANKEND 'b' /* ensure blank line at end of message */
e0b72c68 197# define M_NOCOMMENT 'c' /* don't include comment part of address */
55c35014 198# define M_CANONICAL 'C' /* make addresses canonical "u@dom" */
09ce8c09 199# define M_NOBRACKET 'd' /* never angle bracket envelope route-addrs */
e0b72c68 200 /* 'D' /* CF: include Date: */
55c35014
EA
201# define M_EXPENSIVE 'e' /* it costs to use this mailer.... */
202# define M_ESCFROM 'E' /* escape From lines to >From */
6e8a8adf 203# define M_FOPT 'f' /* mailer takes picky -f flag */
e0b72c68 204 /* 'F' /* CF: include From: or Resent-From: */
aa7457b1 205# define M_NO_NULL_FROM 'g' /* sender of errors should be $g */
55c35014 206# define M_HST_UPPER 'h' /* preserve host case distinction */
68e180c7 207# define M_PREHEAD 'H' /* MAIL11V3: preview headers */
b927c301 208# define M_UDBENVELOPE 'i' /* do udbsender rewriting on envelope */
55c35014 209# define M_INTERNAL 'I' /* SMTP to another sendmail site */
bfdaf8cb 210# define M_UDBRECIPIENT 'j' /* do udbsender rewriting on recipient lines */
2bade550 211# define M_NOLOOPCHECK 'k' /* don't check for loops in HELO command */
09ce8c09 212# define M_LOCALMAILER 'l' /* delivery is to this host */
55c35014 213# define M_LIMITS 'L' /* must enforce SMTP line limits */
6e8a8adf 214# define M_MUSER 'm' /* can handle multiple users at once */
e0b72c68 215 /* 'M' /* CF: include Message-Id: */
55c35014 216# define M_NHDR 'n' /* don't insert From line */
68e180c7 217# define M_MANYSTATUS 'N' /* MAIL11V3: DATA returns multi-status */
2bade550 218# define M_RUNASRCPT 'o' /* always run mailer as recipient */
55c35014 219# define M_FROMPATH 'p' /* use reverse-path in MAIL FROM: */
e0b72c68 220 /* 'P' /* CF: include Return-Path: */
55c35014 221# define M_ROPT 'r' /* mailer takes picky -r flag */
a4f165f5 222# define M_SECURE_PORT 'R' /* try to send on a reserved TCP port */
55c35014 223# define M_STRIPQ 's' /* strip quote chars from user/host */
c1760914 224# define M_SPECIFIC_UID 'S' /* run as specific uid/gid */
6e8a8adf 225# define M_USR_UPPER 'u' /* preserve user case distinction */
6e8a8adf 226# define M_UGLYUUCP 'U' /* this wants an ugly UUCP from line */
2604d017 227# define M_CONTENT_LEN 'v' /* add Content-Length: header (SVr4) */
e0b72c68 228 /* 'V' /* UIUC: !-relativize all addresses */
2bade550 229# define M_HASPWENT 'w' /* check for /etc/passwd entry */
4f163ea3 230 /* 'x' /* CF: include Full-Name: */
6e8a8adf 231# define M_XDOT 'X' /* use hidden-dot algorithm */
c806bc6b 232# define M_EBCDIC '3' /* extend Q-P encoding for EBCDIC */
2bade550 233# define M_TRYRULESET5 '5' /* use ruleset 5 after local aliasing */
8657d05f 234# define M_7BITS '7' /* use 7-bit path */
38f52787 235# define M_8BITS '8' /* force "just send 8" behaviour */
7e3998c7 236# define M_MAKE8BIT '9' /* convert 7 -> 8 bit if appropriate */
2bade550
EA
237# define M_CHECKINCLUDE ':' /* check for :include: files */
238# define M_CHECKPROG '|' /* check for |program addresses */
239# define M_CHECKFILE '/' /* check for /file addresses */
240# define M_CHECKUDB '@' /* user can be user database key */
1a12c7d6 241
179c1218 242EXTERN MAILER *Mailer[MAXMAILERS+1];
4bb4503e 243
179c1218
EA
244EXTERN MAILER *LocalMailer; /* ptr to local mailer */
245EXTERN MAILER *ProgMailer; /* ptr to program mailer */
38817acb
EA
246EXTERN MAILER *FileMailer; /* ptr to *file* mailer */
247EXTERN MAILER *InclMailer; /* ptr to *include* mailer */
2654b031 248\f/*
1a12c7d6
EA
249** Header structure.
250** This structure is used internally to store header items.
251*/
252
253struct header
254{
255 char *h_field; /* the name of the field */
256 char *h_value; /* the value of that field */
257 struct header *h_link; /* the next header */
b2e9d033 258 u_short h_flags; /* status bits, see below */
6e8a8adf 259 BITMAP h_mflags; /* m_flags bits needed */
1a12c7d6
EA
260};
261
262typedef struct header HDR;
263
1a12c7d6
EA
264/*
265** Header information structure.
266** Defined in conf.c, this struct declares the header fields
267** that have some magic meaning.
268*/
269
270struct hdrinfo
271{
272 char *hi_field; /* the name of the field */
b2e9d033 273 u_short hi_flags; /* status bits, see below */
1a12c7d6
EA
274};
275
276extern struct hdrinfo HdrInfo[];
277
278/* bits for h_flags and hi_flags */
b5cdafa3
EA
279# define H_EOH 0x0001 /* this field terminates header */
280# define H_RCPT 0x0002 /* contains recipient addresses */
281# define H_DEFAULT 0x0004 /* if another value is found, drop this */
282# define H_RESENT 0x0008 /* this address is a "Resent-..." address */
283# define H_CHECK 0x0010 /* check h_mflags against m_flags */
284# define H_ACHECK 0x0020 /* ditto, but always (not just default) */
285# define H_FORCE 0x0040 /* force this field, even if default */
286# define H_TRACE 0x0080 /* this field contains trace information */
287# define H_FROM 0x0100 /* this is a from-type field */
288# define H_VALID 0x0200 /* this field has a validated value */
289# define H_RECEIPTTO 0x0400 /* this field has return receipt info */
290# define H_ERRORSTO 0x0800 /* this field has error address info */
291# define H_CTE 0x1000 /* this field is a content-transfer-encoding */
a579cea5 292# define H_CTYPE 0x2000 /* this is a content-type field */
5dc3d2c7 293# define H_STRIPVAL 0x4000 /* strip value from header (Bcc:) */
2654b031 294\f/*
23fafb99
EA
295** Information about currently open connections to mailers, or to
296** hosts that we have looked up recently.
297*/
298
299# define MCI struct mailer_con_info
300
301MCI
302{
303 short mci_flags; /* flag bits, see below */
304 short mci_errno; /* error number on last connection */
305 short mci_herrno; /* h_errno from last DNS lookup */
306 short mci_exitstat; /* exit status from last connection */
307 short mci_state; /* SMTP state */
308 long mci_maxsize; /* max size this server will accept */
309 FILE *mci_in; /* input side of connection */
310 FILE *mci_out; /* output side of connection */
311 int mci_pid; /* process id of subordinate proc */
312 char *mci_phase; /* SMTP phase string */
313 struct mailer *mci_mailer; /* ptr to the mailer for this conn */
314 char *mci_host; /* host name */
a542cc51 315 char *mci_status; /* DSN status to be copied to addrs */
23fafb99
EA
316 time_t mci_lastuse; /* last usage time */
317};
318
319
320/* flag bits */
b5cdafa3
EA
321#define MCIF_VALID 0x0001 /* this entry is valid */
322#define MCIF_TEMP 0x0002 /* don't cache this connection */
323#define MCIF_CACHED 0x0004 /* currently in open cache */
324#define MCIF_ESMTP 0x0008 /* this host speaks ESMTP */
325#define MCIF_EXPN 0x0010 /* EXPN command supported */
326#define MCIF_SIZE 0x0020 /* SIZE option supported */
327#define MCIF_8BITMIME 0x0040 /* BODY=8BITMIME supported */
328#define MCIF_7BIT 0x0080 /* strip this message to 7 bits */
329#define MCIF_MULTSTAT 0x0100 /* MAIL11V3: handles MULT status */
330#define MCIF_INHEADER 0x0200 /* currently outputing header */
331#define MCIF_CVT8TO7 0x0400 /* convert from 8 to 7 bits */
68d9129a 332#define MCIF_DSN 0x0800 /* DSN extension supported */
c7a0eaaf 333#define MCIF_8BITOK 0x1000 /* OK to send 8 bit characters */
7e3998c7 334#define MCIF_CVT7TO8 0x2000 /* convert from 7 to 8 bits */
d8daa013 335#define MCIF_INMIME 0x4000 /* currently reading MIME header */
23fafb99
EA
336
337/* states */
338#define MCIS_CLOSED 0 /* no traffic on this connection */
339#define MCIS_OPENING 1 /* sending initial protocol */
340#define MCIS_OPEN 2 /* open, initial protocol sent */
341#define MCIS_ACTIVE 3 /* message being sent */
342#define MCIS_QUITING 4 /* running quit protocol */
343#define MCIS_SSD 5 /* service shutting down */
344#define MCIS_ERROR 6 /* I/O error on connection */
345\f/*
2654b031
EA
346** Envelope structure.
347** This structure defines the message itself. There is usually
348** only one of these -- for the message that we originally read
349** and which is our primary interest -- but other envelopes can
350** be generated during processing. For example, error messages
351** will have their own envelope.
352*/
1a12c7d6 353
b543d6fa
EA
354# define ENVELOPE struct envelope
355
356ENVELOPE
2654b031 357{
dd1fe05b
EA
358 HDR *e_header; /* head of header list */
359 long e_msgpriority; /* adjusted priority of this message */
96476cab 360 time_t e_ctime; /* time message appeared in the queue */
dd1fe05b 361 char *e_to; /* the target person */
17232873 362 char *e_receiptto; /* return receipt address */
dd1fe05b 363 ADDRESS e_from; /* the person it is from */
547f2e0e 364 char *e_sender; /* e_from.q_paddr w comments stripped */
857afefe 365 char **e_fromdomain; /* the domain part of the sender */
1bcdf0a2 366 ADDRESS *e_returnto; /* place to return the message to */
dd1fe05b 367 ADDRESS *e_sendqueue; /* list of message recipients */
3c7fe765 368 ADDRESS *e_errorqueue; /* the queue for error responses */
dd1fe05b 369 long e_msgsize; /* size of the message in bytes */
b75b15f6 370 long e_flags; /* flags, see below */
2e3062fe 371 int e_nrcpts; /* number of recipients */
dd1fe05b 372 short e_class; /* msg class (priority, junk, etc.) */
7338e3d4 373 short e_hopcount; /* number of times processed */
9f27c6a8 374 short e_nsent; /* number of sends since checkpoint */
8c8e8e94
EA
375 short e_sendmode; /* message send mode */
376 short e_errormode; /* error return mode */
3b2e4211 377 short e_timeoutclass; /* message timeout class */
b09dac84 378 int (*e_puthdr)__P((MCI *, HDR *, ENVELOPE *));
b543d6fa 379 /* function to put header of message */
b09dac84 380 int (*e_putbody)__P((MCI *, ENVELOPE *, char *));
b543d6fa 381 /* function to put body of message */
dd1fe05b 382 struct envelope *e_parent; /* the message this one encloses */
e6f08ab1 383 struct envelope *e_sibling; /* the next envelope of interest */
60eebb0d 384 char *e_bodytype; /* type of message body */
912acb74 385 FILE *e_dfp; /* temporary file */
2cce0c26 386 char *e_id; /* code for this entry in queue */
912acb74 387 FILE *e_xfp; /* transcript file */
3620ad97 388 FILE *e_lockfp; /* the lock file for this message */
553e463f 389 FILE *e_qfp; /* queue control file */
1369934e 390 char *e_message; /* error message */
86575ebf 391 char *e_statmsg; /* stat msg (changes per delivery) */
9e2d8df2 392 char *e_msgboundary; /* MIME-style message part boundary */
e4a5cf08 393 char *e_origrcpt; /* original recipient (one only) */
68d9129a 394 char *e_envid; /* envelope id from MAIL FROM: line */
55f9fc92 395 char *e_status; /* DSN status for this message */
9be5c0a5
EA
396 time_t e_dtime; /* time of last delivery attempt */
397 int e_ntries; /* number of delivery attempts */
1dc7b0e0 398 dev_t e_dfdev; /* df file's device, for crash recov */
9be5c0a5 399 ino_t e_dfino; /* df file's ino, for crash recovery */
1be6e8d1 400 char *e_macro[256]; /* macro definitions */
2654b031 401};
1a12c7d6 402
e6f08ab1 403/* values for e_flags */
b75b15f6
EA
404#define EF_OLDSTYLE 0x0000001 /* use spaces (not commas) in hdrs */
405#define EF_INQUEUE 0x0000002 /* this message is fully queued */
c7a0eaaf 406#define EF_NO_BODY_RETN 0x0000004 /* omit message body on error */
b75b15f6
EA
407#define EF_CLRQUEUE 0x0000008 /* disk copy is no longer needed */
408#define EF_SENDRECEIPT 0x0000010 /* send a return receipt */
409#define EF_FATALERRS 0x0000020 /* fatal errors occured */
410#define EF_KEEPQUEUE 0x0000040 /* keep queue files always */
411#define EF_RESPONSE 0x0000080 /* this is an error or return receipt */
412#define EF_RESENT 0x0000100 /* this message is being forwarded */
413#define EF_VRFYONLY 0x0000200 /* verify only (don't expand aliases) */
414#define EF_WARNING 0x0000400 /* warning message has been sent */
415#define EF_QUEUERUN 0x0000800 /* this envelope is from queue */
416#define EF_GLOBALERRS 0x0001000 /* treat errors as global */
417#define EF_PM_NOTIFY 0x0002000 /* send return mail to postmaster */
418#define EF_METOO 0x0004000 /* send to me too */
419#define EF_LOGSENDER 0x0008000 /* need to log the sender */
cb61ef4b 420#define EF_NORECEIPT 0x0010000 /* suppress all return-receipts */
c23930c0 421#define EF_HAS8BIT 0x0020000 /* at least one 8-bit char in body */
68a0f832
EA
422#define EF_NL_NOT_EOL 0x0040000 /* don't accept raw NL as EOLine */
423#define EF_CRLF_NOT_EOL 0x0080000 /* don't accept CR-LF as EOLine */
c7a0eaaf 424#define EF_RET_PARAM 0x0100000 /* RCPT command had RET argument */
18a81ac0 425#define EF_HAS_DF 0x0200000 /* set when df file is instantiated */
15f70a93 426#define EF_IS_MIME 0x0400000 /* really is a MIME message */
e6f08ab1 427
2654b031
EA
428EXTERN ENVELOPE *CurEnv; /* envelope currently being processed */
429\f/*
505aaba0 430** Message priority classes.
9ccf54c4 431**
505aaba0
EA
432** The message class is read directly from the Priority: header
433** field in the message.
df74deb0 434**
505aaba0
EA
435** CurEnv->e_msgpriority is the number of bytes in the message plus
436** the creation time (so that jobs ``tend'' to be ordered correctly),
437** adjusted by the message class, the number of recipients, and the
438** amount of time the message has been sitting around. This number
439** is used to order the queue. Higher values mean LOWER priority.
440**
441** Each priority class point is worth WkClassFact priority points;
442** each recipient is worth WkRecipFact priority points. Each time
443** we reprocess a message the priority is adjusted by WkTimeFact.
444** WkTimeFact should normally decrease the priority so that jobs
445** that have historically failed will be run later; thanks go to
446** Jay Lepreau at Utah for pointing out the error in my thinking.
ee32daaf 447**
df74deb0
EA
448** The "class" is this number, unadjusted by the age or size of
449** this message. Classes with negative representations will have
450** error messages thrown away if they are not local.
ed45aae1
EA
451*/
452
a444c81b
EA
453struct priority
454{
455 char *pri_name; /* external name of priority */
456 int pri_val; /* internal value for same */
457};
458
459EXTERN struct priority Priorities[MAXPRIORITIES];
460EXTERN int NumPriorities; /* pointer into Priorities */
2654b031 461\f/*
d6a28dd8
EA
462** Rewrite rules.
463*/
464
465struct rewrite
466{
467 char **r_lhs; /* pattern match */
468 char **r_rhs; /* substitution value */
469 struct rewrite *r_next;/* next in chain */
470};
471
792a6b53 472EXTERN struct rewrite *RewriteRules[MAXRWSETS];
d6a28dd8 473
792a6b53
EA
474/*
475** Special characters in rewriting rules.
476** These are used internally only.
477** The COND* rules are actually used in macros rather than in
478** rewriting rules, but are given here because they
479** cannot conflict.
480*/
481
482/* left hand side items */
32549112
EA
483# define MATCHZANY ((u_char)0220) /* match zero or more tokens */
484# define MATCHANY ((u_char)0221) /* match one or more tokens */
485# define MATCHONE ((u_char)0222) /* match exactly one token */
486# define MATCHCLASS ((u_char)0223) /* match one token in a class */
487# define MATCHNCLASS ((u_char)0224) /* match anything not in class */
488# define MATCHREPL ((u_char)0225) /* replacement on RHS for above */
41173b8f
EA
489# define MATCHLOOKUP '\035' /* look up and replace a sequence */
490# define MATCHELOOKUP '\036' /* end of the sequence */
d6a28dd8 491
792a6b53 492/* right hand side items */
32549112
EA
493# define CANONNET ((u_char)0226) /* canonical net, next token */
494# define CANONHOST ((u_char)0227) /* canonical host, next token */
495# define CANONUSER ((u_char)0230) /* canonical user, next N tokens */
496# define CALLSUBR ((u_char)0231) /* call another rewriting set */
d6a28dd8 497
792a6b53 498/* conditionals in macros */
32549112
EA
499# define CONDIF ((u_char)0232) /* conditional if-then */
500# define CONDELSE ((u_char)0233) /* conditional else */
501# define CONDFI ((u_char)0234) /* conditional fi */
a73ae8ac 502
58862a24 503/* bracket characters for host name lookup */
32549112
EA
504# define HOSTBEGIN ((u_char)0235) /* hostname lookup begin */
505# define HOSTEND ((u_char)0236) /* hostname lookup end */
58862a24 506
42fa5d67 507/* bracket characters for generalized lookup */
32549112
EA
508# define LOOKUPBEGIN ((u_char)0205) /* generalized lookup begin */
509# define LOOKUPEND ((u_char)0206) /* generalized lookup end */
42fa5d67 510
2bee003d 511/* macro substitution character */
32549112
EA
512# define MACROEXPAND ((u_char)0201) /* macro expansion */
513# define MACRODEXPAND ((u_char)0202) /* deferred macro expansion */
e45dcea5 514
7703d47a
EA
515/* to make the code clearer */
516# define MATCHZERO CANONHOST
517
e45dcea5
EA
518/* external <==> internal mapping table */
519struct metamac
520{
521 char metaname; /* external code (after $) */
81a5ffcc 522 u_char metaval; /* internal code (as above) */
e45dcea5 523};
2654b031 524\f/*
c96073f7
EA
525** Name canonification short circuit.
526**
527** If the name server for a host is down, the process of trying to
528** canonify the name can hang. This is similar to (but alas, not
529** identical to) looking up the name for delivery. This stab type
530** caches the result of the name server lookup so we don't hang
531** multiple times.
532*/
533
534#define NAMECANON struct _namecanon
535
536NAMECANON
537{
538 short nc_errno; /* cached errno */
539 short nc_herrno; /* cached h_errno */
540 short nc_stat; /* cached exit status code */
67283ab0 541 short nc_flags; /* flag bits */
c96073f7
EA
542 char *nc_cname; /* the canonical name */
543};
67283ab0
EA
544
545/* values for nc_flags */
546#define NCF_VALID 0x0001 /* entry valid */
c96073f7 547\f/*
42fa5d67
EA
548** Mapping functions
549**
550** These allow arbitrary mappings in the config file. The idea
551** (albeit not the implementation) comes from IDA sendmail.
552*/
553
42fa5d67 554# define MAPCLASS struct _mapclass
b543d6fa 555# define MAP struct _map
58979c07 556# define MAXMAPACTIONS 3 /* size of map_actions array */
42fa5d67
EA
557
558
559/*
560** An actual map.
561*/
562
42fa5d67
EA
563MAP
564{
565 MAPCLASS *map_class; /* the class of this map */
713c523f 566 char *map_mname; /* name of this map */
32549112 567 long map_mflags; /* flags, see below */
42fa5d67 568 char *map_file; /* the (nominal) filename */
0639fd0c
EA
569 ARBPTR_T map_db1; /* the open database ptr */
570 ARBPTR_T map_db2; /* an "extra" database pointer */
3b2e4211
EA
571 char *map_keycolnm; /* key column name */
572 char *map_valcolnm; /* value column name */
573 u_char map_keycolno; /* key column number */
574 u_char map_valcolno; /* value column number */
575 char map_coldelim; /* column delimiter */
32fd13db 576 char *map_app; /* to append to successful matches */
33844dcf 577 char *map_domain; /* the (nominal) NIS domain */
9d3eed3f 578 char *map_rebuild; /* program to run to do auto-rebuild */
28f94061 579 time_t map_mtime; /* last database modification time */
66d16835 580 short map_specificity; /* specificity of alaases */
58979c07
EA
581 MAP *map_stack[MAXMAPSTACK]; /* list for stacked maps */
582 short map_return[MAXMAPACTIONS]; /* return bitmaps for stacked maps */
42fa5d67
EA
583};
584
95739e1a 585/* bit values for map_mflags */
32549112
EA
586# define MF_VALID 0x00000001 /* this entry is valid */
587# define MF_INCLNULL 0x00000002 /* include null byte in key */
588# define MF_OPTIONAL 0x00000004 /* don't complain if map not found */
589# define MF_NOFOLDCASE 0x00000008 /* don't fold case in keys */
590# define MF_MATCHONLY 0x00000010 /* don't use the map value */
591# define MF_OPEN 0x00000020 /* this entry is open */
592# define MF_WRITABLE 0x00000040 /* open for writing */
593# define MF_ALIAS 0x00000080 /* this is an alias file */
594# define MF_TRY0NULL 0x00000100 /* try with no null byte */
595# define MF_TRY1NULL 0x00000200 /* try with the null byte */
596# define MF_LOCKED 0x00000400 /* this map is currently locked */
597# define MF_ALIASWAIT 0x00000800 /* alias map in aliaswait state */
598# define MF_IMPL_HASH 0x00001000 /* implicit: underlying hash database */
599# define MF_IMPL_NDBM 0x00002000 /* implicit: underlying NDBM database */
600# define MF_UNSAFEDB 0x00004000 /* this map is world writable */
601# define MF_APPEND 0x00008000 /* append new entry on rebuiled */
b543d6fa 602
3b2e4211
EA
603/* indices for map_actions */
604# define MA_NOTFOUND 0 /* member map returned "not found" */
605# define MA_UNAVAIL 1 /* member map is not available */
606# define MA_TRYAGAIN 2 /* member map returns temp failure */
b543d6fa
EA
607
608/*
609** The class of a map -- essentially the functions to call
610*/
611
612MAPCLASS
613{
713c523f
EA
614 char *map_cname; /* name of this map class */
615 char *map_ext; /* extension for database file */
31f1ab13 616 short map_cflags; /* flag bits, see below */
713c523f
EA
617 bool (*map_parse)__P((MAP *, char *));
618 /* argument parsing function */
619 char *(*map_lookup)__P((MAP *, char *, char **, int *));
b543d6fa 620 /* lookup function */
713c523f
EA
621 void (*map_store)__P((MAP *, char *, char *));
622 /* store function */
713c523f
EA
623 bool (*map_open)__P((MAP *, int));
624 /* open function */
625 void (*map_close)__P((MAP *));
626 /* close function */
b543d6fa 627};
31f1ab13
EA
628
629/* bit values for map_cflags */
630#define MCF_ALIASOK 0x0001 /* can be used for aliases */
631#define MCF_ALIASONLY 0x0002 /* usable only for aliases */
632#define MCF_REBUILDABLE 0x0004 /* can rebuild alias files */
db5bc5c7 633#define MCF_OPTFILE 0x0008 /* file name is optional */
42fa5d67 634\f/*
4d3a97d9
EA
635** Symbol table definitions
636*/
637
638struct symtab
639{
640 char *s_name; /* name to be entered */
cdb17311 641 char s_type; /* general type (see below) */
4d3a97d9 642 struct symtab *s_next; /* pointer to next in chain */
cdb17311
EA
643 union
644 {
2e3062fe
EA
645 BITMAP sv_class; /* bit-map of word classes */
646 ADDRESS *sv_addr; /* pointer to address header */
647 MAILER *sv_mailer; /* pointer to mailer */
648 char *sv_alias; /* alias */
31f1ab13 649 MAPCLASS sv_mapclass; /* mapping function class */
42fa5d67 650 MAP sv_map; /* mapping function */
ae21f7bc 651 char *sv_hostsig; /* host signature */
f2e44ded 652 MCI sv_mci; /* mailer connection info */
c96073f7 653 NAMECANON sv_namecanon; /* canonical name cache */
1be6e8d1 654 int sv_macro; /* macro name => id mapping */
ebec3e1f 655 int sv_ruleset; /* ruleset index */
cdb17311 656 } s_value;
4d3a97d9
EA
657};
658
659typedef struct symtab STAB;
660
cdb17311
EA
661/* symbol types */
662# define ST_UNDEF 0 /* undefined type */
663# define ST_CLASS 1 /* class map */
664# define ST_ADDRESS 2 /* an address in parsed format */
665# define ST_MAILER 3 /* a mailer header */
666# define ST_ALIAS 4 /* an alias */
e62e1144
EA
667# define ST_MAPCLASS 5 /* mapping function class */
668# define ST_MAP 6 /* mapping function */
ae21f7bc 669# define ST_HOSTSIG 7 /* host signature */
c96073f7 670# define ST_NAMECANON 8 /* cached canonical name */
1be6e8d1 671# define ST_MACRO 9 /* macro name to id mapping */
ebec3e1f 672# define ST_RULESET 10 /* ruleset index */
f2e44ded 673# define ST_MCI 16 /* mailer connection info (offset) */
cdb17311
EA
674
675# define s_class s_value.sv_class
14a39063 676# define s_address s_value.sv_addr
cdb17311
EA
677# define s_mailer s_value.sv_mailer
678# define s_alias s_value.sv_alias
2ae0e0ed 679# define s_mci s_value.sv_mci
cdb17311 680
5a972da1 681extern STAB *stab __P((char *, int, int));
46d8f512 682extern void stabapply __P((void (*)(STAB *, int), int));
4d3a97d9
EA
683
684/* opcodes to stab */
685# define ST_FIND 0 /* find entry */
686# define ST_ENTER 1 /* enter if not there */
2654b031 687\f/*
2439b900
EA
688** STRUCT EVENT -- event queue.
689**
690** Maintained in sorted order.
f5d25d7b
EA
691**
692** We store the pid of the process that set this event to insure
693** that when we fork we will not take events intended for the parent.
2439b900
EA
694*/
695
696struct event
697{
698 time_t ev_time; /* time of the function call */
ea07b2d2 699 void (*ev_func)__P((int));
b543d6fa 700 /* function to call */
2439b900 701 int ev_arg; /* argument to ev_func */
f5d25d7b 702 int ev_pid; /* pid that set this event */
2439b900
EA
703 struct event *ev_link; /* link to next item */
704};
705
706typedef struct event EVENT;
707
708EXTERN EVENT *EventQueue; /* head of event queue */
709\f/*
c23930c0 710** Operation, send, error, and MIME modes
75f95954
EA
711**
712** The operation mode describes the basic operation of sendmail.
713** This can be set from the command line, and is "send mail" by
714** default.
715**
716** The send mode tells how to send mail. It can be set in the
717** configuration file. It's setting determines how quickly the
718** mail will be delivered versus the load on your system. If the
719** -v (verbose) flag is given, it will be forced to SM_DELIVER
720** mode.
721**
7338e3d4 722** The error mode tells how to return errors.
d0bd03ce
EA
723*/
724
75f95954 725EXTERN char OpMode; /* operation mode, see below */
d0bd03ce 726
75f95954 727#define MD_DELIVER 'm' /* be a mail sender */
75f95954 728#define MD_SMTP 's' /* run SMTP on standard input */
dd06c909 729#define MD_ARPAFTP 'a' /* obsolete ARPANET mode (Grey Book) */
d0bd03ce
EA
730#define MD_DAEMON 'd' /* run as a daemon */
731#define MD_VERIFY 'v' /* verify: don't collect or deliver */
44cb7eee 732#define MD_TEST 't' /* test mode: resolve addrs only */
6bf17095
EA
733#define MD_INITALIAS 'i' /* initialize alias database */
734#define MD_PRINT 'p' /* print the queue */
735#define MD_FREEZE 'z' /* freeze the configuration file */
d0bd03ce 736
75f95954 737
8c8e8e94 738/* values for e_sendmode -- send modes */
75f95954 739#define SM_DELIVER 'i' /* interactive delivery */
75f95954
EA
740#define SM_FORK 'b' /* deliver in background */
741#define SM_QUEUE 'q' /* queue, don't deliver */
742#define SM_VERIFY 'v' /* verify only (used internally) */
7338e3d4 743
eefcf91f
EA
744/* used only as a parameter to sendall */
745#define SM_DEFAULT '\0' /* unspecified, use SendMode */
746
7338e3d4 747
8c8e8e94 748/* values for e_errormode -- error handling modes */
7338e3d4
EA
749#define EM_PRINT 'p' /* print errors */
750#define EM_MAIL 'm' /* mail back errors */
751#define EM_WRITE 'w' /* write back errors */
752#define EM_BERKNET 'e' /* special berknet processing */
753#define EM_QUIET 'q' /* don't print messages (stat only) */
c23930c0
EA
754
755
756/* MIME processing mode */
757EXTERN int MimeMode;
758
759/* bit values for MimeMode */
760#define MM_CVTMIME 0x0001 /* convert 8 to 7 bit MIME */
761#define MM_PASS8BIT 0x0002 /* just send 8 bit data blind */
762#define MM_MIME8BIT 0x0004 /* convert 8-bit data to MIME */
92830179
EA
763
764/* queue sorting order algorithm */
765EXTERN int QueueSortOrder;
766
767#define QS_BYPRIORITY 0 /* sort by message priority */
768#define QS_BYHOST 1 /* sort by first host name */
5dc3d2c7
EA
769
770
771/* how to handle messages without any recipient addresses */
772EXTERN int NoRecipientAction;
773
774#define NRA_NO_ACTION 0 /* just leave it as is */
775#define NRA_ADD_TO 1 /* add To: header */
776#define NRA_ADD_APPARENTLY_TO 2 /* add Apparently-To: header */
777#define NRA_ADD_BCC 3 /* add empty Bcc: header */
778#define NRA_ADD_TO_UNDISCLOSED 4 /* add To: undisclosed:; header */
568b126e
EA
779
780
781/* flags to putxline */
782#define PXLF_NOTHINGSPECIAL 0 /* no special mapping */
783#define PXLF_MAPFROM 0x0001 /* map From_ to >From_ */
784#define PXLF_STRIP8BIT 0x0002 /* strip 8th bit *e
e3ecd56f
EA
785\f/*
786** Additional definitions
787*/
788
20951c3f 789
e3ecd56f
EA
790/*
791** Privacy flags
792** These are bit values for the PrivacyFlags word.
793*/
794
1c7897ef 795#define PRIV_PUBLIC 0 /* what have I got to hide? */
b5cdafa3
EA
796#define PRIV_NEEDMAILHELO 0x0001 /* insist on HELO for MAIL, at least */
797#define PRIV_NEEDEXPNHELO 0x0002 /* insist on HELO for EXPN */
798#define PRIV_NEEDVRFYHELO 0x0004 /* insist on HELO for VRFY */
799#define PRIV_NOEXPN 0x0008 /* disallow EXPN command entirely */
800#define PRIV_NOVRFY 0x0010 /* disallow VRFY command entirely */
801#define PRIV_AUTHWARNINGS 0x0020 /* flag possible authorization probs */
802#define PRIV_NORECEIPTS 0x0040 /* disallow return receipts */
803#define PRIV_RESTRICTMAILQ 0x1000 /* restrict mailq command */
804#define PRIV_RESTRICTQRUN 0x2000 /* restrict queue run */
805#define PRIV_GOAWAY 0x0fff /* don't give no info, anyway, anyhow */
1c7897ef
EA
806
807/* struct defining such things */
808struct prival
809{
810 char *pv_name; /* name of privacy flag */
811 int pv_flag; /* numeric level */
812};
3341995c 813
e3ecd56f
EA
814
815/*
28f94061 816** Flags passed to remotename, parseaddr, allocaddr, and buildaddr.
e3ecd56f
EA
817*/
818
b5cdafa3
EA
819#define RF_SENDERADDR 0x001 /* this is a sender address */
820#define RF_HEADERADDR 0x002 /* this is a header address */
821#define RF_CANONICAL 0x004 /* strip comment information */
822#define RF_ADDDOMAIN 0x008 /* OK to do domain extension */
823#define RF_COPYPARSE 0x010 /* copy parsed user & host */
824#define RF_COPYPADDR 0x020 /* copy print address */
28f94061
EA
825#define RF_COPYALL (RF_COPYPARSE|RF_COPYPADDR)
826#define RF_COPYNONE 0
e3ecd56f 827
fce21cb9
EA
828
829/*
830** Flags passed to safefile.
831*/
832
f16ad954
EA
833#define SFF_ANYFILE 0 /* no special restrictions */
834#define SFF_MUSTOWN 0x0001 /* user must own this file */
835#define SFF_NOSLINK 0x0002 /* file cannot be a symbolic link */
e2ac6a24 836#define SFF_ROOTOK 0x0004 /* ok for root to own this file */
39ce28fb 837#define SFF_RUNASREALUID 0x0008 /* if no ctladdr, run as real uid */
e4a6739d 838#define SFF_NOPATHCHECK 0x0010 /* don't bother checking dir path */
d52f8819
EA
839#define SFF_SETUIDOK 0x0020 /* setuid files are ok */
840#define SFF_CREAT 0x0040 /* ok to create file if necessary */
6e4a5e06 841#define SFF_REGONLY 0x0080 /* regular files only */
fce21cb9 842
ed47dc44
EA
843/* flags that are actually specific to safefopen */
844#define SFF_OPENASROOT 0x1000 /* open as root instead of real user */
845
fce21cb9 846
022362dd
EA
847/*
848** Flags passed to mime8to7.
849*/
850
851#define M87F_OUTER 0 /* outer context */
852#define M87F_NO8BIT 0x0001 /* can't have 8-bit in this section */
568b126e 853#define M87F_DIGEST 0x0002 /* processing multipart/digest */
022362dd
EA
854
855
3341995c
EA
856/*
857** Regular UNIX sockaddrs are too small to handle ISO addresses, so
858** we are forced to declare a supertype here.
859*/
860
3356c77c 861union bigsockaddr
3341995c 862{
3356c77c 863 struct sockaddr sa; /* general version */
3a4fbef8 864#ifdef NETUNIX
2122a474 865 struct sockaddr_un sunix; /* UNIX family */
3a4fbef8 866#endif
3356c77c
EA
867#ifdef NETINET
868 struct sockaddr_in sin; /* INET family */
869#endif
870#ifdef NETISO
871 struct sockaddr_iso siso; /* ISO family */
872#endif
88e65f7c
EA
873#ifdef NETNS
874 struct sockaddr_ns sns; /* XNS family */
875#endif
876#ifdef NETX25
877 struct sockaddr_x25 sx25; /* X.25 family */
878#endif
3341995c
EA
879};
880
3356c77c 881#define SOCKADDR union bigsockaddr
13311af1
EA
882
883
884/*
885** Vendor codes
886**
887** Vendors can customize sendmail to add special behaviour,
888** generally for back compatibility. Ideally, this should
889** be set up in the .cf file using the "V" command. However,
890** it's quite reasonable for some vendors to want the default
891** be their old version; this can be set using
892** -DVENDOR_DEFAULT=VENDOR_xxx
893** in the Makefile.
894**
895** Vendors should apply to sendmail@CS.Berkeley.EDU for
896** unique vendor codes.
897*/
898
899#define VENDOR_BERKELEY 1 /* Berkeley-native configuration file */
900#define VENDOR_SUN 2 /* Sun-native configuration file */
4874708a 901#define VENDOR_HP 3 /* Hewlett-Packard specific config syntax */
13311af1
EA
902
903EXTERN int VendorCode; /* vendor-specific operation enhancements */
d0bd03ce 904\f/*
b3cbe40f
EA
905** Global variables.
906*/
907
327272f5 908EXTERN bool FromFlag; /* if set, "From" person is explicit */
327272f5
EA
909EXTERN bool MeToo; /* send to the sender also */
910EXTERN bool IgnrDot; /* don't let dot end messages */
911EXTERN bool SaveFrom; /* save leading "From" lines */
912EXTERN bool Verbose; /* set if blow-by-blow desired */
913EXTERN bool GrabTo; /* if set, get recipients from msg */
cbdb7357 914EXTERN bool SuprErrs; /* set if we are suppressing errors */
49086753 915EXTERN bool HoldErrs; /* only output errors to transcript */
3135d20c 916EXTERN bool NoConnect; /* don't connect to non-local mailers */
c1e24818 917EXTERN bool SuperSafe; /* be extra careful, even if expensive */
2e3062fe 918EXTERN bool ForkQueueRuns; /* fork for each job when running the queue */
6bf17095 919EXTERN bool AutoRebuild; /* auto-rebuild the alias database as needed */
7355ccf5 920EXTERN bool CheckAliases; /* parse addresses during newaliases */
c420ea6b 921EXTERN bool NoAlias; /* suppress aliasing */
58979c07 922EXTERN bool UseNameServer; /* using DNS -- interpret h_errno & MX RRs */
bc0cae7d 923EXTERN bool UseHesiod; /* using Hesiod -- interpret Hesiod errors */
c23930c0
EA
924EXTERN bool SevenBitInput; /* force 7-bit data on input */
925EXTERN bool HasEightBits; /* has at least one eight bit input byte */
487582d9 926EXTERN time_t SafeAlias; /* interval to wait until @:@ in alias file */
cbdb7357
EA
927EXTERN FILE *InChannel; /* input connection */
928EXTERN FILE *OutChannel; /* output connection */
05c5b8b4
EA
929EXTERN uid_t RealUid; /* when Daemon, real uid of caller */
930EXTERN gid_t RealGid; /* when Daemon, real gid of caller */
931EXTERN uid_t DefUid; /* default uid to run as */
932EXTERN gid_t DefGid; /* default gid to run as */
3fbc69d6 933EXTERN char *DefUser; /* default user to run as (from DefUid) */
327272f5 934EXTERN int OldUmask; /* umask when sendmail starts up */
1ea752a1 935EXTERN int Errors; /* set if errors (local to single pass) */
327272f5 936EXTERN int ExitStat; /* exit status code */
792a6b53 937EXTERN int LineNumber; /* line number in current input */
c1e24818 938EXTERN int LogLevel; /* level of logging to perform */
d9667c04 939EXTERN int FileMode; /* mode on files */
2e3062fe
EA
940EXTERN int QueueLA; /* load average starting forced queueing */
941EXTERN int RefuseLA; /* load average refusing connections are */
3620ad97 942EXTERN int CurrentLA; /* current load average */
faad4dd5 943EXTERN long QueueFactor; /* slope of queue function */
ed45aae1 944EXTERN time_t QueueIntvl; /* intervals between running the queue */
c1e24818 945EXTERN char *HelpFile; /* location of SMTP help file */
05c5b8b4 946EXTERN char *ErrMsgFile; /* file to prepend to all error messages */
c1e24818
EA
947EXTERN char *StatFile; /* location of statistics summary */
948EXTERN char *QueueDir; /* location of queue directory */
7338e3d4 949EXTERN char *FileName; /* name to print on error messages */
2e3062fe 950EXTERN char *SmtpPhase; /* current phase in SMTP processing */
57c97d4a 951EXTERN char *MyHostName; /* name of this host for SMTP messages */
2e3062fe 952EXTERN char *RealHostName; /* name of host we are talking to */
3341995c 953EXTERN SOCKADDR RealHostAddr; /* address of host we are talking to */
57c97d4a 954EXTERN char *CurHostName; /* current host we are dealing with */
c1e24818
EA
955EXTERN jmp_buf TopFrame; /* branch-to-top-of-loop-on-error frame */
956EXTERN bool QuickAbort; /* .... but only if we want a quick abort */
f61c3c40 957EXTERN bool LogUsrErrs; /* syslog user errors (e.g., SMTP RCPT cmd) */
64409ce4
EA
958EXTERN bool SendMIMEErrors; /* send error messages in MIME format */
959EXTERN bool MatchGecos; /* look for user names in gecos field */
acc25d70 960EXTERN bool UseErrorsTo; /* use Errors-To: header (back compat) */
d4f6a25e 961EXTERN bool TryNullMXList; /* if we are the best MX, try host directly */
fe3849ea 962EXTERN bool InChild; /* true if running in an SMTP subprocess */
2653232b 963EXTERN bool DisConnected; /* running with OutChannel redirected to xf */
79bf226a 964EXTERN bool ColonOkInAddr; /* single colon legal in address */
a7fab044 965EXTERN bool NoMXforCanon; /* don't use MX records when canonifying */
64409ce4 966EXTERN char SpaceSub; /* substitution for <lwsp> */
1c7897ef 967EXTERN int PrivacyFlags; /* privacy flags */
7150062b 968EXTERN char *ConfFile; /* location of configuration file [conf.c] */
1c7897ef 969extern char *PidFile; /* location of proc id file [conf.c] */
2e3062fe 970extern ADDRESS NullAddress; /* a null (template) address [main.c] */
faad4dd5
EA
971EXTERN long WkClassFact; /* multiplier for message class -> priority */
972EXTERN long WkRecipFact; /* multiplier for # of recipients -> priority */
973EXTERN long WkTimeFact; /* priority offset each time this job is run */
64409ce4
EA
974EXTERN char *UdbSpec; /* user database source spec */
975EXTERN int MaxHopCount; /* max # of hops until bounce */
976EXTERN int ConfigLevel; /* config file level */
977EXTERN char *TimeZoneSpec; /* override time zone specification */
978EXTERN char *ForwardPath; /* path to search for .forward files */
979EXTERN long MinBlocksFree; /* min # of blocks free on queue fs */
980EXTERN char *FallBackMX; /* fall back MX host */
981EXTERN long MaxMessageSize; /* advertised max size we will accept */
3d85b03a
EA
982EXTERN time_t MaxHostStatAge; /* max age of cached host status info */
983EXTERN time_t MinQueueAge; /* min delivery interval */
73943d18 984EXTERN time_t DialDelay; /* delay between dial-on-demand tries */
f967a599 985EXTERN char *SafeFileEnv; /* chroot location for file delivery */
f0416b32 986EXTERN char *HostsFile; /* path to /etc/hosts file */
0868adc3 987EXTERN char *ServiceSwitchFile; /* backup service switch */
a50ac3e2 988EXTERN char *DefaultCharSet; /* default character set for MIME */
3d85b03a 989EXTERN int DeliveryNiceness; /* how nice to be during delivery */
2e3062fe 990EXTERN char *PostMasterCopy; /* address to get errs cc's */
8dcff118 991EXTERN int CheckpointInterval; /* queue file checkpoint interval */
63d473ff 992EXTERN bool DontPruneRoutes; /* don't prune source routes */
a979db86 993EXTERN int MaxMciCache; /* maximum entries in MCI cache */
f2e44ded 994EXTERN time_t MciCacheTimeout; /* maximum idle time on connections */
d6c28d1a
EA
995EXTERN char *QueueLimitRecipient; /* limit queue runs to this recipient */
996EXTERN char *QueueLimitSender; /* limit queue runs to this sender */
997EXTERN char *QueueLimitId; /* limit queue runs to this id */
8e5c6745 998EXTERN FILE *TrafficLogFile; /* file in which to log all traffic */
05b75231
EA
999EXTERN char *UserEnviron[MAXUSERENVIRON + 1];
1000 /* saved user environment */
3a4fbef8 1001extern int errno;
7f5e2eef
EA
1002
1003
1004/*
1005** Timeouts
1006**
1007** Indicated values are the MINIMUM per RFC 1123 section 5.3.2.
1008*/
1009
1010EXTERN struct
1011{
cf7a936d 1012 /* RFC 1123-specified timeouts [minimum value] */
7f5e2eef
EA
1013 time_t to_initial; /* initial greeting timeout [5m] */
1014 time_t to_mail; /* MAIL command [5m] */
1015 time_t to_rcpt; /* RCPT command [5m] */
1016 time_t to_datainit; /* DATA initiation [2m] */
1017 time_t to_datablock; /* DATA block [3m] */
1018 time_t to_datafinal; /* DATA completion [10m] */
1019 time_t to_nextcommand; /* next command [5m] */
1020 /* following timeouts are not mentioned in RFC 1123 */
1021 time_t to_rset; /* RSET command */
1022 time_t to_helo; /* HELO command */
1023 time_t to_quit; /* QUIT command */
1024 time_t to_miscshort; /* misc short commands (NOOP, VERB, etc) */
cf7a936d 1025 time_t to_ident; /* IDENT protocol requests */
039f3bb5 1026 time_t to_fileopen; /* opening :include: and .forward files */
c2bdb1dd 1027 /* following are per message */
3b2e4211
EA
1028 time_t to_q_return[MAXTOCLASS]; /* queue return timeouts */
1029 time_t to_q_warning[MAXTOCLASS]; /* queue warning timeouts */
7f5e2eef
EA
1030} TimeOuts;
1031
3b2e4211
EA
1032/* timeout classes for return and warning timeouts */
1033# define TOC_NORMAL 0 /* normal delivery */
1034# define TOC_URGENT 1 /* urgent delivery */
1035# define TOC_NONURGENT 2 /* non-urgent delivery */
1036
7f5e2eef
EA
1037
1038/*
9678c96d
EA
1039** Trace information
1040*/
b3cbe40f 1041
9678c96d
EA
1042/* trace vector and macros for debugging flags */
1043EXTERN u_char tTdvect[100];
1044# define tTd(flag, level) (tTdvect[flag] >= level)
1045# define tTdlevel(flag) (tTdvect[flag])
1046\f/*
1047** Miscellaneous information.
1048*/
b3cbe40f 1049
b3cbe40f 1050
15842c3c
EA
1051
1052/*
1053** Some in-line functions
1054*/
1055
1056/* set exit status */
c8ec8736
EA
1057#define setstat(s) { \
1058 if (ExitStat == EX_OK || ExitStat == EX_TEMPFAIL) \
1059 ExitStat = s; \
1060 }
29871fef 1061
15842c3c 1062/* make a copy of a string */
c8ec8736 1063#define newstr(s) strcpy(xalloc(strlen(s) + 1), s)
15842c3c 1064
2e3062fe
EA
1065#define STRUCTCOPY(s, d) d = s
1066
15842c3c
EA
1067
1068/*
1069** Declarations of useful functions
1070*/
29871fef 1071
713c523f
EA
1072extern ADDRESS *parseaddr __P((char *, ADDRESS *, int, int, char **, ENVELOPE *));
1073extern char *xalloc __P((int));
1074extern bool sameaddr __P((ADDRESS *, ADDRESS *));
1075extern FILE *dfopen __P((char *, int, int));
ea07b2d2 1076extern EVENT *setevent __P((time_t, void(*)(), int));
021f85e3 1077extern char *sfgets __P((char *, int, FILE *, time_t, char *));
713c523f
EA
1078extern char *queuename __P((ENVELOPE *, int));
1079extern time_t curtime __P(());
1080extern bool transienterror __P((int));
1081extern const char *errstring __P((int));
832e8a27 1082extern void expand __P((char *, char *, size_t, ENVELOPE *));
18def49e
EA
1083extern void define __P((int, char *, ENVELOPE *));
1084extern char *macvalue __P((int, ENVELOPE *));
1be6e8d1
EA
1085extern char *macname __P((int));
1086extern int macid __P((char *, char **));
88f24dce 1087extern char **prescan __P((char *, int, char[], int, char **, char *));
e51f59dc 1088extern int rewrite __P((char **, int, int, ENVELOPE *));
5a972da1 1089extern char *fgetfolded __P((char *, int, FILE *));
f8c2f9fd 1090extern ADDRESS *recipient __P((ADDRESS *, ADDRESS **, int, ENVELOPE *));
5a972da1
EA
1091extern ENVELOPE *newenvelope __P((ENVELOPE *, ENVELOPE *));
1092extern void dropenvelope __P((ENVELOPE *));
cb955892 1093extern void clearenvelope __P((ENVELOPE *, bool));
5a972da1
EA
1094extern char *username __P(());
1095extern MCI *mci_get __P((char *, MAILER *));
cb955892 1096extern char *pintvl __P((time_t, bool));
5a972da1
EA
1097extern char *map_rewrite __P((MAP *, char *, int, char **));
1098extern ADDRESS *getctladdr __P((ADDRESS *));
1099extern char *anynet_ntoa __P((SOCKADDR *));
1100extern char *remotename __P((char *, MAILER *, int, int *, ENVELOPE *));
1101extern bool shouldqueue __P((long, time_t));
71936fbe 1102extern bool lockfile __P((int, char *, char *, int));
5a972da1
EA
1103extern char *hostsignature __P((MAILER *, char *, ENVELOPE *));
1104extern void openxscript __P((ENVELOPE *));
1105extern void closexscript __P((ENVELOPE *));
53335960 1106extern sigfunc_t setsignal __P((int, sigfunc_t));
77779257 1107extern char *shortenstring __P((char *, int));
1ee33f7d 1108extern bool usershellok __P((char *));
cb955892 1109extern void commaize __P((HDR *, char *, bool, MCI *, ENVELOPE *));
bcc3f44d 1110extern char *hvalue __P((char *, HDR *));
3caf3b1f 1111extern char *defcharset __P((ENVELOPE *));
bfd66a00 1112extern bool emptyaddr __P((ADDRESS *));
d51d925d 1113extern int sendtolist __P((char *, ADDRESS *, ADDRESS **, int, ENVELOPE *));
28ec685f 1114extern bool wordinclass __P((char *, int));
cb955892 1115extern char *denlstring __P((char *, bool, bool));
ea07b2d2
EA
1116extern void printaddr __P((ADDRESS *, bool));
1117extern void makelower __P((char *));
1118extern void rebuildaliases __P((MAP *, bool));
1119extern void readaliases __P((MAP *, FILE *, bool, bool));
1120extern void finis __P(());
1121extern void clrevent __P((EVENT *));
1122extern void setsender __P((char *, ENVELOPE *, char **, bool));
d52f8819 1123extern FILE *safefopen __P((char *, int, int, int));
5fde1e81
EA
1124extern struct hostent *sm_gethostbyname __P((char *));
1125extern struct hostent *sm_gethostbyaddr __P((char *, int, int));
1435d39a 1126extern struct passwd *sm_getpwnam __P((char *));
782a2f97 1127extern struct passwd *sm_getpwuid __P((UID_T));
58633cc7
EA
1128
1129/* ellipsis is a different case though */
1130#ifdef __STDC__
34025690
EA
1131extern void auth_warning(ENVELOPE *, const char *, ...);
1132extern void syserr(const char *, ...);
1133extern void usrerr(const char *, ...);
1134extern void message(const char *, ...);
1135extern void nmessage(const char *, ...);
58633cc7 1136#else
713c523f
EA
1137extern void auth_warning();
1138extern void syserr();
1139extern void usrerr();
1140extern void message();
1141extern void nmessage();
58633cc7 1142#endif
70aca632
EA
1143
1144/*
1145** HACK to fix bug in C compiler on CCI
1146*/
1147
1148#undef isascii
5eddb1af 1149#define isascii(x) (((x) & ~0177) == 0)