Commit | Line | Data |
---|---|---|
aeb2545d | 1 | /* |
dc45ba8c | 2 | * Copyright (c) 1983 Eric P. Allman |
bee79b64 KB |
3 | * Copyright (c) 1988 Regents of the University of California. |
4 | * All rights reserved. | |
5 | * | |
417f7a11 | 6 | * %sccs.include.redist.c% |
bee79b64 | 7 | * |
07c63e56 | 8 | * @(#)sendmail.h 5.37 (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 |
07c63e56 | 18 | static char SmailSccsId[] = "@(#)sendmail.h 5.37 %G%"; |
4e5e456f | 19 | # endif lint |
327272f5 EA |
20 | # else _DEFINE |
21 | # define EXTERN extern | |
22 | # endif _DEFINE | |
b3cbe40f | 23 | |
030ae776 | 24 | # include <sys/types.h> |
aeb209da EA |
25 | # include <stdio.h> |
26 | # include <ctype.h> | |
37eaaadb | 27 | # include <setjmp.h> |
e234fcd9 | 28 | # include <sysexits.h> |
b5fd168f | 29 | # include "conf.h" |
6bf17095 | 30 | # include "conf.h" |
cb590f52 EA |
31 | # include "useful.h" |
32 | ||
9678c96d | 33 | # ifdef LOG |
da0b895c | 34 | # include <sys/syslog.h> |
9678c96d | 35 | # endif LOG |
6e8a8adf | 36 | |
2e3062fe | 37 | # ifdef DAEMON |
2e3062fe EA |
38 | # include <sys/socket.h> |
39 | # include <netinet/in.h> | |
2e3062fe EA |
40 | # endif DAEMON |
41 | ||
6e8a8adf | 42 | |
a584db60 EA |
43 | # define PSBUFSIZE (MAXNAME + MAXATOM) /* size of prescan buffer */ |
44 | ||
45 | ||
6e8a8adf EA |
46 | /* |
47 | ** Data structure for bit maps. | |
48 | ** | |
49 | ** Each bit in this map can be referenced by an ascii character. | |
50 | ** This is 128 possible bits, or 12 8-bit bytes. | |
51 | */ | |
52 | ||
53 | #define BITMAPBYTES 16 /* number of bytes in a bit map */ | |
54 | #define BYTEBITS 8 /* number of bits in a byte */ | |
55 | ||
56 | /* internal macros */ | |
57 | #define _BITWORD(bit) (bit / (BYTEBITS * sizeof (int))) | |
58 | #define _BITBIT(bit) (1 << (bit % (BYTEBITS * sizeof (int)))) | |
59 | ||
60 | typedef int BITMAP[BITMAPBYTES / sizeof (int)]; | |
61 | ||
62 | /* test bit number N */ | |
63 | #define bitnset(bit, map) ((map)[_BITWORD(bit)] & _BITBIT(bit)) | |
64 | ||
65 | /* set bit number N */ | |
66 | #define setbitn(bit, map) (map)[_BITWORD(bit)] |= _BITBIT(bit) | |
67 | ||
68 | /* clear bit number N */ | |
69 | #define clrbitn(bit, map) (map)[_BITWORD(bit)] &= ~_BITBIT(bit) | |
70 | ||
71 | /* clear an entire bit map */ | |
cca7676f | 72 | #define clrbitmap(map) bzero((char *) map, BITMAPBYTES) |
281f3387 | 73 | \f/* |
9e3c0a28 EA |
74 | ** Address structure. |
75 | ** Addresses are stored internally in this structure. | |
abae7b2d EA |
76 | ** |
77 | ** Each address is on two chains and in one tree. | |
78 | ** The q_next chain is used to link together addresses | |
79 | ** for one mailer (and is rooted in a mailer). | |
80 | ** The q_chain chain is used to maintain a list of | |
81 | ** addresses originating from one call to sendto, and | |
82 | ** is used primarily for printing messages. | |
83 | ** The q_alias, q_sibling, and q_child tree maintains | |
84 | ** a complete tree of the aliases. q_alias points to | |
85 | ** the parent -- obviously, there can be several, and | |
86 | ** so this points to "one" of them. Ditto for q_sibling. | |
9e3c0a28 EA |
87 | */ |
88 | ||
89 | struct address | |
90 | { | |
91 | char *q_paddr; /* the printname for the address */ | |
92 | char *q_user; /* user name */ | |
3fbc69d6 | 93 | char *q_ruser; /* real user name, or NULL if q_user */ |
9e3c0a28 | 94 | char *q_host; /* host name */ |
179c1218 | 95 | struct mailer *q_mailer; /* mailer to use */ |
b2e9d033 | 96 | u_short q_flags; /* status flags, see below */ |
0c9a26a7 EA |
97 | uid_t q_uid; /* user-id of receiver (if known) */ |
98 | gid_t q_gid; /* group-id of receiver (if known) */ | |
4bb4503e | 99 | char *q_home; /* home dir (local mailer only) */ |
f77d50ee | 100 | char *q_fullname; /* full name if known */ |
abae7b2d | 101 | char *q_fullname; /* full name of this person */ |
ed45aae1 | 102 | time_t q_timeout; /* timeout for this address */ |
abae7b2d EA |
103 | struct address *q_next; /* chain */ |
104 | struct address *q_alias; /* parent in alias tree */ | |
105 | struct address *q_sibling; /* sibling in alias tree */ | |
106 | struct address *q_child; /* child in alias tree */ | |
9e3c0a28 EA |
107 | }; |
108 | ||
109 | typedef struct address ADDRESS; | |
110 | ||
111 | # define QDONTSEND 000001 /* don't send to this address */ | |
1ef61b9f | 112 | # define QBADADDR 000002 /* this address is verified bad */ |
2c1457f0 | 113 | # define QGOODUID 000004 /* the q_uid q_gid fields are good */ |
92f12b98 | 114 | # define QPRIMARY 000010 /* set from argv */ |
ed45aae1 | 115 | # define QQUEUEUP 000020 /* queue for later transmission */ |
8dcff118 | 116 | # define QSENT 000040 /* has been successfully delivered */ |
51966dba | 117 | # define QNOTREMOTE 000100 /* not an address for remote forwarding */ |
abae7b2d | 118 | # define QPSEUDO 000040 /* only on the list for verification */ |
2654b031 | 119 | \f/* |
b3cbe40f EA |
120 | ** Mailer definition structure. |
121 | ** Every mailer known to the system is declared in this | |
122 | ** structure. It defines the pathname of the mailer, some | |
123 | ** flags associated with it, and the argument vector to | |
cb590f52 | 124 | ** pass to it. The flags are defined in conf.c |
b3cbe40f | 125 | ** |
b8944683 EA |
126 | ** The argument vector is expanded before actual use. All |
127 | ** words except the first are passed through the macro | |
128 | ** processor. | |
b3cbe40f EA |
129 | */ |
130 | ||
131 | struct mailer | |
132 | { | |
d6a28dd8 | 133 | char *m_name; /* symbolic name of this mailer */ |
9e3c0a28 | 134 | char *m_mailer; /* pathname of the mailer to use */ |
6e8a8adf | 135 | BITMAP m_flags; /* status flags, see below */ |
b14547d5 | 136 | short m_mno; /* mailer number internally */ |
6708a5e3 | 137 | char **m_argv; /* template argument vector */ |
17232873 EA |
138 | short m_s_rwset; /* rewriting set for sender addresses */ |
139 | short m_r_rwset; /* rewriting set for recipient addresses */ | |
b3ef02a2 | 140 | char *m_eol; /* end of line string */ |
6e8a8adf | 141 | long m_maxsize; /* size limit on message to this mailer */ |
8657d05f | 142 | int m_linelimit; /* max # characters per line */ |
b3cbe40f EA |
143 | }; |
144 | ||
cdb17311 EA |
145 | typedef struct mailer MAILER; |
146 | ||
5fbf3fea | 147 | /* bits for m_flags */ |
55c35014 EA |
148 | # define M_CANONICAL 'C' /* make addresses canonical "u@dom" */ |
149 | # define M_EXPENSIVE 'e' /* it costs to use this mailer.... */ | |
150 | # define M_ESCFROM 'E' /* escape From lines to >From */ | |
6e8a8adf | 151 | # define M_FOPT 'f' /* mailer takes picky -f flag */ |
55c35014 EA |
152 | # define M_HST_UPPER 'h' /* preserve host case distinction */ |
153 | # define M_INTERNAL 'I' /* SMTP to another sendmail site */ | |
6e8a8adf | 154 | # define M_LOCAL 'l' /* delivery is to this host */ |
55c35014 | 155 | # define M_LIMITS 'L' /* must enforce SMTP line limits */ |
6e8a8adf | 156 | # define M_MUSER 'm' /* can handle multiple users at once */ |
55c35014 EA |
157 | # define M_NHDR 'n' /* don't insert From line */ |
158 | # define M_FROMPATH 'p' /* use reverse-path in MAIL FROM: */ | |
159 | # define M_ROPT 'r' /* mailer takes picky -r flag */ | |
a4f165f5 | 160 | # define M_SECURE_PORT 'R' /* try to send on a reserved TCP port */ |
55c35014 EA |
161 | # define M_STRIPQ 's' /* strip quote chars from user/host */ |
162 | # define M_RESTR 'S' /* must be daemon to execute */ | |
6e8a8adf | 163 | # define M_USR_UPPER 'u' /* preserve user case distinction */ |
6e8a8adf | 164 | # define M_UGLYUUCP 'U' /* this wants an ugly UUCP from line */ |
6e8a8adf | 165 | # define M_XDOT 'X' /* use hidden-dot algorithm */ |
8657d05f | 166 | # define M_7BITS '7' /* use 7-bit path */ |
1a12c7d6 | 167 | |
179c1218 | 168 | EXTERN MAILER *Mailer[MAXMAILERS+1]; |
4bb4503e | 169 | |
179c1218 EA |
170 | EXTERN MAILER *LocalMailer; /* ptr to local mailer */ |
171 | EXTERN MAILER *ProgMailer; /* ptr to program mailer */ | |
2654b031 | 172 | \f/* |
1a12c7d6 EA |
173 | ** Header structure. |
174 | ** This structure is used internally to store header items. | |
175 | */ | |
176 | ||
177 | struct header | |
178 | { | |
179 | char *h_field; /* the name of the field */ | |
180 | char *h_value; /* the value of that field */ | |
181 | struct header *h_link; /* the next header */ | |
b2e9d033 | 182 | u_short h_flags; /* status bits, see below */ |
6e8a8adf | 183 | BITMAP h_mflags; /* m_flags bits needed */ |
1a12c7d6 EA |
184 | }; |
185 | ||
186 | typedef struct header HDR; | |
187 | ||
1a12c7d6 EA |
188 | /* |
189 | ** Header information structure. | |
190 | ** Defined in conf.c, this struct declares the header fields | |
191 | ** that have some magic meaning. | |
192 | */ | |
193 | ||
194 | struct hdrinfo | |
195 | { | |
196 | char *hi_field; /* the name of the field */ | |
b2e9d033 | 197 | u_short hi_flags; /* status bits, see below */ |
1a12c7d6 EA |
198 | }; |
199 | ||
200 | extern struct hdrinfo HdrInfo[]; | |
201 | ||
202 | /* bits for h_flags and hi_flags */ | |
355a2a04 | 203 | # define H_EOH 00001 /* this field terminates header */ |
028b97f3 | 204 | # define H_RCPT 00002 /* contains recipient addresses */ |
1a12c7d6 | 205 | # define H_DEFAULT 00004 /* if another value is found, drop this */ |
a90807d8 | 206 | # define H_RESENT 00010 /* this address is a "Resent-..." address */ |
2f0c5bd8 | 207 | # define H_CHECK 00020 /* check h_mflags against m_flags */ |
a9e0e597 | 208 | # define H_ACHECK 00040 /* ditto, but always (not just default) */ |
b2e9d033 | 209 | # define H_FORCE 00100 /* force this field, even if default */ |
17232873 | 210 | # define H_TRACE 00200 /* this field contains trace information */ |
91f868d8 | 211 | # define H_FROM 00400 /* this is a from-type field */ |
f5a42e44 | 212 | # define H_VALID 01000 /* this field has a validated value */ |
2654b031 EA |
213 | \f/* |
214 | ** Envelope structure. | |
215 | ** This structure defines the message itself. There is usually | |
216 | ** only one of these -- for the message that we originally read | |
217 | ** and which is our primary interest -- but other envelopes can | |
218 | ** be generated during processing. For example, error messages | |
219 | ** will have their own envelope. | |
220 | */ | |
1a12c7d6 | 221 | |
2654b031 EA |
222 | struct envelope |
223 | { | |
dd1fe05b EA |
224 | HDR *e_header; /* head of header list */ |
225 | long e_msgpriority; /* adjusted priority of this message */ | |
96476cab | 226 | time_t e_ctime; /* time message appeared in the queue */ |
dd1fe05b | 227 | char *e_to; /* the target person */ |
17232873 | 228 | char *e_receiptto; /* return receipt address */ |
dd1fe05b | 229 | ADDRESS e_from; /* the person it is from */ |
f61c3c40 EA |
230 | char *e_sender; /* string version of from person */ |
231 | char *e_returnpath; /* string version of return path */ | |
857afefe | 232 | char **e_fromdomain; /* the domain part of the sender */ |
1bcdf0a2 | 233 | ADDRESS *e_returnto; /* place to return the message to */ |
dd1fe05b | 234 | ADDRESS *e_sendqueue; /* list of message recipients */ |
3c7fe765 | 235 | ADDRESS *e_errorqueue; /* the queue for error responses */ |
dd1fe05b | 236 | long e_msgsize; /* size of the message in bytes */ |
2e3062fe | 237 | int e_nrcpts; /* number of recipients */ |
dd1fe05b | 238 | short e_class; /* msg class (priority, junk, etc.) */ |
e6f08ab1 | 239 | short e_flags; /* flags, see below */ |
7338e3d4 | 240 | short e_hopcount; /* number of times processed */ |
dd1fe05b EA |
241 | int (*e_puthdr)(); /* function to put header of message */ |
242 | int (*e_putbody)(); /* function to put body of message */ | |
243 | struct envelope *e_parent; /* the message this one encloses */ | |
e6f08ab1 | 244 | struct envelope *e_sibling; /* the next envelope of interest */ |
dd1fe05b | 245 | char *e_df; /* location of temp file */ |
912acb74 | 246 | FILE *e_dfp; /* temporary file */ |
2cce0c26 | 247 | char *e_id; /* code for this entry in queue */ |
912acb74 | 248 | FILE *e_xfp; /* transcript file */ |
3620ad97 | 249 | FILE *e_lockfp; /* the lock file for this message */ |
553e463f | 250 | FILE *e_qfp; /* queue control file */ |
1369934e | 251 | char *e_message; /* error message */ |
dd1fe05b | 252 | char *e_macro[128]; /* macro definitions */ |
2654b031 | 253 | }; |
1a12c7d6 | 254 | |
2654b031 | 255 | typedef struct envelope ENVELOPE; |
ed45aae1 | 256 | |
e6f08ab1 EA |
257 | /* values for e_flags */ |
258 | #define EF_OLDSTYLE 000001 /* use spaces (not commas) in hdrs */ | |
259 | #define EF_INQUEUE 000002 /* this message is fully queued */ | |
260 | #define EF_TIMEOUT 000004 /* this message is too old */ | |
261 | #define EF_CLRQUEUE 000010 /* disk copy is no longer needed */ | |
262 | #define EF_SENDRECEIPT 000020 /* send a return receipt */ | |
263 | #define EF_FATALERRS 000040 /* fatal errors occured */ | |
264 | #define EF_KEEPQUEUE 000100 /* keep queue files always */ | |
7338e3d4 | 265 | #define EF_RESPONSE 000200 /* this is an error or return receipt */ |
a90807d8 | 266 | #define EF_RESENT 000400 /* this message is being forwarded */ |
e6f08ab1 | 267 | |
2654b031 EA |
268 | EXTERN ENVELOPE *CurEnv; /* envelope currently being processed */ |
269 | \f/* | |
505aaba0 | 270 | ** Message priority classes. |
9ccf54c4 | 271 | ** |
505aaba0 EA |
272 | ** The message class is read directly from the Priority: header |
273 | ** field in the message. | |
df74deb0 | 274 | ** |
505aaba0 EA |
275 | ** CurEnv->e_msgpriority is the number of bytes in the message plus |
276 | ** the creation time (so that jobs ``tend'' to be ordered correctly), | |
277 | ** adjusted by the message class, the number of recipients, and the | |
278 | ** amount of time the message has been sitting around. This number | |
279 | ** is used to order the queue. Higher values mean LOWER priority. | |
280 | ** | |
281 | ** Each priority class point is worth WkClassFact priority points; | |
282 | ** each recipient is worth WkRecipFact priority points. Each time | |
283 | ** we reprocess a message the priority is adjusted by WkTimeFact. | |
284 | ** WkTimeFact should normally decrease the priority so that jobs | |
285 | ** that have historically failed will be run later; thanks go to | |
286 | ** Jay Lepreau at Utah for pointing out the error in my thinking. | |
ee32daaf | 287 | ** |
df74deb0 EA |
288 | ** The "class" is this number, unadjusted by the age or size of |
289 | ** this message. Classes with negative representations will have | |
290 | ** error messages thrown away if they are not local. | |
ed45aae1 EA |
291 | */ |
292 | ||
a444c81b EA |
293 | struct priority |
294 | { | |
295 | char *pri_name; /* external name of priority */ | |
296 | int pri_val; /* internal value for same */ | |
297 | }; | |
298 | ||
299 | EXTERN struct priority Priorities[MAXPRIORITIES]; | |
300 | EXTERN int NumPriorities; /* pointer into Priorities */ | |
2654b031 | 301 | \f/* |
d6a28dd8 EA |
302 | ** Rewrite rules. |
303 | */ | |
304 | ||
305 | struct rewrite | |
306 | { | |
307 | char **r_lhs; /* pattern match */ | |
308 | char **r_rhs; /* substitution value */ | |
309 | struct rewrite *r_next;/* next in chain */ | |
310 | }; | |
311 | ||
792a6b53 | 312 | EXTERN struct rewrite *RewriteRules[MAXRWSETS]; |
d6a28dd8 | 313 | |
792a6b53 EA |
314 | /* |
315 | ** Special characters in rewriting rules. | |
316 | ** These are used internally only. | |
317 | ** The COND* rules are actually used in macros rather than in | |
318 | ** rewriting rules, but are given here because they | |
319 | ** cannot conflict. | |
320 | */ | |
321 | ||
322 | /* left hand side items */ | |
323 | # define MATCHZANY '\020' /* match zero or more tokens */ | |
324 | # define MATCHANY '\021' /* match one or more tokens */ | |
325 | # define MATCHONE '\022' /* match exactly one token */ | |
326 | # define MATCHCLASS '\023' /* match one token in a class */ | |
96f6c5b6 EA |
327 | # define MATCHNCLASS '\024' /* match anything not in class */ |
328 | # define MATCHREPL '\025' /* replacement on RHS for above */ | |
41173b8f EA |
329 | # define MATCHLOOKUP '\035' /* look up and replace a sequence */ |
330 | # define MATCHELOOKUP '\036' /* end of the sequence */ | |
d6a28dd8 | 331 | |
792a6b53 | 332 | /* right hand side items */ |
96f6c5b6 EA |
333 | # define CANONNET '\026' /* canonical net, next token */ |
334 | # define CANONHOST '\027' /* canonical host, next token */ | |
335 | # define CANONUSER '\030' /* canonical user, next N tokens */ | |
336 | # define CALLSUBR '\031' /* call another rewriting set */ | |
d6a28dd8 | 337 | |
792a6b53 | 338 | /* conditionals in macros */ |
96f6c5b6 EA |
339 | # define CONDIF '\032' /* conditional if-then */ |
340 | # define CONDELSE '\033' /* conditional else */ | |
341 | # define CONDFI '\034' /* conditional fi */ | |
a73ae8ac | 342 | |
58862a24 | 343 | /* bracket characters for host name lookup */ |
96f6c5b6 EA |
344 | # define HOSTBEGIN '\035' /* hostname lookup begin */ |
345 | # define HOSTEND '\036' /* hostname lookup end */ | |
58862a24 | 346 | |
42fa5d67 EA |
347 | /* bracket characters for generalized lookup */ |
348 | # define LOOKUPBEGIN '\005' /* generalized lookup begin */ | |
349 | # define LOOKUPEND '\006' /* generalized lookup end */ | |
350 | ||
a73ae8ac | 351 | /* \001 is also reserved as the macro expansion character */ |
e45dcea5 EA |
352 | |
353 | /* external <==> internal mapping table */ | |
354 | struct metamac | |
355 | { | |
356 | char metaname; /* external code (after $) */ | |
357 | char metaval; /* internal code (as above) */ | |
358 | }; | |
2654b031 | 359 | \f/* |
2ae0e0ed EA |
360 | ** Information about currently open connections to mailers, or to |
361 | ** hosts that we have looked up recently. | |
2e3062fe EA |
362 | */ |
363 | ||
f2e44ded | 364 | # define MCI struct mailer_con_info |
2e3062fe | 365 | |
f2e44ded | 366 | MCI |
2e3062fe | 367 | { |
2ae0e0ed EA |
368 | short mci_flags; /* flag bits, see below */ |
369 | short mci_errno; /* error number on last connection */ | |
370 | short mci_exitstat; /* exit status from last connection */ | |
371 | FILE *mci_in; /* input side of connection */ | |
372 | FILE *mci_out; /* output side of connection */ | |
373 | int mci_pid; /* process id of subordinate proc */ | |
374 | short mci_state; /* SMTP state */ | |
e62e1144 EA |
375 | char *mci_phase; /* SMTP phase string */ |
376 | struct mailer *mci_mailer; /* ptr to the mailer for this conn */ | |
377 | time_t mci_lastuse; /* last usage time */ | |
2e3062fe EA |
378 | }; |
379 | ||
380 | ||
381 | /* flag bits */ | |
2ae0e0ed | 382 | #define MCIF_VALID 00001 /* this entry is valid */ |
06771186 | 383 | #define MCIF_TEMP 00002 /* don't cache this connection */ |
f2e44ded | 384 | #define MCIF_CACHED 00004 /* currently in open cache */ |
06771186 EA |
385 | |
386 | /* states */ | |
387 | #define MCIS_CLOSED 0 /* no traffic on this connection */ | |
e62e1144 EA |
388 | #define MCIS_OPENING 1 /* sending initial protocol */ |
389 | #define MCIS_OPEN 2 /* open, initial protocol sent */ | |
390 | #define MCIS_ACTIVE 3 /* message being sent */ | |
f2e44ded EA |
391 | #define MCIS_QUITING 4 /* running quit protocol */ |
392 | #define MCIS_SSD 5 /* service shutting down */ | |
393 | #define MCIS_ERROR 6 /* I/O error on connection */ | |
2e3062fe | 394 | \f/* |
42fa5d67 EA |
395 | ** Mapping functions |
396 | ** | |
397 | ** These allow arbitrary mappings in the config file. The idea | |
398 | ** (albeit not the implementation) comes from IDA sendmail. | |
399 | */ | |
400 | ||
401 | ||
402 | /* | |
403 | ** The class of a map -- essentially the functions to call | |
404 | */ | |
405 | ||
406 | # define MAPCLASS struct _mapclass | |
407 | ||
408 | MAPCLASS | |
409 | { | |
410 | bool (*map_init)(); /* initialization function */ | |
411 | char *(*map_lookup)(); /* lookup function */ | |
412 | }; | |
413 | ||
414 | ||
415 | /* | |
416 | ** An actual map. | |
417 | */ | |
418 | ||
419 | # define MAP struct _map | |
420 | ||
421 | MAP | |
422 | { | |
423 | MAPCLASS *map_class; /* the class of this map */ | |
424 | int map_flags; /* flags, see below */ | |
425 | char *map_file; /* the (nominal) filename */ | |
426 | }; | |
427 | ||
428 | /* bit values for map_flags */ | |
429 | # define MF_VALID 00001 /* this entry is valid */ | |
430 | \f/* | |
4d3a97d9 EA |
431 | ** Symbol table definitions |
432 | */ | |
433 | ||
434 | struct symtab | |
435 | { | |
436 | char *s_name; /* name to be entered */ | |
cdb17311 | 437 | char s_type; /* general type (see below) */ |
4d3a97d9 | 438 | struct symtab *s_next; /* pointer to next in chain */ |
cdb17311 EA |
439 | union |
440 | { | |
2e3062fe EA |
441 | BITMAP sv_class; /* bit-map of word classes */ |
442 | ADDRESS *sv_addr; /* pointer to address header */ | |
443 | MAILER *sv_mailer; /* pointer to mailer */ | |
444 | char *sv_alias; /* alias */ | |
42fa5d67 EA |
445 | MAPCLASS sv_mapclass; /* mapping function class */ |
446 | MAP sv_map; /* mapping function */ | |
f2e44ded | 447 | MCI sv_mci; /* mailer connection info */ |
cdb17311 | 448 | } s_value; |
4d3a97d9 EA |
449 | }; |
450 | ||
451 | typedef struct symtab STAB; | |
452 | ||
cdb17311 EA |
453 | /* symbol types */ |
454 | # define ST_UNDEF 0 /* undefined type */ | |
455 | # define ST_CLASS 1 /* class map */ | |
456 | # define ST_ADDRESS 2 /* an address in parsed format */ | |
457 | # define ST_MAILER 3 /* a mailer header */ | |
458 | # define ST_ALIAS 4 /* an alias */ | |
e62e1144 EA |
459 | # define ST_MAPCLASS 5 /* mapping function class */ |
460 | # define ST_MAP 6 /* mapping function */ | |
f2e44ded | 461 | # define ST_MCI 16 /* mailer connection info (offset) */ |
cdb17311 EA |
462 | |
463 | # define s_class s_value.sv_class | |
14a39063 | 464 | # define s_address s_value.sv_addr |
cdb17311 EA |
465 | # define s_mailer s_value.sv_mailer |
466 | # define s_alias s_value.sv_alias | |
2ae0e0ed | 467 | # define s_mci s_value.sv_mci |
cdb17311 | 468 | |
4d3a97d9 EA |
469 | extern STAB *stab(); |
470 | ||
471 | /* opcodes to stab */ | |
472 | # define ST_FIND 0 /* find entry */ | |
473 | # define ST_ENTER 1 /* enter if not there */ | |
2654b031 | 474 | \f/* |
2439b900 EA |
475 | ** STRUCT EVENT -- event queue. |
476 | ** | |
477 | ** Maintained in sorted order. | |
f5d25d7b EA |
478 | ** |
479 | ** We store the pid of the process that set this event to insure | |
480 | ** that when we fork we will not take events intended for the parent. | |
2439b900 EA |
481 | */ |
482 | ||
483 | struct event | |
484 | { | |
485 | time_t ev_time; /* time of the function call */ | |
486 | int (*ev_func)(); /* function to call */ | |
487 | int ev_arg; /* argument to ev_func */ | |
f5d25d7b | 488 | int ev_pid; /* pid that set this event */ |
2439b900 EA |
489 | struct event *ev_link; /* link to next item */ |
490 | }; | |
491 | ||
492 | typedef struct event EVENT; | |
493 | ||
494 | EXTERN EVENT *EventQueue; /* head of event queue */ | |
495 | \f/* | |
7338e3d4 | 496 | ** Operation, send, and error modes |
75f95954 EA |
497 | ** |
498 | ** The operation mode describes the basic operation of sendmail. | |
499 | ** This can be set from the command line, and is "send mail" by | |
500 | ** default. | |
501 | ** | |
502 | ** The send mode tells how to send mail. It can be set in the | |
503 | ** configuration file. It's setting determines how quickly the | |
504 | ** mail will be delivered versus the load on your system. If the | |
505 | ** -v (verbose) flag is given, it will be forced to SM_DELIVER | |
506 | ** mode. | |
507 | ** | |
7338e3d4 | 508 | ** The error mode tells how to return errors. |
d0bd03ce EA |
509 | */ |
510 | ||
75f95954 | 511 | EXTERN char OpMode; /* operation mode, see below */ |
d0bd03ce | 512 | |
75f95954 | 513 | #define MD_DELIVER 'm' /* be a mail sender */ |
75f95954 | 514 | #define MD_SMTP 's' /* run SMTP on standard input */ |
d0bd03ce EA |
515 | #define MD_DAEMON 'd' /* run as a daemon */ |
516 | #define MD_VERIFY 'v' /* verify: don't collect or deliver */ | |
44cb7eee | 517 | #define MD_TEST 't' /* test mode: resolve addrs only */ |
6bf17095 EA |
518 | #define MD_INITALIAS 'i' /* initialize alias database */ |
519 | #define MD_PRINT 'p' /* print the queue */ | |
520 | #define MD_FREEZE 'z' /* freeze the configuration file */ | |
d0bd03ce | 521 | |
75f95954 EA |
522 | |
523 | EXTERN char SendMode; /* send mode, see below */ | |
524 | ||
525 | #define SM_DELIVER 'i' /* interactive delivery */ | |
526 | #define SM_QUICKD 'j' /* deliver w/o queueing */ | |
527 | #define SM_FORK 'b' /* deliver in background */ | |
528 | #define SM_QUEUE 'q' /* queue, don't deliver */ | |
529 | #define SM_VERIFY 'v' /* verify only (used internally) */ | |
7338e3d4 | 530 | |
eefcf91f EA |
531 | /* used only as a parameter to sendall */ |
532 | #define SM_DEFAULT '\0' /* unspecified, use SendMode */ | |
533 | ||
7338e3d4 EA |
534 | |
535 | EXTERN char ErrorMode; /* error mode, see below */ | |
536 | ||
537 | #define EM_PRINT 'p' /* print errors */ | |
538 | #define EM_MAIL 'm' /* mail back errors */ | |
539 | #define EM_WRITE 'w' /* write back errors */ | |
540 | #define EM_BERKNET 'e' /* special berknet processing */ | |
541 | #define EM_QUIET 'q' /* don't print messages (stat only) */ | |
20951c3f MAN |
542 | |
543 | /* offset used to issure that the error messages for name server error | |
544 | * codes are unique. | |
545 | */ | |
546 | #define MAX_ERRNO 100 | |
d0bd03ce | 547 | \f/* |
b3cbe40f EA |
548 | ** Global variables. |
549 | */ | |
550 | ||
327272f5 | 551 | EXTERN bool FromFlag; /* if set, "From" person is explicit */ |
327272f5 EA |
552 | EXTERN bool NoAlias; /* if set, don't do any aliasing */ |
553 | EXTERN bool ForceMail; /* if set, mail even if already got a copy */ | |
554 | EXTERN bool MeToo; /* send to the sender also */ | |
555 | EXTERN bool IgnrDot; /* don't let dot end messages */ | |
556 | EXTERN bool SaveFrom; /* save leading "From" lines */ | |
557 | EXTERN bool Verbose; /* set if blow-by-blow desired */ | |
558 | EXTERN bool GrabTo; /* if set, get recipients from msg */ | |
327272f5 | 559 | EXTERN bool NoReturn; /* don't return letter to sender */ |
cbdb7357 | 560 | EXTERN bool SuprErrs; /* set if we are suppressing errors */ |
1ea752a1 | 561 | EXTERN bool QueueRun; /* currently running message from the queue */ |
49086753 | 562 | EXTERN bool HoldErrs; /* only output errors to transcript */ |
3135d20c | 563 | EXTERN bool NoConnect; /* don't connect to non-local mailers */ |
c1e24818 | 564 | EXTERN bool SuperSafe; /* be extra careful, even if expensive */ |
2e3062fe | 565 | EXTERN bool ForkQueueRuns; /* fork for each job when running the queue */ |
6bf17095 | 566 | EXTERN bool AutoRebuild; /* auto-rebuild the alias database as needed */ |
7355ccf5 | 567 | EXTERN bool CheckAliases; /* parse addresses during newaliases */ |
35af2f06 | 568 | EXTERN bool UseNameServer; /* use internet domain name server */ |
8657d05f | 569 | EXTERN bool EightBit; /* try to preserve 8-bit data */ |
fd399267 | 570 | EXTERN int SafeAlias; /* minutes to wait until @:@ in alias file */ |
c1e24818 | 571 | EXTERN time_t TimeOut; /* time until timeout */ |
cbdb7357 EA |
572 | EXTERN FILE *InChannel; /* input connection */ |
573 | EXTERN FILE *OutChannel; /* output connection */ | |
05c5b8b4 EA |
574 | EXTERN uid_t RealUid; /* when Daemon, real uid of caller */ |
575 | EXTERN gid_t RealGid; /* when Daemon, real gid of caller */ | |
576 | EXTERN uid_t DefUid; /* default uid to run as */ | |
577 | EXTERN gid_t DefGid; /* default gid to run as */ | |
3fbc69d6 | 578 | EXTERN char *DefUser; /* default user to run as (from DefUid) */ |
327272f5 | 579 | EXTERN int OldUmask; /* umask when sendmail starts up */ |
1ea752a1 | 580 | EXTERN int Errors; /* set if errors (local to single pass) */ |
327272f5 | 581 | EXTERN int ExitStat; /* exit status code */ |
cbdb7357 | 582 | EXTERN int AliasLevel; /* depth of aliasing */ |
e673aad7 | 583 | EXTERN int MotherPid; /* proc id of parent process */ |
792a6b53 | 584 | EXTERN int LineNumber; /* line number in current input */ |
ce7cfd4c | 585 | EXTERN time_t ReadTimeout; /* timeout on reads */ |
c1e24818 | 586 | EXTERN int LogLevel; /* level of logging to perform */ |
d9667c04 | 587 | EXTERN int FileMode; /* mode on files */ |
2e3062fe EA |
588 | EXTERN int QueueLA; /* load average starting forced queueing */ |
589 | EXTERN int RefuseLA; /* load average refusing connections are */ | |
3620ad97 | 590 | EXTERN int CurrentLA; /* current load average */ |
2e3062fe | 591 | EXTERN int QueueFactor; /* slope of queue function */ |
ed45aae1 | 592 | EXTERN time_t QueueIntvl; /* intervals between running the queue */ |
c1e24818 EA |
593 | EXTERN char *AliasFile; /* location of alias file */ |
594 | EXTERN char *HelpFile; /* location of SMTP help file */ | |
05c5b8b4 | 595 | EXTERN char *ErrMsgFile; /* file to prepend to all error messages */ |
c1e24818 EA |
596 | EXTERN char *StatFile; /* location of statistics summary */ |
597 | EXTERN char *QueueDir; /* location of queue directory */ | |
7338e3d4 | 598 | EXTERN char *FileName; /* name to print on error messages */ |
2e3062fe | 599 | EXTERN char *SmtpPhase; /* current phase in SMTP processing */ |
57c97d4a | 600 | EXTERN char *MyHostName; /* name of this host for SMTP messages */ |
2e3062fe | 601 | EXTERN char *RealHostName; /* name of host we are talking to */ |
ab4889ea | 602 | EXTERN struct sockaddr_in RealHostAddr;/* address of host we are talking to */ |
57c97d4a | 603 | EXTERN char *CurHostName; /* current host we are dealing with */ |
c1e24818 EA |
604 | EXTERN jmp_buf TopFrame; /* branch-to-top-of-loop-on-error frame */ |
605 | EXTERN bool QuickAbort; /* .... but only if we want a quick abort */ | |
f61c3c40 | 606 | EXTERN bool LogUsrErrs; /* syslog user errors (e.g., SMTP RCPT cmd) */ |
96476cab | 607 | extern char *ConfFile; /* location of configuration file [conf.c] */ |
acae5a9d | 608 | extern char *FreezeFile; /* location of frozen memory image [conf.c] */ |
96476cab | 609 | extern char Arpa_Info[]; /* the reply code for Arpanet info [conf.c] */ |
2e3062fe EA |
610 | extern ADDRESS NullAddress; /* a null (template) address [main.c] */ |
611 | EXTERN char SpaceSub; /* substitution for <lwsp> */ | |
505aaba0 EA |
612 | EXTERN int WkClassFact; /* multiplier for message class -> priority */ |
613 | EXTERN int WkRecipFact; /* multiplier for # of recipients -> priority */ | |
614 | EXTERN int WkTimeFact; /* priority offset each time this job is run */ | |
2e3062fe EA |
615 | EXTERN char *PostMasterCopy; /* address to get errs cc's */ |
616 | EXTERN char *TrustedUsers[MAXTRUST+1]; /* list of trusted users */ | |
42bbf376 | 617 | EXTERN char *UserEnviron[MAXUSERENVIRON+1]; /* saved user environment */ |
8dcff118 | 618 | EXTERN int CheckpointInterval; /* queue file checkpoint interval */ |
908cb0dd | 619 | EXTERN bool NoWildcardMX; /* we don't have wildcard MX records */ |
83b7c7b1 | 620 | EXTERN char *UdbSpec; /* user database source spec [udbexpand.c] */ |
0f59c44f | 621 | EXTERN int MaxHopCount; /* number of hops until we give an error */ |
51966dba | 622 | EXTERN int ConfigLevel; /* config file level -- what does .cf expect? */ |
8657d05f | 623 | EXTERN char *TimeZoneSpec; /* override time zone specification */ |
7f0fd60b | 624 | EXTERN bool MatchGecos; /* look for user names in gecos field */ |
f2e44ded EA |
625 | EXTERN int MaxMciCache; /* maximum entries in MCI cache */ |
626 | EXTERN time_t MciCacheTimeout; /* maximum idle time on connections */ | |
9678c96d EA |
627 | \f/* |
628 | ** Trace information | |
629 | */ | |
b3cbe40f | 630 | |
9678c96d EA |
631 | /* trace vector and macros for debugging flags */ |
632 | EXTERN u_char tTdvect[100]; | |
633 | # define tTd(flag, level) (tTdvect[flag] >= level) | |
634 | # define tTdlevel(flag) (tTdvect[flag]) | |
635 | \f/* | |
636 | ** Miscellaneous information. | |
637 | */ | |
b3cbe40f | 638 | |
b3cbe40f | 639 | |
15842c3c EA |
640 | |
641 | /* | |
642 | ** Some in-line functions | |
643 | */ | |
644 | ||
645 | /* set exit status */ | |
c8ec8736 EA |
646 | #define setstat(s) { \ |
647 | if (ExitStat == EX_OK || ExitStat == EX_TEMPFAIL) \ | |
648 | ExitStat = s; \ | |
649 | } | |
29871fef | 650 | |
15842c3c | 651 | /* make a copy of a string */ |
c8ec8736 | 652 | #define newstr(s) strcpy(xalloc(strlen(s) + 1), s) |
15842c3c | 653 | |
2e3062fe EA |
654 | #define STRUCTCOPY(s, d) d = s |
655 | ||
15842c3c EA |
656 | |
657 | /* | |
658 | ** Declarations of useful functions | |
659 | */ | |
29871fef | 660 | |
40d27fed | 661 | extern ADDRESS *parseaddr(); |
29871fef | 662 | extern char *xalloc(); |
29871fef | 663 | extern bool sameaddr(); |
5c373723 | 664 | extern FILE *dfopen(); |
2439b900 EA |
665 | extern EVENT *setevent(); |
666 | extern char *sfgets(); | |
2cce0c26 | 667 | extern char *queuename(); |
88039044 | 668 | extern time_t curtime(); |
70aca632 EA |
669 | |
670 | /* | |
671 | ** HACK to fix bug in C compiler on CCI | |
672 | */ | |
673 | ||
674 | #undef isascii | |
5eddb1af | 675 | #define isascii(x) (((x) & ~0177) == 0) |