1 /* 2 * Copyright (c) 1998-2013 Proofpoint, Inc. and its suppliers. 3 * All rights reserved. 4 * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. 5 * Copyright (c) 1988, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * By using this file, you agree to the terms and conditions set 9 * forth in the LICENSE file which can be found at the top level of 10 * the sendmail distribution. 11 */ 12 13 /* 14 ** SENDMAIL.H -- MTA-specific definitions for sendmail. 15 */ 16 17 #ifndef _SENDMAIL_H 18 # define _SENDMAIL_H 1 19 20 #ifndef MILTER 21 # define MILTER 1 /* turn on MILTER by default */ 22 #endif 23 24 #ifdef _DEFINE 25 # define EXTERN 26 #else 27 # define EXTERN extern 28 #endif 29 30 #include <unistd.h> 31 32 #include <stddef.h> 33 #include <stdlib.h> 34 #include <stdio.h> 35 #include <ctype.h> 36 #include <setjmp.h> 37 #include <string.h> 38 #include <time.h> 39 40 #include "sendmail/sendmail.h" 41 42 #if STARTTLS 43 # include <openssl/ssl.h> 44 # if _FFR_TLSA_DANE && !defined(DANE) 45 # define DANE _FFR_TLSA_DANE 46 # endif 47 #else /* STARTTLS */ 48 # if DANE 49 # ERROR "DANE set but STARTTLS not defined" 50 # endif 51 # if _FFR_TLS_ALTNAMES 52 # ERROR "_FFR_TLS_ALTNAMES set but STARTTLS not defined" 53 # endif 54 # if _FFR_TLSFB2CLEAR 55 # ERROR "_FFR_TLSFB2CLEAR set but STARTTLS not defined" 56 # endif 57 # if _FFR_TLS_USE_CERTIFICATE_CHAIN_FILE 58 # ERROR "_FFR_TLS_USE_CERTIFICATE_CHAIN_FILE set but STARTTLS not defined" 59 # endif 60 #endif /* STARTTLS */ 61 62 /* profiling? */ 63 #if MONCONTROL 64 # define SM_PROF(x) moncontrol(x) 65 #else 66 # define SM_PROF(x) 67 #endif 68 69 #ifdef _DEFINE 70 # ifndef lint 71 SM_UNUSED(static char SmailId[]) = "@(#)$Id: sendmail.h,v 8.1104 2013-11-22 20:51:56 ca Exp $"; 72 # endif 73 #endif 74 75 #include "bf.h" 76 #include "timers.h" 77 #include <sm/exc.h> 78 #include <sm/gen.h> 79 #include <sm/heap.h> 80 #include <sm/debug.h> 81 #include <sm/rpool.h> 82 #include <sm/io.h> 83 #include <sm/path.h> 84 #include <sm/signal.h> 85 #include <sm/clock.h> 86 #include <sm/mbdb.h> 87 #include <sm/errstring.h> 88 #include <sm/sysexits.h> 89 #include <sm/shm.h> 90 #include <sm/misc.h> 91 92 #ifdef LOG 93 # include <syslog.h> 94 #endif 95 96 #if NETINET || NETINET6 || NETUNIX || NETISO || NETNS || NETX25 97 # include <sys/socket.h> 98 #endif 99 #if NETUNIX 100 # include <sys/un.h> 101 #endif 102 #if NETINET || NETINET6 103 # include <netinet/in.h> 104 #endif 105 #if NETINET6 106 /* 107 ** There is no standard yet for IPv6 includes. 108 ** Specify OS specific implementation in conf.h 109 */ 110 #endif /* NETINET6 */ 111 #if NETISO 112 # include <netiso/iso.h> 113 #endif 114 #if NETNS 115 # include <netns/ns.h> 116 #endif 117 #if NETX25 118 # include <netccitt/x25.h> 119 #endif 120 121 #if NAMED_BIND 122 # include <arpa/nameser.h> 123 # ifdef NOERROR 124 # undef NOERROR /* avoid <sys/streams.h> conflict */ 125 # endif 126 # include <resolv.h> 127 #else /* NAMED_BIND */ 128 # undef SM_SET_H_ERRNO 129 # define SM_SET_H_ERRNO(err) 130 #endif /* NAMED_BIND */ 131 132 #if HESIOD 133 # include <hesiod.h> 134 # if !defined(HES_ER_OK) || defined(HESIOD_INTERFACES) 135 # define HESIOD_INIT /* support for the new interface */ 136 # endif 137 #endif /* HESIOD */ 138 139 #if USE_EAI && !defined(ALLOW_255) 140 # define ALLOW_255 1 141 #endif 142 #if _FFR_EAI && _FFR_EIGHT_BIT_ADDR_OK 143 # ERROR "Cannot enable both of these FFRs: _FFR_EAI _FFR_EIGHT_BIT_ADDR_OK" 144 #endif 145 146 #if _FFR_OCC && !SM_CONF_SHM 147 # ERROR "_FFR_OCC requires SM_CONF_SHM" 148 #endif 149 150 #if _FFR_SM_LDAP_DBG && !(LDAPMAP && defined(LBER_OPT_LOG_PRINT_FN)) 151 # ERROR "_FFR_SM_LDAP_DBG requires LDAPMAP and LBER_OPT_LOG_PRINT_FN" 152 #endif 153 154 #if _FFR_LOG_MORE1 > 1 || _FFR_LOG_MORE2 > 1 155 # if _FFR_LOG_MORE1 != _FFR_LOG_MORE2 156 # ERROR "_FFR_LOG_MORE1 != _FFR_LOG_MORE2" 157 # endif 158 #endif 159 160 #if LDAP_NETWORK_TIMEOUT && !(LDAPMAP && defined(LDAP_OPT_NETWORK_TIMEOUT)) 161 # ERROR "LDAP_NETWORK_TIMEOUT requires LDAPMAP" 162 #endif 163 164 #if _FFR_VRFY_TRUSTED_FIRST && !defined(X509_V_FLAG_TRUSTED_FIRST) 165 # ERROR "_FFR_VRFY_TRUSTED_FIRST set but X509_V_FLAG_TRUSTED_FIRST not defined" 166 #endif 167 168 #if _FFR_8BITENVADDR 169 # define MAXNAME_I ((MAXNAME) * 2) 170 #else 171 # define MAXNAME_I MAXNAME 172 #endif 173 174 #define SM_IS_EMPTY(s) (NULL == (s) || '\0' == *(s)) 175 176 #if STARTTLS 177 # if DANE 178 struct dane_vrfy_ctx_S 179 { 180 int dane_vrfy_chk; 181 int dane_vrfy_res; 182 int dane_vrfy_port; 183 184 /* look up TLSA RRs, SNI unless dane_tlsa_sni is set. */ 185 char *dane_vrfy_host; 186 char *dane_vrfy_sni; /* if not NULL: use for SNI */ 187 188 /* full fingerprint in printable format */ 189 char dane_vrfy_fp[1024]; 190 }; 191 192 typedef struct dane_tlsa_S dane_tlsa_T, *dane_tlsa_P; 193 typedef struct dane_vrfy_ctx_S dane_vrfy_ctx_T, *dane_vrfy_ctx_P; 194 # endif /* DANE */ 195 196 /* TLS information context */ 197 struct tlsi_ctx_S 198 { 199 /* use unsigned long? */ 200 BITMAP256 tlsi_flags; 201 # if DANE 202 dane_vrfy_ctx_T tlsi_dvc; 203 # endif 204 }; 205 typedef struct tlsi_ctx_S tlsi_ctx_T, *tlsi_ctx_P; 206 207 /* TLS information context flags */ 208 #define TLSI_FL_CRLREQ 'R' /* CRL required */ 209 #define TLSI_FL_FB2CLR 'C' /* fall back to clear text is ok */ 210 #define TLSI_FL_NOFB2CLR 'c' /* do not fall back to clear text */ 211 #define TLSI_FL_NODANE 'd' /* do not use/lookup DANE */ 212 #define TLSI_FL_NOSTS 'M' /* do not use/lookup STS */ 213 /* internal */ 214 #define TLSI_FL_STS_NOFB2CLR 0x01 /* no clear text: STS is used */ 215 #define SM_TLSI_IS(tlsi_ctx, flag) \ 216 (((tlsi_ctx) != NULL) && bitnset((flag), (tlsi_ctx)->tlsi_flags)) 217 218 /* ugly hack, is it worth using different values? */ 219 # if _FFR_LOG_MORE1 > 1 || _FFR_LOG_MORE2 > 1 220 # define LOG_MORE_2(buf, bp) \ 221 p = macvalue(macid("{tls_version}"), e); \ 222 if (SM_IS_EMPTY(p)) \ 223 p = "NONE"; \ 224 (void) sm_snprintf(bp, SPACELEFT(buf, bp), ", tls_version=%.10s", p); \ 225 bp += strlen(bp); \ 226 p = macvalue(macid("{cipher}"), e); \ 227 if (SM_IS_EMPTY(p)) \ 228 p = "NONE"; \ 229 (void) sm_snprintf(bp, SPACELEFT(buf, bp), ", cipher=%.20s", p); \ 230 bp += strlen(bp); 231 # else 232 # define LOG_MORE_2(buf, bp) 233 # endif 234 235 # define LOG_MORE(buf, bp) \ 236 p = macvalue(macid("{verify}"), e); \ 237 if (SM_IS_EMPTY(p)) \ 238 p = "NONE"; \ 239 (void) sm_snprintf(bp, SPACELEFT(buf, bp), ", tls_verify=%.20s", p); \ 240 bp += strlen(bp); \ 241 LOG_MORE_2(buf, bp) 242 243 #else 244 # define LOG_MORE(buf, bp) 245 #endif /* STARTTLS */ 246 247 #if SASL 248 /* include the sasl include files if we have them */ 249 # if SASL == 2 || SASL >= 20000 250 # include <sasl/sasl.h> 251 # include <sasl/saslplug.h> 252 # include <sasl/saslutil.h> 253 # if SASL_VERSION_FULL < 0x020119 254 typedef int (*sasl_callback_ft)(void); 255 # endif 256 # else /* SASL == 2 || SASL >= 20000 */ 257 # include <sasl.h> 258 # include <saslutil.h> 259 typedef int (*sasl_callback_ft)(void); 260 # endif /* SASL == 2 || SASL >= 20000 */ 261 # if defined(SASL_VERSION_MAJOR) && defined(SASL_VERSION_MINOR) && defined(SASL_VERSION_STEP) 262 # define SASL_VERSION (SASL_VERSION_MAJOR * 10000) + (SASL_VERSION_MINOR * 100) + SASL_VERSION_STEP 263 # if SASL == 1 || SASL == 2 264 # undef SASL 265 # define SASL SASL_VERSION 266 # else /* SASL == 1 || SASL == 2 */ 267 # if SASL != SASL_VERSION 268 # ERROR "README: -DSASL (SASL) does not agree with the version of the CYRUS_SASL library (SASL_VERSION)" 269 # ERROR "README: see README!" 270 # endif /* SASL != SASL_VERSION */ 271 # endif /* SASL == 1 || SASL == 2 */ 272 # else /* defined(SASL_VERSION_MAJOR) && defined(SASL_VERSION_MINOR) && defined(SASL_VERSION_STEP) */ 273 # if SASL == 1 274 # ERROR "README: please set -DSASL to the version of the CYRUS_SASL library" 275 # ERROR "README: see README!" 276 # endif /* SASL == 1 */ 277 # endif /* defined(SASL_VERSION_MAJOR) && defined(SASL_VERSION_MINOR) && defined(SASL_VERSION_STEP) */ 278 #endif /* SASL */ 279 280 /* 281 ** Following are "sort of" configuration constants, but they should 282 ** be pretty solid on most architectures today. They have to be 283 ** defined after <arpa/nameser.h> because some versions of that 284 ** file also define them. In all cases, we can't use sizeof because 285 ** some systems (e.g., Crays) always treat everything as being at 286 ** least 64 bits. 287 */ 288 289 #ifndef INADDRSZ 290 # define INADDRSZ 4 /* size of an IPv4 address in bytes */ 291 #endif 292 #ifndef IN6ADDRSZ 293 # define IN6ADDRSZ 16 /* size of an IPv6 address in bytes */ 294 #endif 295 #ifndef INT16SZ 296 # define INT16SZ 2 /* size of a 16 bit integer in bytes */ 297 #endif 298 #ifndef INT32SZ 299 # define INT32SZ 4 /* size of a 32 bit integer in bytes */ 300 #endif 301 #ifndef INADDR_LOOPBACK 302 # define INADDR_LOOPBACK 0x7f000001 /* loopback address */ 303 #endif 304 305 /* 306 ** Error return from inet_addr(3), in case not defined in /usr/include. 307 */ 308 309 #ifndef INADDR_NONE 310 # define INADDR_NONE 0xffffffff 311 #endif 312 313 /* By default use uncompressed IPv6 address format (no "::") */ 314 #ifndef IPV6_FULL 315 # define IPV6_FULL 1 316 #endif 317 318 /* (f)open() modes for queue files */ 319 #define QF_O_EXTRA 0 320 321 #define SM_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) 322 323 /* 324 ** An 'argument class' describes the storage allocation status 325 ** of an object pointed to by an argument to a function. 326 */ 327 328 typedef enum 329 { 330 A_HEAP, /* the storage was allocated by malloc, and the 331 * ownership of the storage is ceded by the caller 332 * to the called function. */ 333 A_TEMP, /* The storage is temporary, and is only guaranteed 334 * to be valid for the duration of the function call. */ 335 A_PERM /* The storage is 'permanent': this might mean static 336 * storage, or rpool storage. */ 337 } ARGCLASS_T; 338 339 /* forward references for prototypes */ 340 typedef struct envelope ENVELOPE; 341 typedef struct mailer MAILER; 342 typedef struct queuegrp QUEUEGRP; 343 344 /* 345 ** Address structure. 346 ** Addresses are stored internally in this structure. 347 */ 348 349 struct address 350 { 351 char *q_paddr; /* the printname for the address */ 352 char *q_user; /* user name */ 353 char *q_ruser; /* real user name, or NULL if q_user */ 354 char *q_host; /* host name */ 355 #if DANE 356 char *q_qname; /* original query (host) name */ 357 #endif 358 struct mailer *q_mailer; /* mailer to use */ 359 unsigned long q_flags; /* status flags, see below */ 360 uid_t q_uid; /* user-id of receiver (if known) */ 361 gid_t q_gid; /* group-id of receiver (if known) */ 362 char *q_home; /* home dir (local mailer only) */ 363 char *q_fullname; /* full name if known */ 364 struct address *q_next; /* chain */ 365 struct address *q_alias; /* address this results from */ 366 char *q_owner; /* owner of q_alias */ 367 struct address *q_tchain; /* temporary use chain */ 368 #if PIPELINING 369 struct address *q_pchain; /* chain for pipelining */ 370 #endif 371 char *q_finalrcpt; /* Final-Recipient: DSN header */ 372 char *q_orcpt; /* ORCPT parameter from RCPT TO: line */ 373 char *q_status; /* status code for DSNs */ 374 char *q_rstatus; /* remote status message for DSNs */ 375 time_t q_statdate; /* date of status messages */ 376 char *q_statmta; /* MTA generating q_rstatus */ 377 short q_state; /* address state, see below */ 378 char *q_signature; /* MX-based sorting value */ 379 int q_qgrp; /* index into queue groups */ 380 char *q_message; /* error message */ 381 }; 382 383 typedef struct address ADDRESS; 384 385 /* bit values for q_flags */ 386 #define QGOODUID 0x00000001 /* the q_uid q_gid fields are good */ 387 #define QPRIMARY 0x00000002 /* set from RCPT or argv */ 388 #define QNOTREMOTE 0x00000004 /* address not for remote forwarding */ 389 #define QSELFREF 0x00000008 /* this address references itself */ 390 #define QBOGUSSHELL 0x00000010 /* user has no valid shell listed */ 391 #define QUNSAFEADDR 0x00000020 /* address acquired via unsafe path */ 392 #define QPINGONSUCCESS 0x00000040 /* give return on successful delivery */ 393 #define QPINGONFAILURE 0x00000080 /* give return on failure */ 394 #define QPINGONDELAY 0x00000100 /* give return on message delay */ 395 #define QHASNOTIFY 0x00000200 /* propagate notify parameter */ 396 #define QRELAYED 0x00000400 /* DSN: relayed to non-DSN aware sys */ 397 #define QEXPANDED 0x00000800 /* DSN: undergone list expansion */ 398 #define QDELIVERED 0x00001000 /* DSN: successful final delivery */ 399 #define QDELAYED 0x00002000 /* DSN: message delayed */ 400 #define QALIAS 0x00004000 /* expanded alias */ 401 #define QBYTRACE 0x00008000 /* DeliverBy: trace */ 402 #define QBYNDELAY 0x00010000 /* DeliverBy: notify, delay */ 403 #define QBYNRELAY 0x00020000 /* DeliverBy: notify, relayed */ 404 #define QINTBCC 0x00040000 /* internal Bcc */ 405 #define QDYNMAILER 0x00080000 /* "dynamic mailer" */ 406 #define QSECURE 0x00100000 /* DNSSEC ok */ 407 #define QQUEUED 0x00200000 /* queued */ 408 #define QINTREPLY 0x00400000 /* internally rejected (delivery) */ 409 #define QTHISPASS 0x40000000 /* temp: address set this pass */ 410 #define QRCPTOK 0x80000000 /* recipient() processed address */ 411 412 #define QDYNMAILFLG 'Y' 413 414 #define Q_PINGFLAGS (QPINGONSUCCESS|QPINGONFAILURE|QPINGONDELAY) 415 416 #if _FFR_RCPTFLAGS 417 # define QMATCHFLAGS (QINTBCC|QDYNMAILER) 418 # define QMATCH_FLAG(a) ((a)->q_flags & QMATCHFLAGS) 419 # define ADDR_FLAGS_MATCH(a, b) (QMATCH_FLAG(a) == QMATCH_FLAG(b)) 420 #else 421 # define ADDR_FLAGS_MATCH(a, b) true 422 #endif 423 424 /* values for q_state */ 425 #define QS_OK 0 /* address ok (for now)/not yet tried */ 426 #define QS_SENT 1 /* good address, delivery complete */ 427 #define QS_BADADDR 2 /* illegal address */ 428 #define QS_QUEUEUP 3 /* save address in queue */ 429 #define QS_RETRY 4 /* retry delivery for next MX */ 430 #define QS_VERIFIED 5 /* verified, but not expanded */ 431 432 /* 433 ** Notice: all of the following values are variations of QS_DONTSEND. 434 ** If new states are added, they must be inserted in the proper place! 435 ** See the macro definition of QS_IS_DEAD() down below. 436 */ 437 438 #define QS_DONTSEND 6 /* don't send to this address */ 439 #define QS_EXPANDED 7 /* expanded */ 440 #define QS_SENDER 8 /* message sender (MeToo) */ 441 #define QS_CLONED 9 /* addr cloned to split envelope */ 442 #define QS_DISCARDED 10 /* rcpt discarded (EF_DISCARD) */ 443 #define QS_REPLACED 11 /* maplocaluser()/UserDB replaced */ 444 #define QS_REMOVED 12 /* removed (removefromlist()) */ 445 #define QS_DUPLICATE 13 /* duplicate suppressed */ 446 #define QS_INCLUDED 14 /* :include: delivery */ 447 #define QS_FATALERR 15 /* fatal error, don't deliver */ 448 449 /* address state testing primitives */ 450 #define QS_IS_OK(s) ((s) == QS_OK) 451 #define QS_IS_SENT(s) ((s) == QS_SENT) 452 #define QS_IS_BADADDR(s) ((s) == QS_BADADDR) 453 #define QS_IS_QUEUEUP(s) ((s) == QS_QUEUEUP) 454 #define QS_IS_RETRY(s) ((s) == QS_RETRY) 455 #define QS_IS_VERIFIED(s) ((s) == QS_VERIFIED) 456 #define QS_IS_EXPANDED(s) ((s) == QS_EXPANDED) 457 #define QS_IS_REMOVED(s) ((s) == QS_REMOVED) 458 #define QS_IS_UNDELIVERED(s) ((s) == QS_OK || \ 459 (s) == QS_QUEUEUP || \ 460 (s) == QS_RETRY || \ 461 (s) == QS_VERIFIED) 462 #define QS_IS_UNMARKED(s) ((s) == QS_OK || \ 463 (s) == QS_RETRY) 464 #define QS_IS_SENDABLE(s) ((s) == QS_OK || \ 465 (s) == QS_QUEUEUP || \ 466 (s) == QS_RETRY) 467 #define QS_IS_ATTEMPTED(s) ((s) == QS_QUEUEUP || \ 468 (s) == QS_RETRY || \ 469 (s) == QS_SENT || \ 470 (s) == QS_DISCARDED) 471 #define QS_IS_DEAD(s) ((s) >= QS_DONTSEND) 472 #define QS_IS_TEMPFAIL(s) ((s) == QS_QUEUEUP || (s) == QS_RETRY) 473 474 #define QUP_FL_NONE 0x0000 475 #define QUP_FL_ANNOUNCE 0x0001 476 #define QUP_FL_MSYNC 0x0002 477 #define QUP_FL_UNLOCK 0x0004 478 479 #define NULLADDR ((ADDRESS *) NULL) 480 481 extern ADDRESS NullAddress; /* a null (template) address [main.c] */ 482 483 /* for cataddr() */ 484 #define NOSPACESEP 256 485 486 /* functions */ 487 extern void cataddr __P((char **, char **, char *, int, int, bool)); 488 extern char *crackaddr __P((char *, ENVELOPE *)); 489 extern bool emptyaddr __P((ADDRESS *)); 490 extern ADDRESS *getctladdr __P((ADDRESS *)); 491 extern int include __P((char *, bool, ADDRESS *, ADDRESS **, int, ENVELOPE *)); 492 extern bool invalidaddr __P((char *, char *, bool)); 493 extern ADDRESS *parseaddr __P((char *, ADDRESS *, int, int, char **, 494 ENVELOPE *, bool)); 495 extern char **prescan __P((char *, int, char[], int, char **, unsigned char *, bool)); 496 extern void printaddr __P((SM_FILE_T *, ADDRESS *, bool)); 497 extern ADDRESS *recipient __P((ADDRESS *, ADDRESS **, int, ENVELOPE *)); 498 extern char *remotename __P((char *, MAILER *, int, int *, ENVELOPE *)); 499 extern int rewrite __P((char **, int, int, ENVELOPE *, int)); 500 extern bool sameaddr __P((ADDRESS *, ADDRESS *)); 501 extern int sendtolist __P((char *, ADDRESS *, ADDRESS **, int, ENVELOPE *)); 502 #if MILTER 503 extern int removefromlist __P((char *, ADDRESS **, ENVELOPE *)); 504 #endif 505 extern void setsender __P((char *, ENVELOPE *, char **, int, bool)); 506 typedef void esmtp_args_F __P((ADDRESS *, char *, char *, ENVELOPE *)); 507 extern void parse_esmtp_args __P((ENVELOPE *, ADDRESS *, char *, char *, 508 char *, char *args[], esmtp_args_F)); 509 extern esmtp_args_F mail_esmtp_args; 510 extern esmtp_args_F rcpt_esmtp_args; 511 extern void reset_mail_esmtp_args __P((ENVELOPE *)); 512 513 /* macro to simplify the common call to rewrite() */ 514 #define REWRITE(pvp, rs, env) rewrite(pvp, rs, 0, env, MAXATOM) 515 516 /* 517 ** Token Tables for prescan 518 */ 519 520 extern unsigned char ExtTokenTab[256]; /* external strings */ 521 extern unsigned char IntTokenTab[256]; /* internal strings */ 522 523 524 /* 525 ** Mailer definition structure. 526 ** Every mailer known to the system is declared in this 527 ** structure. It defines the pathname of the mailer, some 528 ** flags associated with it, and the argument vector to 529 ** pass to it. The flags are defined in conf.c 530 ** 531 ** The argument vector is expanded before actual use. All 532 ** words except the first are passed through the macro 533 ** processor. 534 */ 535 536 struct mailer 537 { 538 char *m_name; /* symbolic name of this mailer */ 539 char *m_mailer; /* pathname of the mailer to use */ 540 char *m_mtatype; /* type of this MTA */ 541 char *m_addrtype; /* type for addresses */ 542 char *m_diagtype; /* type for diagnostics */ 543 BITMAP256 m_flags; /* status flags, see below */ 544 short m_mno; /* mailer number internally */ 545 short m_nice; /* niceness to run at (mostly for prog) */ 546 char **m_argv; /* template argument vector */ 547 short m_sh_rwset; /* rewrite set: sender header addresses */ 548 short m_se_rwset; /* rewrite set: sender envelope addresses */ 549 short m_rh_rwset; /* rewrite set: recipient header addresses */ 550 short m_re_rwset; /* rewrite set: recipient envelope addresses */ 551 char *m_eol; /* end of line string */ 552 long m_maxsize; /* size limit on message to this mailer */ 553 int m_linelimit; /* max # characters per line */ 554 int m_maxdeliveries; /* max deliveries per mailer connection */ 555 char *m_execdir; /* directory to chdir to before execv */ 556 char *m_rootdir; /* directory to chroot to before execv */ 557 uid_t m_uid; /* UID to run as */ 558 gid_t m_gid; /* GID to run as */ 559 char *m_defcharset; /* default character set */ 560 time_t m_wait; /* timeout to wait for end */ 561 int m_maxrcpt; /* max recipients per envelope client-side */ 562 short m_qgrp; /* queue group for this mailer */ 563 #if DANE 564 unsigned short m_port; /* port (if appropriate for mailer) */ 565 #endif 566 }; 567 568 /* bits for m_flags */ 569 #define M_xSMTP 0x01 /* internal: {ES,S,L}MTP */ 570 #define M_ESMTP 'a' /* run Extended SMTP */ 571 #define M_ALIASABLE 'A' /* user can be LHS of an alias */ 572 #define M_BLANKEND 'b' /* ensure blank line at end of message */ 573 #define M_STRIPBACKSL 'B' /* strip all leading backslashes from user */ 574 #define M_NOCOMMENT 'c' /* don't include comment part of address */ 575 #define M_CANONICAL 'C' /* make addresses canonical "u@dom" */ 576 #define M_NOBRACKET 'd' /* never angle bracket envelope route-addrs */ 577 /* 'D' CF: include Date: */ 578 #define M_EXPENSIVE 'e' /* it costs to use this mailer.... */ 579 #define M_ESCFROM 'E' /* escape From lines to >From */ 580 #define M_FOPT 'f' /* mailer takes picky -f flag */ 581 /* 'F' CF: include From: or Resent-From: */ 582 #define M_NO_NULL_FROM 'g' /* sender of errors should be $g */ 583 #define M_HST_UPPER 'h' /* preserve host case distinction */ 584 #define M_PREHEAD 'H' /* MAIL11V3: preview headers */ 585 #define M_UDBENVELOPE 'i' /* do udbsender rewriting on envelope */ 586 #define M_INTERNAL 'I' /* SMTP to another sendmail site */ 587 #define M_UDBRECIPIENT 'j' /* do udbsender rewriting on recipient lines */ 588 #define M_NOLOOPCHECK 'k' /* don't check for loops in HELO command */ 589 #define M_CHUNKING 'K' /* CHUNKING: reserved for future use */ 590 #define M_LOCALMAILER 'l' /* delivery is to this host */ 591 #define M_LIMITS 'L' /* must enforce SMTP line limits */ 592 #define M_MUSER 'm' /* can handle multiple users at once */ 593 /* 'M' CF: include Message-Id: */ 594 #define M_NHDR 'n' /* don't insert From line */ 595 #define M_MANYSTATUS 'N' /* MAIL11V3: DATA returns multi-status */ 596 #define M_RUNASRCPT 'o' /* always run mailer as recipient */ 597 /* 'O' free? */ 598 #define M_FROMPATH 'p' /* use reverse-path in MAIL FROM: */ 599 /* 'P' CF: include Return-Path: */ 600 #define M_VRFY250 'q' /* VRFY command returns 250 instead of 252 */ 601 #define M_ROPT 'r' /* mailer takes picky -r flag */ 602 #define M_SECURE_PORT 'R' /* try to send on a reserved TCP port */ 603 #define M_STRIPQ 's' /* strip quote chars from user/host */ 604 #define M_SPECIFIC_UID 'S' /* run as specific uid/gid */ 605 #define M_USR_UPPER 'u' /* preserve user case distinction */ 606 #define M_UGLYUUCP 'U' /* this wants an ugly UUCP from line */ 607 #define M_CONTENT_LEN 'v' /* add Content-Length: header (SVr4) */ 608 /* 'V' UIUC: !-relativize all addresses */ 609 #define M_HASPWENT 'w' /* check for /etc/passwd entry */ 610 #define M_NOHOSTSTAT 'W' /* ignore long term host status information */ 611 /* 'x' CF: include Full-Name: */ 612 #define M_XDOT 'X' /* use hidden-dot algorithm */ 613 /* 'y' free? */ 614 /* 'Y' free? */ 615 #define M_LMTP 'z' /* run Local Mail Transport Protocol */ 616 #define M_DIALDELAY 'Z' /* apply dial delay sleeptime */ 617 #define M_NOMX '0' /* turn off MX lookups */ 618 #define M_NONULLS '1' /* don't send null bytes */ 619 #define M_FSMTP '2' /* force SMTP (no ESMTP even if offered) */ 620 /* '4' free? */ 621 #define M_EBCDIC '3' /* extend Q-P encoding for EBCDIC */ 622 #define M_TRYRULESET5 '5' /* use ruleset 5 after local aliasing */ 623 #define M_7BITHDRS '6' /* strip headers to 7 bits even in 8 bit path */ 624 #define M_7BITS '7' /* use 7-bit path */ 625 #define M_8BITS '8' /* force "just send 8" behaviour */ 626 #define M_MAKE8BIT '9' /* convert 7 -> 8 bit if appropriate */ 627 #define M_CHECKINCLUDE ':' /* check for :include: files */ 628 #define M_CHECKPROG '|' /* check for |program addresses */ 629 #define M_CHECKFILE '/' /* check for /file addresses */ 630 #define M_CHECKUDB '@' /* user can be user database key */ 631 #define M_CHECKHDIR '~' /* SGI: check for valid home directory */ 632 #define M_HOLD '%' /* Hold delivery until ETRN/-qI/-qR/-qS */ 633 #define M_PLUS '+' /* Reserved: Used in mc for adding new flags */ 634 #define M_MINUS '-' /* Reserved: Used in mc for removing flags */ 635 #define M_NOMHHACK '!' /* Don't perform HM hack dropping explicit from */ 636 637 /* functions */ 638 extern void initerrmailers __P((void)); 639 extern void makemailer __P((char *)); 640 extern void makequeue __P((char *, bool)); 641 extern void runqueueevent __P((int)); 642 #if _FFR_QUEUE_RUN_PARANOIA 643 extern bool checkqueuerunner __P((void)); 644 #endif 645 646 EXTERN MAILER *FileMailer; /* ptr to *file* mailer */ 647 EXTERN MAILER *InclMailer; /* ptr to *include* mailer */ 648 EXTERN MAILER *LocalMailer; /* ptr to local mailer */ 649 EXTERN MAILER *ProgMailer; /* ptr to program mailer */ 650 #if _FFR_RCPTFLAGS 651 EXTERN MAILER *Mailer[MAXMAILERS * 2 + 1]; 652 #else 653 EXTERN MAILER *Mailer[MAXMAILERS + 1]; 654 #endif 655 656 /* 657 ** Queue group definition structure. 658 ** Every queue group known to the system is declared in this structure. 659 ** It defines the basic pathname of the queue group, some flags 660 ** associated with it, and the argument vector to pass to it. 661 */ 662 663 struct qpaths_s 664 { 665 char *qp_name; /* name of queue dir, relative path */ 666 short qp_subdirs; /* use subdirs? */ 667 short qp_fsysidx; /* file system index of this directory */ 668 #if SM_CONF_SHM 669 int qp_idx; /* index into array for queue information */ 670 #endif 671 }; 672 673 typedef struct qpaths_s QPATHS; 674 675 struct queuegrp 676 { 677 char *qg_name; /* symbolic name of this queue group */ 678 679 /* 680 ** For now this is the same across all queue groups. 681 ** Otherwise we have to play around with chdir(). 682 */ 683 684 char *qg_qdir; /* common component of queue directory */ 685 short qg_index; /* queue number internally, index in Queue[] */ 686 int qg_maxqrun; /* max # of jobs in one queuerun */ 687 int qg_numqueues; /* number of queues in this queue group */ 688 689 /* 690 ** qg_queueintvl == 0 denotes that no individual value is used. 691 ** Whatever accesses this must deal with "<= 0" as 692 ** "not set, use appropriate default". 693 */ 694 695 time_t qg_queueintvl; /* interval for queue runs */ 696 QPATHS *qg_qpaths; /* list of queue directories */ 697 BITMAP256 qg_flags; /* status flags, see below */ 698 short qg_nice; /* niceness for queue run */ 699 int qg_wgrp; /* Assigned to this work group */ 700 int qg_maxlist; /* max items in work queue for this group */ 701 int qg_curnum; /* current number of queue for queue runs */ 702 int qg_maxrcpt; /* max recipients per envelope, 0==no limit */ 703 704 time_t qg_nextrun; /* time for next queue runs */ 705 #if _FFR_QUEUE_GROUP_SORTORDER 706 short qg_sortorder; /* how do we sort this queuerun */ 707 #endif 708 #if 0 709 long qg_wkrcptfact; /* multiplier for # recipients -> priority */ 710 long qg_qfactor; /* slope of queue function */ 711 bool qg_doqueuerun; /* XXX flag is it time to do a queuerun */ 712 #endif /* 0 */ 713 }; 714 715 /* bits for qg_flags */ 716 #define QD_DEFINED ((char) 1) /* queue group has been defined */ 717 #define QD_FORK 'f' /* fork queue runs */ 718 719 extern void filesys_update __P((void)); 720 #if _FFR_ANY_FREE_FS 721 extern bool filesys_free __P((long)); 722 #endif 723 724 #if SASL 725 /* 726 ** SASL 727 */ 728 729 /* lines in authinfo file or index into SASL_AI_T */ 730 # define SASL_WRONG (-1) 731 # define SASL_USER 0 /* authorization id (user) */ 732 # define SASL_AUTHID 1 /* authentication id */ 733 # define SASL_PASSWORD 2 /* password fuer authid */ 734 # define SASL_DEFREALM 3 /* realm to use */ 735 # define SASL_MECHLIST 4 /* list of mechanisms to try */ 736 # define SASL_ID_REALM 5 /* authid@defrealm */ 737 738 /* 739 ** Current mechanism; this is just used to convey information between 740 ** invocation of SASL callback functions. 741 ** It must be last in the list, because it's not allocated by us 742 ** and hence we don't free() it. 743 */ 744 # define SASL_MECH 6 745 # define SASL_ENTRIES 7 /* number of entries in array */ 746 747 # define SASL_USER_BIT (1 << SASL_USER) 748 # define SASL_AUTHID_BIT (1 << SASL_AUTHID) 749 # define SASL_PASSWORD_BIT (1 << SASL_PASSWORD) 750 # define SASL_DEFREALM_BIT (1 << SASL_DEFREALM) 751 # define SASL_MECHLIST_BIT (1 << SASL_MECHLIST) 752 753 /* authenticated? */ 754 # define SASL_NOT_AUTH 0 /* not authenticated */ 755 # define SASL_PROC_AUTH 1 /* in process of authenticating */ 756 # define SASL_IS_AUTH 2 /* authenticated */ 757 758 /* SASL options */ 759 # define SASL_AUTH_AUTH 0x10000 /* use auth= only if authenticated */ 760 # if SASL >= 20101 761 # define SASL_SEC_MASK SASL_SEC_MAXIMUM /* mask for SASL_SEC_* values: sasl.h */ 762 # else /* SASL >= 20101 */ 763 # define SASL_SEC_MASK 0x0fff /* mask for SASL_SEC_* values: sasl.h */ 764 # if (SASL_SEC_NOPLAINTEXT & SASL_SEC_MASK) == 0 || \ 765 (SASL_SEC_NOACTIVE & SASL_SEC_MASK) == 0 || \ 766 (SASL_SEC_NODICTIONARY & SASL_SEC_MASK) == 0 || \ 767 (SASL_SEC_FORWARD_SECRECY & SASL_SEC_MASK) == 0 || \ 768 (SASL_SEC_NOANONYMOUS & SASL_SEC_MASK) == 0 || \ 769 (SASL_SEC_PASS_CREDENTIALS & SASL_SEC_MASK) == 0 770 # ERROR "change SASL_SEC_MASK notify sendmail.org!" 771 # endif /* SASL_SEC_NOPLAINTEXT & SASL_SEC_MASK) == 0 ... */ 772 # endif /* SASL >= 20101 */ 773 # define MAXOUTLEN 8192 /* length of output buffer, should be 2^n */ 774 # if (SASL_AUTH_AUTH & SASL_SEC_MASK) != 0 775 # ERROR "change SASL_AUTH_AUTH notify sendmail.org!" 776 # endif 777 778 /* functions */ 779 extern char *intersect __P((char *, char *, SM_RPOOL_T *)); 780 extern char *iteminlist __P((char *, char *, char *)); 781 # if SASL >= 20000 782 extern int proxy_policy __P((sasl_conn_t *, void *, const char *, unsigned, const char *, unsigned, const char *, unsigned, struct propctx *)); 783 extern int safesaslfile __P((void *, const char *, sasl_verify_type_t)); 784 # else /* SASL >= 20000 */ 785 extern int proxy_policy __P((void *, const char *, const char *, const char **, const char **)); 786 # if SASL > 10515 787 extern int safesaslfile __P((void *, char *, int)); 788 # else /* SASL > 10515 */ 789 extern int safesaslfile __P((void *, char *)); 790 # endif /* SASL > 10515 */ 791 # endif /* SASL >= 20000 */ 792 extern void stop_sasl_client __P((void)); 793 794 /* structure to store authinfo */ 795 typedef char *SASL_AI_T[SASL_ENTRIES]; 796 797 EXTERN char *AuthMechanisms; /* AUTH mechanisms */ 798 EXTERN char *AuthRealm; /* AUTH realm */ 799 EXTERN char *SASLInfo; /* file with AUTH info */ 800 EXTERN int SASLOpts; /* options for SASL */ 801 EXTERN int MaxSLBits; /* max. encryption bits for SASL */ 802 #endif /* SASL */ 803 804 /* 805 ** Structure to store macros. 806 */ 807 typedef struct 808 { 809 SM_RPOOL_T *mac_rpool; /* resource pool */ 810 BITMAP256 mac_allocated; /* storage has been alloc()? */ 811 char *mac_table[MAXMACROID + 1]; /* macros */ 812 } MACROS_T; 813 814 EXTERN MACROS_T GlobalMacros; 815 816 /* 817 ** Information about currently open connections to mailers, or to 818 ** hosts that we have looked up recently. 819 */ 820 821 #define MCI struct mailer_con_info 822 823 MCI 824 { 825 unsigned long mci_flags; /* flag bits, see below */ 826 short mci_errno; /* error number on last connection */ 827 short mci_herrno; /* h_errno from last DNS lookup */ 828 short mci_exitstat; /* exit status from last connection */ 829 short mci_state; /* SMTP state */ 830 int mci_deliveries; /* delivery attempts for connection */ 831 long mci_maxsize; /* max size this server will accept */ 832 SM_FILE_T *mci_in; /* input side of connection */ 833 SM_FILE_T *mci_out; /* output side of connection */ 834 pid_t mci_pid; /* process id of subordinate proc */ 835 char *mci_phase; /* SMTP phase string */ 836 struct mailer *mci_mailer; /* ptr to the mailer for this conn */ 837 char *mci_host; /* host name */ 838 char *mci_status; /* DSN status to be copied to addrs */ 839 char *mci_rstatus; /* SMTP status to be copied to addrs */ 840 time_t mci_lastuse; /* last usage time */ 841 SM_FILE_T *mci_statfile; /* long term status file */ 842 char *mci_heloname; /* name to use as HELO arg */ 843 long mci_min_by; /* minimum DELIVERBY */ 844 bool mci_retryrcpt; /* tempfail for at least one rcpt */ 845 char *mci_tolist; /* list of valid recipients */ 846 SM_RPOOL_T *mci_rpool; /* resource pool */ 847 int mci_okrcpts; /* number of valid recipients */ 848 #if PIPELINING 849 ADDRESS *mci_nextaddr; /* next address for pipelined status */ 850 #endif 851 #if SASL 852 SASL_AI_T mci_sai; /* authentication info */ 853 bool mci_sasl_auth; /* authenticated? */ 854 int mci_sasl_string_len; 855 char *mci_sasl_string; /* sasl reply string */ 856 char *mci_saslcap; /* SASL list of mechanisms */ 857 sasl_conn_t *mci_conn; /* SASL connection */ 858 #endif /* SASL */ 859 #if STARTTLS 860 SSL *mci_ssl; /* SSL connection */ 861 tlsi_ctx_T mci_tlsi; 862 #endif 863 MACROS_T mci_macro; /* macro definitions */ 864 }; 865 866 867 /* MCI flag bits */ 868 /* XREF: mci.c: MciFlags[]: needs to be kept in sync! */ 869 /* 0x00000001 unused, was MCIF_VALID: this entry is valid */ 870 #define MCIF_OCC_INCR 0x00000002 /* occ values increased */ 871 #define MCIF_CACHED 0x00000004 /* currently in open cache */ 872 #define MCIF_ESMTP 0x00000008 /* this host speaks ESMTP */ 873 #define MCIF_EXPN 0x00000010 /* EXPN command supported */ 874 #define MCIF_SIZE 0x00000020 /* SIZE option supported */ 875 #define MCIF_8BITMIME 0x00000040 /* BODY=8BITMIME supported */ 876 #define MCIF_7BIT 0x00000080 /* strip this message to 7 bits */ 877 /* 0x00000100 unused, was MCIF_MULTSTAT: MAIL11V3: handles MULT status */ 878 #define MCIF_INHEADER 0x00000200 /* currently outputing header */ 879 #define MCIF_CVT8TO7 0x00000400 /* convert from 8 to 7 bits */ 880 #define MCIF_DSN 0x00000800 /* DSN extension supported */ 881 #define MCIF_8BITOK 0x00001000 /* OK to send 8 bit characters */ 882 #define MCIF_CVT7TO8 0x00002000 /* convert from 7 to 8 bits */ 883 #define MCIF_INMIME 0x00004000 /* currently reading MIME header */ 884 #define MCIF_AUTH 0x00008000 /* AUTH= supported */ 885 #define MCIF_AUTHACT 0x00010000 /* SASL (AUTH) active */ 886 #define MCIF_ENHSTAT 0x00020000 /* ENHANCEDSTATUSCODES supported */ 887 #define MCIF_PIPELINED 0x00040000 /* PIPELINING supported */ 888 #define MCIF_VERB 0x00080000 /* VERB supported */ 889 #if STARTTLS 890 #define MCIF_TLS 0x00100000 /* STARTTLS supported */ 891 #define MCIF_TLSACT 0x00200000 /* STARTTLS active */ 892 #else /* STARTTLS */ 893 #define MCIF_TLS 0 894 #define MCIF_TLSACT 0 895 #endif /* STARTTLS */ 896 #define MCIF_DLVR_BY 0x00400000 /* DELIVERBY */ 897 #if _FFR_IGNORE_EXT_ON_HELO 898 # define MCIF_HELO 0x00800000 /* we used HELO: ignore extensions */ 899 #endif 900 #define MCIF_INLONGLINE 0x01000000 /* in the middle of a long line */ 901 #define MCIF_AUTH2 0x02000000 /* got 2 AUTH lines */ 902 #define MCIF_ONLY_EHLO 0x10000000 /* use only EHLO in smtpinit */ 903 #if _FFR_HANDLE_HDR_RW_TEMPFAIL 904 /* an error is not sticky (if put{header,body}() etc fail) */ 905 # define MCIF_NOTSTICKY 0x20000000 906 #else 907 # define MCIF_NOTSTICKY 0 908 #endif 909 #if USE_EAI 910 # define MCIF_EAI 0x40000000 /* SMTPUTF8 supported */ 911 #else 912 # define MCIF_EAI 0x00000000 /* for MCIF_EXTENS */ 913 #endif 914 915 #define MCIF_EXTENS (MCIF_EXPN|MCIF_SIZE|MCIF_8BITMIME|MCIF_DSN|MCIF_8BITOK|MCIF_AUTH|MCIF_ENHSTAT|MCIF_PIPELINED|MCIF_VERB|MCIF_TLS|MCIF_DLVR_BY|MCIF_AUTH2|MCIF_EAI) 916 917 /* states */ 918 #define MCIS_CLOSED 0 /* no traffic on this connection */ 919 #define MCIS_OPENING 1 /* sending initial protocol */ 920 #define MCIS_OPEN 2 /* open, initial protocol sent */ 921 #define MCIS_MAIL 3 /* MAIL command sent */ 922 #define MCIS_RCPT 4 /* RCPT commands being sent */ 923 #define MCIS_DATA 5 /* DATA command sent */ 924 #define MCIS_QUITING 6 /* running quit protocol */ 925 #define MCIS_SSD 7 /* service shutting down */ 926 #define MCIS_ERROR 8 /* I/O error on connection */ 927 928 /* functions */ 929 extern void mci_cache __P((MCI *)); 930 extern void mci_close __P((MCI *, char *where)); 931 extern void mci_dump __P((SM_FILE_T *, MCI *, bool)); 932 extern void mci_dump_all __P((SM_FILE_T *, bool)); 933 extern void mci_flush __P((bool, MCI *)); 934 extern void mci_clr_extensions __P((MCI *)); 935 extern MCI *mci_get __P((char *, MAILER *)); 936 extern int mci_lock_host __P((MCI *)); 937 extern bool mci_match __P((char *, MAILER *)); 938 extern int mci_print_persistent __P((char *, char *)); 939 extern int mci_purge_persistent __P((char *, char *)); 940 extern MCI **mci_scan __P((MCI *)); 941 extern void mci_setstat __P((MCI *, int, char *, char *)); 942 extern void mci_store_persistent __P((MCI *)); 943 extern int mci_traverse_persistent __P((int (*)(char *, char *), char *)); 944 extern void mci_unlock_host __P((MCI *)); 945 946 EXTERN int MaxMciCache; /* maximum entries in MCI cache */ 947 EXTERN time_t MciCacheTimeout; /* maximum idle time on connections */ 948 EXTERN time_t MciInfoTimeout; /* how long 'til we retry down hosts */ 949 950 /* 951 ** Header structure. 952 ** This structure is used internally to store header items. 953 */ 954 955 struct header 956 { 957 char *h_field; /* the name of the field */ 958 char *h_value; /* the value of that field */ 959 struct header *h_link; /* the next header */ 960 unsigned char h_macro; /* include header if macro defined */ 961 unsigned long h_flags; /* status bits, see below */ 962 BITMAP256 h_mflags; /* m_flags bits needed */ 963 }; 964 965 typedef struct header HDR; 966 967 /* 968 ** Header information structure. 969 ** Defined in conf.c, this struct declares the header fields 970 ** that have some magic meaning. 971 */ 972 973 struct hdrinfo 974 { 975 char *hi_field; /* the name of the field */ 976 unsigned long hi_flags; /* status bits, see below */ 977 char *hi_ruleset; /* validity check ruleset */ 978 }; 979 980 extern struct hdrinfo HdrInfo[]; 981 982 /* bits for h_flags and hi_flags */ 983 #define H_EOH 0x00000001 /* field terminates header */ 984 #define H_RCPT 0x00000002 /* contains recipient addresses */ 985 #define H_DEFAULT 0x00000004 /* if another value is found, drop this */ 986 #define H_RESENT 0x00000008 /* this address is a "Resent-..." address */ 987 #define H_CHECK 0x00000010 /* check h_mflags against m_flags */ 988 #define H_ACHECK 0x00000020 /* ditto, but always (not just default) */ 989 #define H_FORCE 0x00000040 /* force this field, even if default */ 990 #define H_TRACE 0x00000080 /* this field contains trace information */ 991 #define H_FROM 0x00000100 /* this is a from-type field */ 992 #define H_VALID 0x00000200 /* this field has a validated value */ 993 #define H_RECEIPTTO 0x00000400 /* field has return receipt info */ 994 #define H_ERRORSTO 0x00000800 /* field has error address info */ 995 #define H_CTE 0x00001000 /* field is a content-transfer-encoding */ 996 #define H_CTYPE 0x00002000 /* this is a content-type field */ 997 #define H_BCC 0x00004000 /* Bcc: header: strip value or delete */ 998 #define H_ENCODABLE 0x00008000 /* field can be RFC 1522 encoded */ 999 #define H_STRIPCOMM 0x00010000 /* header check: strip comments */ 1000 #define H_BINDLATE 0x00020000 /* only expand macros at deliver */ 1001 #define H_USER 0x00040000 /* header came from the user/SMTP */ 1002 #if _FFR_MTA_MODE 1003 # define H_ASIS 0x10000000 1004 #endif 1005 1006 /* bits for chompheader() */ 1007 #define CHHDR_DEF 0x0001 /* default header */ 1008 #define CHHDR_CHECK 0x0002 /* call ruleset for header */ 1009 #define CHHDR_USER 0x0004 /* header from user */ 1010 #define CHHDR_QUEUE 0x0008 /* header from queue file */ 1011 1012 /* functions */ 1013 extern void addheader __P((char *, char *, int, ENVELOPE *, bool)); 1014 extern unsigned long chompheader __P((char *, int, HDR **, ENVELOPE *)); 1015 extern bool commaize __P((HDR *, char *, bool, MCI *, ENVELOPE *, int)); 1016 extern HDR *copyheader __P((HDR *, SM_RPOOL_T *)); 1017 extern void eatheader __P((ENVELOPE *, bool, bool)); 1018 extern char *hvalue __P((char *, HDR *)); 1019 extern void insheader __P((int, char *, char *, int, ENVELOPE *, bool)); 1020 extern bool isheader __P((char *)); 1021 extern bool putfromline __P((MCI *, ENVELOPE *)); 1022 extern void setupheaders __P((void)); 1023 1024 /* 1025 ** Performance monitoring 1026 */ 1027 1028 #define TIMERS struct sm_timers 1029 1030 TIMERS 1031 { 1032 TIMER ti_overall; /* the whole process */ 1033 }; 1034 1035 1036 #define PUSHTIMER(l, t) { if (tTd(98, l)) pushtimer(&t); } 1037 #define POPTIMER(l, t) { if (tTd(98, l)) poptimer(&t); } 1038 1039 /* 1040 ** Envelope structure. 1041 ** This structure defines the message itself. There is usually 1042 ** only one of these -- for the message that we originally read 1043 ** and which is our primary interest -- but other envelopes can 1044 ** be generated during processing. For example, error messages 1045 ** will have their own envelope. 1046 */ 1047 1048 struct envelope 1049 { 1050 HDR *e_header; /* head of header list */ 1051 long e_msgpriority; /* adjusted priority of this message */ 1052 time_t e_ctime; /* time message appeared in the queue */ 1053 char *e_to; /* (list of) target person(s) */ 1054 ADDRESS e_from; /* the person it is from */ 1055 char *e_sender; /* e_from.q_paddr w comments stripped */ 1056 char **e_fromdomain; /* the domain part of the sender */ 1057 #if USE_EAI 1058 bool e_smtputf8; /* requires SMTPUTF8? */ 1059 #endif 1060 ADDRESS *e_sendqueue; /* list of message recipients */ 1061 ADDRESS *e_errorqueue; /* the queue for error responses */ 1062 1063 /* 1064 ** Overflow detection is based on < 0, so don't change this 1065 ** to unsigned. We don't use unsigned and == ULONG_MAX because 1066 ** some libc's don't have strtoul(), see mail_esmtp_args(). 1067 */ 1068 1069 long e_msgsize; /* size of the message in bytes */ 1070 char *e_msgid; /* message id (for logging) */ 1071 unsigned long e_flags; /* flags, see below */ 1072 int e_nrcpts; /* number of recipients */ 1073 short e_class; /* msg class (priority, junk, etc.) */ 1074 short e_hopcount; /* number of times processed */ 1075 short e_nsent; /* number of sends since checkpoint */ 1076 short e_sendmode; /* message send mode */ 1077 short e_errormode; /* error return mode */ 1078 short e_timeoutclass; /* message timeout class */ 1079 bool (*e_puthdr)__P((MCI *, HDR *, ENVELOPE *, int)); 1080 /* function to put header of message */ 1081 bool (*e_putbody)__P((MCI *, ENVELOPE *, char *)); 1082 /* function to put body of message */ 1083 ENVELOPE *e_parent; /* the message this one encloses */ 1084 ENVELOPE *e_sibling; /* the next envelope of interest */ 1085 char *e_bodytype; /* type of message body */ 1086 SM_FILE_T *e_dfp; /* data file */ 1087 char *e_id; /* code for this entry in queue */ 1088 #if _FFR_SESSID 1089 char *e_sessid; /* session ID for this envelope */ 1090 #endif 1091 int e_qgrp; /* queue group (index into queues) */ 1092 int e_qdir; /* index into queue directories */ 1093 int e_dfqgrp; /* data file queue group index */ 1094 int e_dfqdir; /* data file queue directory index */ 1095 int e_xfqgrp; /* queue group (index into queues) */ 1096 int e_xfqdir; /* index into queue directories (xf) */ 1097 SM_FILE_T *e_xfp; /* transcript file */ 1098 SM_FILE_T *e_lockfp; /* the lock file for this message */ 1099 char *e_message; /* error message; readonly; NULL, 1100 * or allocated from e_rpool */ 1101 char *e_statmsg; /* stat msg (changes per delivery). 1102 * readonly. NULL or allocated from 1103 * e_rpool. */ 1104 char *e_quarmsg; /* why envelope is quarantined */ 1105 char e_qfletter; /* queue file letter on disk */ 1106 char *e_msgboundary; /* MIME-style message part boundary */ 1107 char *e_origrcpt; /* original recipient (one only) */ 1108 char *e_envid; /* envelope id from MAIL FROM: line */ 1109 char *e_status; /* DSN status for this message */ 1110 time_t e_dtime; /* time of last delivery attempt */ 1111 int e_ntries; /* number of delivery attempts */ 1112 dev_t e_dfdev; /* data file device (crash recovery) */ 1113 ino_t e_dfino; /* data file inode (crash recovery) */ 1114 MACROS_T e_macro; /* macro definitions */ 1115 MCI *e_mci; /* connection info */ 1116 char *e_auth_param; /* readonly; NULL or static storage or 1117 * allocated from e_rpool */ 1118 TIMERS e_timers; /* per job timers */ 1119 long e_deliver_by; /* deliver by */ 1120 int e_dlvr_flag; /* deliver by flag */ 1121 SM_RPOOL_T *e_rpool; /* resource pool for this envelope */ 1122 unsigned int e_features; /* server features */ 1123 #define ENHSC_LEN 11 1124 #if _FFR_MILTER_ENHSC 1125 char e_enhsc[ENHSC_LEN]; /* enhanced status code */ 1126 #endif 1127 /* smtp error codes during delivery */ 1128 int e_rcode; /* reply code */ 1129 char e_renhsc[ENHSC_LEN]; /* enhanced status code */ 1130 char *e_text; /* reply text */ 1131 }; 1132 1133 #define PRT_NONNEGL(v) ((v) < 0 ? LONG_MAX : (v)) 1134 1135 /* values for e_flags */ 1136 #define EF_OLDSTYLE 0x00000001L /* use spaces (not commas) in hdrs */ 1137 #define EF_INQUEUE 0x00000002L /* this message is fully queued */ 1138 #define EF_NO_BODY_RETN 0x00000004L /* omit message body on error */ 1139 #define EF_CLRQUEUE 0x00000008L /* disk copy is no longer needed */ 1140 #define EF_SENDRECEIPT 0x00000010L /* send a return receipt */ 1141 #define EF_FATALERRS 0x00000020L /* fatal errors occurred */ 1142 #define EF_DELETE_BCC 0x00000040L /* delete Bcc: headers entirely */ 1143 #define EF_RESPONSE 0x00000080L /* this is an error or return receipt */ 1144 #define EF_RESENT 0x00000100L /* this message is being forwarded */ 1145 #define EF_VRFYONLY 0x00000200L /* verify only (don't expand aliases) */ 1146 #define EF_WARNING 0x00000400L /* warning message has been sent */ 1147 #define EF_QUEUERUN 0x00000800L /* this envelope is from queue */ 1148 #define EF_GLOBALERRS 0x00001000L /* treat errors as global */ 1149 #define EF_PM_NOTIFY 0x00002000L /* send return mail to postmaster */ 1150 #define EF_METOO 0x00004000L /* send to me too */ 1151 #define EF_LOGSENDER 0x00008000L /* need to log the sender */ 1152 #define EF_NORECEIPT 0x00010000L /* suppress all return-receipts */ 1153 #define EF_HAS8BIT 0x00020000L /* at least one 8-bit char in body */ 1154 /* was: EF_NL_NOT_EOL 0x00040000L * don't accept raw NL as EOLine */ 1155 /* was: EF_CRLF_NOT_EOL 0x00080000L * don't accept CR-LF as EOLine */ 1156 #define EF_RET_PARAM 0x00100000L /* RCPT command had RET argument */ 1157 #define EF_HAS_DF 0x00200000L /* set when data file is instantiated */ 1158 #define EF_IS_MIME 0x00400000L /* really is a MIME message */ 1159 #define EF_DONT_MIME 0x00800000L /* never MIME this message */ 1160 #define EF_DISCARD 0x01000000L /* discard the message */ 1161 #define EF_TOOBIG 0x02000000L /* message is too big */ 1162 #define EF_SPLIT 0x04000000L /* envelope has been split */ 1163 #define EF_UNSAFE 0x08000000L /* unsafe: read from untrusted source */ 1164 #define EF_TOODEEP 0x10000000L /* message is nested too deep */ 1165 #define EF_SECURE 0x20000000L /* DNSSEC for currently parsed addr */ 1166 1167 #define DLVR_NOTIFY 0x01 1168 #define DLVR_RETURN 0x02 1169 #define DLVR_TRACE 0x10 1170 #define IS_DLVR_NOTIFY(e) (((e)->e_dlvr_flag & DLVR_NOTIFY) != 0) 1171 #define IS_DLVR_RETURN(e) (((e)->e_dlvr_flag & DLVR_RETURN) != 0) 1172 #define IS_DLVR_TRACE(e) (((e)->e_dlvr_flag & DLVR_TRACE) != 0) 1173 #define IS_DLVR_BY(e) ((e)->e_dlvr_flag != 0) 1174 1175 #define BODYTYPE_NONE (0) 1176 #define BODYTYPE_7BIT (1) 1177 #define BODYTYPE_8BITMIME (2) 1178 #define BODYTYPE_ILLEGAL (-1) 1179 #define BODYTYPE_VALID(b) ((b) == BODYTYPE_7BIT || (b) == BODYTYPE_8BITMIME) 1180 1181 extern ENVELOPE BlankEnvelope; 1182 1183 /* functions */ 1184 extern void clearenvelope __P((ENVELOPE *, bool, SM_RPOOL_T *)); 1185 extern int dropenvelope __P((ENVELOPE *, bool, bool)); 1186 extern ENVELOPE *newenvelope __P((ENVELOPE *, ENVELOPE *, SM_RPOOL_T *)); 1187 extern void clrsessenvelope __P((ENVELOPE *)); 1188 extern void printenvflags __P((ENVELOPE *)); 1189 extern bool putbody __P((MCI *, ENVELOPE *, char *)); 1190 extern bool putheader __P((MCI *, HDR *, ENVELOPE *, int)); 1191 1192 /* 1193 ** Message priority classes. 1194 ** 1195 ** The message class is read directly from the Priority: header 1196 ** field in the message. 1197 ** 1198 ** CurEnv->e_msgpriority is the number of bytes in the message plus 1199 ** the creation time (so that jobs ``tend'' to be ordered correctly), 1200 ** adjusted by the message class, the number of recipients, and the 1201 ** amount of time the message has been sitting around. This number 1202 ** is used to order the queue. Higher values mean LOWER priority. 1203 ** 1204 ** Each priority class point is worth WkClassFact priority points; 1205 ** each recipient is worth WkRecipFact priority points. Each time 1206 ** we reprocess a message the priority is adjusted by WkTimeFact. 1207 ** WkTimeFact should normally decrease the priority so that jobs 1208 ** that have historically failed will be run later; thanks go to 1209 ** Jay Lepreau at Utah for pointing out the error in my thinking. 1210 ** 1211 ** The "class" is this number, unadjusted by the age or size of 1212 ** this message. Classes with negative representations will have 1213 ** error messages thrown away if they are not local. 1214 */ 1215 1216 struct priority 1217 { 1218 char *pri_name; /* external name of priority */ 1219 int pri_val; /* internal value for same */ 1220 }; 1221 1222 EXTERN int NumPriorities; /* pointer into Priorities */ 1223 EXTERN struct priority Priorities[MAXPRIORITIES]; 1224 1225 /* 1226 ** Rewrite rules. 1227 */ 1228 1229 struct rewrite 1230 { 1231 char **r_lhs; /* pattern match */ 1232 char **r_rhs; /* substitution value */ 1233 struct rewrite *r_next;/* next in chain */ 1234 int r_line; /* rule line in sendmail.cf */ 1235 }; 1236 1237 /* 1238 ** Special characters in rewriting rules. 1239 ** These are used internally only. 1240 ** The COND* rules are actually used in macros rather than in 1241 ** rewriting rules, but are given here because they 1242 ** cannot conflict. 1243 */ 1244 1245 /* 1246 ** "out of band" indicator 1247 ** sm/sendmail.h #define METAQUOTE ((unsigned char)0377) 1248 ** quotes the next octet 1249 ** range: ((ch) & 0340) == 0200 1250 ** see #define SM_MM_QUOTE(ch) in libsm/util.c 1251 */ 1252 1253 /* left hand side items */ 1254 #define MATCHZANY ((unsigned char)0220) /* match zero or more tokens */ 1255 #define MATCHANY ((unsigned char)0221) /* match one or more tokens */ 1256 #define MATCHONE ((unsigned char)0222) /* match exactly one token */ 1257 #define MATCHCLASS ((unsigned char)0223) /* match one token in a class */ 1258 #define MATCHNCLASS ((unsigned char)0224) /* match tokens not in class */ 1259 1260 /* right hand side items */ 1261 #define MATCHREPL ((unsigned char)0225) /* RHS replacement for above */ 1262 #define CANONNET ((unsigned char)0226) /* canonical net, next token */ 1263 #define CANONHOST ((unsigned char)0227) /* canonical host, next token */ 1264 #define CANONUSER ((unsigned char)0230) /* canonical user, next N tokens */ 1265 #define CALLSUBR ((unsigned char)0231) /* call another rewriting set */ 1266 1267 /* conditionals in macros (anywhere) */ 1268 #define CONDIF ((unsigned char)0232) /* conditional if-then */ 1269 #define CONDELSE ((unsigned char)0233) /* conditional else */ 1270 #define CONDFI ((unsigned char)0234) /* conditional fi */ 1271 1272 /* bracket characters for RHS host name lookup */ 1273 #define HOSTBEGIN ((unsigned char)0235) /* hostname lookup begin */ 1274 #define HOSTEND ((unsigned char)0236) /* hostname lookup end */ 1275 1276 /* bracket characters for RHS generalized lookup */ 1277 #define LOOKUPBEGIN ((unsigned char)0205) /* generalized lookup begin */ 1278 #define LOOKUPEND ((unsigned char)0206) /* generalized lookup end */ 1279 1280 /* macro substitution characters (anywhere) */ 1281 #define MACROEXPAND ((unsigned char)0201) /* macro expansion */ 1282 #define MACRODEXPAND ((unsigned char)0202) /* deferred macro expansion */ 1283 1284 /* to make the code clearer */ 1285 #define MATCHZERO CANONHOST 1286 1287 #define MAXMATCH 9 /* max params per rewrite */ 1288 #define MAX_MAP_ARGS 10 /* max arguments for map */ 1289 1290 /* external <==> internal mapping table */ 1291 struct metamac 1292 { 1293 char metaname; /* external code (after $) */ 1294 unsigned char metaval; /* internal code (as above) */ 1295 }; 1296 1297 /* values for macros with external names only */ 1298 #define MID_OPMODE 0202 /* operation mode */ 1299 1300 /* functions */ 1301 #if SM_HEAP_CHECK 1302 extern void 1303 macdefine_tagged __P(( 1304 MACROS_T *_mac, 1305 ARGCLASS_T _vclass, 1306 int _id, 1307 char *_value, 1308 char *_file, 1309 int _line, 1310 int _group)); 1311 # define macdefine(mac,c,id,v) \ 1312 macdefine_tagged(mac,c,id,v,__FILE__,__LINE__,sm_heap_group()) 1313 #else /* SM_HEAP_CHECK */ 1314 extern void 1315 macdefine __P(( 1316 MACROS_T *_mac, 1317 ARGCLASS_T _vclass, 1318 int _id, 1319 char *_value)); 1320 # define macdefine_tagged(mac,c,id,v,file,line,grp) macdefine(mac,c,id,v) 1321 #endif /* SM_HEAP_CHECK */ 1322 extern void macset __P((MACROS_T *, int, char *)); 1323 #define macget(mac, i) (mac)->mac_table[i] 1324 extern void expand __P((char *, char *, size_t, ENVELOPE *)); 1325 extern int macid_parse __P((char *, char **)); 1326 #define macid(name) macid_parse(name, NULL) 1327 extern char *macname __P((int)); 1328 extern char *macvalue __P((int, ENVELOPE *)); 1329 extern void mactabclear __P((MACROS_T *)); 1330 extern int rscheck __P((char *, const char *, const char *, ENVELOPE *, int, int, const char *, const char *, ADDRESS *, char **)); 1331 extern int rscap __P((char *, char *, char *, ENVELOPE *, char ***, char *, int)); 1332 extern void setclass __P((int, char *)); 1333 extern int strtorwset __P((char *, char **, int)); 1334 extern char *translate_dollars __P((char *, char *, int *)); 1335 extern bool wordinclass __P((char *, int)); 1336 1337 /* 1338 ** Name canonification short circuit. 1339 ** 1340 ** If the name server for a host is down, the process of trying to 1341 ** canonify the name can hang. This is similar to (but alas, not 1342 ** identical to) looking up the name for delivery. This stab type 1343 ** caches the result of the name server lookup so we don't hang 1344 ** multiple times. 1345 */ 1346 1347 #define NAMECANON struct _namecanon 1348 1349 NAMECANON 1350 { 1351 short nc_errno; /* cached errno */ 1352 short nc_herrno; /* cached h_errno */ 1353 short nc_stat; /* cached exit status code */ 1354 short nc_flags; /* flag bits */ 1355 char *nc_cname; /* the canonical name */ 1356 time_t nc_exp; /* entry expires at */ 1357 }; 1358 1359 /* values for nc_flags */ 1360 #define NCF_VALID 0x0001 /* entry valid */ 1361 #define NCF_VALID 0x0001 /* entry valid */ 1362 #define NCF_SECURE 0x0002 /* entry secure (DNSSEC) */ 1363 1364 /* hostsignature structure */ 1365 1366 struct hostsig_t 1367 { 1368 char *hs_sig; /* hostsignature */ 1369 time_t hs_exp; /* entry expires at */ 1370 }; 1371 1372 typedef struct hostsig_t HOSTSIG_T; 1373 1374 /* 1375 ** The standard udp packet size PACKETSZ (512) is not sufficient for some 1376 ** nameserver answers containing very many resource records. The resolver 1377 ** may switch to tcp and retry if it detects udp packet overflow. 1378 ** Also note that the resolver routines res_query and res_search return 1379 ** the size of the *un*truncated answer in case the supplied answer buffer 1380 ** it not big enough to accommodate the entire answer. 1381 */ 1382 1383 #ifndef MAXPACKET 1384 # define MAXPACKET 8192 /* max packet size used internally by BIND */ 1385 #endif 1386 1387 /* 1388 ** The resolver functions res_{send,query,querydomain} expect the 1389 ** answer buffer to be aligned, but some versions of gcc4 reverse 1390 ** 25 years of history and no longer align char buffers on the 1391 ** stack, resulting in crashes on strict-alignment platforms. Use 1392 ** this union when putting the buffer on the stack to force the 1393 ** alignment, then cast to (HEADER *) or (unsigned char *) as needed. 1394 */ 1395 typedef union 1396 { 1397 HEADER qb1; 1398 unsigned char qb2[MAXPACKET]; 1399 } querybuf; 1400 1401 1402 /* result values for getcanonname() etc */ 1403 #define HOST_NOTFOUND 0 1404 #define HOST_OK 1 1405 #define HOST_SECURE 2 1406 1407 /* flags for getmxrr() */ 1408 #define DROPLOCALHOST 0x01 1409 #define TRYFALLBACK 0x02 1410 #define ISAD 0x04 1411 1412 /* RFC7505: Null MX */ 1413 #define NULLMX (-2) 1414 1415 /* functions */ 1416 extern int getcanonname __P((char *, int, bool, int *)); 1417 extern int getmxrr __P((char *, char **, unsigned short *, unsigned int, int *, int *, int)); 1418 extern char *hostsignature __P((MAILER *, char *, bool)); 1419 extern int getfallbackmxrr __P((char *)); 1420 1421 /* 1422 ** Mapping functions 1423 ** 1424 ** These allow arbitrary mappings in the config file. The idea 1425 ** (albeit not the implementation) comes from IDA sendmail. 1426 */ 1427 1428 #define MAPCLASS struct _mapclass 1429 #define MAP struct _map 1430 #define MAXMAPACTIONS 5 /* size of map_actions array */ 1431 1432 1433 /* 1434 ** An actual map. 1435 */ 1436 1437 MAP 1438 { 1439 MAPCLASS *map_class; /* the class of this map */ 1440 MAPCLASS *map_orgclass; /* the original class of this map */ 1441 char *map_mname; /* name of this map */ 1442 long map_mflags; /* flags, see below */ 1443 char *map_file; /* the (nominal) filename */ 1444 ARBPTR_T map_db1; /* the open database ptr */ 1445 ARBPTR_T map_db2; /* an "extra" database pointer */ 1446 char *map_keycolnm; /* key column name */ 1447 char *map_valcolnm; /* value column name */ 1448 unsigned char map_keycolno; /* key column number */ 1449 unsigned char map_valcolno; /* value column number */ 1450 char map_coldelim; /* column delimiter */ 1451 char map_spacesub; /* spacesub */ 1452 char *map_app; /* to append to successful matches */ 1453 char *map_tapp; /* to append to "tempfail" matches */ 1454 char *map_domain; /* the (nominal) NIS domain */ 1455 char *map_rebuild; /* program to run to do auto-rebuild */ 1456 time_t map_mtime; /* last database modification time */ 1457 time_t map_timeout; /* timeout for map accesses */ 1458 int map_retry; /* # of retries for map accesses */ 1459 pid_t map_pid; /* PID of process which opened map */ 1460 int map_lockfd; /* auxiliary lock file descriptor */ 1461 MAP *map_stack[MAXMAPSTACK]; /* list for stacked maps */ 1462 short map_return[MAXMAPACTIONS]; /* return bitmaps for stacked maps */ 1463 }; 1464 1465 1466 /* bit values for map_mflags */ 1467 #define MF_VALID 0x00000001 /* this entry is valid */ 1468 #define MF_INCLNULL 0x00000002 /* include null byte in key */ 1469 #define MF_OPTIONAL 0x00000004 /* don't complain if map not found */ 1470 #define MF_NOFOLDCASE 0x00000008 /* don't fold case in keys */ 1471 #define MF_MATCHONLY 0x00000010 /* don't use the map value */ 1472 #define MF_OPEN 0x00000020 /* this entry is open */ 1473 #define MF_WRITABLE 0x00000040 /* open for writing */ 1474 #define MF_ALIAS 0x00000080 /* this is an alias file */ 1475 #define MF_TRY0NULL 0x00000100 /* try with no null byte */ 1476 #define MF_TRY1NULL 0x00000200 /* try with the null byte */ 1477 #define MF_LOCKED 0x00000400 /* this map is currently locked */ 1478 #define MF_ALIASWAIT 0x00000800 /* alias map in aliaswait state */ 1479 #define MF_IMPL_HASH 0x00001000 /* implicit: underlying hash database */ 1480 #define MF_IMPL_NDBM 0x00002000 /* implicit: underlying NDBM database */ 1481 #define MF_IMPL_CDB 0x00004000 /* implicit: underlying CDB database */ 1482 #define MF_APPEND 0x00008000 /* append new entry on rebuild */ 1483 #define MF_KEEPQUOTES 0x00010000 /* don't dequote key before lookup */ 1484 #define MF_NODEFER 0x00020000 /* don't defer if map lookup fails */ 1485 #define MF_REGEX_NOT 0x00040000 /* regular expression negation */ 1486 #define MF_DEFER 0x00080000 /* don't lookup map in defer mode */ 1487 #define MF_SINGLEMATCH 0x00100000 /* successful only if match one key */ 1488 #define MF_SINGLEDN 0x00200000 /* only one match, but multi values */ 1489 #define MF_FILECLASS 0x00400000 /* this is a file class map */ 1490 #define MF_OPENBOGUS 0x00800000 /* open failed, don't call map_close */ 1491 #define MF_CLOSING 0x01000000 /* map is being closed */ 1492 #define MF_SECURE 0x02000000 /* DNSSEC result is "secure" */ 1493 #define MF_KEEPXFMT 0x04000000 /* keep [x] format */ 1494 1495 #define DYNOPENMAP(map) \ 1496 do \ 1497 { \ 1498 if (!bitset(MF_OPEN, (map)->map_mflags)) \ 1499 { \ 1500 if (!openmap(map)) \ 1501 return NULL; \ 1502 } \ 1503 } while (0) 1504 1505 1506 /* indices for map_actions */ 1507 #define MA_NOTFOUND 0 /* member map returned "not found" */ 1508 #define MA_UNAVAIL 1 /* member map is not available */ 1509 #define MA_TRYAGAIN 2 /* member map returns temp failure */ 1510 1511 /* 1512 ** The class of a map -- essentially the functions to call 1513 */ 1514 1515 MAPCLASS 1516 { 1517 char *map_cname; /* name of this map class */ 1518 char *map_ext; /* extension for database file */ 1519 short map_cflags; /* flag bits, see below */ 1520 bool (*map_parse)__P((MAP *, char *)); 1521 /* argument parsing function */ 1522 char *(*map_lookup)__P((MAP *, char *, char **, int *)); 1523 /* lookup function */ 1524 void (*map_store)__P((MAP *, char *, char *)); 1525 /* store function */ 1526 bool (*map_open)__P((MAP *, int)); 1527 /* open function */ 1528 void (*map_close)__P((MAP *)); 1529 /* close function */ 1530 }; 1531 1532 /* bit values for map_cflags */ 1533 #define MCF_ALIASOK 0x0001 /* can be used for aliases */ 1534 /* #define MCF_ALIASONLY 0x0002 * usable only for aliases */ 1535 #define MCF_REBUILDABLE 0x0004 /* can rebuild alias files */ 1536 #define MCF_OPTFILE 0x0008 /* file name is optional */ 1537 #define MCF_NOTPERSIST 0x0010 /* don't keep map open all the time */ 1538 1539 /* functions */ 1540 extern void closemaps __P((bool)); 1541 extern bool impl_map_open __P((MAP *, int)); 1542 extern void initmaps __P((void)); 1543 extern MAP *makemapentry __P((char *)); 1544 extern void maplocaluser __P((ADDRESS *, ADDRESS **, int, ENVELOPE *)); 1545 extern char *map_rewrite __P((MAP *, const char *, size_t, char **)); 1546 #if NETINFO 1547 extern char *ni_propval __P((char *, char *, char *, char *, int)); 1548 #endif 1549 extern bool openmap __P((MAP *)); 1550 extern int udbexpand __P((ADDRESS *, ADDRESS **, int, ENVELOPE *)); 1551 #if USERDB 1552 extern void _udbx_close __P((void)); 1553 extern char *udbsender __P((char *, SM_RPOOL_T *)); 1554 #endif 1555 1556 /* 1557 ** LDAP related items 1558 */ 1559 #if LDAPMAP 1560 /* struct defining LDAP Auth Methods */ 1561 struct lamvalues 1562 { 1563 char *lam_name; /* name of LDAP auth method */ 1564 int lam_code; /* numeric code */ 1565 }; 1566 1567 /* struct defining LDAP Alias Dereferencing */ 1568 struct ladvalues 1569 { 1570 char *lad_name; /* name of LDAP alias dereferencing method */ 1571 int lad_code; /* numeric code */ 1572 }; 1573 1574 /* struct defining LDAP Search Scope */ 1575 struct lssvalues 1576 { 1577 char *lss_name; /* name of LDAP search scope */ 1578 int lss_code; /* numeric code */ 1579 }; 1580 1581 /* functions */ 1582 extern bool ldapmap_parseargs __P((MAP *, char *)); 1583 extern void ldapmap_set_defaults __P((char *)); 1584 #endif /* LDAPMAP */ 1585 1586 /* 1587 ** PH related items 1588 */ 1589 1590 #if PH_MAP 1591 1592 # include <phclient.h> 1593 1594 struct ph_map_struct 1595 { 1596 char *ph_servers; /* list of ph servers */ 1597 char *ph_field_list; /* list of fields to search for match */ 1598 PH *ph; /* PH server handle */ 1599 int ph_fastclose; /* send "quit" command on close */ 1600 time_t ph_timeout; /* timeout interval */ 1601 }; 1602 typedef struct ph_map_struct PH_MAP_STRUCT; 1603 1604 #endif /* PH_MAP */ 1605 1606 /* 1607 ** Regular UNIX sockaddrs are too small to handle ISO addresses, so 1608 ** we are forced to declare a supertype here. 1609 */ 1610 1611 #if NETINET || NETINET6 || NETUNIX || NETISO || NETNS || NETX25 1612 union bigsockaddr 1613 { 1614 struct sockaddr sa; /* general version */ 1615 # if NETUNIX 1616 struct sockaddr_un sunix; /* UNIX family */ 1617 # endif 1618 # if NETINET 1619 struct sockaddr_in sin; /* INET family */ 1620 # endif 1621 # if NETINET6 1622 struct sockaddr_in6 sin6; /* INET/IPv6 */ 1623 # endif 1624 # if NETISO 1625 struct sockaddr_iso siso; /* ISO family */ 1626 # endif 1627 # if NETNS 1628 struct sockaddr_ns sns; /* XNS family */ 1629 # endif 1630 # if NETX25 1631 struct sockaddr_x25 sx25; /* X.25 family */ 1632 # endif 1633 }; 1634 1635 # define SOCKADDR union bigsockaddr 1636 1637 /* functions */ 1638 extern char *anynet_ntoa __P((SOCKADDR *)); 1639 # if NETINET6 1640 extern char *anynet_ntop __P((struct in6_addr *, char *, size_t)); 1641 extern int anynet_pton __P((int, const char *, void *)); 1642 # endif 1643 extern char *hostnamebyanyaddr __P((SOCKADDR *)); 1644 extern char *validate_connection __P((SOCKADDR *, char *, ENVELOPE *)); 1645 # if SASL >= 20000 1646 extern bool iptostring __P((SOCKADDR *, SOCKADDR_LEN_T, char *, unsigned)); 1647 # endif 1648 1649 #endif /* NETINET || NETINET6 || NETUNIX || NETISO || NETNS || NETX25 */ 1650 1651 /* 1652 ** Process List (proclist) 1653 */ 1654 1655 #define NO_PID ((pid_t) 0) 1656 #ifndef PROC_LIST_SEG 1657 # define PROC_LIST_SEG 32 /* number of pids to alloc at a time */ 1658 #endif 1659 1660 /* process types */ 1661 #define PROC_NONE 0 1662 #define PROC_DAEMON 1 1663 #define PROC_DAEMON_CHILD 2 1664 #define PROC_QUEUE 3 1665 #define PROC_QUEUE_CHILD 3 1666 #define PROC_CONTROL 4 1667 #define PROC_CONTROL_CHILD 5 1668 #define PROC_QM 6 1669 1670 /* functions */ 1671 extern void proc_list_add __P((pid_t, char *, int, int, int, SOCKADDR *)); 1672 extern void proc_list_clear __P((void)); 1673 extern void proc_list_display __P((SM_FILE_T *, char *)); 1674 extern void proc_list_drop __P((pid_t, int, int *)); 1675 extern void proc_list_probe __P((void)); 1676 extern void proc_list_set __P((pid_t, char *)); 1677 extern void proc_list_signal __P((int, int)); 1678 1679 /* 1680 ** Symbol table definitions 1681 */ 1682 1683 struct symtab 1684 { 1685 char *s_name; /* name to be entered */ 1686 short s_symtype; /* general type (see below) */ 1687 struct symtab *s_next; /* pointer to next in chain */ 1688 union 1689 { 1690 BITMAP256 sv_class; /* bit-map of word classes */ 1691 MAILER *sv_mailer; /* pointer to mailer */ 1692 char *sv_alias; /* alias */ 1693 MAPCLASS sv_mapclass; /* mapping function class */ 1694 MAP sv_map; /* mapping function */ 1695 HOSTSIG_T sv_hostsig; /* host signature */ 1696 MCI sv_mci; /* mailer connection info */ 1697 NAMECANON sv_namecanon; /* canonical name cache */ 1698 int sv_macro; /* macro name => id mapping */ 1699 int sv_ruleset; /* ruleset index */ 1700 struct hdrinfo sv_header; /* header metainfo */ 1701 char *sv_service[MAXMAPSTACK]; /* service switch */ 1702 #if LDAPMAP 1703 MAP *sv_lmap; /* Maps for LDAP connection */ 1704 #endif 1705 #if SOCKETMAP 1706 MAP *sv_socketmap; /* Maps for SOCKET connection */ 1707 #endif 1708 #if MILTER 1709 struct milter *sv_milter; /* milter filter name */ 1710 #endif 1711 QUEUEGRP *sv_queue; /* pointer to queue */ 1712 #if DANE 1713 dane_tlsa_P sv_tlsa; /* pointer to TLSA RRs */ 1714 #endif 1715 } s_value; 1716 }; 1717 1718 typedef struct symtab STAB; 1719 1720 /* symbol types */ 1721 #define ST_UNDEF 0 /* undefined type */ 1722 #define ST_CLASS 1 /* class map */ 1723 /* #define ST_unused 2 UNUSED */ 1724 #define ST_MAILER 3 /* a mailer header */ 1725 #define ST_ALIAS 4 /* an alias */ 1726 #define ST_MAPCLASS 5 /* mapping function class */ 1727 #define ST_MAP 6 /* mapping function */ 1728 #define ST_HOSTSIG 7 /* host signature */ 1729 #define ST_NAMECANON 8 /* cached canonical name */ 1730 #define ST_MACRO 9 /* macro name to id mapping */ 1731 #define ST_RULESET 10 /* ruleset index */ 1732 #define ST_SERVICE 11 /* service switch entry */ 1733 #define ST_HEADER 12 /* special header flags */ 1734 #if LDAPMAP 1735 # define ST_LMAP 13 /* List head of maps for LDAP connection */ 1736 #endif 1737 #if MILTER 1738 # define ST_MILTER 14 /* milter filter */ 1739 #endif 1740 #define ST_QUEUE 15 /* a queue entry */ 1741 1742 #if SOCKETMAP 1743 # define ST_SOCKETMAP 16 /* List head of maps for SOCKET connection */ 1744 #endif 1745 1746 #if DANE 1747 # define ST_TLSA_RR 17 /* cached TLSA RRs */ 1748 #endif 1749 1750 /* This entry must be last */ 1751 #define ST_MCI 18 /* mailer connection info (offset) */ 1752 1753 #define s_class s_value.sv_class 1754 #define s_mailer s_value.sv_mailer 1755 #define s_alias s_value.sv_alias 1756 #define s_mci s_value.sv_mci 1757 #define s_mapclass s_value.sv_mapclass 1758 #define s_hostsig s_value.sv_hostsig 1759 #define s_map s_value.sv_map 1760 #define s_namecanon s_value.sv_namecanon 1761 #define s_macro s_value.sv_macro 1762 #define s_ruleset s_value.sv_ruleset 1763 #define s_service s_value.sv_service 1764 #define s_header s_value.sv_header 1765 #if LDAPMAP 1766 # define s_lmap s_value.sv_lmap 1767 #endif 1768 #if SOCKETMAP 1769 # define s_socketmap s_value.sv_socketmap 1770 #endif 1771 #if MILTER 1772 # define s_milter s_value.sv_milter 1773 #endif 1774 #define s_quegrp s_value.sv_queue 1775 #if DANE 1776 # define s_tlsa s_value.sv_tlsa 1777 #endif 1778 1779 /* opcodes to stab */ 1780 #define ST_FIND 0 /* find entry */ 1781 #define ST_ENTER 1 /* enter if not there */ 1782 1783 /* functions */ 1784 extern STAB *stab __P((char *, int, int)); 1785 extern void stabapply __P((void (*)(STAB *, int), int)); 1786 1787 /* 1788 ** Operation, send, error, and MIME modes 1789 ** 1790 ** The operation mode describes the basic operation of sendmail. 1791 ** This can be set from the command line, and is "send mail" by 1792 ** default. 1793 ** 1794 ** The send mode tells how to send mail. It can be set in the 1795 ** configuration file. Its setting determines how quickly the 1796 ** mail will be delivered versus the load on your system. If the 1797 ** -v (verbose) flag is given, it will be forced to SM_DELIVER 1798 ** mode. 1799 ** 1800 ** The error mode tells how to return errors. 1801 */ 1802 1803 #define MD_DELIVER 'm' /* be a mail sender */ 1804 #define MD_SMTP 's' /* run SMTP on standard input */ 1805 #define MD_ARPAFTP 'a' /* obsolete ARPANET mode (Grey Book) */ 1806 #define MD_DAEMON 'd' /* run as a daemon */ 1807 #define MD_FGDAEMON 'D' /* run daemon in foreground */ 1808 #define MD_LOCAL 'l' /* like daemon, but localhost only */ 1809 #define MD_VERIFY 'v' /* verify: don't collect or deliver */ 1810 #define MD_TEST 't' /* test mode: resolve addrs only */ 1811 #define MD_INITALIAS 'i' /* initialize alias database */ 1812 #define MD_PRINT 'p' /* print the queue */ 1813 #define MD_PRINTNQE 'P' /* print number of entries in queue */ 1814 #define MD_FREEZE 'z' /* freeze the configuration file */ 1815 #define MD_HOSTSTAT 'h' /* print persistent host stat info */ 1816 #define MD_PURGESTAT 'H' /* purge persistent host stat info */ 1817 #define MD_QUEUERUN 'q' /* queue run */ 1818 #define MD_CHECKCONFIG 'C' /* check configuration file */ 1819 #define MD_SHOWCONFIG 'O' /* show cf options */ 1820 1821 #if _FFR_LOCAL_DAEMON 1822 EXTERN bool LocalDaemon; 1823 # if NETINET6 1824 EXTERN bool V6LoopbackAddrFound; /* found an IPv6 loopback address */ 1825 # define SETV6LOOPBACKADDRFOUND(sa) \ 1826 do \ 1827 { \ 1828 if (isloopback(sa)) \ 1829 V6LoopbackAddrFound = true; \ 1830 } while (0) 1831 # endif /* NETINET6 */ 1832 #else /* _FFR_LOCAL_DAEMON */ 1833 # define LocalDaemon false 1834 # define V6LoopbackAddrFound false 1835 # define SETV6LOOPBACKADDRFOUND(sa) 1836 #endif /* _FFR_LOCAL_DAEMON */ 1837 1838 /* Note: see also include/sendmail/pathnames.h: GET_CLIENT_CF */ 1839 1840 /* values for e_sendmode -- send modes */ 1841 #define SM_DELIVER 'i' /* interactive delivery */ 1842 #if _FFR_PROXY 1843 # define SM_PROXY_REQ 's' /* synchronous mode requested */ 1844 # define SM_PROXY 'S' /* synchronous mode activated */ 1845 #endif 1846 #define SM_FORK 'b' /* deliver in background */ 1847 #if _FFR_DM_ONE 1848 # define SM_DM_ONE 'o' /* deliver first TA in background, then queue */ 1849 #endif 1850 #if _FFR_DMTRIGGER 1851 # define SM_TRIGGER 't' /* queue and tell "queue manager" */ 1852 # define IS_SM_TRIGGER(m) ((m) == SM_TRIGGER) 1853 #else 1854 # define IS_SM_TRIGGER(m) false 1855 #endif 1856 #define SM_QUEUE 'q' /* queue, don't deliver */ 1857 #define SM_DEFER 'd' /* defer map lookups as well as queue */ 1858 #define SM_VERIFY 'v' /* verify only (used internally) */ 1859 #define DM_NOTSET (-1) /* DeliveryMode (per daemon) option not set */ 1860 #if _FFR_PROXY 1861 # define SM_IS_INTERACTIVE(m) ((m) == SM_DELIVER || (m) == SM_PROXY_REQ || (m) == SM_PROXY) 1862 #else 1863 # define SM_IS_INTERACTIVE(m) ((m) == SM_DELIVER) 1864 #endif 1865 1866 #define WILL_BE_QUEUED(m) ((m) == SM_QUEUE || (m) == SM_DEFER || IS_SM_TRIGGER(m)) 1867 1868 /* used only as a parameter to sendall */ 1869 #define SM_DEFAULT '\0' /* unspecified, use SendMode */ 1870 1871 /* functions */ 1872 extern void set_delivery_mode __P((int, ENVELOPE *)); 1873 1874 /* values for e_errormode -- error handling modes */ 1875 #define EM_PRINT 'p' /* print errors */ 1876 #define EM_MAIL 'm' /* mail back errors */ 1877 #define EM_WRITE 'w' /* write back errors */ 1878 #define EM_BERKNET 'e' /* special berknet processing */ 1879 #define EM_QUIET 'q' /* don't print messages (stat only) */ 1880 1881 1882 /* bit values for MimeMode */ 1883 #define MM_CVTMIME 0x0001 /* convert 8 to 7 bit MIME */ 1884 #define MM_PASS8BIT 0x0002 /* just send 8 bit data blind */ 1885 #define MM_MIME8BIT 0x0004 /* convert 8-bit data to MIME */ 1886 1887 1888 /* how to handle messages without any recipient addresses */ 1889 #define NRA_NO_ACTION 0 /* just leave it as is */ 1890 #define NRA_ADD_TO 1 /* add To: header */ 1891 #define NRA_ADD_APPARENTLY_TO 2 /* add Apparently-To: header */ 1892 #define NRA_ADD_BCC 3 /* add empty Bcc: header */ 1893 #define NRA_ADD_TO_UNDISCLOSED 4 /* add To: undisclosed:; header */ 1894 1895 1896 /* flags to putxline */ 1897 #define PXLF_NOTHINGSPECIAL 0 /* no special mapping */ 1898 #define PXLF_MAPFROM 0x0001 /* map From_ to >From_ */ 1899 #define PXLF_STRIP8BIT 0x0002 /* strip 8th bit */ 1900 #define PXLF_HEADER 0x0004 /* map newlines in headers */ 1901 #define PXLF_NOADDEOL 0x0008 /* if EOL not present, don't add one */ 1902 #define PXLF_STRIPMQUOTE 0x0010 /* strip METAQUOTEs */ 1903 1904 /* 1905 ** Privacy flags 1906 ** These are bit values for the PrivacyFlags word. 1907 */ 1908 1909 #define PRIV_PUBLIC 0 /* what have I got to hide? */ 1910 #define PRIV_NEEDMAILHELO 0x00000001 /* insist on HELO for MAIL */ 1911 #define PRIV_NEEDEXPNHELO 0x00000002 /* insist on HELO for EXPN */ 1912 #define PRIV_NEEDVRFYHELO 0x00000004 /* insist on HELO for VRFY */ 1913 #define PRIV_NOEXPN 0x00000008 /* disallow EXPN command */ 1914 #define PRIV_NOVRFY 0x00000010 /* disallow VRFY command */ 1915 #define PRIV_AUTHWARNINGS 0x00000020 /* flag possible auth probs */ 1916 #define PRIV_NOVERB 0x00000040 /* disallow VERB command */ 1917 #define PRIV_RESTRICTMAILQ 0x00010000 /* restrict mailq command */ 1918 #define PRIV_RESTRICTQRUN 0x00020000 /* restrict queue run */ 1919 #define PRIV_RESTRICTEXPAND 0x00040000 /* restrict alias/forward expansion */ 1920 #define PRIV_NOETRN 0x00080000 /* disallow ETRN command */ 1921 #define PRIV_NOBODYRETN 0x00100000 /* do not return bodies on bounces */ 1922 #define PRIV_NORECEIPTS 0x00200000 /* disallow return receipts */ 1923 #define PRIV_NOACTUALRECIPIENT 0x00400000 /* no X-Actual-Recipient in DSNs */ 1924 #define PRIV_NOREFLECTION 0x00800000 /* do not show original command */ 1925 1926 /* don't give no info, anyway, anyhow (in the main SMTP transaction) */ 1927 #define PRIV_GOAWAY (0x0000ffff|PRIV_NOREFLECTION) 1928 1929 /* struct defining such things */ 1930 struct prival 1931 { 1932 char *pv_name; /* name of privacy flag */ 1933 unsigned long pv_flag; /* numeric level */ 1934 }; 1935 1936 EXTERN unsigned long PrivacyFlags; /* privacy flags */ 1937 1938 1939 /* 1940 ** Flags passed to remotename, parseaddr, allocaddr, and buildaddr. 1941 */ 1942 1943 #define RF_SENDERADDR 0x001 /* this is a sender address */ 1944 #define RF_HEADERADDR 0x002 /* this is a header address */ 1945 #define RF_CANONICAL 0x004 /* strip comment information */ 1946 #define RF_ADDDOMAIN 0x008 /* OK to do domain extension */ 1947 #define RF_COPYPARSE 0x010 /* copy parsed user & host */ 1948 #define RF_COPYPADDR 0x020 /* copy print address */ 1949 #define RF_COPYALL (RF_COPYPARSE|RF_COPYPADDR) 1950 #define RF_COPYNONE 0 1951 #define RF_RM_ADDR 0x040 /* address to be removed */ 1952 #define RF_IS_EXT 0x100 /* address is in external format */ 1953 1954 /* 1955 ** Flags passed to rscheck 1956 */ 1957 1958 #define RSF_RMCOMM 0x0001 /* strip comments */ 1959 #define RSF_UNSTRUCTURED 0x0002 /* unstructured, ignore syntax errors */ 1960 #define RSF_COUNT 0x0004 /* count rejections (statistics)? */ 1961 #define RSF_ADDR 0x0008 /* reassemble address */ 1962 #define RSF_STRING 0x0010 /* reassemble address as string */ 1963 1964 /* 1965 ** Flags passed to mime8to7 and putheader. 1966 */ 1967 1968 #define M87F_OUTER 0 /* outer context */ 1969 #define M87F_NO8BIT 0x0001 /* can't have 8-bit in this section */ 1970 #define M87F_DIGEST 0x0002 /* processing multipart/digest */ 1971 #define M87F_NO8TO7 0x0004 /* don't do 8->7 bit conversions */ 1972 1973 /* functions */ 1974 extern bool mime7to8 __P((MCI *, HDR *, ENVELOPE *)); 1975 extern int mime8to7 __P((MCI *, HDR *, ENVELOPE *, char **, int, int)); 1976 1977 /* 1978 ** Flags passed to returntosender. 1979 */ 1980 1981 #define RTSF_NO_BODY 0 /* send headers only */ 1982 #define RTSF_SEND_BODY 0x0001 /* include body of message in return */ 1983 #define RTSF_PM_BOUNCE 0x0002 /* this is a postmaster bounce */ 1984 1985 /* functions */ 1986 extern int returntosender __P((char *, ADDRESS *, int, ENVELOPE *)); 1987 1988 /* 1989 ** Mail Filters (milter) 1990 */ 1991 1992 /* 1993 ** 32-bit type used by milter 1994 ** (needed by libmilter even if MILTER isn't defined) 1995 */ 1996 1997 typedef SM_INT32 mi_int32; 1998 1999 #if MILTER 2000 # define SMFTO_WRITE 0 /* Timeout for sending information */ 2001 # define SMFTO_READ 1 /* Timeout waiting for a response */ 2002 # define SMFTO_EOM 2 /* Timeout for ACK/NAK to EOM */ 2003 # define SMFTO_CONNECT 3 /* Timeout for connect() */ 2004 2005 # define SMFTO_NUM_TO 4 /* Total number of timeouts */ 2006 2007 struct milter 2008 { 2009 char *mf_name; /* filter name */ 2010 BITMAP256 mf_flags; /* MTA flags */ 2011 mi_int32 mf_fvers; /* filter version */ 2012 mi_int32 mf_fflags; /* filter flags */ 2013 mi_int32 mf_pflags; /* protocol flags */ 2014 char *mf_conn; /* connection info */ 2015 int mf_sock; /* connected socket */ 2016 char mf_state; /* state of filter */ 2017 char mf_lflags; /* "local" flags */ 2018 int mf_idx; /* milter number (index) */ 2019 time_t mf_timeout[SMFTO_NUM_TO]; /* timeouts */ 2020 # if _FFR_MILTER_CHECK 2021 /* for testing only */ 2022 mi_int32 mf_mta_prot_version; 2023 mi_int32 mf_mta_prot_flags; 2024 mi_int32 mf_mta_actions; 2025 # endif /* _FFR_MILTER_CHECK */ 2026 }; 2027 2028 # define MI_LFL_NONE 0x00000000 2029 # define MI_LFLAGS_SYM(st) (1 << (st)) /* has its own symlist for stage st */ 2030 2031 struct milters 2032 { 2033 mi_int32 mis_flags; /* filter flags */ 2034 }; 2035 typedef struct milters milters_T; 2036 2037 # define MIS_FL_NONE 0x00000000 /* no requirements... */ 2038 # define MIS_FL_DEL_RCPT 0x00000001 /* can delete rcpt */ 2039 # define MIS_FL_REJ_RCPT 0x00000002 /* can reject rcpt */ 2040 2041 2042 /* MTA flags */ 2043 # define SMF_REJECT 'R' /* Reject connection on filter fail */ 2044 # define SMF_TEMPFAIL 'T' /* tempfail connection on failure */ 2045 # define SMF_TEMPDROP '4' /* 421 connection on failure */ 2046 2047 EXTERN struct milter *InputFilters[MAXFILTERS]; 2048 EXTERN char *InputFilterList; 2049 EXTERN int MilterLogLevel; 2050 2051 /* functions */ 2052 extern void setup_daemon_milters __P((void)); 2053 #endif /* MILTER */ 2054 2055 /* 2056 ** Vendor codes 2057 ** 2058 ** Vendors can customize sendmail to add special behaviour, 2059 ** generally for back compatibility. Ideally, this should 2060 ** be set up in the .cf file using the "V" command. However, 2061 ** it's quite reasonable for some vendors to want the default 2062 ** be their old version; this can be set using 2063 ** -DVENDOR_DEFAULT=VENDOR_xxx 2064 ** in the Makefile. 2065 ** 2066 ** Vendors should apply to sendmail-YYYY@support.sendmail.org 2067 ** (replace YYYY with the current year) 2068 ** for unique vendor codes. 2069 */ 2070 2071 #define VENDOR_BERKELEY 1 /* Berkeley-native configuration file */ 2072 #define VENDOR_SUN 2 /* Sun-native configuration file */ 2073 #define VENDOR_HP 3 /* Hewlett-Packard specific config syntax */ 2074 #define VENDOR_IBM 4 /* IBM specific config syntax */ 2075 #define VENDOR_SENDMAIL 5 /* Proofpoint, Inc. specific config syntax */ 2076 #define VENDOR_DEC 6 /* Compaq, DEC, Digital */ 2077 2078 /* prototypes for vendor-specific hook routines */ 2079 extern void vendor_daemon_setup __P((ENVELOPE *)); 2080 extern void vendor_set_uid __P((UID_T)); 2081 2082 2083 /* 2084 ** Terminal escape codes. 2085 ** 2086 ** To make debugging output clearer. 2087 */ 2088 2089 struct termescape 2090 { 2091 char *te_rv_on; /* turn reverse-video on */ 2092 char *te_under_on; /* turn underlining on */ 2093 char *te_normal; /* revert to normal output */ 2094 }; 2095 2096 /* 2097 ** Additional definitions 2098 */ 2099 2100 /* 2101 ** d_flags, see daemon.c 2102 ** general rule: lower case: required, upper case: No 2103 */ 2104 2105 #define D_AUTHREQ 'a' /* authentication required */ 2106 #define D_BINDIF 'b' /* use if_addr for outgoing connection */ 2107 #define D_CANONREQ 'c' /* canonification required (cf) */ 2108 #define D_IFNHELO 'h' /* use if name for HELO */ 2109 #define D_FQMAIL 'f' /* fq sender address required (cf) */ 2110 #define D_FQRCPT 'r' /* fq recipient address required (cf) */ 2111 #define D_SMTPS 's' /* SMTP over SSL (smtps) */ 2112 #define D_UNQUALOK 'u' /* unqualified address is ok (cf) */ 2113 #define D_NOAUTH 'A' /* no AUTH */ 2114 #define D_NOCANON 'C' /* no canonification (cf) */ 2115 #define D_NODANE 'D' /* no DANE (client) */ 2116 #define D_NOETRN 'E' /* no ETRN (MSA) */ 2117 #define D_NOSTS 'M' /* no MTA-STS (client) */ 2118 #define D_NOTLS 'S' /* don't use STARTTLS */ 2119 #define D_ETRNONLY ((char)0x01) /* allow only ETRN (disk low) */ 2120 #define D_OPTIONAL 'O' /* optional socket */ 2121 #define D_DISABLE ((char)0x02) /* optional socket disabled */ 2122 #define D_ISSET ((char)0x03) /* this client struct is set */ 2123 #if _FFR_XCNCT 2124 #define D_XCNCT ((char)0x04) /* X-Connect was used */ 2125 #define D_XCNCT_M ((char)0x05) /* X-Connect was used + "forged" */ 2126 #endif 2127 2128 2129 /* 2130 ** Queue related items 2131 */ 2132 2133 /* queue file names */ 2134 #define ANYQFL_LETTER '?' 2135 #define QUARQF_LETTER 'h' 2136 #define DATAFL_LETTER 'd' 2137 #define XSCRPT_LETTER 'x' 2138 #define NORMQF_LETTER 'q' 2139 #define NEWQFL_LETTER 't' 2140 2141 # define TEMPQF_LETTER 'T' 2142 # define LOSEQF_LETTER 'Q' 2143 2144 /* queue sort order */ 2145 #define QSO_BYPRIORITY 0 /* sort by message priority */ 2146 #define QSO_BYHOST 1 /* sort by first host name */ 2147 #define QSO_BYTIME 2 /* sort by submission time */ 2148 #define QSO_BYFILENAME 3 /* sort by file name only */ 2149 #define QSO_RANDOM 4 /* sort in random order */ 2150 #define QSO_BYMODTIME 5 /* sort by modification time */ 2151 #define QSO_NONE 6 /* do not sort */ 2152 #if _FFR_RHS 2153 # define QSO_BYSHUFFLE 7 /* sort by shuffled host name */ 2154 #endif 2155 2156 #define NOQGRP (-1) /* no queue group (yet) */ 2157 #define ENVQGRP (-2) /* use queue group of envelope */ 2158 #define NOAQGRP (-3) /* no queue group in addr (yet) */ 2159 #define ISVALIDQGRP(x) ((x) >= 0) /* valid queue group? */ 2160 #define NOQDIR (-1) /* no queue directory (yet) */ 2161 #define ENVQDIR (-2) /* use queue directory of envelope */ 2162 #define NOAQDIR (-3) /* no queue directory in addr (yet) */ 2163 #define ISVALIDQDIR(x) ((x) >= 0) /* valid queue directory? */ 2164 #define RS_QUEUEGROUP "queuegroup" /* ruleset for queue group selection */ 2165 2166 #define NOW ((time_t) (-1)) /* queue return: now */ 2167 2168 /* SuperSafe values */ 2169 #define SAFE_NO 0 /* no fsync(): don't use... */ 2170 #define SAFE_INTERACTIVE 1 /* limit fsync() in -odi */ 2171 #define SAFE_REALLY 2 /* always fsync() */ 2172 #define SAFE_REALLY_POSTMILTER 3 /* fsync() if milter says OK */ 2173 2174 /* QueueMode bits */ 2175 #define QM_NORMAL ' ' 2176 #define QM_QUARANTINE 'Q' 2177 #define QM_LOST 'L' 2178 2179 /* Queue Run Limitations */ 2180 struct queue_char 2181 { 2182 char *queue_match; /* string to match */ 2183 bool queue_negate; /* or not match, if set */ 2184 struct queue_char *queue_next; 2185 }; 2186 2187 /* run_work_group() flags */ 2188 #define RWG_NONE 0x0000 2189 #define RWG_FORK 0x0001 2190 #define RWG_VERBOSE 0x0002 2191 #define RWG_PERSISTENT 0x0004 2192 #define RWG_FORCE 0x0008 2193 #define RWG_RUNALL 0x0010 2194 2195 typedef struct queue_char QUEUE_CHAR; 2196 2197 EXTERN int volatile CurRunners; /* current number of runner children */ 2198 EXTERN int MaxQueueRun; /* maximum number of jobs in one queue run */ 2199 EXTERN int MaxQueueChildren; /* max # of forked queue children */ 2200 EXTERN int MaxRunnersPerQueue; /* max # proc's active in queue group */ 2201 EXTERN int NiceQueueRun; /* nice queue runs to this value */ 2202 EXTERN int NumQueue; /* number of queue groups */ 2203 EXTERN int QueueFileMode; /* mode on files in mail queue */ 2204 EXTERN int QueueMode; /* which queue items to act upon */ 2205 EXTERN int QueueSortOrder; /* queue sorting order algorithm */ 2206 EXTERN time_t MinQueueAge; /* min delivery interval */ 2207 EXTERN time_t MaxQueueAge; /* max delivery interval */ 2208 EXTERN time_t QueueIntvl; /* intervals between running the queue */ 2209 EXTERN char *QueueDir; /* location of queue directory */ 2210 EXTERN QUEUE_CHAR *QueueLimitId; /* limit queue run to id */ 2211 EXTERN QUEUE_CHAR *QueueLimitQuarantine; /* limit queue run to quarantine reason */ 2212 EXTERN QUEUE_CHAR *QueueLimitRecipient; /* limit queue run to rcpt */ 2213 EXTERN QUEUE_CHAR *QueueLimitSender; /* limit queue run to sender */ 2214 EXTERN QUEUEGRP *Queue[MAXQUEUEGROUPS + 1]; /* queue groups */ 2215 #if _FFR_BOUNCE_QUEUE 2216 EXTERN int BounceQueue; 2217 #endif 2218 2219 /* functions */ 2220 extern void assign_queueid __P((ENVELOPE *)); 2221 extern ADDRESS *copyqueue __P((ADDRESS *, SM_RPOOL_T *)); 2222 extern void cleanup_queues __P((void)); 2223 extern bool doqueuerun __P((void)); 2224 extern void initsys __P((ENVELOPE *)); 2225 extern void loseqfile __P((ENVELOPE *, char *)); 2226 extern int name2qid __P((char *)); 2227 extern char *qid_printname __P((ENVELOPE *)); 2228 extern char *qid_printqueue __P((int, int)); 2229 extern void quarantine_queue __P((char *, int)); 2230 extern char *queuename __P((ENVELOPE *, int)); 2231 extern void queueup __P((ENVELOPE *, unsigned int)); 2232 extern bool runqueue __P((bool, bool, bool, bool)); 2233 extern bool run_work_group __P((int, int)); 2234 extern void set_def_queueval __P((QUEUEGRP *, bool)); 2235 extern void setup_queues __P((bool)); 2236 extern bool setnewqueue __P((ENVELOPE *)); 2237 extern bool shouldqueue __P((long, time_t)); 2238 extern void sync_queue_time __P((void)); 2239 extern void init_qid_alg __P((void)); 2240 extern int print_single_queue __P((int, int)); 2241 #if REQUIRES_DIR_FSYNC 2242 # define SYNC_DIR(path, panic) sync_dir(path, panic) 2243 extern void sync_dir __P((char *, bool)); 2244 #else 2245 # define SYNC_DIR(path, panic) ((void) 0) 2246 #endif 2247 #if _FFR_DMTRIGGER 2248 extern bool qm __P((void)); 2249 #endif 2250 2251 /* 2252 ** Timeouts 2253 ** 2254 ** Indicated values are the MINIMUM per RFC 1123 section 5.3.2. 2255 */ 2256 2257 EXTERN struct 2258 { 2259 /* RFC 1123-specified timeouts [minimum value] */ 2260 time_t to_initial; /* initial greeting timeout [5m] */ 2261 time_t to_mail; /* MAIL command [5m] */ 2262 time_t to_rcpt; /* RCPT command [5m] */ 2263 time_t to_datainit; /* DATA initiation [2m] */ 2264 time_t to_datablock; /* DATA block [3m] */ 2265 time_t to_datafinal; /* DATA completion [10m] */ 2266 time_t to_nextcommand; /* next command [5m] */ 2267 /* following timeouts are not mentioned in RFC 1123 */ 2268 time_t to_iconnect; /* initial connection timeout (first try) */ 2269 time_t to_connect; /* initial connection timeout (later tries) */ 2270 time_t to_aconnect; /* all connections timeout (MX and A records) */ 2271 time_t to_rset; /* RSET command */ 2272 time_t to_helo; /* HELO command */ 2273 time_t to_quit; /* QUIT command */ 2274 time_t to_miscshort; /* misc short commands (NOOP, VERB, etc) */ 2275 time_t to_ident; /* IDENT protocol requests */ 2276 time_t to_fileopen; /* opening :include: and .forward files */ 2277 time_t to_control; /* process a control socket command */ 2278 time_t to_lhlo; /* LMTP: LHLO command */ 2279 #if SASL 2280 time_t to_auth; /* AUTH dialogue [10m] */ 2281 #endif 2282 #if STARTTLS 2283 time_t to_starttls; /* STARTTLS dialogue [10m] */ 2284 #endif 2285 /* following are per message */ 2286 time_t to_q_return[MAXTOCLASS]; /* queue return timeouts */ 2287 time_t to_q_warning[MAXTOCLASS]; /* queue warning timeouts */ 2288 time_t res_retrans[MAXRESTOTYPES]; /* resolver retransmit */ 2289 int res_retry[MAXRESTOTYPES]; /* resolver retry */ 2290 } TimeOuts; 2291 2292 /* timeout classes for return and warning timeouts */ 2293 #define TOC_NORMAL 0 /* normal delivery */ 2294 #define TOC_URGENT 1 /* urgent delivery */ 2295 #define TOC_NONURGENT 2 /* non-urgent delivery */ 2296 #define TOC_DSN 3 /* DSN delivery */ 2297 2298 /* resolver timeout specifiers */ 2299 #define RES_TO_FIRST 0 /* first attempt */ 2300 #define RES_TO_NORMAL 1 /* subsequent attempts */ 2301 #define RES_TO_DEFAULT 2 /* default value */ 2302 2303 /* functions */ 2304 extern void inittimeouts __P((char *, bool)); 2305 2306 /* 2307 ** Interface probing 2308 */ 2309 2310 #define DPI_PROBENONE 0 /* Don't probe any interfaces */ 2311 #define DPI_PROBEALL 1 /* Probe all interfaces */ 2312 #define DPI_SKIPLOOPBACK 2 /* Don't probe loopback interfaces */ 2313 2314 /* 2315 ** Trace information 2316 */ 2317 2318 /* macros for debugging flags */ 2319 #if NOT_SENDMAIL 2320 # define tTd(flag, level) (tTdvect[flag] >= (unsigned char)level) 2321 #else 2322 # define tTd(flag, level) (tTdvect[flag] >= (unsigned char)level && !IntSig) 2323 #endif 2324 #define tTdlevel(flag) (tTdvect[flag]) 2325 2326 /* variables */ 2327 extern unsigned char tTdvect[100]; /* trace vector */ 2328 2329 /* 2330 ** Miscellaneous information. 2331 */ 2332 2333 /* 2334 ** The "no queue id" queue id for sm_syslog 2335 */ 2336 2337 #define NOQID "" 2338 2339 #define CURHOSTNAME (CurHostName == NULL ? "local" : CurHostName) 2340 2341 /* 2342 ** Some in-line functions 2343 */ 2344 2345 /* set exit status */ 2346 #define setstat(s) \ 2347 do \ 2348 { \ 2349 if (ExitStat == EX_OK || ExitStat == EX_TEMPFAIL) \ 2350 ExitStat = s; \ 2351 } while (0) 2352 2353 2354 #define STRUCTCOPY(s, d) d = s 2355 2356 /* 2357 ** Update a permanent string variable with a new value. 2358 ** The old value is freed, the new value is strdup'ed. 2359 ** 2360 ** We use sm_pstrdup_x to duplicate the string because it raises 2361 ** an exception on error, and because it allocates "permanent storage" 2362 ** which is not expected to be freed before process exit. 2363 ** The latter is important for memory leak analysis. 2364 ** 2365 ** If an exception occurs while strdup'ing the new value, 2366 ** then the variable remains set to the old value. 2367 ** That's why the strdup must occur before we free the old value. 2368 */ 2369 #define PSTRSET(var, val) \ 2370 do \ 2371 { \ 2372 char *_newval = sm_pstrdup_x(val); \ 2373 if (var != NULL) \ 2374 sm_free(var); \ 2375 var = _newval; \ 2376 } while (0) 2377 2378 #define _CHECK_RESTART \ 2379 do \ 2380 { \ 2381 if (ShutdownRequest != NULL) \ 2382 shutdown_daemon(); \ 2383 else if (RestartRequest != NULL) \ 2384 restart_daemon(); \ 2385 else if (RestartWorkGroup) \ 2386 restart_marked_work_groups(); \ 2387 } while (0) 2388 2389 # define CHECK_RESTART _CHECK_RESTART 2390 2391 #define CHK_CUR_RUNNERS(fct, idx, count) \ 2392 do \ 2393 { \ 2394 if (CurRunners < 0) \ 2395 { \ 2396 if (LogLevel > 3) \ 2397 sm_syslog(LOG_ERR, NOQID, \ 2398 "%s: CurRunners=%d, i=%d, count=%d, status=should not happen", \ 2399 fct, CurRunners, idx, count); \ 2400 CurRunners = 0; \ 2401 } \ 2402 } while (0) 2403 2404 /* reply types (text in SmtpMsgBuffer) */ 2405 #define XS_DEFAULT 0 /* other commands, e.g., RSET */ 2406 #define XS_STARTTLS 1 2407 #define XS_AUTH 2 2408 #define XS_GREET 3 2409 #define XS_EHLO 4 2410 #define XS_MAIL 5 2411 #define XS_RCPT 6 2412 #define XS_DATA 7 2413 #define XS_EOM 8 2414 #define XS_DATA2 9 /* LMTP */ 2415 #define XS_QUIT 10 2416 2417 /* 2418 ** Global variables. 2419 */ 2420 2421 #if _FFR_ADD_BCC 2422 EXTERN bool AddBcc; 2423 #endif 2424 #if _FFR_ADDR_TYPE_MODES 2425 EXTERN bool AddrTypeModes; /* addr_type: extra "mode" information */ 2426 #endif 2427 EXTERN bool AllowBogusHELO; /* allow syntax errors on HELO command */ 2428 EXTERN bool CheckAliases; /* parse addresses during newaliases */ 2429 #if _FFR_QUEUE_RUN_PARANOIA 2430 EXTERN int CheckQueueRunners; /* check whether queue runners are OK */ 2431 #endif 2432 EXTERN bool ColonOkInAddr; /* single colon legal in address */ 2433 #if !defined(_USE_SUN_NSSWITCH_) && !defined(_USE_DEC_SVC_CONF_) 2434 EXTERN bool ConfigFileRead; /* configuration file has been read */ 2435 #endif 2436 EXTERN bool DisConnected; /* running with OutChannel redirect to transcript file */ 2437 EXTERN bool DontExpandCnames; /* do not $[...$] expand CNAMEs */ 2438 EXTERN bool DontInitGroups; /* avoid initgroups() because of NIS cost */ 2439 EXTERN bool DontLockReadFiles; /* don't read lock support files */ 2440 EXTERN bool DontPruneRoutes; /* don't prune source routes */ 2441 EXTERN bool ForkQueueRuns; /* fork for each job when running the queue */ 2442 EXTERN bool FromFlag; /* if set, "From" person is explicit */ 2443 EXTERN bool FipsMode; 2444 EXTERN bool GrabTo; /* if set, get recipients from msg */ 2445 #if _FFR_EIGHT_BIT_ADDR_OK 2446 EXTERN bool EightBitAddrOK; /* we'll let 8-bit addresses through */ 2447 #else 2448 # define EightBitAddrOK false 2449 #endif 2450 EXTERN bool HasEightBits; /* has at least one eight bit input byte */ 2451 EXTERN bool HasWildcardMX; /* don't use MX records when canonifying */ 2452 EXTERN bool HoldErrs; /* only output errors to transcript */ 2453 EXTERN bool IgnoreHostStatus; /* ignore long term host status files */ 2454 EXTERN bool IgnrDot; /* don't let dot end messages */ 2455 #if _FFR_KEEPBCC 2456 EXTERN bool KeepBcc; 2457 #else 2458 # define KeepBcc false 2459 #endif 2460 EXTERN bool LogUsrErrs; /* syslog user errors (e.g., SMTP RCPT cmd) */ 2461 EXTERN bool MatchGecos; /* look for user names in gecos field */ 2462 EXTERN bool MeToo; /* send to the sender also */ 2463 EXTERN bool NoAlias; /* suppress aliasing */ 2464 EXTERN bool NoConnect; /* don't connect to non-local mailers */ 2465 EXTERN bool OnlyOneError; /* .... or only want to give one SMTP reply */ 2466 EXTERN bool QuickAbort; /* .... but only if we want a quick abort */ 2467 #if _FFR_REJECT_NUL_BYTE 2468 EXTERN bool RejectNUL; /* reject NUL input byte? */ 2469 #endif 2470 #if REQUIRES_DIR_FSYNC 2471 EXTERN bool RequiresDirfsync; /* requires fsync() for directory */ 2472 #endif 2473 EXTERN bool volatile RestartWorkGroup; /* daemon needs to restart some work groups */ 2474 EXTERN bool RrtImpliesDsn; /* turn Return-Receipt-To: into DSN */ 2475 EXTERN bool SaveFrom; /* save leading "From" lines */ 2476 EXTERN bool SendMIMEErrors; /* send error messages in MIME format */ 2477 EXTERN bool SevenBitInput; /* force 7-bit data on input */ 2478 EXTERN bool SingleLineFromHeader; /* force From: header to be one line */ 2479 EXTERN bool SingleThreadDelivery; /* single thread hosts on delivery */ 2480 EXTERN bool SoftBounce; /* replace 5xy by 4xy (for testing) */ 2481 EXTERN bool volatile StopRequest; /* stop sending output */ 2482 EXTERN bool SuprErrs; /* set if we are suppressing errors */ 2483 EXTERN bool TryNullMXList; /* if we are the best MX, try host directly */ 2484 EXTERN bool UseMSP; /* mail submission: group writable queue ok? */ 2485 EXTERN bool WorkAroundBrokenAAAA; /* some nameservers return SERVFAIL on AAAA queries */ 2486 EXTERN bool UseErrorsTo; /* use Errors-To: header (back compat) */ 2487 EXTERN bool UseNameServer; /* using DNS -- interpret h_errno & MX RRs */ 2488 EXTERN bool UseCompressedIPv6Addresses; /* for more specific zero-subnet matches */ 2489 EXTERN char InetMode; /* default network for daemon mode */ 2490 EXTERN char OpMode; /* operation mode, see below */ 2491 EXTERN char SpaceSub; /* substitution for <lwsp> */ 2492 #if _FFR_BADRCPT_SHUTDOWN 2493 EXTERN int BadRcptShutdown; /* Shutdown connection for rejected RCPTs */ 2494 EXTERN int BadRcptShutdownGood; /* above even when there are good RCPTs */ 2495 #endif 2496 EXTERN int BadRcptThrottle; /* Throttle rejected RCPTs per SMTP message */ 2497 #if _FFR_RCPTTHROTDELAY 2498 EXTERN unsigned int BadRcptThrottleDelay; /* delay for BadRcptThrottle */ 2499 #else 2500 # define BadRcptThrottleDelay 1 2501 #endif 2502 #if _FFR_TLS_ALTNAMES 2503 EXTERN bool SetCertAltnames; 2504 #endif 2505 EXTERN int CheckpointInterval; /* queue file checkpoint interval */ 2506 EXTERN int ConfigLevel; /* config file level */ 2507 EXTERN int ConnRateThrottle; /* throttle for SMTP connection rate */ 2508 EXTERN int volatile CurChildren; /* current number of daemonic children */ 2509 EXTERN int CurrentLA; /* current load average */ 2510 #if DANE 2511 EXTERN int Dane; /* DANE */ 2512 #endif 2513 EXTERN int DefaultNotify; /* default DSN notification flags */ 2514 EXTERN int DelayLA; /* load average to delay connections */ 2515 EXTERN int DontProbeInterfaces; /* don't probe interfaces for names */ 2516 EXTERN int Errors; /* set if errors (local to single pass) */ 2517 EXTERN int ExitStat; /* exit status code */ 2518 EXTERN int FastSplit; /* fast initial splitting of envelopes */ 2519 EXTERN int FileMode; /* mode on files */ 2520 EXTERN int LineNumber; /* line number in current input */ 2521 EXTERN int LogLevel; /* level of logging to perform */ 2522 EXTERN int MaxAliasRecursion; /* maximum depth of alias recursion */ 2523 EXTERN int MaxChildren; /* maximum number of daemonic children */ 2524 EXTERN int MaxForwardEntries; /* maximum number of forward entries */ 2525 EXTERN int MaxHeadersLength; /* max length of headers */ 2526 EXTERN int MaxHopCount; /* max # of hops until bounce */ 2527 EXTERN int MaxMacroRecursion; /* maximum depth of macro recursion */ 2528 EXTERN int MaxMimeFieldLength; /* maximum MIME field length */ 2529 EXTERN int MaxMimeHeaderLength; /* maximum MIME header length */ 2530 EXTERN int MaxNOOPCommands; /* max "noise" commands before slowdown */ 2531 2532 EXTERN int MaxRcptPerMsg; /* max recipients per SMTP message */ 2533 EXTERN int MaxRuleRecursion; /* maximum depth of ruleset recursion */ 2534 #if _FFR_MSG_ACCEPT 2535 EXTERN char *MessageAccept; /* "Message accepted for delivery" reply text */ 2536 #endif 2537 2538 EXTERN int MimeMode; /* MIME processing mode */ 2539 #if _FFR_MTA_STS 2540 EXTERN bool MTASTS; 2541 EXTERN char *STS_SNI; 2542 #endif 2543 EXTERN int NoRecipientAction; 2544 2545 #if SM_CONF_SHM 2546 EXTERN int Numfilesys; /* number of queue file systems */ 2547 EXTERN int *PNumFileSys; 2548 # define NumFileSys (*PNumFileSys) 2549 #else /* SM_CONF_SHM */ 2550 EXTERN int NumFileSys; /* number of queue file systems */ 2551 #endif /* SM_CONF_SHM */ 2552 2553 EXTERN int QueueLA; /* load average starting forced queueing */ 2554 EXTERN int RefuseLA; /* load average refusing connections */ 2555 EXTERN time_t RejectLogInterval; /* time btwn log msgs while refusing */ 2556 #if _FFR_MEMSTAT 2557 EXTERN long QueueLowMem; /* low memory starting forced queueing */ 2558 EXTERN long RefuseLowMem; /* low memory refusing connections */ 2559 EXTERN char *MemoryResource;/* memory resource to look up */ 2560 #endif /* _FFR_MEMSTAT */ 2561 EXTERN int SuperSafe; /* be extra careful, even if expensive */ 2562 #if USE_EAI 2563 EXTERN int SMTPUTF8; /* enable SMTPUTF8 support */ 2564 #else 2565 # define SMTPUTF8 false 2566 #endif 2567 EXTERN int VendorCode; /* vendor-specific operation enhancements */ 2568 EXTERN int Verbose; /* set if blow-by-blow desired */ 2569 EXTERN gid_t DefGid; /* default gid to run as */ 2570 EXTERN gid_t RealGid; /* real gid of caller */ 2571 EXTERN gid_t RunAsGid; /* GID to become for bulk of run */ 2572 EXTERN gid_t EffGid; /* effective gid */ 2573 #if SM_CONF_SHM 2574 EXTERN key_t ShmKey; /* shared memory key */ 2575 EXTERN char *ShmKeyFile; /* shared memory key file */ 2576 #endif 2577 EXTERN pid_t CurrentPid; /* current process id */ 2578 EXTERN pid_t DaemonPid; /* process id of daemon */ 2579 EXTERN pid_t PidFilePid; /* daemon/queue runner who wrote pid file */ 2580 EXTERN uid_t DefUid; /* default uid to run as */ 2581 EXTERN uid_t RealUid; /* real uid of caller */ 2582 EXTERN uid_t RunAsUid; /* UID to become for bulk of run */ 2583 EXTERN uid_t TrustedUid; /* uid of trusted user for files and startup */ 2584 EXTERN size_t DataFileBufferSize; /* size of buf for in-core data file */ 2585 EXTERN time_t DeliverByMin; /* deliver by minimum time */ 2586 EXTERN time_t DialDelay; /* delay between dial-on-demand tries */ 2587 EXTERN time_t SafeAlias; /* interval to wait until @:@ in alias file */ 2588 EXTERN time_t ServiceCacheMaxAge; /* refresh interval for cache */ 2589 EXTERN size_t XscriptFileBufferSize; /* size of buf for in-core transcript file */ 2590 EXTERN MODE_T OldUmask; /* umask when sendmail starts up */ 2591 EXTERN long MaxMessageSize; /* advertised max size we will accept */ 2592 EXTERN long MinBlocksFree; /* min # of blocks free on queue fs */ 2593 EXTERN long QueueFactor; /* slope of queue function */ 2594 EXTERN long WkClassFact; /* multiplier for message class -> priority */ 2595 EXTERN long WkRecipFact; /* multiplier for # of recipients -> priority */ 2596 EXTERN long WkTimeFact; /* priority offset each time this job is run */ 2597 EXTERN char *ControlSocketName; /* control socket filename [control.c] */ 2598 EXTERN char *CurHostName; /* current host we are dealing with */ 2599 EXTERN char *DeadLetterDrop; /* path to dead letter office */ 2600 EXTERN char *DefUser; /* default user to run as (from DefUid) */ 2601 EXTERN char *DefaultCharSet; /* default character set for MIME */ 2602 EXTERN char *DoubleBounceAddr; /* where to send double bounces */ 2603 EXTERN char *ErrMsgFile; /* file to prepend to all error messages */ 2604 EXTERN char *FallbackMX; /* fall back MX host */ 2605 EXTERN char *FallbackSmartHost; /* fall back smart host */ 2606 EXTERN char *FileName; /* name to print on error messages */ 2607 EXTERN char *ForwardPath; /* path to search for .forward files */ 2608 EXTERN char *HeloName; /* hostname to announce in HELO */ 2609 EXTERN char *HelpFile; /* location of SMTP help file */ 2610 EXTERN char *HostStatDir; /* location of host status information */ 2611 EXTERN char *HostsFile; /* path to /etc/hosts file */ 2612 extern char *Mbdb; /* mailbox database type */ 2613 EXTERN char *MustQuoteChars; /* quote these characters in phrases */ 2614 EXTERN char *MyHostName; /* name of this host for SMTP messages */ 2615 EXTERN char *OperatorChars; /* operators (old $o macro) */ 2616 EXTERN char *PidFile; /* location of proc id file [conf.c] */ 2617 EXTERN char *PostMasterCopy; /* address to get errs cc's */ 2618 EXTERN char *ProcTitlePrefix; /* process title prefix */ 2619 EXTERN char *RealHostName; /* name of host we are talking to */ 2620 EXTERN char *RealUserName; /* real user name of caller */ 2621 EXTERN char *volatile RestartRequest;/* a sendmail restart has been requested */ 2622 EXTERN char *RunAsUserName; /* user to become for bulk of run */ 2623 EXTERN char *SafeFileEnv; /* chroot location for file delivery */ 2624 EXTERN char *ServiceSwitchFile; /* backup service switch */ 2625 EXTERN char *volatile ShutdownRequest;/* a sendmail shutdown has been requested */ 2626 EXTERN bool volatile IntSig; 2627 EXTERN char *SmtpGreeting; /* SMTP greeting message (old $e macro) */ 2628 EXTERN char *SmtpPhase; /* current phase in SMTP processing */ 2629 EXTERN char SmtpError[MAXLINE]; /* save failure error messages */ 2630 EXTERN char *StatFile; /* location of statistics summary */ 2631 EXTERN char *TimeZoneSpec; /* override time zone specification */ 2632 EXTERN char *UdbSpec; /* user database source spec */ 2633 EXTERN char *UnixFromLine; /* UNIX From_ line (old $l macro) */ 2634 EXTERN char **ExternalEnviron; /* saved user (input) environment */ 2635 EXTERN char **SaveArgv; /* argument vector for re-execing */ 2636 EXTERN BITMAP256 DontBlameSendmail; /* DontBlameSendmail bits */ 2637 EXTERN SM_FILE_T *InChannel; /* input connection */ 2638 EXTERN SM_FILE_T *OutChannel; /* output connection */ 2639 EXTERN SM_FILE_T *TrafficLogFile; /* file in which to log all traffic */ 2640 #if HESIOD 2641 EXTERN void *HesiodContext; 2642 #endif 2643 EXTERN ENVELOPE *CurEnv; /* envelope currently being processed */ 2644 EXTERN char *RuleSetNames[MAXRWSETS]; /* ruleset number to name */ 2645 EXTERN char *UserEnviron[MAXUSERENVIRON + 1]; 2646 EXTERN struct rewrite *RewriteRules[MAXRWSETS]; 2647 EXTERN struct termescape TermEscape; /* terminal escape codes */ 2648 EXTERN SOCKADDR ConnectOnlyTo; /* override connection address (for testing) */ 2649 EXTERN SOCKADDR RealHostAddr; /* address of host we are talking to */ 2650 extern const SM_EXC_TYPE_T EtypeQuickAbort; /* type of a QuickAbort exception */ 2651 2652 #if _FFR_BLANKENV_MACV 2653 EXTERN int Hacks; /* bit field of run-time enabled "hacks" */ 2654 # define H_LOOKUP_MACRO_IN_BLANKENV 0x0001 2655 # define LOOKUP_MACRO_IN_BLANKENV (Hacks & H_LOOKUP_MACRO_IN_BLANKENV) 2656 #else 2657 # define LOOKUP_MACRO_IN_BLANKENV false 2658 #endif 2659 2660 EXTERN int ConnectionRateWindowSize; 2661 2662 /* 2663 ** Declarations of useful functions 2664 */ 2665 2666 /* Transcript file */ 2667 extern void closexscript __P((ENVELOPE *)); 2668 extern void openxscript __P((ENVELOPE *)); 2669 2670 #if SM_DEVELOPER 2671 #define NR_PRINTFLIKE(a, b) PRINTFLIKE(a, b) 2672 #else 2673 #define NR_PRINTFLIKE(a, b) 2674 #endif 2675 2676 /* error related */ 2677 extern void buffer_errors __P((void)); 2678 extern void flush_errors __P((bool)); 2679 extern void NR_PRINTFLIKE(1, 2) message __P((const char *, ...)); 2680 extern void NR_PRINTFLIKE(1, 2) nmessage __P((const char *, ...)); 2681 #if _FFR_PROXY 2682 extern void NR_PRINTFLIKE(3, 4) emessage __P((const char *, const char *, const char *, ...)); 2683 extern int extsc __P((const char *, int, char *, char *)); 2684 #endif 2685 extern void NR_PRINTFLIKE(1, 2) syserr __P((const char *, ...)); 2686 extern void NR_PRINTFLIKE(2, 3) usrerrenh __P((char *, const char *, ...)); 2687 extern void NR_PRINTFLIKE(1, 2) usrerr __P((const char *, ...)); 2688 extern int isenhsc __P((const char *, int)); 2689 extern int extenhsc __P((const char *, int, char *)); 2690 extern int skipaddrhost __P((const char *, bool)); 2691 2692 /* alias file */ 2693 extern void alias __P((ADDRESS *, ADDRESS **, int, ENVELOPE *)); 2694 extern bool aliaswait __P((MAP *, char *, bool)); 2695 extern void forward __P((ADDRESS *, ADDRESS **, int, ENVELOPE *)); 2696 extern void readaliases __P((MAP *, SM_FILE_T *, bool, bool)); 2697 extern bool rebuildaliases __P((MAP *, bool)); 2698 extern void setalias __P((char *)); 2699 2700 /* logging */ 2701 extern void logdelivery __P((MAILER *, MCI *, char *, const char *, ADDRESS *, time_t, ENVELOPE *, ADDRESS *, int)); 2702 extern void logsender __P((ENVELOPE *, char *)); 2703 extern void PRINTFLIKE(3, 4) sm_syslog __P((int, const char *, const char *, ...)); 2704 2705 /* SMTP */ 2706 extern void giveresponse __P((int, char *, MAILER *, MCI *, ADDRESS *, time_t, ENVELOPE *, ADDRESS *)); 2707 extern int reply __P((MAILER *, MCI *, ENVELOPE *, time_t, void (*)__P((char *, bool, MAILER *, MCI *, ENVELOPE *)), char **, int)); 2708 extern void smtp __P((char *volatile, BITMAP256, ENVELOPE *volatile)); 2709 #if SASL 2710 extern int smtpauth __P((MAILER *, MCI *, ENVELOPE *)); 2711 #endif 2712 extern void smtpclrse __P((ENVELOPE *)); 2713 extern int smtpdata __P((MAILER *, MCI *, ENVELOPE *, ADDRESS *, time_t)); 2714 extern int smtpgetstat __P((MAILER *, MCI *, ENVELOPE *)); 2715 extern int smtpmailfrom __P((MAILER *, MCI *, ENVELOPE *)); 2716 extern void smtpmessage __P((char *, MAILER *, MCI *, ...)); 2717 extern void smtpinit __P((MAILER *, MCI *, ENVELOPE *, bool)); 2718 extern char *smtptodsn __P((int)); 2719 extern int smtpprobe __P((MCI *)); 2720 extern void smtpquit __P((MAILER *, MCI *, ENVELOPE *)); 2721 extern int smtprcpt __P((ADDRESS *, MAILER *, MCI *, ENVELOPE *, ADDRESS *, time_t)); 2722 extern void smtprset __P((MAILER *, MCI *, ENVELOPE *)); 2723 2724 #define REPLYTYPE(r) ((r) / 100) /* first digit of reply code */ 2725 #define REPLYCLASS(r) (((r) / 10) % 10) /* second digit of reply code */ 2726 #define REPLYMINOR(r) ((r) % 10) /* last digit of reply code */ 2727 #define ISSMTPCODE(c) (isascii(c[0]) && isdigit(c[0]) && \ 2728 isascii(c[1]) && isdigit(c[1]) && \ 2729 isascii(c[2]) && isdigit(c[2])) 2730 #define ISSMTPREPLY(c) (ISSMTPCODE(c) && \ 2731 (c[3] == ' ' || c[3] == '-' || c[3] == '\0')) 2732 #define SM_ISSPACE(c) (isascii(c) && isspace(c)) 2733 2734 /* delivery */ 2735 extern pid_t dowork __P((int, int, char *, bool, bool, ENVELOPE *)); 2736 extern pid_t doworklist __P((ENVELOPE *, bool, bool)); 2737 extern int endmailer __P((MCI *, ENVELOPE *, char **)); 2738 extern int mailfile __P((char *volatile, MAILER *volatile, ADDRESS *, volatile long, ENVELOPE *)); 2739 extern void sendall __P((ENVELOPE *, int)); 2740 2741 /* stats */ 2742 #define STATS_NORMAL 'n' 2743 #define STATS_QUARANTINE 'q' 2744 #define STATS_REJECT 'r' 2745 #define STATS_CONNECT 'c' 2746 2747 extern void markstats __P((ENVELOPE *, ADDRESS *, int)); 2748 extern void clearstats __P((void)); 2749 extern void poststats __P((char *)); 2750 2751 /* control socket */ 2752 extern void closecontrolsocket __P((bool)); 2753 extern void clrcontrol __P((void)); 2754 extern void control_command __P((int, ENVELOPE *)); 2755 extern int opencontrolsocket __P((void)); 2756 2757 #if MILTER 2758 /* milter functions */ 2759 extern void milter_config __P((char *, struct milter **, int)); 2760 extern void milter_setup __P((char *)); 2761 extern void milter_set_option __P((char *, char *, bool)); 2762 extern bool milter_init __P((ENVELOPE *, char *, milters_T *)); 2763 extern void milter_quit __P((ENVELOPE *)); 2764 extern void milter_abort __P((ENVELOPE *)); 2765 extern char *milter_connect __P((char *, SOCKADDR, ENVELOPE *, char *)); 2766 extern char *milter_helo __P((char *, ENVELOPE *, char *)); 2767 extern char *milter_envfrom __P((char **, ENVELOPE *, char *)); 2768 extern char *milter_data_cmd __P((ENVELOPE *, char *)); 2769 extern char *milter_envrcpt __P((char **, ENVELOPE *, char *, bool)); 2770 extern char *milter_data __P((ENVELOPE *, char *)); 2771 extern char *milter_unknown __P((char *, ENVELOPE *, char *)); 2772 #endif /* MILTER */ 2773 2774 extern char *addquotes __P((char *, SM_RPOOL_T *)); 2775 extern char *arpadate __P((char *)); 2776 extern bool atobool __P((char *)); 2777 extern int atooct __P((char *)); 2778 extern void auth_warning __P((ENVELOPE *, const char *, ...)); 2779 extern int blocksignal __P((int)); 2780 extern bool bitintersect __P((BITMAP256, BITMAP256)); 2781 extern bool bitzerop __P((BITMAP256)); 2782 extern int check_bodytype __P((char *)); 2783 extern void buildfname __P((char *, char *, char *, int)); 2784 extern bool chkclientmodifiers __P((int)); 2785 extern bool chkdaemonmodifiers __P((int)); 2786 extern int checkcompat __P((ADDRESS *, ENVELOPE *)); 2787 #ifdef XDEBUG 2788 extern void checkfd012 __P((char *)); 2789 extern void checkfdopen __P((int, char *)); 2790 #endif 2791 extern void checkfds __P((char *)); 2792 extern bool chownsafe __P((int, bool)); 2793 extern void cleanstrcpy __P((char *, char *, int)); 2794 #if SM_CONF_SHM 2795 extern void cleanup_shm __P((bool)); 2796 #endif 2797 extern void close_sendmail_pid __P((void)); 2798 extern void clrdaemon __P((void)); 2799 extern void collect __P((SM_FILE_T *, bool, HDR **, ENVELOPE *, bool)); 2800 extern time_t convtime __P((char *, int)); 2801 extern char **copyplist __P((char **, bool, SM_RPOOL_T *)); 2802 extern void copy_class __P((int, int)); 2803 extern int count_open_connections __P((SOCKADDR *)); 2804 extern time_t curtime __P((void)); 2805 extern char *defcharset __P((ENVELOPE *)); 2806 extern char *denlstring __P((char *, bool, bool)); 2807 extern void dferror __P((SM_FILE_T *volatile, char *, ENVELOPE *)); 2808 extern void disconnect __P((int, ENVELOPE *)); 2809 extern void disk_status __P((SM_FILE_T *, char *)); 2810 extern int dns_getcanonname __P((char *, int, bool, int *, int *)); 2811 extern pid_t dofork __P((void)); 2812 extern int drop_privileges __P((bool)); 2813 extern int dsntoexitstat __P((char *)); 2814 extern void dumpfd __P((int, bool, bool)); 2815 #if SM_HEAP_CHECK 2816 extern void dumpstab __P((void)); 2817 #endif 2818 extern void dumpstate __P((char *)); 2819 extern bool enoughdiskspace __P((long, ENVELOPE *)); 2820 extern char *exitstat __P((char *)); 2821 extern void fatal_error __P((SM_EXC_T *)); 2822 extern char *fgetfolded __P((char *, int *, SM_FILE_T *)); 2823 extern void fill_fd __P((int, char *)); 2824 extern char *find_character __P((char *, int)); 2825 extern int finduser __P((char *, bool *, SM_MBDB_T *)); 2826 extern void finis __P((bool, bool, volatile int)); 2827 extern void fixcrlf __P((char *, bool)); 2828 extern long freediskspace __P((const char *, long *)); 2829 #if NETINET6 && NEEDSGETIPNODE 2830 extern void freehostent __P((struct hostent *)); 2831 #endif 2832 extern char *get_column __P((char *, int, int, char *, int)); 2833 extern char *getauthinfo __P((int, bool *)); 2834 extern int getdtsize __P((void)); 2835 extern int getla __P((void)); 2836 extern char *getmodifiers __P((char *, BITMAP256)); 2837 extern BITMAP256 *getrequests __P((ENVELOPE *)); 2838 extern char *getvendor __P((int)); 2839 extern void help __P((char *, ENVELOPE *)); 2840 extern void init_md __P((int, char **)); 2841 extern void initdaemon __P((void)); 2842 extern void inithostmaps __P((void)); 2843 extern void initmacros __P((ENVELOPE *)); 2844 extern void initsetproctitle __P((int, char **, char **)); 2845 extern void init_vendor_macros __P((ENVELOPE *)); 2846 extern SIGFUNC_DECL intsig __P((int)); 2847 extern bool isatom __P((const char *)); 2848 extern bool isloopback __P((SOCKADDR sa)); 2849 extern void load_if_names __P((void)); 2850 extern bool lockfile __P((int, char *, char *, int)); 2851 extern void log_sendmail_pid __P((ENVELOPE *)); 2852 extern void logundelrcpts __P((ENVELOPE *, char *, int, bool)); 2853 extern char lower __P((int)); 2854 extern char *makelower_a __P((char **, SM_RPOOL_T *)); 2855 extern void makelower_buf __P((char *, char *, int)); 2856 extern int makeconnection_ds __P((char *, MCI *)); 2857 #if DANE 2858 extern int makeconnection __P((char *, volatile unsigned int, MCI *, ENVELOPE *, time_t, unsigned long *)); 2859 #else 2860 extern int makeconnection __P((char *, volatile unsigned int, MCI *, ENVELOPE *, time_t)); 2861 #endif 2862 extern void makeworkgroups __P((void)); 2863 extern void markfailure __P((ENVELOPE *, ADDRESS *, MCI *, int, bool)); 2864 extern void mark_work_group_restart __P((int, int)); 2865 extern MCI *mci_new __P((SM_RPOOL_T *)); 2866 extern char *munchstring __P((char *, char **, int)); 2867 extern struct hostent *myhostname __P((char *, int)); 2868 #if SM_HEAP_CHECK > 2 2869 extern char *newstr_tagged __P((const char *, char *, int, int)); 2870 # define newstr(str) newstr_tagged(str, "newstr:" __FILE__, __LINE__, SmHeapGroup) 2871 #else 2872 extern char *newstr __P((const char *)); 2873 # define newstr_tagged(str, file, line, grp) newstr(str) 2874 #endif 2875 #if NISPLUS 2876 extern char *nisplus_default_domain __P((void)); /* extern for Sun */ 2877 #endif 2878 extern bool path_is_dir __P((char *, bool)); 2879 extern int pickqdir __P((QUEUEGRP *qg, long fsize, ENVELOPE *e)); 2880 extern char *pintvl __P((time_t, bool)); 2881 extern void printav __P((SM_FILE_T *, char **)); 2882 extern void printmailer __P((SM_FILE_T *, MAILER *)); 2883 extern void printnqe __P((SM_FILE_T *, char *)); 2884 extern void printopenfds __P((bool)); 2885 extern void printqueue __P((void)); 2886 extern void printrules __P((void)); 2887 extern pid_t prog_open __P((char **, int *, ENVELOPE *)); 2888 extern bool putline __P((char *, MCI *)); 2889 extern bool putxline __P((char *, size_t, MCI *, int)); 2890 extern void queueup_macros __P((int, SM_FILE_T *, ENVELOPE *)); 2891 extern void readcf __P((char *, bool, ENVELOPE *)); 2892 extern SIGFUNC_DECL reapchild __P((int)); 2893 extern int releasesignal __P((int)); 2894 extern void resetlimits __P((void)); 2895 extern void restart_daemon __P((void)); 2896 extern void restart_marked_work_groups __P((void)); 2897 extern bool rfc822_string __P((char *)); 2898 extern void rmexpstab __P((void)); 2899 extern bool savemail __P((ENVELOPE *, bool)); 2900 extern void seed_random __P((void)); 2901 extern void sendtoargv __P((char **, ENVELOPE *)); 2902 extern void setclientoptions __P((char *)); 2903 extern bool setdaemonoptions __P((char *)); 2904 extern void setdefaults __P((ENVELOPE *)); 2905 extern void setdefuser __P((void)); 2906 extern bool setvendor __P((char *)); 2907 extern void set_op_mode __P((int)); 2908 extern void setoption __P((int, char *, bool, bool, ENVELOPE *)); 2909 extern sigfunc_t setsignal __P((int, sigfunc_t)); 2910 extern void sm_setuserenv __P((const char *, const char *)); 2911 extern void settime __P((ENVELOPE *)); 2912 #if STARTTLS 2913 extern int set_tls_rd_tmo __P((int)); 2914 #else 2915 # define set_tls_rd_tmo(rd_tmo) 0 2916 #endif 2917 extern char *sfgets __P((char *, int, SM_FILE_T *, time_t, char *)); 2918 extern char *shortenstring __P((const char *, size_t)); 2919 extern char *shorten_hostname __P((char [])); 2920 extern bool shorten_rfc822_string __P((char *, size_t)); 2921 extern void showcfopts __P((void)); 2922 extern void shutdown_daemon __P((void)); 2923 extern void sm_closefrom __P((int lowest, int highest)); 2924 extern void sm_close_on_exec __P((int lowest, int highest)); 2925 extern struct hostent *sm_gethostbyname __P((char *, int)); 2926 extern struct hostent *sm_gethostbyaddr __P((char *, int, int)); 2927 extern void sm_getla __P((void)); 2928 extern struct passwd *sm_getpwnam __P((char *)); 2929 extern struct passwd *sm_getpwuid __P((UID_T)); 2930 extern void sm_setproctitle __P((bool, ENVELOPE *, const char *, ...)); 2931 extern pid_t sm_wait __P((int *)); 2932 extern bool split_by_recipient __P((ENVELOPE *e)); 2933 extern void stop_sendmail __P((void)); 2934 extern void stripbackslash __P((char *)); 2935 extern bool strreplnonprt __P((char *, int)); 2936 extern bool strcontainedin __P((bool, char *, char *)); 2937 extern int switch_map_find __P((char *, char *[], short [])); 2938 #if STARTTLS 2939 extern void tls_set_verify __P((SSL_CTX *, SSL *, bool)); 2940 #endif 2941 extern bool transienterror __P((int)); 2942 extern void truncate_at_delim __P((char *, size_t, int)); 2943 extern void tTflag __P((char *)); 2944 extern void tTsetup __P((unsigned char *, unsigned int, char *)); 2945 extern SIGFUNC_DECL tick __P((int)); 2946 extern char *ttypath __P((void)); 2947 extern void unlockqueue __P((ENVELOPE *)); 2948 #if !HASUNSETENV 2949 extern void unsetenv __P((char *)); 2950 #endif 2951 2952 /* update file system information: +/- some blocks */ 2953 #if SM_CONF_SHM 2954 extern void upd_qs __P((ENVELOPE *, int, int, char *)); 2955 # define updfs(e, count, space, where) upd_qs(e, count, space, where) 2956 #else /* SM_CONF_SHM */ 2957 # define updfs(e, count, space, where) 2958 # define upd_qs(e, count, space, where) 2959 #endif /* SM_CONF_SHM */ 2960 2961 extern char *username __P((void)); 2962 extern bool usershellok __P((char *, char *)); 2963 extern void vendor_post_defaults __P((ENVELOPE *)); 2964 extern void vendor_pre_defaults __P((ENVELOPE *)); 2965 extern int waitfor __P((pid_t)); 2966 extern bool writable __P((char *, ADDRESS *, long)); 2967 #if SM_HEAP_CHECK 2968 # define xalloc(size) xalloc_tagged(size, __FILE__, __LINE__) 2969 extern char *xalloc_tagged __P((int, char *, int)); 2970 #else 2971 extern char *xalloc __P((int)); 2972 #endif /* SM_HEAP_CHECK */ 2973 #if _FFR_XCNCT 2974 extern int xconnect __P((SM_FILE_T *)); 2975 #endif 2976 extern void xputs __P((SM_FILE_T *, const char *)); 2977 extern char *xtextify __P((char *, char *)); 2978 extern bool xtextok __P((char *)); 2979 extern int xunlink __P((char *)); 2980 extern char *xuntextify __P((char *)); 2981 2982 #define ASSIGN_IFDIFF(old, new) \ 2983 do \ 2984 { \ 2985 if ((new) != (old)) \ 2986 { \ 2987 SM_FREE(old); \ 2988 old = new; \ 2989 new = NULL; \ 2990 } \ 2991 } while (0); 2992 2993 #if USE_EAI 2994 extern bool addr_is_ascii __P((const char *)); 2995 extern const char *hn2alabel __P((const char *)); 2996 #endif 2997 2998 #if _FFR_RCPTFLAGS 2999 extern bool newmodmailer __P((ADDRESS *, int)); 3000 #endif 3001 3002 #define SM_CLOSE_FP(fp) \ 3003 do \ 3004 { \ 3005 if ((fp) != NULL) \ 3006 { \ 3007 (void) sm_io_close((fp), SM_TIME_DEFAULT); \ 3008 fp = NULL; \ 3009 } \ 3010 } while (0); 3011 3012 #undef EXTERN 3013 #endif /* ! _SENDMAIL_H */ 3014