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 | * |
66d16835 | 8 | * @(#)sendmail.h 8.107 (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 |
66d16835 | 18 | static char SmailSccsId[] = "@(#)sendmail.h 8.107 %G%"; |
6353954f | 19 | # endif |
f3d8f6d6 | 20 | # else /* _DEFINE */ |
327272f5 | 21 | # define EXTERN extern |
f3d8f6d6 | 22 | # endif /* _DEFINE */ |
b3cbe40f | 23 | |
9dfbef75 | 24 | # include <unistd.h> |
f3d8f6d6 EA |
25 | # include <stddef.h> |
26 | # include <stdlib.h> | |
aeb209da EA |
27 | # include <stdio.h> |
28 | # include <ctype.h> | |
37eaaadb | 29 | # include <setjmp.h> |
f3d8f6d6 EA |
30 | # include <string.h> |
31 | # include <time.h> | |
32 | # include <errno.h> | |
3f7592f7 EA |
33 | # ifdef EX_OK |
34 | # undef EX_OK | |
35 | # endif | |
36 | # include <sysexits.h> | |
f3d8f6d6 | 37 | |
b5fd168f | 38 | # include "conf.h" |
6bf17095 | 39 | # include "conf.h" |
cb590f52 EA |
40 | # include "useful.h" |
41 | ||
9678c96d | 42 | # ifdef LOG |
5031c0bb | 43 | # include <syslog.h> |
f3d8f6d6 | 44 | # endif /* LOG */ |
6e8a8adf | 45 | |
2e3062fe | 46 | # ifdef DAEMON |
2e3062fe | 47 | # include <sys/socket.h> |
3356c77c | 48 | # endif |
3a4fbef8 EA |
49 | # ifdef NETUNIX |
50 | # include <sys/un.h> | |
51 | # endif | |
3356c77c | 52 | # ifdef NETINET |
2e3062fe | 53 | # include <netinet/in.h> |
3356c77c EA |
54 | # endif |
55 | # ifdef NETISO | |
56 | # include <netiso/iso.h> | |
57 | # endif | |
88e65f7c EA |
58 | # ifdef NETNS |
59 | # include <netns/ns.h> | |
60 | # endif | |
61 | # ifdef NETX25 | |
62 | # include <netccitt/x25.h> | |
63 | # endif | |
2e3062fe | 64 | |
6e8a8adf | 65 | |
a584db60 EA |
66 | |
67 | ||
6e8a8adf EA |
68 | /* |
69 | ** Data structure for bit maps. | |
70 | ** | |
71 | ** Each bit in this map can be referenced by an ascii character. | |
5d9e8d9a | 72 | ** This is 256 possible bits, or 32 8-bit bytes. |
6e8a8adf EA |
73 | */ |
74 | ||
5d9e8d9a | 75 | #define BITMAPBYTES 32 /* number of bytes in a bit map */ |
6e8a8adf EA |
76 | #define BYTEBITS 8 /* number of bits in a byte */ |
77 | ||
78 | /* internal macros */ | |
022362dd EA |
79 | #define _BITWORD(bit) ((bit) / (BYTEBITS * sizeof (int))) |
80 | #define _BITBIT(bit) (1 << ((bit) % (BYTEBITS * sizeof (int)))) | |
6e8a8adf EA |
81 | |
82 | typedef 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 | ||
111 | struct 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 | ||
130 | typedef 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 | ||
166 | struct 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 |
189 | typedef 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 | 237 | EXTERN MAILER *Mailer[MAXMAILERS+1]; |
4bb4503e | 238 | |
179c1218 EA |
239 | EXTERN MAILER *LocalMailer; /* ptr to local mailer */ |
240 | EXTERN MAILER *ProgMailer; /* ptr to program mailer */ | |
38817acb EA |
241 | EXTERN MAILER *FileMailer; /* ptr to *file* mailer */ |
242 | EXTERN 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 | ||
248 | struct 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 | ||
257 | typedef 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 | ||
265 | struct 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 | ||
271 | extern 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 | ||
296 | MCI | |
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 | ||
349 | ENVELOPE | |
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 |
419 | EXTERN 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 |
444 | struct priority |
445 | { | |
446 | char *pri_name; /* external name of priority */ | |
447 | int pri_val; /* internal value for same */ | |
448 | }; | |
449 | ||
450 | EXTERN struct priority Priorities[MAXPRIORITIES]; | |
451 | EXTERN int NumPriorities; /* pointer into Priorities */ | |
2654b031 | 452 | \f/* |
d6a28dd8 EA |
453 | ** Rewrite rules. |
454 | */ | |
455 | ||
456 | struct 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 | 463 | EXTERN 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 */ |
510 | struct 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 | ||
527 | NAMECANON | |
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 |
554 | MAP |
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 | ||
603 | MAPCLASS | |
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 | ||
629 | struct 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 | ||
650 | typedef 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 | 672 | extern STAB *stab __P((char *, int, int)); |
46d8f512 | 673 | extern 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 | ||
687 | struct 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 | ||
697 | typedef struct event EVENT; | |
698 | ||
699 | EXTERN 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 | 716 | EXTERN 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 EA |
730 | #define SM_DELIVER 'i' /* interactive delivery */ |
731 | #define SM_QUICKD 'j' /* deliver w/o queueing */ | |
732 | #define SM_FORK 'b' /* deliver in background */ | |
733 | #define SM_QUEUE 'q' /* queue, don't deliver */ | |
734 | #define SM_VERIFY 'v' /* verify only (used internally) */ | |
7338e3d4 | 735 | |
eefcf91f EA |
736 | /* used only as a parameter to sendall */ |
737 | #define SM_DEFAULT '\0' /* unspecified, use SendMode */ | |
738 | ||
7338e3d4 | 739 | |
8c8e8e94 | 740 | /* values for e_errormode -- error handling modes */ |
7338e3d4 EA |
741 | #define EM_PRINT 'p' /* print errors */ |
742 | #define EM_MAIL 'm' /* mail back errors */ | |
743 | #define EM_WRITE 'w' /* write back errors */ | |
744 | #define EM_BERKNET 'e' /* special berknet processing */ | |
745 | #define EM_QUIET 'q' /* don't print messages (stat only) */ | |
c23930c0 EA |
746 | |
747 | ||
748 | /* MIME processing mode */ | |
749 | EXTERN int MimeMode; | |
750 | ||
751 | /* bit values for MimeMode */ | |
752 | #define MM_CVTMIME 0x0001 /* convert 8 to 7 bit MIME */ | |
753 | #define MM_PASS8BIT 0x0002 /* just send 8 bit data blind */ | |
754 | #define MM_MIME8BIT 0x0004 /* convert 8-bit data to MIME */ | |
92830179 EA |
755 | |
756 | /* queue sorting order algorithm */ | |
757 | EXTERN int QueueSortOrder; | |
758 | ||
759 | #define QS_BYPRIORITY 0 /* sort by message priority */ | |
760 | #define QS_BYHOST 1 /* sort by first host name */ | |
5dc3d2c7 EA |
761 | |
762 | ||
763 | /* how to handle messages without any recipient addresses */ | |
764 | EXTERN int NoRecipientAction; | |
765 | ||
766 | #define NRA_NO_ACTION 0 /* just leave it as is */ | |
767 | #define NRA_ADD_TO 1 /* add To: header */ | |
768 | #define NRA_ADD_APPARENTLY_TO 2 /* add Apparently-To: header */ | |
769 | #define NRA_ADD_BCC 3 /* add empty Bcc: header */ | |
770 | #define NRA_ADD_TO_UNDISCLOSED 4 /* add To: undisclosed:; header */ | |
e3ecd56f EA |
771 | \f/* |
772 | ** Additional definitions | |
773 | */ | |
774 | ||
20951c3f | 775 | |
e3ecd56f EA |
776 | /* |
777 | ** Privacy flags | |
778 | ** These are bit values for the PrivacyFlags word. | |
779 | */ | |
780 | ||
1c7897ef | 781 | #define PRIV_PUBLIC 0 /* what have I got to hide? */ |
b5cdafa3 EA |
782 | #define PRIV_NEEDMAILHELO 0x0001 /* insist on HELO for MAIL, at least */ |
783 | #define PRIV_NEEDEXPNHELO 0x0002 /* insist on HELO for EXPN */ | |
784 | #define PRIV_NEEDVRFYHELO 0x0004 /* insist on HELO for VRFY */ | |
785 | #define PRIV_NOEXPN 0x0008 /* disallow EXPN command entirely */ | |
786 | #define PRIV_NOVRFY 0x0010 /* disallow VRFY command entirely */ | |
787 | #define PRIV_AUTHWARNINGS 0x0020 /* flag possible authorization probs */ | |
788 | #define PRIV_NORECEIPTS 0x0040 /* disallow return receipts */ | |
789 | #define PRIV_RESTRICTMAILQ 0x1000 /* restrict mailq command */ | |
790 | #define PRIV_RESTRICTQRUN 0x2000 /* restrict queue run */ | |
791 | #define PRIV_GOAWAY 0x0fff /* don't give no info, anyway, anyhow */ | |
1c7897ef EA |
792 | |
793 | /* struct defining such things */ | |
794 | struct prival | |
795 | { | |
796 | char *pv_name; /* name of privacy flag */ | |
797 | int pv_flag; /* numeric level */ | |
798 | }; | |
3341995c | 799 | |
e3ecd56f EA |
800 | |
801 | /* | |
28f94061 | 802 | ** Flags passed to remotename, parseaddr, allocaddr, and buildaddr. |
e3ecd56f EA |
803 | */ |
804 | ||
b5cdafa3 EA |
805 | #define RF_SENDERADDR 0x001 /* this is a sender address */ |
806 | #define RF_HEADERADDR 0x002 /* this is a header address */ | |
807 | #define RF_CANONICAL 0x004 /* strip comment information */ | |
808 | #define RF_ADDDOMAIN 0x008 /* OK to do domain extension */ | |
809 | #define RF_COPYPARSE 0x010 /* copy parsed user & host */ | |
810 | #define RF_COPYPADDR 0x020 /* copy print address */ | |
28f94061 EA |
811 | #define RF_COPYALL (RF_COPYPARSE|RF_COPYPADDR) |
812 | #define RF_COPYNONE 0 | |
e3ecd56f | 813 | |
fce21cb9 EA |
814 | |
815 | /* | |
816 | ** Flags passed to safefile. | |
817 | */ | |
818 | ||
f16ad954 EA |
819 | #define SFF_ANYFILE 0 /* no special restrictions */ |
820 | #define SFF_MUSTOWN 0x0001 /* user must own this file */ | |
821 | #define SFF_NOSLINK 0x0002 /* file cannot be a symbolic link */ | |
e2ac6a24 | 822 | #define SFF_ROOTOK 0x0004 /* ok for root to own this file */ |
e4a6739d | 823 | #define SFF_NOPATHCHECK 0x0010 /* don't bother checking dir path */ |
d52f8819 EA |
824 | #define SFF_SETUIDOK 0x0020 /* setuid files are ok */ |
825 | #define SFF_CREAT 0x0040 /* ok to create file if necessary */ | |
6e4a5e06 | 826 | #define SFF_REGONLY 0x0080 /* regular files only */ |
fce21cb9 | 827 | |
ed47dc44 EA |
828 | /* flags that are actually specific to safefopen */ |
829 | #define SFF_OPENASROOT 0x1000 /* open as root instead of real user */ | |
830 | ||
fce21cb9 | 831 | |
022362dd EA |
832 | /* |
833 | ** Flags passed to mime8to7. | |
834 | */ | |
835 | ||
836 | #define M87F_OUTER 0 /* outer context */ | |
837 | #define M87F_NO8BIT 0x0001 /* can't have 8-bit in this section */ | |
838 | ||
839 | ||
3341995c EA |
840 | /* |
841 | ** Regular UNIX sockaddrs are too small to handle ISO addresses, so | |
842 | ** we are forced to declare a supertype here. | |
843 | */ | |
844 | ||
3356c77c | 845 | union bigsockaddr |
3341995c | 846 | { |
3356c77c | 847 | struct sockaddr sa; /* general version */ |
3a4fbef8 | 848 | #ifdef NETUNIX |
2122a474 | 849 | struct sockaddr_un sunix; /* UNIX family */ |
3a4fbef8 | 850 | #endif |
3356c77c EA |
851 | #ifdef NETINET |
852 | struct sockaddr_in sin; /* INET family */ | |
853 | #endif | |
854 | #ifdef NETISO | |
855 | struct sockaddr_iso siso; /* ISO family */ | |
856 | #endif | |
88e65f7c EA |
857 | #ifdef NETNS |
858 | struct sockaddr_ns sns; /* XNS family */ | |
859 | #endif | |
860 | #ifdef NETX25 | |
861 | struct sockaddr_x25 sx25; /* X.25 family */ | |
862 | #endif | |
3341995c EA |
863 | }; |
864 | ||
3356c77c | 865 | #define SOCKADDR union bigsockaddr |
13311af1 EA |
866 | |
867 | ||
868 | /* | |
869 | ** Vendor codes | |
870 | ** | |
871 | ** Vendors can customize sendmail to add special behaviour, | |
872 | ** generally for back compatibility. Ideally, this should | |
873 | ** be set up in the .cf file using the "V" command. However, | |
874 | ** it's quite reasonable for some vendors to want the default | |
875 | ** be their old version; this can be set using | |
876 | ** -DVENDOR_DEFAULT=VENDOR_xxx | |
877 | ** in the Makefile. | |
878 | ** | |
879 | ** Vendors should apply to sendmail@CS.Berkeley.EDU for | |
880 | ** unique vendor codes. | |
881 | */ | |
882 | ||
883 | #define VENDOR_BERKELEY 1 /* Berkeley-native configuration file */ | |
884 | #define VENDOR_SUN 2 /* Sun-native configuration file */ | |
885 | ||
886 | EXTERN int VendorCode; /* vendor-specific operation enhancements */ | |
d0bd03ce | 887 | \f/* |
b3cbe40f EA |
888 | ** Global variables. |
889 | */ | |
890 | ||
327272f5 | 891 | EXTERN bool FromFlag; /* if set, "From" person is explicit */ |
327272f5 EA |
892 | EXTERN bool MeToo; /* send to the sender also */ |
893 | EXTERN bool IgnrDot; /* don't let dot end messages */ | |
894 | EXTERN bool SaveFrom; /* save leading "From" lines */ | |
895 | EXTERN bool Verbose; /* set if blow-by-blow desired */ | |
896 | EXTERN bool GrabTo; /* if set, get recipients from msg */ | |
cbdb7357 | 897 | EXTERN bool SuprErrs; /* set if we are suppressing errors */ |
49086753 | 898 | EXTERN bool HoldErrs; /* only output errors to transcript */ |
3135d20c | 899 | EXTERN bool NoConnect; /* don't connect to non-local mailers */ |
c1e24818 | 900 | EXTERN bool SuperSafe; /* be extra careful, even if expensive */ |
2e3062fe | 901 | EXTERN bool ForkQueueRuns; /* fork for each job when running the queue */ |
6bf17095 | 902 | EXTERN bool AutoRebuild; /* auto-rebuild the alias database as needed */ |
7355ccf5 | 903 | EXTERN bool CheckAliases; /* parse addresses during newaliases */ |
c420ea6b | 904 | EXTERN bool NoAlias; /* suppress aliasing */ |
58979c07 | 905 | EXTERN bool UseNameServer; /* using DNS -- interpret h_errno & MX RRs */ |
bc0cae7d | 906 | EXTERN bool UseHesiod; /* using Hesiod -- interpret Hesiod errors */ |
c23930c0 EA |
907 | EXTERN bool SevenBitInput; /* force 7-bit data on input */ |
908 | EXTERN bool HasEightBits; /* has at least one eight bit input byte */ | |
487582d9 | 909 | EXTERN time_t SafeAlias; /* interval to wait until @:@ in alias file */ |
cbdb7357 EA |
910 | EXTERN FILE *InChannel; /* input connection */ |
911 | EXTERN FILE *OutChannel; /* output connection */ | |
05c5b8b4 EA |
912 | EXTERN uid_t RealUid; /* when Daemon, real uid of caller */ |
913 | EXTERN gid_t RealGid; /* when Daemon, real gid of caller */ | |
914 | EXTERN uid_t DefUid; /* default uid to run as */ | |
915 | EXTERN gid_t DefGid; /* default gid to run as */ | |
3fbc69d6 | 916 | EXTERN char *DefUser; /* default user to run as (from DefUid) */ |
327272f5 | 917 | EXTERN int OldUmask; /* umask when sendmail starts up */ |
1ea752a1 | 918 | EXTERN int Errors; /* set if errors (local to single pass) */ |
327272f5 | 919 | EXTERN int ExitStat; /* exit status code */ |
792a6b53 | 920 | EXTERN int LineNumber; /* line number in current input */ |
c1e24818 | 921 | EXTERN int LogLevel; /* level of logging to perform */ |
d9667c04 | 922 | EXTERN int FileMode; /* mode on files */ |
2e3062fe EA |
923 | EXTERN int QueueLA; /* load average starting forced queueing */ |
924 | EXTERN int RefuseLA; /* load average refusing connections are */ | |
3620ad97 | 925 | EXTERN int CurrentLA; /* current load average */ |
faad4dd5 | 926 | EXTERN long QueueFactor; /* slope of queue function */ |
ed45aae1 | 927 | EXTERN time_t QueueIntvl; /* intervals between running the queue */ |
c1e24818 | 928 | EXTERN char *HelpFile; /* location of SMTP help file */ |
05c5b8b4 | 929 | EXTERN char *ErrMsgFile; /* file to prepend to all error messages */ |
c1e24818 EA |
930 | EXTERN char *StatFile; /* location of statistics summary */ |
931 | EXTERN char *QueueDir; /* location of queue directory */ | |
7338e3d4 | 932 | EXTERN char *FileName; /* name to print on error messages */ |
2e3062fe | 933 | EXTERN char *SmtpPhase; /* current phase in SMTP processing */ |
57c97d4a | 934 | EXTERN char *MyHostName; /* name of this host for SMTP messages */ |
2e3062fe | 935 | EXTERN char *RealHostName; /* name of host we are talking to */ |
3341995c | 936 | EXTERN SOCKADDR RealHostAddr; /* address of host we are talking to */ |
57c97d4a | 937 | EXTERN char *CurHostName; /* current host we are dealing with */ |
c1e24818 EA |
938 | EXTERN jmp_buf TopFrame; /* branch-to-top-of-loop-on-error frame */ |
939 | EXTERN bool QuickAbort; /* .... but only if we want a quick abort */ | |
f61c3c40 | 940 | EXTERN bool LogUsrErrs; /* syslog user errors (e.g., SMTP RCPT cmd) */ |
64409ce4 EA |
941 | EXTERN bool SendMIMEErrors; /* send error messages in MIME format */ |
942 | EXTERN bool MatchGecos; /* look for user names in gecos field */ | |
acc25d70 | 943 | EXTERN bool UseErrorsTo; /* use Errors-To: header (back compat) */ |
d4f6a25e | 944 | EXTERN bool TryNullMXList; /* if we are the best MX, try host directly */ |
fe3849ea | 945 | EXTERN bool InChild; /* true if running in an SMTP subprocess */ |
2653232b | 946 | EXTERN bool DisConnected; /* running with OutChannel redirected to xf */ |
64409ce4 | 947 | EXTERN char SpaceSub; /* substitution for <lwsp> */ |
1c7897ef | 948 | EXTERN int PrivacyFlags; /* privacy flags */ |
7150062b | 949 | EXTERN char *ConfFile; /* location of configuration file [conf.c] */ |
1c7897ef | 950 | extern char *PidFile; /* location of proc id file [conf.c] */ |
2e3062fe | 951 | extern ADDRESS NullAddress; /* a null (template) address [main.c] */ |
faad4dd5 EA |
952 | EXTERN long WkClassFact; /* multiplier for message class -> priority */ |
953 | EXTERN long WkRecipFact; /* multiplier for # of recipients -> priority */ | |
954 | EXTERN long WkTimeFact; /* priority offset each time this job is run */ | |
64409ce4 EA |
955 | EXTERN char *UdbSpec; /* user database source spec */ |
956 | EXTERN int MaxHopCount; /* max # of hops until bounce */ | |
957 | EXTERN int ConfigLevel; /* config file level */ | |
958 | EXTERN char *TimeZoneSpec; /* override time zone specification */ | |
959 | EXTERN char *ForwardPath; /* path to search for .forward files */ | |
960 | EXTERN long MinBlocksFree; /* min # of blocks free on queue fs */ | |
961 | EXTERN char *FallBackMX; /* fall back MX host */ | |
962 | EXTERN long MaxMessageSize; /* advertised max size we will accept */ | |
3d85b03a EA |
963 | EXTERN time_t MaxHostStatAge; /* max age of cached host status info */ |
964 | EXTERN time_t MinQueueAge; /* min delivery interval */ | |
73943d18 | 965 | EXTERN time_t DialDelay; /* delay between dial-on-demand tries */ |
f967a599 | 966 | EXTERN char *SafeFileEnv; /* chroot location for file delivery */ |
0868adc3 | 967 | EXTERN char *ServiceSwitchFile; /* backup service switch */ |
a50ac3e2 | 968 | EXTERN char *DefaultCharSet; /* default character set for MIME */ |
3d85b03a | 969 | EXTERN int DeliveryNiceness; /* how nice to be during delivery */ |
2e3062fe | 970 | EXTERN char *PostMasterCopy; /* address to get errs cc's */ |
8dcff118 | 971 | EXTERN int CheckpointInterval; /* queue file checkpoint interval */ |
63d473ff | 972 | EXTERN bool DontPruneRoutes; /* don't prune source routes */ |
8e648300 | 973 | EXTERN bool BrokenSmtpPeers; /* peers can't handle 2-line greeting */ |
a979db86 | 974 | EXTERN int MaxMciCache; /* maximum entries in MCI cache */ |
f2e44ded | 975 | EXTERN time_t MciCacheTimeout; /* maximum idle time on connections */ |
d6c28d1a EA |
976 | EXTERN char *QueueLimitRecipient; /* limit queue runs to this recipient */ |
977 | EXTERN char *QueueLimitSender; /* limit queue runs to this sender */ | |
978 | EXTERN char *QueueLimitId; /* limit queue runs to this id */ | |
8e5c6745 | 979 | EXTERN FILE *TrafficLogFile; /* file in which to log all traffic */ |
3a4fbef8 | 980 | extern int errno; |
7f5e2eef EA |
981 | |
982 | ||
983 | /* | |
984 | ** Timeouts | |
985 | ** | |
986 | ** Indicated values are the MINIMUM per RFC 1123 section 5.3.2. | |
987 | */ | |
988 | ||
989 | EXTERN struct | |
990 | { | |
cf7a936d | 991 | /* RFC 1123-specified timeouts [minimum value] */ |
7f5e2eef EA |
992 | time_t to_initial; /* initial greeting timeout [5m] */ |
993 | time_t to_mail; /* MAIL command [5m] */ | |
994 | time_t to_rcpt; /* RCPT command [5m] */ | |
995 | time_t to_datainit; /* DATA initiation [2m] */ | |
996 | time_t to_datablock; /* DATA block [3m] */ | |
997 | time_t to_datafinal; /* DATA completion [10m] */ | |
998 | time_t to_nextcommand; /* next command [5m] */ | |
999 | /* following timeouts are not mentioned in RFC 1123 */ | |
1000 | time_t to_rset; /* RSET command */ | |
1001 | time_t to_helo; /* HELO command */ | |
1002 | time_t to_quit; /* QUIT command */ | |
1003 | time_t to_miscshort; /* misc short commands (NOOP, VERB, etc) */ | |
cf7a936d | 1004 | time_t to_ident; /* IDENT protocol requests */ |
039f3bb5 | 1005 | time_t to_fileopen; /* opening :include: and .forward files */ |
c2bdb1dd | 1006 | /* following are per message */ |
3b2e4211 EA |
1007 | time_t to_q_return[MAXTOCLASS]; /* queue return timeouts */ |
1008 | time_t to_q_warning[MAXTOCLASS]; /* queue warning timeouts */ | |
7f5e2eef EA |
1009 | } TimeOuts; |
1010 | ||
3b2e4211 EA |
1011 | /* timeout classes for return and warning timeouts */ |
1012 | # define TOC_NORMAL 0 /* normal delivery */ | |
1013 | # define TOC_URGENT 1 /* urgent delivery */ | |
1014 | # define TOC_NONURGENT 2 /* non-urgent delivery */ | |
1015 | ||
7f5e2eef EA |
1016 | |
1017 | /* | |
9678c96d EA |
1018 | ** Trace information |
1019 | */ | |
b3cbe40f | 1020 | |
9678c96d EA |
1021 | /* trace vector and macros for debugging flags */ |
1022 | EXTERN u_char tTdvect[100]; | |
1023 | # define tTd(flag, level) (tTdvect[flag] >= level) | |
1024 | # define tTdlevel(flag) (tTdvect[flag]) | |
1025 | \f/* | |
1026 | ** Miscellaneous information. | |
1027 | */ | |
b3cbe40f | 1028 | |
b3cbe40f | 1029 | |
15842c3c EA |
1030 | |
1031 | /* | |
1032 | ** Some in-line functions | |
1033 | */ | |
1034 | ||
1035 | /* set exit status */ | |
c8ec8736 EA |
1036 | #define setstat(s) { \ |
1037 | if (ExitStat == EX_OK || ExitStat == EX_TEMPFAIL) \ | |
1038 | ExitStat = s; \ | |
1039 | } | |
29871fef | 1040 | |
15842c3c | 1041 | /* make a copy of a string */ |
c8ec8736 | 1042 | #define newstr(s) strcpy(xalloc(strlen(s) + 1), s) |
15842c3c | 1043 | |
2e3062fe EA |
1044 | #define STRUCTCOPY(s, d) d = s |
1045 | ||
15842c3c EA |
1046 | |
1047 | /* | |
1048 | ** Declarations of useful functions | |
1049 | */ | |
29871fef | 1050 | |
713c523f EA |
1051 | extern ADDRESS *parseaddr __P((char *, ADDRESS *, int, int, char **, ENVELOPE *)); |
1052 | extern char *xalloc __P((int)); | |
1053 | extern bool sameaddr __P((ADDRESS *, ADDRESS *)); | |
1054 | extern FILE *dfopen __P((char *, int, int)); | |
ea07b2d2 | 1055 | extern EVENT *setevent __P((time_t, void(*)(), int)); |
021f85e3 | 1056 | extern char *sfgets __P((char *, int, FILE *, time_t, char *)); |
713c523f EA |
1057 | extern char *queuename __P((ENVELOPE *, int)); |
1058 | extern time_t curtime __P(()); | |
1059 | extern bool transienterror __P((int)); | |
1060 | extern const char *errstring __P((int)); | |
832e8a27 | 1061 | extern void expand __P((char *, char *, size_t, ENVELOPE *)); |
18def49e EA |
1062 | extern void define __P((int, char *, ENVELOPE *)); |
1063 | extern char *macvalue __P((int, ENVELOPE *)); | |
1be6e8d1 EA |
1064 | extern char *macname __P((int)); |
1065 | extern int macid __P((char *, char **)); | |
d8a2fd4c | 1066 | extern char **prescan __P((char *, int, char[], int, char **)); |
e51f59dc | 1067 | extern int rewrite __P((char **, int, int, ENVELOPE *)); |
5a972da1 | 1068 | extern char *fgetfolded __P((char *, int, FILE *)); |
f8c2f9fd | 1069 | extern ADDRESS *recipient __P((ADDRESS *, ADDRESS **, int, ENVELOPE *)); |
5a972da1 EA |
1070 | extern ENVELOPE *newenvelope __P((ENVELOPE *, ENVELOPE *)); |
1071 | extern void dropenvelope __P((ENVELOPE *)); | |
18def49e | 1072 | extern void clearenvelope __P((ENVELOPE *, int)); |
5a972da1 EA |
1073 | extern char *username __P(()); |
1074 | extern MCI *mci_get __P((char *, MAILER *)); | |
18def49e | 1075 | extern char *pintvl __P((time_t, int)); |
5a972da1 EA |
1076 | extern char *map_rewrite __P((MAP *, char *, int, char **)); |
1077 | extern ADDRESS *getctladdr __P((ADDRESS *)); | |
1078 | extern char *anynet_ntoa __P((SOCKADDR *)); | |
1079 | extern char *remotename __P((char *, MAILER *, int, int *, ENVELOPE *)); | |
1080 | extern bool shouldqueue __P((long, time_t)); | |
71936fbe | 1081 | extern bool lockfile __P((int, char *, char *, int)); |
5a972da1 EA |
1082 | extern char *hostsignature __P((MAILER *, char *, ENVELOPE *)); |
1083 | extern void openxscript __P((ENVELOPE *)); | |
1084 | extern void closexscript __P((ENVELOPE *)); | |
53335960 | 1085 | extern sigfunc_t setsignal __P((int, sigfunc_t)); |
77779257 | 1086 | extern char *shortenstring __P((char *, int)); |
1ee33f7d | 1087 | extern bool usershellok __P((char *)); |
23fafb99 | 1088 | extern void commaize __P((HDR *, char *, int, MCI *, ENVELOPE *)); |
bcc3f44d | 1089 | extern char *hvalue __P((char *, HDR *)); |
3caf3b1f | 1090 | extern char *defcharset __P((ENVELOPE *)); |
bfd66a00 | 1091 | extern bool emptyaddr __P((ADDRESS *)); |
d51d925d | 1092 | extern int sendtolist __P((char *, ADDRESS *, ADDRESS **, int, ENVELOPE *)); |
28ec685f | 1093 | extern bool wordinclass __P((char *, int)); |
4ec4fa70 | 1094 | extern char *denlstring __P((char *, int, int)); |
ea07b2d2 EA |
1095 | extern void printaddr __P((ADDRESS *, bool)); |
1096 | extern void makelower __P((char *)); | |
1097 | extern void rebuildaliases __P((MAP *, bool)); | |
1098 | extern void readaliases __P((MAP *, FILE *, bool, bool)); | |
1099 | extern void finis __P(()); | |
1100 | extern void clrevent __P((EVENT *)); | |
1101 | extern void setsender __P((char *, ENVELOPE *, char **, bool)); | |
d52f8819 | 1102 | extern FILE *safefopen __P((char *, int, int, int)); |
58633cc7 EA |
1103 | |
1104 | /* ellipsis is a different case though */ | |
1105 | #ifdef __STDC__ | |
34025690 EA |
1106 | extern void auth_warning(ENVELOPE *, const char *, ...); |
1107 | extern void syserr(const char *, ...); | |
1108 | extern void usrerr(const char *, ...); | |
1109 | extern void message(const char *, ...); | |
1110 | extern void nmessage(const char *, ...); | |
58633cc7 | 1111 | #else |
713c523f EA |
1112 | extern void auth_warning(); |
1113 | extern void syserr(); | |
1114 | extern void usrerr(); | |
1115 | extern void message(); | |
1116 | extern void nmessage(); | |
58633cc7 | 1117 | #endif |
70aca632 EA |
1118 | |
1119 | /* | |
1120 | ** HACK to fix bug in C compiler on CCI | |
1121 | */ | |
1122 | ||
1123 | #undef isascii | |
5eddb1af | 1124 | #define isascii(x) (((x) & ~0177) == 0) |