1 /* 2 * Copyright (c) 1983 Eric P. Allman 3 * Copyright (c) 1988 Regents of the University of California. 4 * All rights reserved. 5 * 6 * %sccs.include.redist.c% 7 * 8 * @(#)sendmail.h 6.32 (Berkeley) 03/19/93 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 6.32 03/19/93"; 19 # endif lint 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 <sysexits.h> 31 # include <string.h> 32 # include <time.h> 33 # include <errno.h> 34 # include <sys/types.h> 35 36 # include "conf.h" 37 # include "useful.h" 38 39 # ifdef LOG 40 # include <syslog.h> 41 # endif /* LOG */ 42 43 # ifdef DAEMON 44 # include <sys/socket.h> 45 # include <netinet/in.h> 46 # endif /* DAEMON */ 47 48 49 50 51 /* 52 ** Data structure for bit maps. 53 ** 54 ** Each bit in this map can be referenced by an ascii character. 55 ** This is 128 possible bits, or 12 8-bit bytes. 56 */ 57 58 #define BITMAPBYTES 16 /* number of bytes in a bit map */ 59 #define BYTEBITS 8 /* number of bits in a byte */ 60 61 /* internal macros */ 62 #define _BITWORD(bit) (bit / (BYTEBITS * sizeof (int))) 63 #define _BITBIT(bit) (1 << (bit % (BYTEBITS * sizeof (int)))) 64 65 typedef int BITMAP[BITMAPBYTES / sizeof (int)]; 66 67 /* test bit number N */ 68 #define bitnset(bit, map) ((map)[_BITWORD(bit)] & _BITBIT(bit)) 69 70 /* set bit number N */ 71 #define setbitn(bit, map) (map)[_BITWORD(bit)] |= _BITBIT(bit) 72 73 /* clear bit number N */ 74 #define clrbitn(bit, map) (map)[_BITWORD(bit)] &= ~_BITBIT(bit) 75 76 /* clear an entire bit map */ 77 #define clrbitmap(map) bzero((char *) map, BITMAPBYTES) 78 /* 79 ** Address structure. 80 ** Addresses are stored internally in this structure. 81 */ 82 83 struct address 84 { 85 char *q_paddr; /* the printname for the address */ 86 char *q_user; /* user name */ 87 char *q_ruser; /* real user name, or NULL if q_user */ 88 char *q_host; /* host name */ 89 struct mailer *q_mailer; /* mailer to use */ 90 u_short q_flags; /* status flags, see below */ 91 uid_t q_uid; /* user-id of receiver (if known) */ 92 gid_t q_gid; /* group-id of receiver (if known) */ 93 char *q_home; /* home dir (local mailer only) */ 94 char *q_fullname; /* full name if known */ 95 struct address *q_next; /* chain */ 96 struct address *q_alias; /* address this results from */ 97 char *q_owner; /* owner of q_alias */ 98 struct address *q_tchain; /* temporary use chain */ 99 time_t q_timeout; /* timeout for this address */ 100 }; 101 102 typedef struct address ADDRESS; 103 104 # define QDONTSEND 000001 /* don't send to this address */ 105 # define QBADADDR 000002 /* this address is verified bad */ 106 # define QGOODUID 000004 /* the q_uid q_gid fields are good */ 107 # define QPRIMARY 000010 /* set from argv */ 108 # define QQUEUEUP 000020 /* queue for later transmission */ 109 # define QSENT 000040 /* has been successfully delivered */ 110 # define QNOTREMOTE 000100 /* not an address for remote forwarding */ 111 # define QSELFREF 000200 /* this address references itself */ 112 # define QVERIFIED 000400 /* verified, but not expanded */ 113 /* 114 ** Mailer definition structure. 115 ** Every mailer known to the system is declared in this 116 ** structure. It defines the pathname of the mailer, some 117 ** flags associated with it, and the argument vector to 118 ** pass to it. The flags are defined in conf.c 119 ** 120 ** The argument vector is expanded before actual use. All 121 ** words except the first are passed through the macro 122 ** processor. 123 */ 124 125 struct mailer 126 { 127 char *m_name; /* symbolic name of this mailer */ 128 char *m_mailer; /* pathname of the mailer to use */ 129 BITMAP m_flags; /* status flags, see below */ 130 short m_mno; /* mailer number internally */ 131 char **m_argv; /* template argument vector */ 132 short m_sh_rwset; /* rewrite set: sender header addresses */ 133 short m_se_rwset; /* rewrite set: sender envelope addresses */ 134 short m_rh_rwset; /* rewrite set: recipient header addresses */ 135 short m_re_rwset; /* rewrite set: recipient envelope addresses */ 136 char *m_eol; /* end of line string */ 137 long m_maxsize; /* size limit on message to this mailer */ 138 int m_linelimit; /* max # characters per line */ 139 }; 140 141 typedef struct mailer MAILER; 142 143 /* bits for m_flags */ 144 # define M_NOCOMMENT 'c' /* don't include comment part of address */ 145 # define M_CANONICAL 'C' /* make addresses canonical "u@dom" */ 146 /* 'D' /* CF: include Date: */ 147 # define M_EXPENSIVE 'e' /* it costs to use this mailer.... */ 148 # define M_ESCFROM 'E' /* escape From lines to >From */ 149 # define M_FOPT 'f' /* mailer takes picky -f flag */ 150 /* 'F' /* CF: include From: or Resent-From: */ 151 # define M_HST_UPPER 'h' /* preserve host case distinction */ 152 /* 'H' /* UIUC: MAIL11V3: preview headers */ 153 # define M_INTERNAL 'I' /* SMTP to another sendmail site */ 154 # define M_LOCALMAILER 'l' /* delivery is to this host */ 155 # define M_LIMITS 'L' /* must enforce SMTP line limits */ 156 # define M_MUSER 'm' /* can handle multiple users at once */ 157 /* 'M' /* CF: include Message-Id: */ 158 # define M_NHDR 'n' /* don't insert From line */ 159 /* 'N' /* UIUC: MAIL11V3: DATA returns multi-status */ 160 # define M_FROMPATH 'p' /* use reverse-path in MAIL FROM: */ 161 /* 'P' /* CF: include Return-Path: */ 162 # define M_ROPT 'r' /* mailer takes picky -r flag */ 163 # define M_SECURE_PORT 'R' /* try to send on a reserved TCP port */ 164 # define M_STRIPQ 's' /* strip quote chars from user/host */ 165 # define M_RESTR 'S' /* must be daemon to execute */ 166 # define M_USR_UPPER 'u' /* preserve user case distinction */ 167 # define M_UGLYUUCP 'U' /* this wants an ugly UUCP from line */ 168 /* 'V' /* UIUC: !-relativize all addresses */ 169 # define M_XDOT 'X' /* use hidden-dot algorithm */ 170 # define M_7BITS '7' /* use 7-bit path */ 171 172 EXTERN MAILER *Mailer[MAXMAILERS+1]; 173 174 EXTERN MAILER *LocalMailer; /* ptr to local mailer */ 175 EXTERN MAILER *ProgMailer; /* ptr to program mailer */ 176 EXTERN MAILER *FileMailer; /* ptr to *file* mailer */ 177 EXTERN MAILER *InclMailer; /* ptr to *include* mailer */ 178 /* 179 ** Header structure. 180 ** This structure is used internally to store header items. 181 */ 182 183 struct header 184 { 185 char *h_field; /* the name of the field */ 186 char *h_value; /* the value of that field */ 187 struct header *h_link; /* the next header */ 188 u_short h_flags; /* status bits, see below */ 189 BITMAP h_mflags; /* m_flags bits needed */ 190 }; 191 192 typedef struct header HDR; 193 194 /* 195 ** Header information structure. 196 ** Defined in conf.c, this struct declares the header fields 197 ** that have some magic meaning. 198 */ 199 200 struct hdrinfo 201 { 202 char *hi_field; /* the name of the field */ 203 u_short hi_flags; /* status bits, see below */ 204 }; 205 206 extern struct hdrinfo HdrInfo[]; 207 208 /* bits for h_flags and hi_flags */ 209 # define H_EOH 00001 /* this field terminates header */ 210 # define H_RCPT 00002 /* contains recipient addresses */ 211 # define H_DEFAULT 00004 /* if another value is found, drop this */ 212 # define H_RESENT 00010 /* this address is a "Resent-..." address */ 213 # define H_CHECK 00020 /* check h_mflags against m_flags */ 214 # define H_ACHECK 00040 /* ditto, but always (not just default) */ 215 # define H_FORCE 00100 /* force this field, even if default */ 216 # define H_TRACE 00200 /* this field contains trace information */ 217 # define H_FROM 00400 /* this is a from-type field */ 218 # define H_VALID 01000 /* this field has a validated value */ 219 # define H_RECEIPTTO 02000 /* this field has return receipt info */ 220 # define H_ERRORSTO 04000 /* this field has error address info */ 221 /* 222 ** Envelope structure. 223 ** This structure defines the message itself. There is usually 224 ** only one of these -- for the message that we originally read 225 ** and which is our primary interest -- but other envelopes can 226 ** be generated during processing. For example, error messages 227 ** will have their own envelope. 228 */ 229 230 struct envelope 231 { 232 HDR *e_header; /* head of header list */ 233 long e_msgpriority; /* adjusted priority of this message */ 234 time_t e_ctime; /* time message appeared in the queue */ 235 char *e_to; /* the target person */ 236 char *e_receiptto; /* return receipt address */ 237 ADDRESS e_from; /* the person it is from */ 238 char *e_sender; /* e_from.q_paddr w comments stripped */ 239 char **e_fromdomain; /* the domain part of the sender */ 240 ADDRESS *e_sendqueue; /* list of message recipients */ 241 ADDRESS *e_errorqueue; /* the queue for error responses */ 242 long e_msgsize; /* size of the message in bytes */ 243 int e_nrcpts; /* number of recipients */ 244 short e_class; /* msg class (priority, junk, etc.) */ 245 short e_flags; /* flags, see below */ 246 short e_hopcount; /* number of times processed */ 247 short e_nsent; /* number of sends since checkpoint */ 248 short e_sendmode; /* message send mode */ 249 short e_errormode; /* error return mode */ 250 int (*e_puthdr)(); /* function to put header of message */ 251 int (*e_putbody)(); /* function to put body of message */ 252 struct envelope *e_parent; /* the message this one encloses */ 253 struct envelope *e_sibling; /* the next envelope of interest */ 254 char *e_df; /* location of temp file */ 255 FILE *e_dfp; /* temporary file */ 256 char *e_id; /* code for this entry in queue */ 257 FILE *e_xfp; /* transcript file */ 258 FILE *e_lockfp; /* the lock file for this message */ 259 char *e_message; /* error message */ 260 char *e_macro[128]; /* macro definitions */ 261 }; 262 263 typedef struct envelope ENVELOPE; 264 265 /* values for e_flags */ 266 #define EF_OLDSTYLE 000001 /* use spaces (not commas) in hdrs */ 267 #define EF_INQUEUE 000002 /* this message is fully queued */ 268 #define EF_TIMEOUT 000004 /* this message is too old */ 269 #define EF_CLRQUEUE 000010 /* disk copy is no longer needed */ 270 #define EF_SENDRECEIPT 000020 /* send a return receipt */ 271 #define EF_FATALERRS 000040 /* fatal errors occured */ 272 #define EF_KEEPQUEUE 000100 /* keep queue files always */ 273 #define EF_RESPONSE 000200 /* this is an error or return receipt */ 274 #define EF_RESENT 000400 /* this message is being forwarded */ 275 #define EF_VRFYONLY 001000 /* verify only (don't expand aliases) */ 276 #define EF_WARNING 002000 /* warning message has been sent */ 277 #define EF_QUEUERUN 004000 /* this envelope is from queue */ 278 279 EXTERN ENVELOPE *CurEnv; /* envelope currently being processed */ 280 /* 281 ** Message priority classes. 282 ** 283 ** The message class is read directly from the Priority: header 284 ** field in the message. 285 ** 286 ** CurEnv->e_msgpriority is the number of bytes in the message plus 287 ** the creation time (so that jobs ``tend'' to be ordered correctly), 288 ** adjusted by the message class, the number of recipients, and the 289 ** amount of time the message has been sitting around. This number 290 ** is used to order the queue. Higher values mean LOWER priority. 291 ** 292 ** Each priority class point is worth WkClassFact priority points; 293 ** each recipient is worth WkRecipFact priority points. Each time 294 ** we reprocess a message the priority is adjusted by WkTimeFact. 295 ** WkTimeFact should normally decrease the priority so that jobs 296 ** that have historically failed will be run later; thanks go to 297 ** Jay Lepreau at Utah for pointing out the error in my thinking. 298 ** 299 ** The "class" is this number, unadjusted by the age or size of 300 ** this message. Classes with negative representations will have 301 ** error messages thrown away if they are not local. 302 */ 303 304 struct priority 305 { 306 char *pri_name; /* external name of priority */ 307 int pri_val; /* internal value for same */ 308 }; 309 310 EXTERN struct priority Priorities[MAXPRIORITIES]; 311 EXTERN int NumPriorities; /* pointer into Priorities */ 312 /* 313 ** Rewrite rules. 314 */ 315 316 struct rewrite 317 { 318 char **r_lhs; /* pattern match */ 319 char **r_rhs; /* substitution value */ 320 struct rewrite *r_next;/* next in chain */ 321 }; 322 323 EXTERN struct rewrite *RewriteRules[MAXRWSETS]; 324 325 /* 326 ** Special characters in rewriting rules. 327 ** These are used internally only. 328 ** The COND* rules are actually used in macros rather than in 329 ** rewriting rules, but are given here because they 330 ** cannot conflict. 331 */ 332 333 /* left hand side items */ 334 # define MATCHZANY 0220 /* match zero or more tokens */ 335 # define MATCHANY 0221 /* match one or more tokens */ 336 # define MATCHONE 0222 /* match exactly one token */ 337 # define MATCHCLASS 0223 /* match one token in a class */ 338 # define MATCHNCLASS 0224 /* match anything not in class */ 339 # define MATCHREPL 0225 /* replacement on RHS for above */ 340 341 /* right hand side items */ 342 # define CANONNET 0226 /* canonical net, next token */ 343 # define CANONHOST 0227 /* canonical host, next token */ 344 # define CANONUSER 0230 /* canonical user, next N tokens */ 345 # define CALLSUBR 0231 /* call another rewriting set */ 346 347 /* conditionals in macros */ 348 # define CONDIF 0232 /* conditional if-then */ 349 # define CONDELSE 0233 /* conditional else */ 350 # define CONDFI 0234 /* conditional fi */ 351 352 /* bracket characters for host name lookup */ 353 # define HOSTBEGIN 0235 /* hostname lookup begin */ 354 # define HOSTEND 0236 /* hostname lookup end */ 355 356 /* bracket characters for generalized lookup */ 357 # define LOOKUPBEGIN 0205 /* generalized lookup begin */ 358 # define LOOKUPEND 0206 /* generalized lookup end */ 359 360 /* macro substitution character */ 361 # define MACROEXPAND 0201 /* macro expansion */ 362 363 /* external <==> internal mapping table */ 364 struct metamac 365 { 366 char metaname; /* external code (after $) */ 367 char metaval; /* internal code (as above) */ 368 }; 369 /* 370 ** Information about currently open connections to mailers, or to 371 ** hosts that we have looked up recently. 372 */ 373 374 # define MCI struct mailer_con_info 375 376 MCI 377 { 378 short mci_flags; /* flag bits, see below */ 379 short mci_errno; /* error number on last connection */ 380 short mci_exitstat; /* exit status from last connection */ 381 short mci_state; /* SMTP state */ 382 FILE *mci_in; /* input side of connection */ 383 FILE *mci_out; /* output side of connection */ 384 int mci_pid; /* process id of subordinate proc */ 385 char *mci_phase; /* SMTP phase string */ 386 struct mailer *mci_mailer; /* ptr to the mailer for this conn */ 387 char *mci_host; /* host name */ 388 time_t mci_lastuse; /* last usage time */ 389 }; 390 391 392 /* flag bits */ 393 #define MCIF_VALID 00001 /* this entry is valid */ 394 #define MCIF_TEMP 00002 /* don't cache this connection */ 395 #define MCIF_CACHED 00004 /* currently in open cache */ 396 397 /* states */ 398 #define MCIS_CLOSED 0 /* no traffic on this connection */ 399 #define MCIS_OPENING 1 /* sending initial protocol */ 400 #define MCIS_OPEN 2 /* open, initial protocol sent */ 401 #define MCIS_ACTIVE 3 /* message being sent */ 402 #define MCIS_QUITING 4 /* running quit protocol */ 403 #define MCIS_SSD 5 /* service shutting down */ 404 #define MCIS_ERROR 6 /* I/O error on connection */ 405 /* 406 ** Mapping functions 407 ** 408 ** These allow arbitrary mappings in the config file. The idea 409 ** (albeit not the implementation) comes from IDA sendmail. 410 */ 411 412 413 /* 414 ** The class of a map -- essentially the functions to call 415 */ 416 417 # define MAPCLASS struct _mapclass 418 419 MAPCLASS 420 { 421 bool (*map_init)(); /* initialization function */ 422 char *(*map_lookup)(); /* lookup function */ 423 }; 424 425 426 /* 427 ** An actual map. 428 */ 429 430 # define MAP struct _map 431 432 MAP 433 { 434 MAPCLASS *map_class; /* the class of this map */ 435 int map_flags; /* flags, see below */ 436 char *map_file; /* the (nominal) filename */ 437 void *map_db; /* the open database ptr */ 438 char *map_app; /* to append to successful matches */ 439 char *map_domain; /* the (nominal) NIS domain */ 440 }; 441 442 /* bit values for map_flags */ 443 # define MF_VALID 00001 /* this entry is valid */ 444 # define MF_INCLNULL 00002 /* include null byte in key */ 445 # define MF_OPTIONAL 00004 /* don't complain if map not found */ 446 # define MF_NOFOLDCASE 00010 /* don't fold case in keys */ 447 # define MF_MATCHONLY 00020 /* don't use the map value */ 448 /* 449 ** Symbol table definitions 450 */ 451 452 struct symtab 453 { 454 char *s_name; /* name to be entered */ 455 char s_type; /* general type (see below) */ 456 struct symtab *s_next; /* pointer to next in chain */ 457 union 458 { 459 BITMAP sv_class; /* bit-map of word classes */ 460 ADDRESS *sv_addr; /* pointer to address header */ 461 MAILER *sv_mailer; /* pointer to mailer */ 462 char *sv_alias; /* alias */ 463 MAPCLASS sv_mapclass; /* mapping function class */ 464 MAP sv_map; /* mapping function */ 465 char *sv_hostsig; /* host signature */ 466 MCI sv_mci; /* mailer connection info */ 467 } s_value; 468 }; 469 470 typedef struct symtab STAB; 471 472 /* symbol types */ 473 # define ST_UNDEF 0 /* undefined type */ 474 # define ST_CLASS 1 /* class map */ 475 # define ST_ADDRESS 2 /* an address in parsed format */ 476 # define ST_MAILER 3 /* a mailer header */ 477 # define ST_ALIAS 4 /* an alias */ 478 # define ST_MAPCLASS 5 /* mapping function class */ 479 # define ST_MAP 6 /* mapping function */ 480 # define ST_HOSTSIG 7 /* host signature */ 481 # define ST_MCI 16 /* mailer connection info (offset) */ 482 483 # define s_class s_value.sv_class 484 # define s_address s_value.sv_addr 485 # define s_mailer s_value.sv_mailer 486 # define s_alias s_value.sv_alias 487 # define s_mci s_value.sv_mci 488 # define s_mapclass s_value.sv_mapclass 489 # define s_hostsig s_value.sv_hostsig 490 # define s_map s_value.sv_map 491 492 extern STAB *stab(); 493 494 /* opcodes to stab */ 495 # define ST_FIND 0 /* find entry */ 496 # define ST_ENTER 1 /* enter if not there */ 497 /* 498 ** STRUCT EVENT -- event queue. 499 ** 500 ** Maintained in sorted order. 501 ** 502 ** We store the pid of the process that set this event to insure 503 ** that when we fork we will not take events intended for the parent. 504 */ 505 506 struct event 507 { 508 time_t ev_time; /* time of the function call */ 509 int (*ev_func)(); /* function to call */ 510 int ev_arg; /* argument to ev_func */ 511 int ev_pid; /* pid that set this event */ 512 struct event *ev_link; /* link to next item */ 513 }; 514 515 typedef struct event EVENT; 516 517 EXTERN EVENT *EventQueue; /* head of event queue */ 518 /* 519 ** Operation, send, and error modes 520 ** 521 ** The operation mode describes the basic operation of sendmail. 522 ** This can be set from the command line, and is "send mail" by 523 ** default. 524 ** 525 ** The send mode tells how to send mail. It can be set in the 526 ** configuration file. It's setting determines how quickly the 527 ** mail will be delivered versus the load on your system. If the 528 ** -v (verbose) flag is given, it will be forced to SM_DELIVER 529 ** mode. 530 ** 531 ** The error mode tells how to return errors. 532 */ 533 534 EXTERN char OpMode; /* operation mode, see below */ 535 536 #define MD_DELIVER 'm' /* be a mail sender */ 537 #define MD_SMTP 's' /* run SMTP on standard input */ 538 #define MD_DAEMON 'd' /* run as a daemon */ 539 #define MD_VERIFY 'v' /* verify: don't collect or deliver */ 540 #define MD_TEST 't' /* test mode: resolve addrs only */ 541 #define MD_INITALIAS 'i' /* initialize alias database */ 542 #define MD_PRINT 'p' /* print the queue */ 543 #define MD_FREEZE 'z' /* freeze the configuration file */ 544 545 546 /* values for e_sendmode -- send modes */ 547 #define SM_DELIVER 'i' /* interactive delivery */ 548 #define SM_QUICKD 'j' /* deliver w/o queueing */ 549 #define SM_FORK 'b' /* deliver in background */ 550 #define SM_QUEUE 'q' /* queue, don't deliver */ 551 #define SM_VERIFY 'v' /* verify only (used internally) */ 552 553 /* used only as a parameter to sendall */ 554 #define SM_DEFAULT '\0' /* unspecified, use SendMode */ 555 556 557 /* values for e_errormode -- error handling modes */ 558 #define EM_PRINT 'p' /* print errors */ 559 #define EM_MAIL 'm' /* mail back errors */ 560 #define EM_WRITE 'w' /* write back errors */ 561 #define EM_BERKNET 'e' /* special berknet processing */ 562 #define EM_QUIET 'q' /* don't print messages (stat only) */ 563 564 /* Offset used to ensure that name server error * codes are unique */ 565 #define MAX_ERRNO 100 566 567 /* privacy flags */ 568 #define PRIV_PUBLIC 0 /* what have I got to hide? */ 569 #define PRIV_NEEDMAILHELO 00001 /* insist on HELO for MAIL, at least */ 570 #define PRIV_NEEDEXPNHELO 00002 /* insist on HELO for EXPN */ 571 #define PRIV_NEEDVRFYHELO 00004 /* insist on HELO for VRFY */ 572 #define PRIV_NOEXPN 00010 /* disallow EXPN command entirely */ 573 #define PRIV_NOVRFY 00020 /* disallow VRFY command entirely */ 574 #define PRIV_RESTRMAILQ 01000 /* restrict mailq command */ 575 #define PRIV_GOAWAY 00777 /* don't give no info, anyway, anyhow */ 576 577 /* struct defining such things */ 578 struct prival 579 { 580 char *pv_name; /* name of privacy flag */ 581 int pv_flag; /* numeric level */ 582 }; 583 584 /* 585 ** Regular UNIX sockaddrs are too small to handle ISO addresses, so 586 ** we are forced to declare a supertype here. 587 */ 588 589 struct bigsockaddr 590 { 591 u_char sa_len; /* address length */ 592 u_char sa_family; /* address family */ 593 union 594 { 595 char sa_data[256]; /* make sure there's plenty of space */ 596 struct 597 { 598 u_short sin_port; /* INET port */ 599 struct in_addr sin_addr; /* INET address */ 600 } sa_inet; 601 } sa_u; 602 }; 603 604 #define SOCKADDR struct bigsockaddr 605 606 /* 607 ** Global variables. 608 */ 609 610 EXTERN bool FromFlag; /* if set, "From" person is explicit */ 611 EXTERN bool NoAlias; /* if set, don't do any aliasing */ 612 EXTERN bool MeToo; /* send to the sender also */ 613 EXTERN bool IgnrDot; /* don't let dot end messages */ 614 EXTERN bool SaveFrom; /* save leading "From" lines */ 615 EXTERN bool Verbose; /* set if blow-by-blow desired */ 616 EXTERN bool GrabTo; /* if set, get recipients from msg */ 617 EXTERN bool NoReturn; /* don't return letter to sender */ 618 EXTERN bool SuprErrs; /* set if we are suppressing errors */ 619 EXTERN bool HoldErrs; /* only output errors to transcript */ 620 EXTERN bool NoConnect; /* don't connect to non-local mailers */ 621 EXTERN bool SuperSafe; /* be extra careful, even if expensive */ 622 EXTERN bool ForkQueueRuns; /* fork for each job when running the queue */ 623 EXTERN bool AutoRebuild; /* auto-rebuild the alias database as needed */ 624 EXTERN bool CheckAliases; /* parse addresses during newaliases */ 625 EXTERN bool UseNameServer; /* use internet domain name server */ 626 EXTERN bool EightBit; /* try to preserve 8-bit data */ 627 EXTERN int SafeAlias; /* minutes to wait until @:@ in alias file */ 628 EXTERN FILE *InChannel; /* input connection */ 629 EXTERN FILE *OutChannel; /* output connection */ 630 EXTERN uid_t RealUid; /* when Daemon, real uid of caller */ 631 EXTERN gid_t RealGid; /* when Daemon, real gid of caller */ 632 EXTERN uid_t DefUid; /* default uid to run as */ 633 EXTERN gid_t DefGid; /* default gid to run as */ 634 EXTERN char *DefUser; /* default user to run as (from DefUid) */ 635 EXTERN int OldUmask; /* umask when sendmail starts up */ 636 EXTERN int Errors; /* set if errors (local to single pass) */ 637 EXTERN int ExitStat; /* exit status code */ 638 EXTERN int AliasLevel; /* depth of aliasing */ 639 EXTERN int LineNumber; /* line number in current input */ 640 EXTERN int LogLevel; /* level of logging to perform */ 641 EXTERN int FileMode; /* mode on files */ 642 EXTERN int QueueLA; /* load average starting forced queueing */ 643 EXTERN int RefuseLA; /* load average refusing connections are */ 644 EXTERN int CurrentLA; /* current load average */ 645 EXTERN long QueueFactor; /* slope of queue function */ 646 EXTERN time_t QueueIntvl; /* intervals between running the queue */ 647 EXTERN char *AliasFile; /* location of alias file */ 648 EXTERN char *HelpFile; /* location of SMTP help file */ 649 EXTERN char *ErrMsgFile; /* file to prepend to all error messages */ 650 EXTERN char *StatFile; /* location of statistics summary */ 651 EXTERN char *QueueDir; /* location of queue directory */ 652 EXTERN char *FileName; /* name to print on error messages */ 653 EXTERN char *SmtpPhase; /* current phase in SMTP processing */ 654 EXTERN char *MyHostName; /* name of this host for SMTP messages */ 655 EXTERN char *RealHostName; /* name of host we are talking to */ 656 EXTERN SOCKADDR RealHostAddr; /* address of host we are talking to */ 657 EXTERN char *CurHostName; /* current host we are dealing with */ 658 EXTERN jmp_buf TopFrame; /* branch-to-top-of-loop-on-error frame */ 659 EXTERN bool QuickAbort; /* .... but only if we want a quick abort */ 660 EXTERN bool LogUsrErrs; /* syslog user errors (e.g., SMTP RCPT cmd) */ 661 EXTERN int PrivacyFlags; /* privacy flags */ 662 extern char *ConfFile; /* location of configuration file [conf.c] */ 663 extern char *FreezeFile; /* location of frozen memory image [conf.c] */ 664 extern char *PidFile; /* location of proc id file [conf.c] */ 665 extern ADDRESS NullAddress; /* a null (template) address [main.c] */ 666 EXTERN char SpaceSub; /* substitution for <lwsp> */ 667 EXTERN long WkClassFact; /* multiplier for message class -> priority */ 668 EXTERN long WkRecipFact; /* multiplier for # of recipients -> priority */ 669 EXTERN long WkTimeFact; /* priority offset each time this job is run */ 670 EXTERN char *PostMasterCopy; /* address to get errs cc's */ 671 EXTERN int CheckpointInterval; /* queue file checkpoint interval */ 672 EXTERN char *UdbSpec; /* user database source spec [udbexpand.c] */ 673 EXTERN int MaxHopCount; /* number of hops until we give an error */ 674 EXTERN int ConfigLevel; /* config file level -- what does .cf expect? */ 675 EXTERN char *TimeZoneSpec; /* override time zone specification */ 676 EXTERN bool MatchGecos; /* look for user names in gecos field */ 677 EXTERN bool DontPruneRoutes; /* don't prune source routes */ 678 EXTERN int MaxMciCache; /* maximum entries in MCI cache */ 679 EXTERN time_t MciCacheTimeout; /* maximum idle time on connections */ 680 EXTERN char *ForwardPath; /* path to search for .forward files */ 681 EXTERN long MinBlocksFree; /* minimum number of blocks free on queue fs */ 682 EXTERN char *QueueLimitRecipient; /* limit queue runs to this recipient */ 683 EXTERN char *QueueLimitSender; /* limit queue runs to this sender */ 684 EXTERN char *QueueLimitId; /* limit queue runs to this id */ 685 686 687 /* 688 ** Timeouts 689 ** 690 ** Indicated values are the MINIMUM per RFC 1123 section 5.3.2. 691 */ 692 693 EXTERN struct 694 { 695 time_t to_initial; /* initial greeting timeout [5m] */ 696 time_t to_mail; /* MAIL command [5m] */ 697 time_t to_rcpt; /* RCPT command [5m] */ 698 time_t to_datainit; /* DATA initiation [2m] */ 699 time_t to_datablock; /* DATA block [3m] */ 700 time_t to_datafinal; /* DATA completion [10m] */ 701 time_t to_nextcommand; /* next command [5m] */ 702 /* following timeouts are not mentioned in RFC 1123 */ 703 time_t to_rset; /* RSET command */ 704 time_t to_helo; /* HELO command */ 705 time_t to_quit; /* QUIT command */ 706 time_t to_miscshort; /* misc short commands (NOOP, VERB, etc) */ 707 /* following are per message */ 708 time_t to_q_return; /* queue return timeout */ 709 time_t to_q_warning; /* queue warning timeout */ 710 } TimeOuts; 711 712 713 /* 714 ** Trace information 715 */ 716 717 /* trace vector and macros for debugging flags */ 718 EXTERN u_char tTdvect[100]; 719 # define tTd(flag, level) (tTdvect[flag] >= level) 720 # define tTdlevel(flag) (tTdvect[flag]) 721 /* 722 ** Miscellaneous information. 723 */ 724 725 726 727 /* 728 ** Some in-line functions 729 */ 730 731 /* set exit status */ 732 #define setstat(s) { \ 733 if (ExitStat == EX_OK || ExitStat == EX_TEMPFAIL) \ 734 ExitStat = s; \ 735 } 736 737 /* make a copy of a string */ 738 #define newstr(s) strcpy(xalloc(strlen(s) + 1), s) 739 740 #define STRUCTCOPY(s, d) d = s 741 742 743 /* 744 ** Declarations of useful functions 745 */ 746 747 extern ADDRESS *parseaddr(); 748 extern char *xalloc(); 749 extern bool sameaddr(); 750 extern FILE *dfopen(); 751 extern EVENT *setevent(); 752 extern char *sfgets(); 753 extern char *queuename(); 754 extern time_t curtime(); 755 extern bool transienterror(); 756