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