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