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