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