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