xref: /freebsd/contrib/sendmail/src/sendmail.h (revision 11afcc8f9f96d657b8e6f7547c02c1957331fc96)
1 /*
2  * Copyright (c) 1998 Sendmail, Inc.  All rights reserved.
3  * Copyright (c) 1983, 1995-1997 Eric P. Allman.  All rights reserved.
4  * Copyright (c) 1988, 1993
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * By using this file, you agree to the terms and conditions set
8  * forth in the LICENSE file which can be found at the top level of
9  * the sendmail distribution.
10  *
11  *
12  *	@(#)sendmail.h	8.280 (Berkeley) 6/5/98
13  */
14 
15 /*
16 **  SENDMAIL.H -- Global definitions for sendmail.
17 */
18 
19 # ifdef _DEFINE
20 # define EXTERN
21 # ifndef lint
22 static char SmailSccsId[] =	"@(#)sendmail.h	8.280		6/5/98";
23 # endif
24 # else /*  _DEFINE */
25 # define EXTERN extern
26 # endif /* _DEFINE */
27 
28 # include <unistd.h>
29 # include <stddef.h>
30 # include <stdlib.h>
31 # include <stdio.h>
32 # include <ctype.h>
33 # include <setjmp.h>
34 # include <string.h>
35 # include <time.h>
36 # include <errno.h>
37 # ifdef EX_OK
38 #  undef EX_OK			/* for SVr4.2 SMP */
39 # endif
40 # include <sysexits.h>
41 
42 # include "conf.h"
43 # include "useful.h"
44 
45 # ifdef LOG
46 # include <syslog.h>
47 # endif /* LOG */
48 
49 # if NETINET || NETUNIX || NETISO || NETNS || NETX25
50 # include <sys/socket.h>
51 # endif
52 # if NETUNIX
53 # include <sys/un.h>
54 # endif
55 # if NETINET
56 # include <netinet/in.h>
57 # endif
58 # if NETISO
59 # include <netiso/iso.h>
60 # endif
61 # if NETNS
62 # include <netns/ns.h>
63 # endif
64 # if NETX25
65 # include <netccitt/x25.h>
66 # endif
67 
68 #if NAMED_BIND
69 # include <arpa/nameser.h>
70 # ifdef NOERROR
71 #  undef NOERROR		/* avoid <sys/streams.h> conflict */
72 # endif
73 #endif
74 
75 #ifdef HESIOD
76 # include <hesiod.h>
77 # if !defined(HES_ER_OK) || defined(HESIOD_INTERFACES)
78 #  define HESIOD_INIT		/* support for the new interface */
79 EXTERN void	*HesiodContext;
80 # endif
81 #endif
82 
83 /*
84 **  Following are "sort of" configuration constants, but they should
85 **  be pretty solid on most architectures today.  They have to be
86 **  defined after <arpa/nameser.h> because some versions of that
87 **  file also define them.  In all cases, we can't use sizeof because
88 **  some systems (e.g., Crays) always treat everything as being at
89 **  least 64 bits.
90 */
91 
92 #ifndef INADDRSZ
93 # define INADDRSZ	4		/* size of an IPv4 address in bytes */
94 #endif
95 #ifndef INT16SZ
96 # define INT16SZ	2		/* size of a 16 bit integer in bytes */
97 #endif
98 #ifndef INT32SZ
99 # define INT32SZ	4		/* size of a 32 bit integer in bytes */
100 #endif
101 
102 
103 
104 /* forward references for prototypes */
105 typedef struct envelope	ENVELOPE;
106 typedef struct mailer	MAILER;
107 
108 
109 /*
110 **  Data structure for bit maps.
111 **
112 **	Each bit in this map can be referenced by an ascii character.
113 **	This is 256 possible bits, or 32 8-bit bytes.
114 */
115 
116 #define BITMAPBYTES	32	/* number of bytes in a bit map */
117 #define BYTEBITS	8	/* number of bits in a byte */
118 
119 /* internal macros */
120 #define _BITWORD(bit)	((bit) / (BYTEBITS * sizeof (int)))
121 #define _BITBIT(bit)	(1 << ((bit) % (BYTEBITS * sizeof (int))))
122 
123 typedef int	BITMAP[BITMAPBYTES / sizeof (int)];
124 
125 /* test bit number N */
126 #define bitnset(bit, map)	((map)[_BITWORD(bit)] & _BITBIT(bit))
127 
128 /* set bit number N */
129 #define setbitn(bit, map)	(map)[_BITWORD(bit)] |= _BITBIT(bit)
130 
131 /* clear bit number N */
132 #define clrbitn(bit, map)	(map)[_BITWORD(bit)] &= ~_BITBIT(bit)
133 
134 /* clear an entire bit map */
135 #define clrbitmap(map)		bzero((char *) map, BITMAPBYTES)
136 
137 
138 /*
139 **  Utility macros
140 */
141 
142 /* return number of bytes left in a buffer */
143 #define SPACELEFT(buf, ptr)	(sizeof buf - ((ptr) - buf))
144 /*
145 **  Address structure.
146 **	Addresses are stored internally in this structure.
147 */
148 
149 struct address
150 {
151 	char		*q_paddr;	/* the printname for the address */
152 	char		*q_user;	/* user name */
153 	char		*q_ruser;	/* real user name, or NULL if q_user */
154 	char		*q_host;	/* host name */
155 	struct mailer	*q_mailer;	/* mailer to use */
156 	u_long		q_flags;	/* status flags, see below */
157 	uid_t		q_uid;		/* user-id of receiver (if known) */
158 	gid_t		q_gid;		/* group-id of receiver (if known) */
159 	char		*q_home;	/* home dir (local mailer only) */
160 	char		*q_fullname;	/* full name if known */
161 	struct address	*q_next;	/* chain */
162 	struct address	*q_alias;	/* address this results from */
163 	char		*q_owner;	/* owner of q_alias */
164 	struct address	*q_tchain;	/* temporary use chain */
165 	char		*q_orcpt;	/* ORCPT parameter from RCPT TO: line */
166 	char		*q_status;	/* status code for DSNs */
167 	char		*q_rstatus;	/* remote status message for DSNs */
168 	time_t		q_statdate;	/* date of status messages */
169 	char		*q_statmta;	/* MTA generating q_rstatus */
170 	short		q_specificity;	/* how "specific" this address is */
171 };
172 
173 typedef struct address ADDRESS;
174 
175 # define QDONTSEND	0x00000001	/* don't send to this address */
176 # define QBADADDR	0x00000002	/* this address is verified bad */
177 # define QGOODUID	0x00000004	/* the q_uid q_gid fields are good */
178 # define QPRIMARY	0x00000008	/* set from RCPT or argv */
179 # define QQUEUEUP	0x00000010	/* queue for later transmission */
180 # define QSENT		0x00000020	/* has been successfully delivered */
181 # define QNOTREMOTE	0x00000040	/* address not for remote forwarding */
182 # define QSELFREF	0x00000080	/* this address references itself */
183 # define QVERIFIED	0x00000100	/* verified, but not expanded */
184 # define QBOGUSSHELL	0x00000400	/* user has no valid shell listed */
185 # define QUNSAFEADDR	0x00000800	/* address aquired via unsafe path */
186 # define QPINGONSUCCESS	0x00001000	/* give return on successful delivery */
187 # define QPINGONFAILURE	0x00002000	/* give return on failure */
188 # define QPINGONDELAY	0x00004000	/* give return on message delay */
189 # define QHASNOTIFY	0x00008000	/* propogate notify parameter */
190 # define QRELAYED	0x00010000	/* DSN: relayed to non-DSN aware sys */
191 # define QEXPANDED	0x00020000	/* DSN: undergone list expansion */
192 # define QDELIVERED	0x00040000	/* DSN: successful final delivery */
193 # define QDELAYED	0x00080000	/* DSN: message delayed */
194 # define QTHISPASS	0x40000000	/* temp: address set this pass */
195 # define QRCPTOK	0x80000000	/* recipient() processed address */
196 
197 # define Q_PINGFLAGS	(QPINGONSUCCESS|QPINGONFAILURE|QPINGONDELAY)
198 
199 # define NULLADDR	((ADDRESS *) NULL)
200 
201 /* functions */
202 extern ADDRESS	*parseaddr __P((char *, ADDRESS *, int, int, char **, ENVELOPE *));
203 extern ADDRESS	*buildaddr __P((char **, ADDRESS *, int, ENVELOPE *));
204 extern ADDRESS	*recipient __P((ADDRESS *, ADDRESS **, int, ENVELOPE *));
205 extern char	**prescan __P((char *, int, char[], int, char **, u_char *));
206 extern int	rewrite __P((char **, int, int, ENVELOPE *));
207 extern char	*remotename __P((char *, MAILER *, int, int *, ENVELOPE *));
208 extern ADDRESS	*getctladdr __P((ADDRESS *));
209 extern bool	sameaddr __P((ADDRESS *, ADDRESS *));
210 extern bool	emptyaddr __P((ADDRESS *));
211 extern void	printaddr __P((ADDRESS *, bool));
212 extern void	cataddr __P((char **, char **, char *, int, int));
213 extern int	sendtolist __P((char *, ADDRESS *, ADDRESS **, int, ENVELOPE *));
214 /*
215 **  Mailer definition structure.
216 **	Every mailer known to the system is declared in this
217 **	structure.  It defines the pathname of the mailer, some
218 **	flags associated with it, and the argument vector to
219 **	pass to it.  The flags are defined in conf.c
220 **
221 **	The argument vector is expanded before actual use.  All
222 **	words except the first are passed through the macro
223 **	processor.
224 */
225 
226 struct mailer
227 {
228 	char	*m_name;	/* symbolic name of this mailer */
229 	char	*m_mailer;	/* pathname of the mailer to use */
230 	char	*m_mtatype;	/* type of this MTA */
231 	char	*m_addrtype;	/* type for addresses */
232 	char	*m_diagtype;	/* type for diagnostics */
233 	BITMAP	m_flags;	/* status flags, see below */
234 	short	m_mno;		/* mailer number internally */
235 	short	m_nice;		/* niceness to run at (mostly for prog) */
236 	char	**m_argv;	/* template argument vector */
237 	short	m_sh_rwset;	/* rewrite set: sender header addresses */
238 	short	m_se_rwset;	/* rewrite set: sender envelope addresses */
239 	short	m_rh_rwset;	/* rewrite set: recipient header addresses */
240 	short	m_re_rwset;	/* rewrite set: recipient envelope addresses */
241 	char	*m_eol;		/* end of line string */
242 	long	m_maxsize;	/* size limit on message to this mailer */
243 	int	m_linelimit;	/* max # characters per line */
244 	char	*m_execdir;	/* directory to chdir to before execv */
245 	uid_t	m_uid;		/* UID to run as */
246 	gid_t	m_gid;		/* GID to run as */
247 	char	*m_defcharset;	/* default character set */
248 };
249 
250 /* bits for m_flags */
251 # define M_ESMTP	'a'	/* run Extended SMTP protocol */
252 # define M_ALIASABLE	'A'	/* user can be LHS of an alias */
253 # define M_BLANKEND	'b'	/* ensure blank line at end of message */
254 # define M_NOCOMMENT	'c'	/* don't include comment part of address */
255 # define M_CANONICAL	'C'	/* make addresses canonical "u@dom" */
256 # define M_NOBRACKET	'd'	/* never angle bracket envelope route-addrs */
257 		/*	'D'	   CF: include Date: */
258 # define M_EXPENSIVE	'e'	/* it costs to use this mailer.... */
259 # define M_ESCFROM	'E'	/* escape From lines to >From */
260 # define M_FOPT		'f'	/* mailer takes picky -f flag */
261 		/*	'F'	   CF: include From: or Resent-From: */
262 # define M_NO_NULL_FROM	'g'	/* sender of errors should be $g */
263 # define M_HST_UPPER	'h'	/* preserve host case distinction */
264 # define M_PREHEAD	'H'	/* MAIL11V3: preview headers */
265 # define M_UDBENVELOPE	'i'	/* do udbsender rewriting on envelope */
266 # define M_INTERNAL	'I'	/* SMTP to another sendmail site */
267 # define M_UDBRECIPIENT	'j'	/* do udbsender rewriting on recipient lines */
268 # define M_NOLOOPCHECK	'k'	/* don't check for loops in HELO command */
269 # define M_CHUNKING	'K'	/* CHUNKING: reserved for future use */
270 # define M_LOCALMAILER	'l'	/* delivery is to this host */
271 # define M_LIMITS	'L'	/* must enforce SMTP line limits */
272 # define M_MUSER	'm'	/* can handle multiple users at once */
273 		/*	'M'	   CF: include Message-Id: */
274 # define M_NHDR		'n'	/* don't insert From line */
275 # define M_MANYSTATUS	'N'	/* MAIL11V3: DATA returns multi-status */
276 # define M_RUNASRCPT	'o'	/* always run mailer as recipient */
277 # define M_FROMPATH	'p'	/* use reverse-path in MAIL FROM: */
278 		/*	'P'	   CF: include Return-Path: */
279 # define M_VRFY250	'q'	/* VRFY command returns 250 instead of 252 */
280 # define M_ROPT		'r'	/* mailer takes picky -r flag */
281 # define M_SECURE_PORT	'R'	/* try to send on a reserved TCP port */
282 # define M_STRIPQ	's'	/* strip quote chars from user/host */
283 # define M_SPECIFIC_UID	'S'	/* run as specific uid/gid */
284 # define M_USR_UPPER	'u'	/* preserve user case distinction */
285 # define M_UGLYUUCP	'U'	/* this wants an ugly UUCP from line */
286 # define M_CONTENT_LEN	'v'	/* add Content-Length: header (SVr4) */
287 		/*	'V'	   UIUC: !-relativize all addresses */
288 # define M_HASPWENT	'w'	/* check for /etc/passwd entry */
289 		/*	'x'	   CF: include Full-Name: */
290 # define M_XDOT		'X'	/* use hidden-dot algorithm */
291 # define M_LMTP		'z'	/* run Local Mail Transport Protocol */
292 # define M_NOMX		'0'	/* turn off MX lookups */
293 # define M_NONULLS	'1'	/* don't send null bytes */
294 # define M_EBCDIC	'3'	/* extend Q-P encoding for EBCDIC */
295 # define M_TRYRULESET5	'5'	/* use ruleset 5 after local aliasing */
296 # define M_7BITHDRS	'6'	/* strip headers to 7 bits even in 8 bit path */
297 # define M_7BITS	'7'	/* use 7-bit path */
298 # define M_8BITS	'8'	/* force "just send 8" behaviour */
299 # define M_MAKE8BIT	'9'	/* convert 7 -> 8 bit if appropriate */
300 # define M_CHECKINCLUDE	':'	/* check for :include: files */
301 # define M_CHECKPROG	'|'	/* check for |program addresses */
302 # define M_CHECKFILE	'/'	/* check for /file addresses */
303 # define M_CHECKUDB	'@'	/* user can be user database key */
304 # define M_CHECKHDIR	'~'	/* SGI: check for valid home directory */
305 
306 EXTERN MAILER	*Mailer[MAXMAILERS+1];
307 
308 EXTERN MAILER	*LocalMailer;		/* ptr to local mailer */
309 EXTERN MAILER	*ProgMailer;		/* ptr to program mailer */
310 EXTERN MAILER	*FileMailer;		/* ptr to *file* mailer */
311 EXTERN MAILER	*InclMailer;		/* ptr to *include* mailer */
312 /*
313 **  Information about currently open connections to mailers, or to
314 **  hosts that we have looked up recently.
315 */
316 
317 # define MCI		struct mailer_con_info
318 
319 MCI
320 {
321 	short		mci_flags;	/* flag bits, see below */
322 	short		mci_errno;	/* error number on last connection */
323 	short		mci_herrno;	/* h_errno from last DNS lookup */
324 	short		mci_exitstat;	/* exit status from last connection */
325 	short		mci_state;	/* SMTP state */
326 	off_t		mci_contentlen;	/* body length for Content-Length: */
327 	long		mci_maxsize;	/* max size this server will accept */
328 	FILE		*mci_in;	/* input side of connection */
329 	FILE		*mci_out;	/* output side of connection */
330 	pid_t		mci_pid;	/* process id of subordinate proc */
331 	char		*mci_phase;	/* SMTP phase string */
332 	struct mailer	*mci_mailer;	/* ptr to the mailer for this conn */
333 	char		*mci_host;	/* host name */
334 	char		*mci_status;	/* DSN status to be copied to addrs */
335 	char		*mci_rstatus;	/* SMTP status to be copied to addrs */
336 	time_t		mci_lastuse;	/* last usage time */
337 	FILE		*mci_statfile;	/* long term status file */
338 };
339 
340 
341 /* flag bits */
342 #define MCIF_VALID	0x0001		/* this entry is valid */
343 #define MCIF_TEMP	0x0002		/* don't cache this connection */
344 #define MCIF_CACHED	0x0004		/* currently in open cache */
345 #define MCIF_ESMTP	0x0008		/* this host speaks ESMTP */
346 #define MCIF_EXPN	0x0010		/* EXPN command supported */
347 #define MCIF_SIZE	0x0020		/* SIZE option supported */
348 #define MCIF_8BITMIME	0x0040		/* BODY=8BITMIME supported */
349 #define MCIF_7BIT	0x0080		/* strip this message to 7 bits */
350 #define MCIF_MULTSTAT	0x0100		/* MAIL11V3: handles MULT status */
351 #define MCIF_INHEADER	0x0200		/* currently outputing header */
352 #define MCIF_CVT8TO7	0x0400		/* convert from 8 to 7 bits */
353 #define MCIF_DSN	0x0800		/* DSN extension supported */
354 #define MCIF_8BITOK	0x1000		/* OK to send 8 bit characters */
355 #define MCIF_CVT7TO8	0x2000		/* convert from 7 to 8 bits */
356 #define MCIF_INMIME	0x4000		/* currently reading MIME header */
357 
358 /* states */
359 #define MCIS_CLOSED	0		/* no traffic on this connection */
360 #define MCIS_OPENING	1		/* sending initial protocol */
361 #define MCIS_OPEN	2		/* open, initial protocol sent */
362 #define MCIS_ACTIVE	3		/* message being sent */
363 #define MCIS_QUITING	4		/* running quit protocol */
364 #define MCIS_SSD	5		/* service shutting down */
365 #define MCIS_ERROR	6		/* I/O error on connection */
366 
367 /* functions */
368 extern MCI	*mci_get __P((char *, MAILER *));
369 extern void	mci_cache __P((MCI *));
370 extern void	mci_flush __P((bool, MCI *));
371 extern void	mci_dump __P((MCI *, bool));
372 extern void	mci_dump_all __P((bool));
373 extern MCI	**mci_scan __P((MCI *));
374 extern int 	mci_traverse_persistent __P((int (*)(), char *));
375 extern int	mci_print_persistent __P((char *, char *));
376 extern int	mci_purge_persistent __P((char *, char *));
377 extern int	mci_lock_host __P((MCI *));
378 extern void	mci_unlock_host __P((MCI *));
379 extern int	mci_lock_host_statfile __P((MCI *));
380 extern void 	mci_store_persistent __P((MCI *));
381 extern int 	mci_read_persistent __P((FILE *, MCI *));
382 /*
383 **  Header structure.
384 **	This structure is used internally to store header items.
385 */
386 
387 struct header
388 {
389 	char		*h_field;	/* the name of the field */
390 	char		*h_value;	/* the value of that field */
391 	struct header	*h_link;	/* the next header */
392 	u_short		h_flags;	/* status bits, see below */
393 	BITMAP		h_mflags;	/* m_flags bits needed */
394 };
395 
396 typedef struct header	HDR;
397 
398 /*
399 **  Header information structure.
400 **	Defined in conf.c, this struct declares the header fields
401 **	that have some magic meaning.
402 */
403 
404 struct hdrinfo
405 {
406 	char	*hi_field;	/* the name of the field */
407 	u_short	hi_flags;	/* status bits, see below */
408 	char	*hi_ruleset;	/* validity check ruleset */
409 };
410 
411 extern struct hdrinfo	HdrInfo[];
412 
413 /* bits for h_flags and hi_flags */
414 # define H_EOH		0x0001	/* this field terminates header */
415 # define H_RCPT		0x0002	/* contains recipient addresses */
416 # define H_DEFAULT	0x0004	/* if another value is found, drop this */
417 # define H_RESENT	0x0008	/* this address is a "Resent-..." address */
418 # define H_CHECK	0x0010	/* check h_mflags against m_flags */
419 # define H_ACHECK	0x0020	/* ditto, but always (not just default) */
420 # define H_FORCE	0x0040	/* force this field, even if default */
421 # define H_TRACE	0x0080	/* this field contains trace information */
422 # define H_FROM		0x0100	/* this is a from-type field */
423 # define H_VALID	0x0200	/* this field has a validated value */
424 # define H_RECEIPTTO	0x0400	/* this field has return receipt info */
425 # define H_ERRORSTO	0x0800	/* this field has error address info */
426 # define H_CTE		0x1000	/* this field is a content-transfer-encoding */
427 # define H_CTYPE	0x2000	/* this is a content-type field */
428 # define H_BCC		0x4000	/* Bcc: header: strip value or delete */
429 # define H_ENCODABLE	0x8000	/* field can be RFC 1522 encoded */
430 
431 /* functions */
432 extern void	addheader __P((char *, char *, HDR **));
433 extern char	*hvalue __P((char *, HDR *));
434 extern void	commaize __P((HDR *, char *, bool, MCI *, ENVELOPE *));
435 extern void	put_vanilla_header __P((HDR *, char *, MCI *));
436 extern void	eatheader __P((ENVELOPE *, bool));
437 extern int	chompheader __P((char *, bool, HDR **, ENVELOPE *));
438 /*
439 **  Envelope structure.
440 **	This structure defines the message itself.  There is usually
441 **	only one of these -- for the message that we originally read
442 **	and which is our primary interest -- but other envelopes can
443 **	be generated during processing.  For example, error messages
444 **	will have their own envelope.
445 */
446 
447 struct envelope
448 {
449 	HDR		*e_header;	/* head of header list */
450 	long		e_msgpriority;	/* adjusted priority of this message */
451 	time_t		e_ctime;	/* time message appeared in the queue */
452 	char		*e_to;		/* the target person */
453 	ADDRESS		e_from;		/* the person it is from */
454 	char		*e_sender;	/* e_from.q_paddr w comments stripped */
455 	char		**e_fromdomain;	/* the domain part of the sender */
456 	ADDRESS		*e_sendqueue;	/* list of message recipients */
457 	ADDRESS		*e_errorqueue;	/* the queue for error responses */
458 	long		e_msgsize;	/* size of the message in bytes */
459 	long		e_flags;	/* flags, see below */
460 	int		e_nrcpts;	/* number of recipients */
461 	short		e_class;	/* msg class (priority, junk, etc.) */
462 	short		e_hopcount;	/* number of times processed */
463 	short		e_nsent;	/* number of sends since checkpoint */
464 	short		e_sendmode;	/* message send mode */
465 	short		e_errormode;	/* error return mode */
466 	short		e_timeoutclass;	/* message timeout class */
467 	void		(*e_puthdr)__P((MCI *, HDR *, ENVELOPE *));
468 					/* function to put header of message */
469 	void		(*e_putbody)__P((MCI *, ENVELOPE *, char *));
470 					/* function to put body of message */
471 	struct envelope	*e_parent;	/* the message this one encloses */
472 	struct envelope *e_sibling;	/* the next envelope of interest */
473 	char		*e_bodytype;	/* type of message body */
474 	FILE		*e_dfp;		/* temporary file */
475 	char		*e_id;		/* code for this entry in queue */
476 	FILE		*e_xfp;		/* transcript file */
477 	FILE		*e_lockfp;	/* the lock file for this message */
478 	char		*e_message;	/* error message */
479 	char		*e_statmsg;	/* stat msg (changes per delivery) */
480 	char		*e_msgboundary;	/* MIME-style message part boundary */
481 	char		*e_origrcpt;	/* original recipient (one only) */
482 	char		*e_envid;	/* envelope id from MAIL FROM: line */
483 	char		*e_status;	/* DSN status for this message */
484 	time_t		e_dtime;	/* time of last delivery attempt */
485 	int		e_ntries;	/* number of delivery attempts */
486 	dev_t		e_dfdev;	/* df file's device, for crash recov */
487 	ino_t		e_dfino;	/* df file's ino, for crash recovery */
488 	char		*e_macro[256];	/* macro definitions */
489 };
490 
491 /* values for e_flags */
492 #define EF_OLDSTYLE	0x0000001	/* use spaces (not commas) in hdrs */
493 #define EF_INQUEUE	0x0000002	/* this message is fully queued */
494 #define EF_NO_BODY_RETN	0x0000004	/* omit message body on error */
495 #define EF_CLRQUEUE	0x0000008	/* disk copy is no longer needed */
496 #define EF_SENDRECEIPT	0x0000010	/* send a return receipt */
497 #define EF_FATALERRS	0x0000020	/* fatal errors occured */
498 #define EF_DELETE_BCC	0x0000040	/* delete Bcc: headers entirely */
499 #define EF_RESPONSE	0x0000080	/* this is an error or return receipt */
500 #define EF_RESENT	0x0000100	/* this message is being forwarded */
501 #define EF_VRFYONLY	0x0000200	/* verify only (don't expand aliases) */
502 #define EF_WARNING	0x0000400	/* warning message has been sent */
503 #define EF_QUEUERUN	0x0000800	/* this envelope is from queue */
504 #define EF_GLOBALERRS	0x0001000	/* treat errors as global */
505 #define EF_PM_NOTIFY	0x0002000	/* send return mail to postmaster */
506 #define EF_METOO	0x0004000	/* send to me too */
507 #define EF_LOGSENDER	0x0008000	/* need to log the sender */
508 #define EF_NORECEIPT	0x0010000	/* suppress all return-receipts */
509 #define EF_HAS8BIT	0x0020000	/* at least one 8-bit char in body */
510 #define EF_NL_NOT_EOL	0x0040000	/* don't accept raw NL as EOLine */
511 #define EF_CRLF_NOT_EOL	0x0080000	/* don't accept CR-LF as EOLine */
512 #define EF_RET_PARAM	0x0100000	/* RCPT command had RET argument */
513 #define EF_HAS_DF	0x0200000	/* set when df file is instantiated */
514 #define EF_IS_MIME	0x0400000	/* really is a MIME message */
515 #define EF_DONT_MIME	0x0800000	/* never MIME this message */
516 #define EF_DISCARD	0x1000000	/* discard the message */
517 
518 EXTERN ENVELOPE	*CurEnv;	/* envelope currently being processed */
519 
520 /* functions */
521 extern ENVELOPE	*newenvelope __P((ENVELOPE *, ENVELOPE *));
522 extern void	dropenvelope __P((ENVELOPE *, bool));
523 extern void	clearenvelope __P((ENVELOPE *, bool));
524 
525 extern void	putheader __P((MCI *, HDR *, ENVELOPE *));
526 extern void	putbody __P((MCI *, ENVELOPE *, char *));
527 /*
528 **  Message priority classes.
529 **
530 **	The message class is read directly from the Priority: header
531 **	field in the message.
532 **
533 **	CurEnv->e_msgpriority is the number of bytes in the message plus
534 **	the creation time (so that jobs ``tend'' to be ordered correctly),
535 **	adjusted by the message class, the number of recipients, and the
536 **	amount of time the message has been sitting around.  This number
537 **	is used to order the queue.  Higher values mean LOWER priority.
538 **
539 **	Each priority class point is worth WkClassFact priority points;
540 **	each recipient is worth WkRecipFact priority points.  Each time
541 **	we reprocess a message the priority is adjusted by WkTimeFact.
542 **	WkTimeFact should normally decrease the priority so that jobs
543 **	that have historically failed will be run later; thanks go to
544 **	Jay Lepreau at Utah for pointing out the error in my thinking.
545 **
546 **	The "class" is this number, unadjusted by the age or size of
547 **	this message.  Classes with negative representations will have
548 **	error messages thrown away if they are not local.
549 */
550 
551 struct priority
552 {
553 	char	*pri_name;	/* external name of priority */
554 	int	pri_val;	/* internal value for same */
555 };
556 
557 EXTERN struct priority	Priorities[MAXPRIORITIES];
558 EXTERN int		NumPriorities;	/* pointer into Priorities */
559 /*
560 **  Rewrite rules.
561 */
562 
563 struct rewrite
564 {
565 	char	**r_lhs;	/* pattern match */
566 	char	**r_rhs;	/* substitution value */
567 	struct rewrite	*r_next;/* next in chain */
568 };
569 
570 EXTERN struct rewrite	*RewriteRules[MAXRWSETS];
571 
572 /*
573 **  Special characters in rewriting rules.
574 **	These are used internally only.
575 **	The COND* rules are actually used in macros rather than in
576 **		rewriting rules, but are given here because they
577 **		cannot conflict.
578 */
579 
580 /* left hand side items */
581 # define MATCHZANY	((u_char)0220)	/* match zero or more tokens */
582 # define MATCHANY	((u_char)0221)	/* match one or more tokens */
583 # define MATCHONE	((u_char)0222)	/* match exactly one token */
584 # define MATCHCLASS	((u_char)0223)	/* match one token in a class */
585 # define MATCHNCLASS	((u_char)0224)	/* match anything not in class */
586 # define MATCHREPL	((u_char)0225)	/* replacement on RHS for above */
587 
588 /* right hand side items */
589 # define CANONNET	((u_char)0226)	/* canonical net, next token */
590 # define CANONHOST	((u_char)0227)	/* canonical host, next token */
591 # define CANONUSER	((u_char)0230)	/* canonical user, next N tokens */
592 # define CALLSUBR	((u_char)0231)	/* call another rewriting set */
593 
594 /* conditionals in macros */
595 # define CONDIF		((u_char)0232)	/* conditional if-then */
596 # define CONDELSE	((u_char)0233)	/* conditional else */
597 # define CONDFI		((u_char)0234)	/* conditional fi */
598 
599 /* bracket characters for host name lookup */
600 # define HOSTBEGIN	((u_char)0235)	/* hostname lookup begin */
601 # define HOSTEND	((u_char)0236)	/* hostname lookup end */
602 
603 /* bracket characters for generalized lookup */
604 # define LOOKUPBEGIN	((u_char)0205)	/* generalized lookup begin */
605 # define LOOKUPEND	((u_char)0206)	/* generalized lookup end */
606 
607 /* macro substitution character */
608 # define MACROEXPAND	((u_char)0201)	/* macro expansion */
609 # define MACRODEXPAND	((u_char)0202)	/* deferred macro expansion */
610 
611 /* to make the code clearer */
612 # define MATCHZERO	CANONHOST
613 
614 /* external <==> internal mapping table */
615 struct metamac
616 {
617 	char	metaname;	/* external code (after $) */
618 	u_char	metaval;	/* internal code (as above) */
619 };
620 
621 /* values for macros with external names only */
622 # define MID_OPMODE	0202	/* operation mode */
623 
624 /* functions */
625 extern void	expand __P((char *, char *, size_t, ENVELOPE *));
626 extern void	define __P((int, char *, ENVELOPE *));
627 extern char	*macvalue __P((int, ENVELOPE *));
628 extern char	*macname __P((int));
629 extern int	macid __P((char *, char **));
630 /*
631 **  Name canonification short circuit.
632 **
633 **	If the name server for a host is down, the process of trying to
634 **	canonify the name can hang.  This is similar to (but alas, not
635 **	identical to) looking up the name for delivery.  This stab type
636 **	caches the result of the name server lookup so we don't hang
637 **	multiple times.
638 */
639 
640 #define NAMECANON	struct _namecanon
641 
642 NAMECANON
643 {
644 	short		nc_errno;	/* cached errno */
645 	short		nc_herrno;	/* cached h_errno */
646 	short		nc_stat;	/* cached exit status code */
647 	short		nc_flags;	/* flag bits */
648 	char		*nc_cname;	/* the canonical name */
649 };
650 
651 /* values for nc_flags */
652 #define NCF_VALID	0x0001	/* entry valid */
653 /*
654 **  Mapping functions
655 **
656 **	These allow arbitrary mappings in the config file.  The idea
657 **	(albeit not the implementation) comes from IDA sendmail.
658 */
659 
660 # define MAPCLASS	struct _mapclass
661 # define MAP		struct _map
662 # define MAXMAPACTIONS	3		/* size of map_actions array */
663 
664 
665 /*
666 **  An actual map.
667 */
668 
669 MAP
670 {
671 	MAPCLASS	*map_class;	/* the class of this map */
672 	char		*map_mname;	/* name of this map */
673 	long		map_mflags;	/* flags, see below */
674 	char		*map_file;	/* the (nominal) filename */
675 	ARBPTR_T	map_db1;	/* the open database ptr */
676 	ARBPTR_T	map_db2;	/* an "extra" database pointer */
677 	char		*map_keycolnm;	/* key column name */
678 	char		*map_valcolnm;	/* value column name */
679 	u_char		map_keycolno;	/* key column number */
680 	u_char		map_valcolno;	/* value column number */
681 	char		map_coldelim;	/* column delimiter */
682 	char		*map_app;	/* to append to successful matches */
683 	char		*map_tapp;	/* to append to "tempfail" matches */
684 	char		*map_domain;	/* the (nominal) NIS domain */
685 	char		*map_rebuild;	/* program to run to do auto-rebuild */
686 	time_t		map_mtime;	/* last database modification time */
687 	int		map_lockfd;	/* auxiliary lock file descriptor */
688 	short		map_specificity;	/* specificity of aliases */
689 	MAP		*map_stack[MAXMAPSTACK];   /* list for stacked maps */
690 	short		map_return[MAXMAPACTIONS]; /* return bitmaps for stacked maps */
691 };
692 
693 /* bit values for map_mflags */
694 # define MF_VALID	0x00000001	/* this entry is valid */
695 # define MF_INCLNULL	0x00000002	/* include null byte in key */
696 # define MF_OPTIONAL	0x00000004	/* don't complain if map not found */
697 # define MF_NOFOLDCASE	0x00000008	/* don't fold case in keys */
698 # define MF_MATCHONLY	0x00000010	/* don't use the map value */
699 # define MF_OPEN	0x00000020	/* this entry is open */
700 # define MF_WRITABLE	0x00000040	/* open for writing */
701 # define MF_ALIAS	0x00000080	/* this is an alias file */
702 # define MF_TRY0NULL	0x00000100	/* try with no null byte */
703 # define MF_TRY1NULL	0x00000200	/* try with the null byte */
704 # define MF_LOCKED	0x00000400	/* this map is currently locked */
705 # define MF_ALIASWAIT	0x00000800	/* alias map in aliaswait state */
706 # define MF_IMPL_HASH	0x00001000	/* implicit: underlying hash database */
707 # define MF_IMPL_NDBM	0x00002000	/* implicit: underlying NDBM database */
708 # define MF_UNSAFEDB	0x00004000	/* this map is world writable */
709 # define MF_APPEND	0x00008000	/* append new entry on rebuiled */
710 # define MF_KEEPQUOTES	0x00010000	/* don't dequote key before lookup */
711 # define MF_NODEFER	0x00020000	/* don't defer if map lookup fails */
712 # define MF_REGEX_NOT	0x00040000	/* regular expression negation */
713 
714 /* indices for map_actions */
715 # define MA_NOTFOUND	0		/* member map returned "not found" */
716 # define MA_UNAVAIL	1		/* member map is not available */
717 # define MA_TRYAGAIN	2		/* member map returns temp failure */
718 
719 /*
720 **  The class of a map -- essentially the functions to call
721 */
722 
723 MAPCLASS
724 {
725 	char	*map_cname;		/* name of this map class */
726 	char	*map_ext;		/* extension for database file */
727 	short	map_cflags;		/* flag bits, see below */
728 	bool	(*map_parse)__P((MAP *, char *));
729 					/* argument parsing function */
730 	char	*(*map_lookup)__P((MAP *, char *, char **, int *));
731 					/* lookup function */
732 	void	(*map_store)__P((MAP *, char *, char *));
733 					/* store function */
734 	bool	(*map_open)__P((MAP *, int));
735 					/* open function */
736 	void	(*map_close)__P((MAP *));
737 					/* close function */
738 };
739 
740 /* bit values for map_cflags */
741 #define MCF_ALIASOK	0x0001		/* can be used for aliases */
742 #define MCF_ALIASONLY	0x0002		/* usable only for aliases */
743 #define MCF_REBUILDABLE	0x0004		/* can rebuild alias files */
744 #define MCF_OPTFILE	0x0008		/* file name is optional */
745 
746 /* functions */
747 extern char	*map_rewrite __P((MAP *, const char *, size_t, char **));
748 extern MAP	*makemapentry __P((char *));
749 extern void	initmaps __P((bool, ENVELOPE *));
750 /*
751 **  Symbol table definitions
752 */
753 
754 struct symtab
755 {
756 	char		*s_name;	/* name to be entered */
757 	short		s_type;		/* general type (see below) */
758 	short		s_len;		/* length of this entry */
759 	struct symtab	*s_next;	/* pointer to next in chain */
760 	union
761 	{
762 		BITMAP		sv_class;	/* bit-map of word classes */
763 		ADDRESS		*sv_addr;	/* pointer to address header */
764 		MAILER		*sv_mailer;	/* pointer to mailer */
765 		char		*sv_alias;	/* alias */
766 		MAPCLASS	sv_mapclass;	/* mapping function class */
767 		MAP		sv_map;		/* mapping function */
768 		char		*sv_hostsig;	/* host signature */
769 		MCI		sv_mci;		/* mailer connection info */
770 		NAMECANON	sv_namecanon;	/* canonical name cache */
771 		int		sv_macro;	/* macro name => id mapping */
772 		int		sv_ruleset;	/* ruleset index */
773 		struct hdrinfo	sv_header;	/* header metainfo */
774 		char		*sv_service[MAXMAPSTACK]; /* service switch */
775 	}	s_value;
776 };
777 
778 typedef struct symtab	STAB;
779 
780 /* symbol types */
781 # define ST_UNDEF	0	/* undefined type */
782 # define ST_CLASS	1	/* class map */
783 # define ST_ADDRESS	2	/* an address in parsed format */
784 # define ST_MAILER	3	/* a mailer header */
785 # define ST_ALIAS	4	/* an alias */
786 # define ST_MAPCLASS	5	/* mapping function class */
787 # define ST_MAP		6	/* mapping function */
788 # define ST_HOSTSIG	7	/* host signature */
789 # define ST_NAMECANON	8	/* cached canonical name */
790 # define ST_MACRO	9	/* macro name to id mapping */
791 # define ST_RULESET	10	/* ruleset index */
792 # define ST_SERVICE	11	/* service switch entry */
793 # define ST_HEADER	12	/* special header flags */
794 # define ST_MCI		16	/* mailer connection info (offset) */
795 
796 # define s_class	s_value.sv_class
797 # define s_address	s_value.sv_addr
798 # define s_mailer	s_value.sv_mailer
799 # define s_alias	s_value.sv_alias
800 # define s_mci		s_value.sv_mci
801 # define s_mapclass	s_value.sv_mapclass
802 # define s_hostsig	s_value.sv_hostsig
803 # define s_map		s_value.sv_map
804 # define s_namecanon	s_value.sv_namecanon
805 # define s_macro	s_value.sv_macro
806 # define s_ruleset	s_value.sv_ruleset
807 # define s_service	s_value.sv_service
808 # define s_header	s_value.sv_header
809 
810 extern STAB		*stab __P((char *, int, int));
811 extern void		stabapply __P((void (*)(STAB *, int), int));
812 
813 /* opcodes to stab */
814 # define ST_FIND	0	/* find entry */
815 # define ST_ENTER	1	/* enter if not there */
816 /*
817 **  STRUCT EVENT -- event queue.
818 **
819 **	Maintained in sorted order.
820 **
821 **	We store the pid of the process that set this event to insure
822 **	that when we fork we will not take events intended for the parent.
823 */
824 
825 struct event
826 {
827 	time_t		ev_time;	/* time of the function call */
828 	void		(*ev_func)__P((int));
829 					/* function to call */
830 	int		ev_arg;		/* argument to ev_func */
831 	int		ev_pid;		/* pid that set this event */
832 	struct event	*ev_link;	/* link to next item */
833 };
834 
835 typedef struct event	EVENT;
836 
837 EXTERN EVENT	*EventQueue;		/* head of event queue */
838 
839 /* functions */
840 extern EVENT	*setevent __P((time_t, void(*)(), int));
841 extern void	clrevent __P((EVENT *));
842 /*
843 **  Operation, send, error, and MIME modes
844 **
845 **	The operation mode describes the basic operation of sendmail.
846 **	This can be set from the command line, and is "send mail" by
847 **	default.
848 **
849 **	The send mode tells how to send mail.  It can be set in the
850 **	configuration file.  It's setting determines how quickly the
851 **	mail will be delivered versus the load on your system.  If the
852 **	-v (verbose) flag is given, it will be forced to SM_DELIVER
853 **	mode.
854 **
855 **	The error mode tells how to return errors.
856 */
857 
858 EXTERN char	OpMode;		/* operation mode, see below */
859 
860 #define MD_DELIVER	'm'		/* be a mail sender */
861 #define MD_SMTP		's'		/* run SMTP on standard input */
862 #define MD_ARPAFTP	'a'		/* obsolete ARPANET mode (Grey Book) */
863 #define MD_DAEMON	'd'		/* run as a daemon */
864 #define MD_FGDAEMON	'D'		/* run daemon in foreground */
865 #define MD_VERIFY	'v'		/* verify: don't collect or deliver */
866 #define MD_TEST		't'		/* test mode: resolve addrs only */
867 #define MD_INITALIAS	'i'		/* initialize alias database */
868 #define MD_PRINT	'p'		/* print the queue */
869 #define MD_FREEZE	'z'		/* freeze the configuration file */
870 #define MD_HOSTSTAT	'h'		/* print persistent host stat info */
871 #define MD_PURGESTAT	'H'		/* purge persistent host stat info */
872 
873 /* values for e_sendmode -- send modes */
874 #define SM_DELIVER	'i'		/* interactive delivery */
875 #define SM_FORK		'b'		/* deliver in background */
876 #define SM_QUEUE	'q'		/* queue, don't deliver */
877 #define SM_DEFER	'd'		/* defer map lookups as well as queue */
878 #define SM_VERIFY	'v'		/* verify only (used internally) */
879 
880 /* used only as a parameter to sendall */
881 #define SM_DEFAULT	'\0'		/* unspecified, use SendMode */
882 
883 
884 /* values for e_errormode -- error handling modes */
885 #define EM_PRINT	'p'		/* print errors */
886 #define EM_MAIL		'm'		/* mail back errors */
887 #define EM_WRITE	'w'		/* write back errors */
888 #define EM_BERKNET	'e'		/* special berknet processing */
889 #define EM_QUIET	'q'		/* don't print messages (stat only) */
890 
891 
892 /* MIME processing mode */
893 EXTERN int	MimeMode;
894 
895 /* bit values for MimeMode */
896 #define MM_CVTMIME	0x0001		/* convert 8 to 7 bit MIME */
897 #define MM_PASS8BIT	0x0002		/* just send 8 bit data blind */
898 #define MM_MIME8BIT	0x0004		/* convert 8-bit data to MIME */
899 
900 /* queue sorting order algorithm */
901 EXTERN int	QueueSortOrder;
902 
903 #define QS_BYPRIORITY	0		/* sort by message priority */
904 #define QS_BYHOST	1		/* sort by first host name */
905 #define QS_BYTIME	2		/* sort by submission time */
906 
907 
908 /* how to handle messages without any recipient addresses */
909 EXTERN int		NoRecipientAction;
910 
911 #define NRA_NO_ACTION		0	/* just leave it as is */
912 #define NRA_ADD_TO		1	/* add To: header */
913 #define NRA_ADD_APPARENTLY_TO	2	/* add Apparently-To: header */
914 #define NRA_ADD_BCC		3	/* add empty Bcc: header */
915 #define NRA_ADD_TO_UNDISCLOSED	4	/* add To: undisclosed:; header */
916 
917 
918 /* flags to putxline */
919 #define PXLF_NOTHINGSPECIAL	0	/* no special mapping */
920 #define PXLF_MAPFROM		0x0001	/* map From_ to >From_ */
921 #define PXLF_STRIP8BIT		0x0002	/* strip 8th bit */
922 #define PXLF_HEADER		0x0004	/* map newlines in headers */
923 /*
924 **  Additional definitions
925 */
926 
927 
928 /*
929 **  Privacy flags
930 **	These are bit values for the PrivacyFlags word.
931 */
932 
933 #define PRIV_PUBLIC		0	/* what have I got to hide? */
934 #define PRIV_NEEDMAILHELO	0x0001	/* insist on HELO for MAIL, at least */
935 #define PRIV_NEEDEXPNHELO	0x0002	/* insist on HELO for EXPN */
936 #define PRIV_NEEDVRFYHELO	0x0004	/* insist on HELO for VRFY */
937 #define PRIV_NOEXPN		0x0008	/* disallow EXPN command entirely */
938 #define PRIV_NOVRFY		0x0010	/* disallow VRFY command entirely */
939 #define PRIV_AUTHWARNINGS	0x0020	/* flag possible authorization probs */
940 #define PRIV_NORECEIPTS		0x0040	/* disallow return receipts */
941 #define PRIV_NOETRN		0x0080	/* disallow ETRN command entirely */
942 #define PRIV_NOVERB		0x0100	/* disallow VERB command entirely */
943 #define PRIV_RESTRICTMAILQ	0x1000	/* restrict mailq command */
944 #define PRIV_RESTRICTQRUN	0x2000	/* restrict queue run */
945 #define PRIV_GOAWAY		0x0fff	/* don't give no info, anyway, anyhow */
946 
947 /* struct defining such things */
948 struct prival
949 {
950 	char	*pv_name;	/* name of privacy flag */
951 	int	pv_flag;	/* numeric level */
952 };
953 
954 
955 /*
956 **  Flags passed to remotename, parseaddr, allocaddr, and buildaddr.
957 */
958 
959 #define RF_SENDERADDR		0x001	/* this is a sender address */
960 #define RF_HEADERADDR		0x002	/* this is a header address */
961 #define RF_CANONICAL		0x004	/* strip comment information */
962 #define RF_ADDDOMAIN		0x008	/* OK to do domain extension */
963 #define RF_COPYPARSE		0x010	/* copy parsed user & host */
964 #define RF_COPYPADDR		0x020	/* copy print address */
965 #define RF_COPYALL		(RF_COPYPARSE|RF_COPYPADDR)
966 #define RF_COPYNONE		0
967 
968 
969 /*
970 **  Flags passed to safefile/safedirpath.
971 */
972 
973 #define SFF_ANYFILE		0	/* no special restrictions */
974 #define SFF_MUSTOWN		0x0001	/* user must own this file */
975 #define SFF_NOSLINK		0x0002	/* file cannot be a symbolic link */
976 #define SFF_ROOTOK		0x0004	/* ok for root to own this file */
977 #define SFF_RUNASREALUID	0x0008	/* if no ctladdr, run as real uid */
978 #define SFF_NOPATHCHECK		0x0010	/* don't bother checking dir path */
979 #define SFF_SETUIDOK		0x0020	/* setuid files are ok */
980 #define SFF_CREAT		0x0040	/* ok to create file if necessary */
981 #define SFF_REGONLY		0x0080	/* regular files only */
982 #define SFF_SAFEDIRPATH		0x0100	/* no writable directories allowed */
983 #define SFF_NOHLINK		0x0200	/* file cannot have hard links */
984 #define SFF_NOWLINK		0x0400	/* links only in non-writable dirs */
985 #define SFF_NOGWFILES		0x0800	/* disallow world writable files */
986 #define SFF_NOWWFILES		0x1000	/* disallow group writable files */
987 
988 /* flags that are actually specific to safeopen/safefopen/dfopen */
989 #define SFF_OPENASROOT		0x2000	/* open as root instead of real user */
990 #define SFF_NOLOCK		0x4000	/* don't lock the file */
991 
992 /* pseudo-flags */
993 #define SFF_NOLINK		(SFF_NOHLINK|SFF_NOSLINK)
994 
995 /* functions */
996 extern int	safefile __P((char *, UID_T, GID_T, char *, int, int, struct stat *));
997 extern int	safedirpath __P((char *, UID_T, GID_T, char *, int));
998 extern int	safeopen __P((char *, int, int, int));
999 extern FILE	*safefopen __P((char *, int, int, int));
1000 extern int	dfopen __P((char *, int, int, int));
1001 extern bool	filechanged __P((char *, int, struct stat *));
1002 
1003 
1004 /*
1005 **  Flags passed to mime8to7.
1006 */
1007 
1008 #define M87F_OUTER		0	/* outer context */
1009 #define M87F_NO8BIT		0x0001	/* can't have 8-bit in this section */
1010 #define M87F_DIGEST		0x0002	/* processing multipart/digest */
1011 
1012 
1013 /*
1014 **  Flags passed to returntosender.
1015 */
1016 
1017 #define RTSF_NO_BODY		0	/* send headers only */
1018 #define RTSF_SEND_BODY		0x0001	/* include body of message in return */
1019 #define RTSF_PM_BOUNCE		0x0002	/* this is a postmaster bounce */
1020 
1021 
1022 /*
1023 **  Regular UNIX sockaddrs are too small to handle ISO addresses, so
1024 **  we are forced to declare a supertype here.
1025 */
1026 
1027 # if NETINET || NETUNIX || NETISO || NETNS || NETX25
1028 union bigsockaddr
1029 {
1030 	struct sockaddr		sa;	/* general version */
1031 #if NETUNIX
1032 	struct sockaddr_un	sunix;	/* UNIX family */
1033 #endif
1034 #if NETINET
1035 	struct sockaddr_in	sin;	/* INET family */
1036 #endif
1037 #if NETISO
1038 	struct sockaddr_iso	siso;	/* ISO family */
1039 #endif
1040 #if NETNS
1041 	struct sockaddr_ns	sns;	/* XNS family */
1042 #endif
1043 #if NETX25
1044 	struct sockaddr_x25	sx25;	/* X.25 family */
1045 #endif
1046 };
1047 
1048 #define SOCKADDR	union bigsockaddr
1049 
1050 EXTERN SOCKADDR RealHostAddr;	/* address of host we are talking to */
1051 
1052 extern char	*hostnamebyanyaddr __P((SOCKADDR *));
1053 extern char	*anynet_ntoa __P((SOCKADDR *));
1054 # if DAEMON
1055 extern char	*validate_connection __P((SOCKADDR *, char *, ENVELOPE *));
1056 # endif
1057 
1058 #endif
1059 
1060 
1061 /*
1062 **  Vendor codes
1063 **
1064 **	Vendors can customize sendmail to add special behaviour,
1065 **	generally for back compatibility.  Ideally, this should
1066 **	be set up in the .cf file using the "V" command.  However,
1067 **	it's quite reasonable for some vendors to want the default
1068 **	be their old version; this can be set using
1069 **		-DVENDOR_DEFAULT=VENDOR_xxx
1070 **	in the Makefile.
1071 **
1072 **	Vendors should apply to sendmail@CS.Berkeley.EDU for
1073 **	unique vendor codes.
1074 */
1075 
1076 #define VENDOR_BERKELEY	1	/* Berkeley-native configuration file */
1077 #define VENDOR_SUN	2	/* Sun-native configuration file */
1078 #define VENDOR_HP	3	/* Hewlett-Packard specific config syntax */
1079 #define VENDOR_IBM	4	/* IBM specific config syntax */
1080 
1081 EXTERN int	VendorCode;	/* vendor-specific operation enhancements */
1082 
1083 /* prototypes for vendor-specific hook routines */
1084 extern void	vendor_set_uid __P((UID_T));
1085 extern void	vendor_daemon_setup __P((ENVELOPE *));
1086 
1087 /*
1088 **  DontBlameSendmail options
1089 **
1090 **	Hopefully nobody uses these.
1091 */
1092 #define DBS_SAFE					0
1093 #define DBS_ASSUMESAFECHOWN				0x00000001
1094 #define DBS_GROUPWRITABLEDIRPATHSAFE			0x00000002
1095 #define DBS_GROUPWRITABLEFORWARDFILESAFE		0x00000004
1096 #define DBS_GROUPWRITABLEINCLUDEFILESAFE		0x00000008
1097 #define DBS_GROUPWRITABLEALIASFILE			0x00000010
1098 #define DBS_WORLDWRITABLEALIASFILE			0x00000020
1099 #define DBS_FORWARDFILEINUNSAFEDIRPATH			0x00000040
1100 #define DBS_INCLUDEFILEINUNSAFEDIRPATH			0x00000060
1101 #define DBS_MAPINUNSAFEDIRPATH				0x00000080
1102 #define DBS_LINKEDALIASFILEINWRITABLEDIR		0x00000100
1103 #define DBS_LINKEDCLASSFILEINWRITABLEDIR		0x00000200
1104 #define DBS_LINKEDFORWARDFILEINWRITABLEDIR		0x00000400
1105 #define DBS_LINKEDINCLUDEFILEINWRITABLEDIR		0x00000800
1106 #define DBS_LINKEDMAPINWRITABLEDIR			0x00001000
1107 #define DBS_LINKEDSERVICESWITCHFILEINWRITABLEDIR	0x00002000
1108 #define DBS_FILEDELIVERYTOHARDLINK			0x00004000
1109 #define DBS_FILEDELIVERYTOSYMLINK			0x00008000
1110 #define DBS_WRITEMAPTOHARDLINK				0x00010000
1111 #define DBS_WRITEMAPTOSYMLINK				0x00020000
1112 #define DBS_WRITESTATSTOHARDLINK			0x00040000
1113 #define DBS_WRITESTATSTOSYMLINK				0x00080000
1114 #define DBS_FORWARDFILEINGROUPWRITABLEDIRPATH		0x00100000
1115 #define DBS_INCLUDEFILEINGROUPWRITABLEDIRPATH		0x00200000
1116 #define DBS_CLASSFILEINUNSAFEDIRPATH			0x00400000
1117 #define DBS_ERRORHEADERINUNSAFEDIRPATH			0x00800000
1118 #define DBS_HELPFILEINUNSAFEDIRPATH			0x01000000
1119 #define DBS_FORWARDFILEINUNSAFEDIRPATHSAFE		0x02000000
1120 #define DBS_INCLUDEFILEINUNSAFEDIRPATHSAFE		0x04000000
1121 #define DBS_RUNPROGRAMINUNSAFEDIRPATH			0x08000000
1122 #define DBS_RUNWRITABLEPROGRAM				0x10000000
1123 
1124 /* struct defining such things */
1125 struct dbsval
1126 {
1127 	char	*dbs_name;	/* name of DontBlameSendmail flag */
1128 	long	dbs_flag;	/* numeric level */
1129 };
1130 
1131 EXTERN long	DontBlameSendmail;	/* DontBlameSendmail option bits */
1132 
1133 /*
1134 **  Terminal escape codes.
1135 **
1136 **	To make debugging output clearer.
1137 */
1138 
1139 struct termescape
1140 {
1141 	char	*te_rv_on;	/* turn reverse-video on */
1142 	char	*te_rv_off;	/* turn reverse-video off */
1143 };
1144 
1145 EXTERN struct termescape	TermEscape;
1146 
1147 
1148 /*
1149 **  Error return from inet_addr(3), in case not defined in /usr/include.
1150 */
1151 
1152 #ifndef INADDR_NONE
1153 # define INADDR_NONE	0xffffffff
1154 #endif
1155 /*
1156 **  Global variables.
1157 */
1158 
1159 EXTERN bool	FromFlag;	/* if set, "From" person is explicit */
1160 EXTERN bool	MeToo;		/* send to the sender also */
1161 EXTERN bool	IgnrDot;	/* don't let dot end messages */
1162 EXTERN bool	SaveFrom;	/* save leading "From" lines */
1163 EXTERN bool	GrabTo;		/* if set, get recipients from msg */
1164 EXTERN bool	SuprErrs;	/* set if we are suppressing errors */
1165 EXTERN bool	HoldErrs;	/* only output errors to transcript */
1166 EXTERN bool	NoConnect;	/* don't connect to non-local mailers */
1167 EXTERN bool	SuperSafe;	/* be extra careful, even if expensive */
1168 EXTERN bool	ForkQueueRuns;	/* fork for each job when running the queue */
1169 EXTERN bool	AutoRebuild;	/* auto-rebuild the alias database as needed */
1170 EXTERN bool	CheckAliases;	/* parse addresses during newaliases */
1171 EXTERN bool	NoAlias;	/* suppress aliasing */
1172 EXTERN bool	UseNameServer;	/* using DNS -- interpret h_errno & MX RRs */
1173 EXTERN bool	UseHesiod;	/* using Hesiod -- interpret Hesiod errors */
1174 EXTERN bool	SevenBitInput;	/* force 7-bit data on input */
1175 EXTERN bool	HasEightBits;	/* has at least one eight bit input byte */
1176 EXTERN bool	ConfigFileRead;	/* configuration file has been read */
1177 EXTERN time_t	SafeAlias;	/* interval to wait until @:@ in alias file */
1178 EXTERN FILE	*InChannel;	/* input connection */
1179 EXTERN FILE	*OutChannel;	/* output connection */
1180 EXTERN char	*RealUserName;	/* real user name of caller */
1181 EXTERN uid_t	RealUid;	/* real uid of caller */
1182 EXTERN gid_t	RealGid;	/* real gid of caller */
1183 EXTERN uid_t	DefUid;		/* default uid to run as */
1184 EXTERN gid_t	DefGid;		/* default gid to run as */
1185 EXTERN char	*DefUser;	/* default user to run as (from DefUid) */
1186 EXTERN uid_t	TrustedFileUid;	/* uid of trusted owner of files and dirs */
1187 EXTERN MODE_T	OldUmask;	/* umask when sendmail starts up */
1188 EXTERN int	Verbose;	/* set if blow-by-blow desired */
1189 EXTERN int	Errors;		/* set if errors (local to single pass) */
1190 EXTERN int	ExitStat;	/* exit status code */
1191 EXTERN int	LineNumber;	/* line number in current input */
1192 EXTERN int	LogLevel;	/* level of logging to perform */
1193 EXTERN int	FileMode;	/* mode on files */
1194 EXTERN int	QueueLA;	/* load average starting forced queueing */
1195 EXTERN int	RefuseLA;	/* load average refusing connections are */
1196 EXTERN int	CurrentLA;	/* current load average */
1197 EXTERN long	QueueFactor;	/* slope of queue function */
1198 EXTERN time_t	QueueIntvl;	/* intervals between running the queue */
1199 EXTERN char	*HelpFile;	/* location of SMTP help file */
1200 EXTERN char	*ErrMsgFile;	/* file to prepend to all error messages */
1201 EXTERN char	*StatFile;	/* location of statistics summary */
1202 EXTERN char	*QueueDir;	/* location of queue directory */
1203 EXTERN char	*FileName;	/* name to print on error messages */
1204 EXTERN char	*SmtpPhase;	/* current phase in SMTP processing */
1205 EXTERN char	*MyHostName;	/* name of this host for SMTP messages */
1206 EXTERN char	*RealHostName;	/* name of host we are talking to */
1207 EXTERN char	*CurHostName;	/* current host we are dealing with */
1208 EXTERN jmp_buf	TopFrame;	/* branch-to-top-of-loop-on-error frame */
1209 EXTERN bool	QuickAbort;	/*  .... but only if we want a quick abort */
1210 EXTERN bool	OnlyOneError;	/*  .... or only want to give one SMTP reply */
1211 EXTERN bool	LogUsrErrs;	/* syslog user errors (e.g., SMTP RCPT cmd) */
1212 EXTERN bool	SendMIMEErrors;	/* send error messages in MIME format */
1213 EXTERN bool	MatchGecos;	/* look for user names in gecos field */
1214 EXTERN bool	UseErrorsTo;	/* use Errors-To: header (back compat) */
1215 EXTERN bool	TryNullMXList;	/* if we are the best MX, try host directly */
1216 EXTERN bool	InChild;	/* true if running in an SMTP subprocess */
1217 EXTERN bool	DisConnected;	/* running with OutChannel redirected to xf */
1218 EXTERN bool	ColonOkInAddr;	/* single colon legal in address */
1219 EXTERN bool	HasWildcardMX;	/* don't use MX records when canonifying */
1220 EXTERN char	SpaceSub;	/* substitution for <lwsp> */
1221 EXTERN int	PrivacyFlags;	/* privacy flags */
1222 EXTERN char	*ConfFile;	/* location of configuration file [conf.c] */
1223 EXTERN char	*PidFile;	/* location of proc id file [conf.c] */
1224 extern ADDRESS	NullAddress;	/* a null (template) address [main.c] */
1225 EXTERN long	WkClassFact;	/* multiplier for message class -> priority */
1226 EXTERN long	WkRecipFact;	/* multiplier for # of recipients -> priority */
1227 EXTERN long	WkTimeFact;	/* priority offset each time this job is run */
1228 EXTERN char	*UdbSpec;	/* user database source spec */
1229 EXTERN int	MaxHopCount;	/* max # of hops until bounce */
1230 EXTERN int	ConfigLevel;	/* config file level */
1231 EXTERN char	*TimeZoneSpec;	/* override time zone specification */
1232 EXTERN char	*ForwardPath;	/* path to search for .forward files */
1233 EXTERN long	MinBlocksFree;	/* min # of blocks free on queue fs */
1234 EXTERN char	*FallBackMX;	/* fall back MX host */
1235 EXTERN long	MaxMessageSize;	/* advertised max size we will accept */
1236 EXTERN time_t	MinQueueAge;	/* min delivery interval */
1237 EXTERN time_t	DialDelay;	/* delay between dial-on-demand tries */
1238 EXTERN char	*SafeFileEnv;	/* chroot location for file delivery */
1239 EXTERN char	*HostsFile;	/* path to /etc/hosts file */
1240 EXTERN char	*HostStatDir;	/* location of host status information */
1241 EXTERN int	MaxQueueRun;	/* maximum number of jobs in one queue run */
1242 EXTERN int	MaxChildren;	/* maximum number of daemonic children */
1243 EXTERN int	CurChildren;	/* current number of daemonic children */
1244 EXTERN char	*SmtpGreeting;	/* SMTP greeting message (old $e macro) */
1245 EXTERN char	*UnixFromLine;	/* UNIX From_ line (old $l macro) */
1246 EXTERN char	*OperatorChars;	/* operators (old $o macro) */
1247 EXTERN bool	DontInitGroups;	/* avoid initgroups() because of NIS cost */
1248 EXTERN int	DefaultNotify;	/* default DSN notification flags */
1249 EXTERN bool	AllowBogusHELO;	/* allow syntax errors on HELO command */
1250 EXTERN bool	UserSubmission;	/* initial (user) mail submission */
1251 EXTERN char	*RunAsUserName;	/* user to become for bulk of run */
1252 EXTERN uid_t	RunAsUid;	/* UID to become for bulk of run */
1253 EXTERN gid_t	RunAsGid;	/* GID to become for bulk of run */
1254 EXTERN int	MaxRcptPerMsg;	/* max recipients per SMTP message */
1255 EXTERN bool	DoQueueRun;	/* non-interrupt time queue run needed */
1256 EXTERN u_long	ConnectOnlyTo;	/* override connection address (for testing) */
1257 #if _FFR_DSN_RRT_OPTION
1258 EXTERN bool	RrtImpliesDsn;	/* turn Return-Receipt-To: into DSN */
1259 #endif
1260 EXTERN char	*DeadLetterDrop;	/* path to dead letter office */
1261 EXTERN bool	DontProbeInterfaces;	/* don't probe interfaces for names */
1262 EXTERN bool	ChownAlwaysSafe;	/* treat chown(2) as safe */
1263 EXTERN bool	IgnoreHostStatus;	/* ignore long term host status files */
1264 EXTERN bool	SingleThreadDelivery;	/* single thread hosts on delivery */
1265 EXTERN bool	SingleLineFromHeader;	/* force From: header to be one line */
1266 EXTERN bool	DontLockReadFiles;	/* don't read lock support files */
1267 EXTERN int	ConnRateThrottle;	/* throttle for SMTP connection rate */
1268 EXTERN int	MaxAliasRecursion;	/* maximum depth of alias recursion */
1269 EXTERN int	MaxMacroRecursion;	/* maximum depth of macro recursion */
1270 EXTERN int	MaxRuleRecursion;	/* maximum depth of ruleset recursion */
1271 EXTERN char	*MustQuoteChars;	/* quote these characters in phrases */
1272 EXTERN char	*ServiceSwitchFile;	/* backup service switch */
1273 EXTERN char	*DefaultCharSet;	/* default character set for MIME */
1274 EXTERN char	*PostMasterCopy;	/* address to get errs cc's */
1275 EXTERN int	CheckpointInterval;	/* queue file checkpoint interval */
1276 EXTERN bool	DontPruneRoutes;	/* don't prune source routes */
1277 EXTERN bool	DontExpandCnames;	/* do not $[...$] expand CNAMEs */
1278 EXTERN int	MaxMciCache;		/* maximum entries in MCI cache */
1279 EXTERN time_t	ServiceCacheTime;	/* time service switch was cached */
1280 EXTERN time_t	ServiceCacheMaxAge;	/* refresh interval for cache */
1281 EXTERN time_t	MciCacheTimeout;	/* maximum idle time on connections */
1282 EXTERN time_t	MciInfoTimeout;		/* how long 'til we retry down hosts */
1283 EXTERN FILE	*TrafficLogFile;	/* file in which to log all traffic */
1284 EXTERN char	*DoubleBounceAddr;	/* where to send double bounces */
1285 EXTERN char	**ExternalEnviron;	/* input environment */
1286 EXTERN char	*UserEnviron[MAXUSERENVIRON + 1];
1287 					/* saved user environment */
1288 extern int	errno;
1289 
1290 /*
1291 ** Queue Run Limitations
1292 */
1293 struct queue_char
1294 {
1295 	char *queue_match;		/* string to match */
1296 	struct queue_char *queue_next;
1297 };
1298 
1299 typedef struct queue_char QUEUE_CHAR;
1300 
1301 EXTERN QUEUE_CHAR	*QueueLimitRecipient;	/* limit queue runs to this recipient */
1302 EXTERN QUEUE_CHAR	*QueueLimitSender;	/* limit queue runs to this sender */
1303 EXTERN QUEUE_CHAR	*QueueLimitId;		/* limit queue runs to this id */
1304 
1305 /*
1306 **  Timeouts
1307 **
1308 **	Indicated values are the MINIMUM per RFC 1123 section 5.3.2.
1309 */
1310 
1311 EXTERN struct
1312 {
1313 			/* RFC 1123-specified timeouts [minimum value] */
1314 	time_t	to_initial;	/* initial greeting timeout [5m] */
1315 	time_t	to_mail;	/* MAIL command [5m] */
1316 	time_t	to_rcpt;	/* RCPT command [5m] */
1317 	time_t	to_datainit;	/* DATA initiation [2m] */
1318 	time_t	to_datablock;	/* DATA block [3m] */
1319 	time_t	to_datafinal;	/* DATA completion [10m] */
1320 	time_t	to_nextcommand;	/* next command [5m] */
1321 			/* following timeouts are not mentioned in RFC 1123 */
1322 	time_t	to_iconnect;	/* initial connection timeout (first try) */
1323 	time_t	to_connect;	/* initial connection timeout (later tries) */
1324 	time_t	to_rset;	/* RSET command */
1325 	time_t	to_helo;	/* HELO command */
1326 	time_t	to_quit;	/* QUIT command */
1327 	time_t	to_miscshort;	/* misc short commands (NOOP, VERB, etc) */
1328 	time_t	to_ident;	/* IDENT protocol requests */
1329 	time_t	to_fileopen;	/* opening :include: and .forward files */
1330 			/* following are per message */
1331 	time_t	to_q_return[MAXTOCLASS];	/* queue return timeouts */
1332 	time_t	to_q_warning[MAXTOCLASS];	/* queue warning timeouts */
1333 } TimeOuts;
1334 
1335 /* timeout classes for return and warning timeouts */
1336 # define TOC_NORMAL	0	/* normal delivery */
1337 # define TOC_URGENT	1	/* urgent delivery */
1338 # define TOC_NONURGENT	2	/* non-urgent delivery */
1339 
1340 
1341 /*
1342 **  Trace information
1343 */
1344 
1345 /* trace vector and macros for debugging flags */
1346 EXTERN u_char	tTdvect[100];
1347 # define tTd(flag, level)	(tTdvect[flag] >= level)
1348 # define tTdlevel(flag)		(tTdvect[flag])
1349 /*
1350 **  Miscellaneous information.
1351 */
1352 
1353 
1354 /*
1355 **  The "no queue id" queue id for sm_syslog
1356 */
1357 
1358 #define NOQID		"*~*"
1359 
1360 
1361 /*
1362 **  Some in-line functions
1363 */
1364 
1365 /* set exit status */
1366 #define setstat(s)	{ \
1367 				if (ExitStat == EX_OK || ExitStat == EX_TEMPFAIL) \
1368 					ExitStat = s; \
1369 			}
1370 
1371 /* make a copy of a string */
1372 #define newstr(s)	strcpy(xalloc(strlen(s) + 1), s)
1373 
1374 #define STRUCTCOPY(s, d)	d = s
1375 
1376 
1377 
1378 /*
1379 **  Declarations of useful functions
1380 */
1381 
1382 extern char	*xalloc __P((int));
1383 extern char	*sfgets __P((char *, int, FILE *, time_t, char *));
1384 extern char	*queuename __P((ENVELOPE *, int));
1385 extern time_t	curtime __P((void));
1386 extern bool	transienterror __P((int));
1387 extern char	*fgetfolded __P((char *, int, FILE *));
1388 extern char	*username __P((void));
1389 extern char	*pintvl __P((time_t, bool));
1390 extern bool	shouldqueue __P((long, time_t));
1391 extern bool	lockfile __P((int, char *, char *, int));
1392 extern char	*hostsignature __P((MAILER *, char *, ENVELOPE *));
1393 extern void	openxscript __P((ENVELOPE *));
1394 extern void	closexscript __P((ENVELOPE *));
1395 extern char	*shortenstring __P((const char *, int));
1396 extern bool	usershellok __P((char *, char *));
1397 extern char	*defcharset __P((ENVELOPE *));
1398 extern bool	wordinclass __P((char *, int));
1399 extern char	*denlstring __P((char *, bool, bool));
1400 extern void	makelower __P((char *));
1401 extern bool	rebuildaliases __P((MAP *, bool));
1402 extern void	readaliases __P((MAP *, FILE *, bool, bool));
1403 extern void	finis __P((void));
1404 extern void	setsender __P((char *, ENVELOPE *, char **, int, bool));
1405 extern void	xputs __P((const char *));
1406 extern void	logsender __P((ENVELOPE *, char *));
1407 extern void	smtprset __P((MAILER *, MCI *, ENVELOPE *));
1408 extern void	smtpquit __P((MAILER *, MCI *, ENVELOPE *));
1409 extern void	setuserenv __P((const char *, const char *));
1410 extern char	*getextenv __P((const char *));
1411 extern void	disconnect __P((int, ENVELOPE *));
1412 extern void	putxline __P((char *, size_t, MCI *, int));
1413 extern void	dumpfd __P((int, bool, bool));
1414 extern void	makemailer __P((char *));
1415 extern void	putfromline __P((MCI *, ENVELOPE *));
1416 extern void	setoption __P((int, char *, bool, bool, ENVELOPE *));
1417 extern void	setclass __P((int, char *));
1418 extern void	inittimeouts __P((char *));
1419 extern void	logdelivery __P((MAILER *, MCI *, const char *, ADDRESS *, time_t, ENVELOPE *));
1420 extern void	giveresponse __P((int, MAILER *, MCI *, ADDRESS *, time_t, ENVELOPE *));
1421 extern void	buildfname __P((char *, char *, char *, int));
1422 extern void	mci_setstat __P((MCI *, int, char *, char *));
1423 extern char	*smtptodsn __P((int));
1424 extern int	rscheck __P((char *, char *, char *, ENVELOPE *e));
1425 extern void	mime7to8 __P((MCI *, HDR *, ENVELOPE *));
1426 extern int	mime8to7 __P((MCI *, HDR *, ENVELOPE *, char **, int));
1427 extern void	xfclose __P((FILE *, char *, char *));
1428 extern int	switch_map_find __P((char *, char *[], short []));
1429 extern void	shorten_hostname __P((char []));
1430 extern int	waitfor __P((pid_t));
1431 extern void	proc_list_add __P((pid_t));
1432 extern void	proc_list_drop __P((pid_t));
1433 extern void	proc_list_clear __P((void));
1434 extern void	buffer_errors __P((void));
1435 extern void	flush_errors __P((bool));
1436 extern void	putline __P((char *, MCI *));
1437 extern bool	xtextok __P((char *));
1438 extern char	*xtextify __P((char *, char *));
1439 extern char	*xuntextify __P((char *));
1440 extern void	cleanstrcpy __P((char *, char *, int));
1441 extern int	getmxrr __P((char *, char **, bool, int *));
1442 extern int	strtorwset __P((char *, char **, int));
1443 extern void	printav __P((char **));
1444 extern void	printopenfds __P((bool));
1445 extern int	endmailer __P((MCI *, ENVELOPE *, char **));
1446 extern void	fixcrlf __P((char *, bool));
1447 extern int	dofork __P((void));
1448 extern void	initsys __P((ENVELOPE *));
1449 extern void	collect __P((FILE *, bool, HDR **, ENVELOPE *));
1450 extern void	stripquotes __P((char *));
1451 extern int	include __P((char *, bool, ADDRESS *, ADDRESS **, int, ENVELOPE  *));
1452 extern void	unlockqueue __P((ENVELOPE *));
1453 extern void	xunlink __P((char *));
1454 extern bool	runqueue __P((bool, bool));
1455 extern int	getla __P((void));
1456 extern void	sendall __P((ENVELOPE *, int));
1457 extern void	queueup __P((ENVELOPE *, bool));
1458 extern void	checkfds __P((char *));
1459 extern int	returntosender __P((char *, ADDRESS *, int, ENVELOPE *));
1460 extern void	markstats __P((ENVELOPE *, ADDRESS *, bool));
1461 extern void	poststats __P((char *));
1462 extern char	*arpadate __P((char *));
1463 extern int	mailfile __P((char *volatile, MAILER *volatile, ADDRESS *, volatile int, ENVELOPE *));
1464 extern void	loseqfile __P((ENVELOPE *, char *));
1465 extern int	prog_open __P((char **, int *, ENVELOPE *));
1466 extern bool	getcanonname __P((char *, int, bool));
1467 extern bool	path_is_dir __P((char *, bool));
1468 extern pid_t	dowork __P((char *, bool, bool, ENVELOPE *));
1469 extern int	drop_privileges __P((bool));
1470 extern void	fill_fd __P((int, char *));
1471 
1472 extern const char	*errstring __P((int));
1473 extern sigfunc_t	setsignal __P((int, sigfunc_t));
1474 extern int		blocksignal __P((int));
1475 extern int		releasesignal __P((int));
1476 extern struct hostent	*sm_gethostbyname __P((char *));
1477 extern struct hostent	*sm_gethostbyaddr __P((char *, int, int));
1478 extern struct passwd	*sm_getpwnam __P((char *));
1479 extern struct passwd	*sm_getpwuid __P((UID_T));
1480 extern struct passwd	*finduser __P((char *, bool *));
1481 
1482 #ifdef XDEBUG
1483 extern void		checkfdopen __P((int, char *));
1484 extern void		checkfd012 __P((char *));
1485 #endif
1486 
1487 /* ellipsis is a different case though */
1488 extern void		auth_warning __P((ENVELOPE *, const char *, ...));
1489 extern void		syserr __P((const char *, ...));
1490 extern void		usrerr __P((const char *, ...));
1491 extern void		message __P((const char *, ...));
1492 extern void		nmessage __P((const char *, ...));
1493 extern void		setproctitle __P((const char *, ...));
1494 extern void		sm_syslog __P((int, const char *, const char *, ...));
1495 
1496 #if !HASSNPRINTF
1497 extern int		snprintf __P((char *, size_t, const char *, ...));
1498 extern int		vsnprintf __P((char *, size_t, const char *, va_list));
1499 #endif
1500 extern char		*quad_to_string __P((QUAD_T));
1501