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