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