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