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