1 /* 2 * Copyright (c) 1998-2001 Sendmail, 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 #ifdef _DEFINE 21 # define EXTERN 22 # ifndef lint 23 static char SmailId[] = "@(#)$Id: sendmail.h,v 8.517.4.69 2001/07/20 18:46:01 gshapiro Exp $"; 24 # endif /* ! lint */ 25 #else /* _DEFINE */ 26 # define EXTERN extern 27 #endif /* _DEFINE */ 28 29 30 #include <unistd.h> 31 32 #if SFIO 33 # include <sfio/stdio.h> 34 # if defined(SFIO_VERSION) && SFIO_VERSION > 20000000L 35 ERROR README: SFIO 2000 does not work with sendmail, use SFIO 1999 instead. 36 # endif /* defined(SFIO_VERSION) && SFIO_VERSION > 20000000L */ 37 #endif /* SFIO */ 38 39 #include <stddef.h> 40 #include <stdlib.h> 41 #if !SFIO 42 # include <stdio.h> 43 #endif /* !SFIO */ 44 #include <ctype.h> 45 #include <setjmp.h> 46 #include <string.h> 47 #include <time.h> 48 # ifdef EX_OK 49 # undef EX_OK /* for SVr4.2 SMP */ 50 # endif /* EX_OK */ 51 #include <sysexits.h> 52 53 #include "sendmail/sendmail.h" 54 #include "bf.h" 55 #include "timers.h" 56 57 #ifdef LOG 58 # include <syslog.h> 59 #endif /* LOG */ 60 61 62 63 # if NETINET || NETINET6 || NETUNIX || NETISO || NETNS || NETX25 64 # include <sys/socket.h> 65 # endif /* NETINET || NETINET6 || NETUNIX || NETISO || NETNS || NETX25 */ 66 # if NETUNIX 67 # include <sys/un.h> 68 # endif /* NETUNIX */ 69 # if NETINET || NETINET6 70 # include <netinet/in.h> 71 # endif /* NETINET || NETINET6 */ 72 # if NETINET6 73 /* 74 ** There is no standard yet for IPv6 includes. 75 ** Specify OS specific implementation in conf.h 76 */ 77 # endif /* NETINET6 */ 78 # if NETISO 79 # include <netiso/iso.h> 80 # endif /* NETISO */ 81 # if NETNS 82 # include <netns/ns.h> 83 # endif /* NETNS */ 84 # if NETX25 85 # include <netccitt/x25.h> 86 # endif /* NETX25 */ 87 88 # if NAMED_BIND 89 # include <arpa/nameser.h> 90 # ifdef NOERROR 91 # undef NOERROR /* avoid <sys/streams.h> conflict */ 92 # endif /* NOERROR */ 93 # include <resolv.h> 94 # endif /* NAMED_BIND */ 95 96 # ifdef HESIOD 97 # include <hesiod.h> 98 # if !defined(HES_ER_OK) || defined(HESIOD_INTERFACES) 99 # define HESIOD_INIT /* support for the new interface */ 100 # endif /* !defined(HES_ER_OK) || defined(HESIOD_INTERFACES) */ 101 # endif /* HESIOD */ 102 103 #if STARTTLS 104 # if !SFIO && !_FFR_TLS_TOREK 105 ERROR README: STARTTLS requires SFIO 106 # endif /* !SFIO && !_FFR_TLS_TOREK */ 107 # if SFIO && _FFR_TLS_TOREK 108 ERROR README: Can not do both SFIO and _FFR_TLS_TOREK 109 # endif /* SFIO && _FFR_TLS_TOREK */ 110 # include <openssl/ssl.h> 111 #endif /* STARTTLS */ 112 113 #if SASL /* include the sasl include files if we have them */ 114 # include <sasl.h> 115 # if defined(SASL_VERSION_MAJOR) && defined(SASL_VERSION_MINOR) && defined(SASL_VERSION_STEP) 116 # define SASL_VERSION (SASL_VERSION_MAJOR * 10000) + (SASL_VERSION_MINOR * 100) + SASL_VERSION_STEP 117 # if SASL == 1 118 # undef SASL 119 # define SASL SASL_VERSION 120 # else /* SASL == 1 */ 121 # if SASL != SASL_VERSION 122 ERROR README: -DSASL (SASL) does not agree with the version of the CYRUS_SASL library (SASL_VERSION) 123 ERROR README: see README! 124 # endif /* SASL != SASL_VERSION */ 125 # endif /* SASL == 1 */ 126 # else /* defined(SASL_VERSION_MAJOR) && defined(SASL_VERSION_MINOR) && defined(SASL_VERSION_STEP) */ 127 # if SASL == 1 128 ERROR README: please set -DSASL to the version of the CYRUS_SASL library 129 ERROR README: see README! 130 # endif /* SASL == 1 */ 131 # endif /* defined(SASL_VERSION_MAJOR) && defined(SASL_VERSION_MINOR) && defined(SASL_VERSION_STEP) */ 132 #endif /* SASL */ 133 134 /* 135 ** Following are "sort of" configuration constants, but they should 136 ** be pretty solid on most architectures today. They have to be 137 ** defined after <arpa/nameser.h> because some versions of that 138 ** file also define them. In all cases, we can't use sizeof because 139 ** some systems (e.g., Crays) always treat everything as being at 140 ** least 64 bits. 141 */ 142 143 #ifndef INADDRSZ 144 # define INADDRSZ 4 /* size of an IPv4 address in bytes */ 145 #endif /* ! INADDRSZ */ 146 #ifndef IN6ADDRSZ 147 # define IN6ADDRSZ 16 /* size of an IPv6 address in bytes */ 148 #endif /* ! IN6ADDRSZ */ 149 #ifndef INT16SZ 150 # define INT16SZ 2 /* size of a 16 bit integer in bytes */ 151 #endif /* ! INT16SZ */ 152 #ifndef INT32SZ 153 # define INT32SZ 4 /* size of a 32 bit integer in bytes */ 154 #endif /* ! INT32SZ */ 155 #ifndef INADDR_LOOPBACK 156 # define INADDR_LOOPBACK 0x7f000001 /* loopback address */ 157 #endif /* ! INADDR_LOOPBACK */ 158 159 /* 160 ** Error return from inet_addr(3), in case not defined in /usr/include. 161 */ 162 163 #ifndef INADDR_NONE 164 # define INADDR_NONE 0xffffffff 165 #endif /* ! INADDR_NONE */ 166 167 168 /* forward references for prototypes */ 169 typedef struct envelope ENVELOPE; 170 typedef struct mailer MAILER; 171 172 /* 173 ** Address structure. 174 ** Addresses are stored internally in this structure. 175 */ 176 177 struct address 178 { 179 char *q_paddr; /* the printname for the address */ 180 char *q_user; /* user name */ 181 char *q_ruser; /* real user name, or NULL if q_user */ 182 char *q_host; /* host name */ 183 struct mailer *q_mailer; /* mailer to use */ 184 u_long q_flags; /* status flags, see below */ 185 uid_t q_uid; /* user-id of receiver (if known) */ 186 gid_t q_gid; /* group-id of receiver (if known) */ 187 char *q_home; /* home dir (local mailer only) */ 188 char *q_fullname; /* full name if known */ 189 struct address *q_next; /* chain */ 190 struct address *q_alias; /* address this results from */ 191 char *q_owner; /* owner of q_alias */ 192 struct address *q_tchain; /* temporary use chain */ 193 char *q_orcpt; /* ORCPT parameter from RCPT TO: line */ 194 char *q_status; /* status code for DSNs */ 195 char *q_rstatus; /* remote status message for DSNs */ 196 time_t q_statdate; /* date of status messages */ 197 char *q_statmta; /* MTA generating q_rstatus */ 198 short q_state; /* address state, see below */ 199 short q_specificity; /* how "specific" this address is */ 200 }; 201 202 typedef struct address ADDRESS; 203 204 /* bit values for q_flags */ 205 #define QGOODUID 0x00000001 /* the q_uid q_gid fields are good */ 206 #define QPRIMARY 0x00000002 /* set from RCPT or argv */ 207 #define QNOTREMOTE 0x00000004 /* address not for remote forwarding */ 208 #define QSELFREF 0x00000008 /* this address references itself */ 209 #define QBOGUSSHELL 0x00000010 /* user has no valid shell listed */ 210 #define QUNSAFEADDR 0x00000020 /* address acquired via unsafe path */ 211 #define QPINGONSUCCESS 0x00000040 /* give return on successful delivery */ 212 #define QPINGONFAILURE 0x00000080 /* give return on failure */ 213 #define QPINGONDELAY 0x00000100 /* give return on message delay */ 214 #define QHASNOTIFY 0x00000200 /* propogate notify parameter */ 215 #define QRELAYED 0x00000400 /* DSN: relayed to non-DSN aware sys */ 216 #define QEXPANDED 0x00000800 /* DSN: undergone list expansion */ 217 #define QDELIVERED 0x00001000 /* DSN: successful final delivery */ 218 #define QDELAYED 0x00002000 /* DSN: message delayed */ 219 #define QALIAS 0x00004000 /* expanded alias */ 220 #define QTHISPASS 0x40000000 /* temp: address set this pass */ 221 #define QRCPTOK 0x80000000 /* recipient() processed address */ 222 223 #define Q_PINGFLAGS (QPINGONSUCCESS|QPINGONFAILURE|QPINGONDELAY) 224 225 /* values for q_state */ 226 #define QS_OK 0 /* address ok (for now)/not yet tried */ 227 #define QS_SENT 1 /* good address, delivery complete */ 228 #define QS_BADADDR 2 /* illegal address */ 229 #define QS_QUEUEUP 3 /* save address in queue */ 230 #define QS_VERIFIED 4 /* verified, but not expanded */ 231 #define QS_DONTSEND 5 /* don't send to this address */ 232 #define QS_EXPANDED 6 /* QS_DONTSEND: expanded */ 233 #define QS_SENDER 7 /* QS_DONTSEND: message sender (MeToo) */ 234 #define QS_CLONED 8 /* QS_DONTSEND: addr cloned to split envelope */ 235 #define QS_DISCARDED 9 /* QS_DONTSEND: rcpt discarded (EF_DISCARD) */ 236 #define QS_REPLACED 10 /* QS_DONTSEND: maplocaluser()/UserDB replaced */ 237 #define QS_REMOVED 11 /* QS_DONTSEND: removed (removefromlist()) */ 238 #define QS_DUPLICATE 12 /* QS_DONTSEND: duplicate suppressed */ 239 #define QS_INCLUDED 13 /* QS_DONTSEND: :include: delivery */ 240 241 /* address state testing primitives */ 242 #define QS_IS_OK(s) ((s) == QS_OK) 243 #define QS_IS_SENT(s) ((s) == QS_SENT) 244 #define QS_IS_BADADDR(s) ((s) == QS_BADADDR) 245 #define QS_IS_QUEUEUP(s) ((s) == QS_QUEUEUP) 246 #define QS_IS_VERIFIED(s) ((s) == QS_VERIFIED) 247 #define QS_IS_EXPANDED(s) ((s) == QS_EXPANDED) 248 #define QS_IS_REMOVED(s) ((s) == QS_REMOVED) 249 #define QS_IS_UNDELIVERED(s) ((s) == QS_OK || \ 250 (s) == QS_QUEUEUP || \ 251 (s) == QS_VERIFIED) 252 #define QS_IS_SENDABLE(s) ((s) == QS_OK || \ 253 (s) == QS_QUEUEUP) 254 #define QS_IS_ATTEMPTED(s) ((s) == QS_QUEUEUP || \ 255 (s) == QS_SENT) 256 #define QS_IS_DEAD(s) ((s) == QS_DONTSEND || \ 257 (s) == QS_CLONED || \ 258 (s) == QS_SENDER || \ 259 (s) == QS_DISCARDED || \ 260 (s) == QS_REPLACED || \ 261 (s) == QS_REMOVED || \ 262 (s) == QS_DUPLICATE || \ 263 (s) == QS_INCLUDED || \ 264 (s) == QS_EXPANDED) 265 266 267 #define NULLADDR ((ADDRESS *) NULL) 268 269 extern ADDRESS NullAddress; /* a null (template) address [main.c] */ 270 271 /* functions */ 272 extern void cataddr __P((char **, char **, char *, int, int)); 273 extern char *crackaddr __P((char *)); 274 extern bool emptyaddr __P((ADDRESS *)); 275 extern ADDRESS *getctladdr __P((ADDRESS *)); 276 extern int include __P((char *, bool, ADDRESS *, ADDRESS **, int, ENVELOPE *)); 277 extern bool invalidaddr __P((char *, char *)); 278 extern ADDRESS *parseaddr __P((char *, ADDRESS *, int, int, char **, ENVELOPE *)); 279 extern char **prescan __P((char *, int, char[], int, char **, u_char *)); 280 extern void printaddr __P((ADDRESS *, bool)); 281 extern ADDRESS *recipient __P((ADDRESS *, ADDRESS **, int, ENVELOPE *)); 282 extern char *remotename __P((char *, MAILER *, int, int *, ENVELOPE *)); 283 extern int rewrite __P((char **, int, int, ENVELOPE *)); 284 extern bool sameaddr __P((ADDRESS *, ADDRESS *)); 285 extern int sendtolist __P((char *, ADDRESS *, ADDRESS **, int, ENVELOPE *)); 286 extern int removefromlist __P((char *, ADDRESS **, ENVELOPE *)); 287 extern void setsender __P((char *, ENVELOPE *, char **, int, bool)); 288 289 /* 290 ** Mailer definition structure. 291 ** Every mailer known to the system is declared in this 292 ** structure. It defines the pathname of the mailer, some 293 ** flags associated with it, and the argument vector to 294 ** pass to it. The flags are defined in conf.c 295 ** 296 ** The argument vector is expanded before actual use. All 297 ** words except the first are passed through the macro 298 ** processor. 299 */ 300 301 struct mailer 302 { 303 char *m_name; /* symbolic name of this mailer */ 304 char *m_mailer; /* pathname of the mailer to use */ 305 char *m_mtatype; /* type of this MTA */ 306 char *m_addrtype; /* type for addresses */ 307 char *m_diagtype; /* type for diagnostics */ 308 BITMAP256 m_flags; /* status flags, see below */ 309 short m_mno; /* mailer number internally */ 310 short m_nice; /* niceness to run at (mostly for prog) */ 311 char **m_argv; /* template argument vector */ 312 short m_sh_rwset; /* rewrite set: sender header addresses */ 313 short m_se_rwset; /* rewrite set: sender envelope addresses */ 314 short m_rh_rwset; /* rewrite set: recipient header addresses */ 315 short m_re_rwset; /* rewrite set: recipient envelope addresses */ 316 char *m_eol; /* end of line string */ 317 long m_maxsize; /* size limit on message to this mailer */ 318 int m_linelimit; /* max # characters per line */ 319 int m_maxdeliveries; /* max deliveries per mailer connection */ 320 char *m_execdir; /* directory to chdir to before execv */ 321 char *m_rootdir; /* directory to chroot to before execv */ 322 uid_t m_uid; /* UID to run as */ 323 gid_t m_gid; /* GID to run as */ 324 char *m_defcharset; /* default character set */ 325 time_t m_wait; /* timeout to wait for end */ 326 #if _FFR_DYNAMIC_TOBUF 327 int m_maxrcpt; /* max recipients per envelope client-side */ 328 #endif /* _FFR_DYNAMIC_TOBUF */ 329 }; 330 331 /* bits for m_flags */ 332 #define M_ESMTP 'a' /* run Extended SMTP protocol */ 333 #define M_ALIASABLE 'A' /* user can be LHS of an alias */ 334 #define M_BLANKEND 'b' /* ensure blank line at end of message */ 335 #define M_NOCOMMENT 'c' /* don't include comment part of address */ 336 #define M_CANONICAL 'C' /* make addresses canonical "u@dom" */ 337 #define M_NOBRACKET 'd' /* never angle bracket envelope route-addrs */ 338 /* 'D' CF: include Date: */ 339 #define M_EXPENSIVE 'e' /* it costs to use this mailer.... */ 340 #define M_ESCFROM 'E' /* escape From lines to >From */ 341 #define M_FOPT 'f' /* mailer takes picky -f flag */ 342 /* 'F' CF: include From: or Resent-From: */ 343 #define M_NO_NULL_FROM 'g' /* sender of errors should be $g */ 344 #define M_HST_UPPER 'h' /* preserve host case distinction */ 345 #define M_PREHEAD 'H' /* MAIL11V3: preview headers */ 346 #define M_UDBENVELOPE 'i' /* do udbsender rewriting on envelope */ 347 #define M_INTERNAL 'I' /* SMTP to another sendmail site */ 348 #define M_UDBRECIPIENT 'j' /* do udbsender rewriting on recipient lines */ 349 #define M_NOLOOPCHECK 'k' /* don't check for loops in HELO command */ 350 #define M_CHUNKING 'K' /* CHUNKING: reserved for future use */ 351 #define M_LOCALMAILER 'l' /* delivery is to this host */ 352 #define M_LIMITS 'L' /* must enforce SMTP line limits */ 353 #define M_MUSER 'm' /* can handle multiple users at once */ 354 /* 'M' CF: include Message-Id: */ 355 #define M_NHDR 'n' /* don't insert From line */ 356 #define M_MANYSTATUS 'N' /* MAIL11V3: DATA returns multi-status */ 357 #define M_RUNASRCPT 'o' /* always run mailer as recipient */ 358 #define M_FROMPATH 'p' /* use reverse-path in MAIL FROM: */ 359 /* 'P' CF: include Return-Path: */ 360 #define M_VRFY250 'q' /* VRFY command returns 250 instead of 252 */ 361 #define M_ROPT 'r' /* mailer takes picky -r flag */ 362 #define M_SECURE_PORT 'R' /* try to send on a reserved TCP port */ 363 #define M_STRIPQ 's' /* strip quote chars from user/host */ 364 #define M_SPECIFIC_UID 'S' /* run as specific uid/gid */ 365 #define M_USR_UPPER 'u' /* preserve user case distinction */ 366 #define M_UGLYUUCP 'U' /* this wants an ugly UUCP from line */ 367 #define M_CONTENT_LEN 'v' /* add Content-Length: header (SVr4) */ 368 /* 'V' UIUC: !-relativize all addresses */ 369 #define M_HASPWENT 'w' /* check for /etc/passwd entry */ 370 /* 'x' CF: include Full-Name: */ 371 #define M_XDOT 'X' /* use hidden-dot algorithm */ 372 #define M_LMTP 'z' /* run Local Mail Transport Protocol */ 373 #define M_NOMX '0' /* turn off MX lookups */ 374 #define M_NONULLS '1' /* don't send null bytes */ 375 #define M_EBCDIC '3' /* extend Q-P encoding for EBCDIC */ 376 #define M_TRYRULESET5 '5' /* use ruleset 5 after local aliasing */ 377 #define M_7BITHDRS '6' /* strip headers to 7 bits even in 8 bit path */ 378 #define M_7BITS '7' /* use 7-bit path */ 379 #define M_8BITS '8' /* force "just send 8" behaviour */ 380 #define M_MAKE8BIT '9' /* convert 7 -> 8 bit if appropriate */ 381 #define M_CHECKINCLUDE ':' /* check for :include: files */ 382 #define M_CHECKPROG '|' /* check for |program addresses */ 383 #define M_CHECKFILE '/' /* check for /file addresses */ 384 #define M_CHECKUDB '@' /* user can be user database key */ 385 #define M_CHECKHDIR '~' /* SGI: check for valid home directory */ 386 #define M_HOLD '%' /* Hold delivery until ETRN/-qI/-qR/-qS */ 387 #define M_PLUS '+' /* Reserved: Used in mc for adding new flags */ 388 #define M_MINUS '-' /* Reserved: Used in mc for removing flags */ 389 390 /* functions */ 391 extern void initerrmailers __P((void)); 392 extern void makemailer __P((char *)); 393 394 /* 395 ** Information about currently open connections to mailers, or to 396 ** hosts that we have looked up recently. 397 */ 398 399 #define MCI struct mailer_con_info 400 401 MCI 402 { 403 u_long mci_flags; /* flag bits, see below */ 404 short mci_errno; /* error number on last connection */ 405 short mci_herrno; /* h_errno from last DNS lookup */ 406 short mci_exitstat; /* exit status from last connection */ 407 short mci_state; /* SMTP state */ 408 int mci_deliveries; /* delivery attempts for connection */ 409 long mci_maxsize; /* max size this server will accept */ 410 #if SFIO 411 Sfio_t *mci_in; /* input side of connection */ 412 Sfio_t *mci_out; /* output side of connection */ 413 #else /* SFIO */ 414 FILE *mci_in; /* input side of connection */ 415 FILE *mci_out; /* output side of connection */ 416 #endif /* SFIO */ 417 pid_t mci_pid; /* process id of subordinate proc */ 418 char *mci_phase; /* SMTP phase string */ 419 struct mailer *mci_mailer; /* ptr to the mailer for this conn */ 420 char *mci_host; /* host name */ 421 char *mci_status; /* DSN status to be copied to addrs */ 422 char *mci_rstatus; /* SMTP status to be copied to addrs */ 423 time_t mci_lastuse; /* last usage time */ 424 FILE *mci_statfile; /* long term status file */ 425 char *mci_heloname; /* name to use as HELO arg */ 426 #if SASL 427 bool mci_sasl_auth; /* authenticated? */ 428 int mci_sasl_string_len; 429 char *mci_sasl_string; /* sasl reply string */ 430 char *mci_saslcap; /* SASL list of mechanisms */ 431 sasl_conn_t *mci_conn; /* SASL connection */ 432 #endif /* SASL */ 433 #if STARTTLS 434 SSL *mci_ssl; /* SSL connection */ 435 #endif /* STARTTLS */ 436 }; 437 438 439 /* flag bits */ 440 #define MCIF_VALID 0x00000001 /* this entry is valid */ 441 #define MCIF_TEMP 0x00000002 /* don't cache this connection */ 442 #define MCIF_CACHED 0x00000004 /* currently in open cache */ 443 #define MCIF_ESMTP 0x00000008 /* this host speaks ESMTP */ 444 #define MCIF_EXPN 0x00000010 /* EXPN command supported */ 445 #define MCIF_SIZE 0x00000020 /* SIZE option supported */ 446 #define MCIF_8BITMIME 0x00000040 /* BODY=8BITMIME supported */ 447 #define MCIF_7BIT 0x00000080 /* strip this message to 7 bits */ 448 #define MCIF_MULTSTAT 0x00000100 /* MAIL11V3: handles MULT status */ 449 #define MCIF_INHEADER 0x00000200 /* currently outputing header */ 450 #define MCIF_CVT8TO7 0x00000400 /* convert from 8 to 7 bits */ 451 #define MCIF_DSN 0x00000800 /* DSN extension supported */ 452 #define MCIF_8BITOK 0x00001000 /* OK to send 8 bit characters */ 453 #define MCIF_CVT7TO8 0x00002000 /* convert from 7 to 8 bits */ 454 #define MCIF_INMIME 0x00004000 /* currently reading MIME header */ 455 #define MCIF_AUTH 0x00008000 /* AUTH= supported */ 456 #define MCIF_AUTHACT 0x00010000 /* SASL (AUTH) active */ 457 #define MCIF_ENHSTAT 0x00020000 /* ENHANCEDSTATUSCODES supported */ 458 #if STARTTLS 459 #define MCIF_TLS 0x00100000 /* STARTTLS supported */ 460 #define MCIF_TLSACT 0x00200000 /* STARTTLS active */ 461 #define MCIF_EXTENS (MCIF_EXPN | MCIF_SIZE | MCIF_8BITMIME | MCIF_DSN | MCIF_8BITOK | MCIF_AUTH | MCIF_ENHSTAT | MCIF_TLS) 462 #else /* STARTTLS */ 463 #define MCIF_EXTENS (MCIF_EXPN | MCIF_SIZE | MCIF_8BITMIME | MCIF_DSN | MCIF_8BITOK | MCIF_AUTH | MCIF_ENHSTAT) 464 #endif /* STARTTLS */ 465 #define MCIF_ONLY_EHLO 0x10000000 /* use only EHLO in smtpinit */ 466 467 468 /* states */ 469 #define MCIS_CLOSED 0 /* no traffic on this connection */ 470 #define MCIS_OPENING 1 /* sending initial protocol */ 471 #define MCIS_OPEN 2 /* open, initial protocol sent */ 472 #define MCIS_ACTIVE 3 /* message being sent */ 473 #define MCIS_QUITING 4 /* running quit protocol */ 474 #define MCIS_SSD 5 /* service shutting down */ 475 #define MCIS_ERROR 6 /* I/O error on connection */ 476 477 /* functions */ 478 extern void mci_cache __P((MCI *)); 479 extern void mci_dump __P((MCI *, bool)); 480 extern void mci_dump_all __P((bool)); 481 extern void mci_flush __P((bool, MCI *)); 482 extern MCI *mci_get __P((char *, MAILER *)); 483 extern int mci_lock_host __P((MCI *)); 484 extern bool mci_match __P((char *, MAILER *)); 485 extern int mci_print_persistent __P((char *, char *)); 486 extern int mci_purge_persistent __P((char *, char *)); 487 extern MCI **mci_scan __P((MCI *)); 488 extern void mci_setstat __P((MCI *, int, char *, char *)); 489 extern void mci_store_persistent __P((MCI *)); 490 extern int mci_traverse_persistent __P((int (*)(), char *)); 491 extern void mci_unlock_host __P((MCI *)); 492 493 /* 494 ** Header structure. 495 ** This structure is used internally to store header items. 496 */ 497 498 struct header 499 { 500 char *h_field; /* the name of the field */ 501 char *h_value; /* the value of that field */ 502 struct header *h_link; /* the next header */ 503 u_char h_macro; /* include header if macro defined */ 504 u_long h_flags; /* status bits, see below */ 505 BITMAP256 h_mflags; /* m_flags bits needed */ 506 }; 507 508 typedef struct header HDR; 509 510 /* 511 ** Header information structure. 512 ** Defined in conf.c, this struct declares the header fields 513 ** that have some magic meaning. 514 */ 515 516 struct hdrinfo 517 { 518 char *hi_field; /* the name of the field */ 519 u_long hi_flags; /* status bits, see below */ 520 char *hi_ruleset; /* validity check ruleset */ 521 }; 522 523 extern struct hdrinfo HdrInfo[]; 524 525 /* bits for h_flags and hi_flags */ 526 #define H_EOH 0x00000001 /* field terminates header */ 527 #define H_RCPT 0x00000002 /* contains recipient addresses */ 528 #define H_DEFAULT 0x00000004 /* if another value is found, drop this */ 529 #define H_RESENT 0x00000008 /* this address is a "Resent-..." address */ 530 #define H_CHECK 0x00000010 /* check h_mflags against m_flags */ 531 #define H_ACHECK 0x00000020 /* ditto, but always (not just default) */ 532 #define H_FORCE 0x00000040 /* force this field, even if default */ 533 #define H_TRACE 0x00000080 /* this field contains trace information */ 534 #define H_FROM 0x00000100 /* this is a from-type field */ 535 #define H_VALID 0x00000200 /* this field has a validated value */ 536 #define H_RECEIPTTO 0x00000400 /* field has return receipt info */ 537 #define H_ERRORSTO 0x00000800 /* field has error address info */ 538 #define H_CTE 0x00001000 /* field is a content-transfer-encoding */ 539 #define H_CTYPE 0x00002000 /* this is a content-type field */ 540 #define H_BCC 0x00004000 /* Bcc: header: strip value or delete */ 541 #define H_ENCODABLE 0x00008000 /* field can be RFC 1522 encoded */ 542 #define H_STRIPCOMM 0x00010000 /* header check: strip comments */ 543 #define H_BINDLATE 0x00020000 /* only expand macros at deliver */ 544 #define H_USER 0x00040000 /* header came from the user/SMTP */ 545 546 /* bits for chompheader() */ 547 #define CHHDR_DEF 0x0001 /* default header */ 548 #define CHHDR_CHECK 0x0002 /* call ruleset for header */ 549 #define CHHDR_USER 0x0004 /* header from user */ 550 #define CHHDR_QUEUE 0x0008 /* header from qf file */ 551 552 /* functions */ 553 extern void addheader __P((char *, char *, int, HDR **)); 554 extern u_long chompheader __P((char *, int, HDR **, ENVELOPE *)); 555 extern void commaize __P((HDR *, char *, bool, MCI *, ENVELOPE *)); 556 extern HDR *copyheader __P((HDR *)); 557 extern void eatheader __P((ENVELOPE *, bool)); 558 extern char *hvalue __P((char *, HDR *)); 559 extern bool isheader __P((char *)); 560 extern void putfromline __P((MCI *, ENVELOPE *)); 561 extern void setupheaders __P((void)); 562 563 /* 564 ** Performance monitoring 565 */ 566 567 #define TIMERS struct sm_timers 568 569 TIMERS 570 { 571 TIMER ti_overall; /* the whole process */ 572 }; 573 574 575 #define PUSHTIMER(l, t) { if (tTd(98, l)) pushtimer(&t); } 576 #define POPTIMER(l, t) { if (tTd(98, l)) poptimer(&t); } 577 578 /* 579 ** Envelope structure. 580 ** This structure defines the message itself. There is usually 581 ** only one of these -- for the message that we originally read 582 ** and which is our primary interest -- but other envelopes can 583 ** be generated during processing. For example, error messages 584 ** will have their own envelope. 585 */ 586 587 struct envelope 588 { 589 HDR *e_header; /* head of header list */ 590 long e_msgpriority; /* adjusted priority of this message */ 591 time_t e_ctime; /* time message appeared in the queue */ 592 char *e_to; /* the target person */ 593 ADDRESS e_from; /* the person it is from */ 594 char *e_sender; /* e_from.q_paddr w comments stripped */ 595 char **e_fromdomain; /* the domain part of the sender */ 596 ADDRESS *e_sendqueue; /* list of message recipients */ 597 ADDRESS *e_errorqueue; /* the queue for error responses */ 598 599 /* 600 ** Overflow detection is based on < 0, so don't change this 601 ** to unsigned. We don't use unsigned and == ULONG_MAX because 602 ** some libc's don't have strtoul(), see mail_esmtp_args(). 603 */ 604 long e_msgsize; /* size of the message in bytes */ 605 long e_flags; /* flags, see below */ 606 int e_nrcpts; /* number of recipients */ 607 short e_class; /* msg class (priority, junk, etc.) */ 608 short e_hopcount; /* number of times processed */ 609 short e_nsent; /* number of sends since checkpoint */ 610 short e_sendmode; /* message send mode */ 611 short e_errormode; /* error return mode */ 612 short e_timeoutclass; /* message timeout class */ 613 void (*e_puthdr)__P((MCI *, HDR *, ENVELOPE *, int)); 614 /* function to put header of message */ 615 void (*e_putbody)__P((MCI *, ENVELOPE *, char *)); 616 /* function to put body of message */ 617 ENVELOPE *e_parent; /* the message this one encloses */ 618 ENVELOPE *e_sibling; /* the next envelope of interest */ 619 char *e_bodytype; /* type of message body */ 620 FILE *e_dfp; /* data file */ 621 char *e_id; /* code for this entry in queue */ 622 int e_queuedir; /* index into queue directories */ 623 FILE *e_xfp; /* transcript file */ 624 FILE *e_lockfp; /* the lock file for this message */ 625 char *e_message; /* error message */ 626 char *e_statmsg; /* stat msg (changes per delivery) */ 627 char *e_msgboundary; /* MIME-style message part boundary */ 628 char *e_origrcpt; /* original recipient (one only) */ 629 char *e_envid; /* envelope id from MAIL FROM: line */ 630 char *e_status; /* DSN status for this message */ 631 time_t e_dtime; /* time of last delivery attempt */ 632 int e_ntries; /* number of delivery attempts */ 633 dev_t e_dfdev; /* df file's device, for crash recov */ 634 ino_t e_dfino; /* df file's ino, for crash recovery */ 635 char *e_macro[MAXMACROID + 1]; /* macro definitions */ 636 char *e_if_macros[2]; /* HACK: incoming interface info */ 637 char *e_auth_param; 638 TIMERS e_timers; /* per job timers */ 639 #if _FFR_QUEUEDELAY 640 int e_queuealg; /* algorithm for queue delay */ 641 time_t e_queuedelay; /* current delay */ 642 #endif /* _FFR_QUEUEDELAY */ 643 }; 644 645 /* values for e_flags */ 646 #define EF_OLDSTYLE 0x0000001L /* use spaces (not commas) in hdrs */ 647 #define EF_INQUEUE 0x0000002L /* this message is fully queued */ 648 #define EF_NO_BODY_RETN 0x0000004L /* omit message body on error */ 649 #define EF_CLRQUEUE 0x0000008L /* disk copy is no longer needed */ 650 #define EF_SENDRECEIPT 0x0000010L /* send a return receipt */ 651 #define EF_FATALERRS 0x0000020L /* fatal errors occurred */ 652 #define EF_DELETE_BCC 0x0000040L /* delete Bcc: headers entirely */ 653 #define EF_RESPONSE 0x0000080L /* this is an error or return receipt */ 654 #define EF_RESENT 0x0000100L /* this message is being forwarded */ 655 #define EF_VRFYONLY 0x0000200L /* verify only (don't expand aliases) */ 656 #define EF_WARNING 0x0000400L /* warning message has been sent */ 657 #define EF_QUEUERUN 0x0000800L /* this envelope is from queue */ 658 #define EF_GLOBALERRS 0x0001000L /* treat errors as global */ 659 #define EF_PM_NOTIFY 0x0002000L /* send return mail to postmaster */ 660 #define EF_METOO 0x0004000L /* send to me too */ 661 #define EF_LOGSENDER 0x0008000L /* need to log the sender */ 662 #define EF_NORECEIPT 0x0010000L /* suppress all return-receipts */ 663 #define EF_HAS8BIT 0x0020000L /* at least one 8-bit char in body */ 664 #define EF_NL_NOT_EOL 0x0040000L /* don't accept raw NL as EOLine */ 665 #define EF_CRLF_NOT_EOL 0x0080000L /* don't accept CR-LF as EOLine */ 666 #define EF_RET_PARAM 0x0100000L /* RCPT command had RET argument */ 667 #define EF_HAS_DF 0x0200000L /* set when df file is instantiated */ 668 #define EF_IS_MIME 0x0400000L /* really is a MIME message */ 669 #define EF_DONT_MIME 0x0800000L /* never MIME this message */ 670 #define EF_DISCARD 0x1000000L /* discard the message */ 671 #define EF_TOOBIG 0x2000000L /* message is too big */ 672 673 /* values for e_if_macros */ 674 #define EIF_ADDR 0 /* ${if_addr} */ 675 676 /* functions */ 677 extern void clearenvelope __P((ENVELOPE *, bool)); 678 extern void dropenvelope __P((ENVELOPE *, bool)); 679 extern ENVELOPE *newenvelope __P((ENVELOPE *, ENVELOPE *)); 680 extern void printenvflags __P((ENVELOPE *)); 681 extern void putbody __P((MCI *, ENVELOPE *, char *)); 682 extern void putheader __P((MCI *, HDR *, ENVELOPE *, int)); 683 684 /* 685 ** Message priority classes. 686 ** 687 ** The message class is read directly from the Priority: header 688 ** field in the message. 689 ** 690 ** CurEnv->e_msgpriority is the number of bytes in the message plus 691 ** the creation time (so that jobs ``tend'' to be ordered correctly), 692 ** adjusted by the message class, the number of recipients, and the 693 ** amount of time the message has been sitting around. This number 694 ** is used to order the queue. Higher values mean LOWER priority. 695 ** 696 ** Each priority class point is worth WkClassFact priority points; 697 ** each recipient is worth WkRecipFact priority points. Each time 698 ** we reprocess a message the priority is adjusted by WkTimeFact. 699 ** WkTimeFact should normally decrease the priority so that jobs 700 ** that have historically failed will be run later; thanks go to 701 ** Jay Lepreau at Utah for pointing out the error in my thinking. 702 ** 703 ** The "class" is this number, unadjusted by the age or size of 704 ** this message. Classes with negative representations will have 705 ** error messages thrown away if they are not local. 706 */ 707 708 struct priority 709 { 710 char *pri_name; /* external name of priority */ 711 int pri_val; /* internal value for same */ 712 }; 713 714 /* 715 ** Rewrite rules. 716 */ 717 718 struct rewrite 719 { 720 char **r_lhs; /* pattern match */ 721 char **r_rhs; /* substitution value */ 722 struct rewrite *r_next;/* next in chain */ 723 int r_line; /* rule line in sendmail.cf */ 724 }; 725 726 /* 727 ** Special characters in rewriting rules. 728 ** These are used internally only. 729 ** The COND* rules are actually used in macros rather than in 730 ** rewriting rules, but are given here because they 731 ** cannot conflict. 732 */ 733 734 /* left hand side items */ 735 #define MATCHZANY ((u_char)0220) /* match zero or more tokens */ 736 #define MATCHANY ((u_char)0221) /* match one or more tokens */ 737 #define MATCHONE ((u_char)0222) /* match exactly one token */ 738 #define MATCHCLASS ((u_char)0223) /* match one token in a class */ 739 #define MATCHNCLASS ((u_char)0224) /* match anything not in class */ 740 #define MATCHREPL ((u_char)0225) /* replacement on RHS for above */ 741 742 /* right hand side items */ 743 #define CANONNET ((u_char)0226) /* canonical net, next token */ 744 #define CANONHOST ((u_char)0227) /* canonical host, next token */ 745 #define CANONUSER ((u_char)0230) /* canonical user, next N tokens */ 746 #define CALLSUBR ((u_char)0231) /* call another rewriting set */ 747 748 /* conditionals in macros */ 749 #define CONDIF ((u_char)0232) /* conditional if-then */ 750 #define CONDELSE ((u_char)0233) /* conditional else */ 751 #define CONDFI ((u_char)0234) /* conditional fi */ 752 753 /* bracket characters for host name lookup */ 754 #define HOSTBEGIN ((u_char)0235) /* hostname lookup begin */ 755 #define HOSTEND ((u_char)0236) /* hostname lookup end */ 756 757 /* bracket characters for generalized lookup */ 758 #define LOOKUPBEGIN ((u_char)0205) /* generalized lookup begin */ 759 #define LOOKUPEND ((u_char)0206) /* generalized lookup end */ 760 761 /* macro substitution character */ 762 #define MACROEXPAND ((u_char)0201) /* macro expansion */ 763 #define MACRODEXPAND ((u_char)0202) /* deferred macro expansion */ 764 765 /* to make the code clearer */ 766 #define MATCHZERO CANONHOST 767 768 /* external <==> internal mapping table */ 769 struct metamac 770 { 771 char metaname; /* external code (after $) */ 772 u_char metaval; /* internal code (as above) */ 773 }; 774 775 /* values for macros with external names only */ 776 #define MID_OPMODE 0202 /* operation mode */ 777 778 /* functions */ 779 extern void define __P((int, char *, ENVELOPE *)); 780 extern void expand __P((char *, char *, size_t, ENVELOPE *)); 781 extern int macid __P((char *, char **)); 782 extern char *macname __P((int)); 783 extern char *macvalue __P((int, ENVELOPE *)); 784 extern int rscheck __P((char *, char *, char *, ENVELOPE *, bool, bool, int, char *)); 785 extern void setclass __P((int, char *)); 786 extern int strtorwset __P((char *, char **, int)); 787 extern void translate_dollars __P((char *)); 788 extern bool wordinclass __P((char *, int)); 789 790 /* 791 ** Name canonification short circuit. 792 ** 793 ** If the name server for a host is down, the process of trying to 794 ** canonify the name can hang. This is similar to (but alas, not 795 ** identical to) looking up the name for delivery. This stab type 796 ** caches the result of the name server lookup so we don't hang 797 ** multiple times. 798 */ 799 800 #define NAMECANON struct _namecanon 801 802 NAMECANON 803 { 804 short nc_errno; /* cached errno */ 805 short nc_herrno; /* cached h_errno */ 806 short nc_stat; /* cached exit status code */ 807 short nc_flags; /* flag bits */ 808 char *nc_cname; /* the canonical name */ 809 }; 810 811 /* values for nc_flags */ 812 #define NCF_VALID 0x0001 /* entry valid */ 813 814 /* functions */ 815 extern bool getcanonname __P((char *, int, bool)); 816 extern int getmxrr __P((char *, char **, u_short *, bool, int *)); 817 818 /* 819 ** Mapping functions 820 ** 821 ** These allow arbitrary mappings in the config file. The idea 822 ** (albeit not the implementation) comes from IDA sendmail. 823 */ 824 825 #define MAPCLASS struct _mapclass 826 #define MAP struct _map 827 #define MAXMAPACTIONS 5 /* size of map_actions array */ 828 829 830 /* 831 ** An actual map. 832 */ 833 834 MAP 835 { 836 MAPCLASS *map_class; /* the class of this map */ 837 char *map_mname; /* name of this map */ 838 long map_mflags; /* flags, see below */ 839 char *map_file; /* the (nominal) filename */ 840 ARBPTR_T map_db1; /* the open database ptr */ 841 ARBPTR_T map_db2; /* an "extra" database pointer */ 842 char *map_keycolnm; /* key column name */ 843 char *map_valcolnm; /* value column name */ 844 u_char map_keycolno; /* key column number */ 845 u_char map_valcolno; /* value column number */ 846 char map_coldelim; /* column delimiter */ 847 char map_spacesub; /* spacesub */ 848 char *map_app; /* to append to successful matches */ 849 char *map_tapp; /* to append to "tempfail" matches */ 850 char *map_domain; /* the (nominal) NIS domain */ 851 char *map_rebuild; /* program to run to do auto-rebuild */ 852 time_t map_mtime; /* last database modification time */ 853 pid_t map_pid; /* PID of process which opened map */ 854 int map_lockfd; /* auxiliary lock file descriptor */ 855 short map_specificity; /* specificity of aliases */ 856 MAP *map_stack[MAXMAPSTACK]; /* list for stacked maps */ 857 short map_return[MAXMAPACTIONS]; /* return bitmaps for stacked maps */ 858 }; 859 860 861 /* bit values for map_mflags */ 862 #define MF_VALID 0x00000001 /* this entry is valid */ 863 #define MF_INCLNULL 0x00000002 /* include null byte in key */ 864 #define MF_OPTIONAL 0x00000004 /* don't complain if map not found */ 865 #define MF_NOFOLDCASE 0x00000008 /* don't fold case in keys */ 866 #define MF_MATCHONLY 0x00000010 /* don't use the map value */ 867 #define MF_OPEN 0x00000020 /* this entry is open */ 868 #define MF_WRITABLE 0x00000040 /* open for writing */ 869 #define MF_ALIAS 0x00000080 /* this is an alias file */ 870 #define MF_TRY0NULL 0x00000100 /* try with no null byte */ 871 #define MF_TRY1NULL 0x00000200 /* try with the null byte */ 872 #define MF_LOCKED 0x00000400 /* this map is currently locked */ 873 #define MF_ALIASWAIT 0x00000800 /* alias map in aliaswait state */ 874 #define MF_IMPL_HASH 0x00001000 /* implicit: underlying hash database */ 875 #define MF_IMPL_NDBM 0x00002000 /* implicit: underlying NDBM database */ 876 #define MF_UNSAFEDB 0x00004000 /* this map is world writable */ 877 #define MF_APPEND 0x00008000 /* append new entry on rebuild */ 878 #define MF_KEEPQUOTES 0x00010000 /* don't dequote key before lookup */ 879 #define MF_NODEFER 0x00020000 /* don't defer if map lookup fails */ 880 #define MF_REGEX_NOT 0x00040000 /* regular expression negation */ 881 #define MF_DEFER 0x00080000 /* don't lookup map in defer mode */ 882 #define MF_SINGLEMATCH 0x00100000 /* successful only if match one key */ 883 #define MF_NOREWRITE 0x00200000 /* don't rewrite result, return as-is */ 884 #define MF_CLOSING 0x00400000 /* map is being closed */ 885 886 #define DYNOPENMAP(map) if (!bitset(MF_OPEN, (map)->map_mflags)) \ 887 { \ 888 if (!openmap(map)) \ 889 return NULL; \ 890 } 891 892 893 /* indices for map_actions */ 894 #define MA_NOTFOUND 0 /* member map returned "not found" */ 895 #define MA_UNAVAIL 1 /* member map is not available */ 896 #define MA_TRYAGAIN 2 /* member map returns temp failure */ 897 898 /* 899 ** The class of a map -- essentially the functions to call 900 */ 901 902 MAPCLASS 903 { 904 char *map_cname; /* name of this map class */ 905 char *map_ext; /* extension for database file */ 906 short map_cflags; /* flag bits, see below */ 907 bool (*map_parse)__P((MAP *, char *)); 908 /* argument parsing function */ 909 char *(*map_lookup)__P((MAP *, char *, char **, int *)); 910 /* lookup function */ 911 void (*map_store)__P((MAP *, char *, char *)); 912 /* store function */ 913 bool (*map_open)__P((MAP *, int)); 914 /* open function */ 915 void (*map_close)__P((MAP *)); 916 /* close function */ 917 }; 918 919 /* bit values for map_cflags */ 920 #define MCF_ALIASOK 0x0001 /* can be used for aliases */ 921 #define MCF_ALIASONLY 0x0002 /* usable only for aliases */ 922 #define MCF_REBUILDABLE 0x0004 /* can rebuild alias files */ 923 #define MCF_OPTFILE 0x0008 /* file name is optional */ 924 925 /* functions */ 926 extern void closemaps __P((void)); 927 extern bool impl_map_open __P((MAP *, int)); 928 extern void initmaps __P((void)); 929 extern MAP *makemapentry __P((char *)); 930 extern void maplocaluser __P((ADDRESS *, ADDRESS **, int, ENVELOPE *)); 931 extern char *map_rewrite __P((MAP *, const char *, size_t, char **)); 932 #if NETINFO 933 extern char *ni_propval __P((char *, char *, char *, char *, int)); 934 #endif /* NETINFO */ 935 extern bool openmap __P((MAP *)); 936 #if USERDB 937 extern void _udbx_close __P((void)); 938 extern int udbexpand __P((ADDRESS *, ADDRESS **, int, ENVELOPE *)); 939 extern char *udbsender __P((char *)); 940 #endif /* USERDB */ 941 /* 942 ** LDAP related items 943 */ 944 #ifdef LDAPMAP 945 struct ldapmap_struct 946 { 947 /* needed for ldap_open or ldap_init */ 948 char *ldap_host; 949 int ldap_port; 950 951 /* options set in ld struct before ldap_bind_s */ 952 int ldap_deref; 953 time_t ldap_timelimit; 954 int ldap_sizelimit; 955 int ldap_options; 956 957 /* args for ldap_bind_s */ 958 LDAP *ldap_ld; 959 char *ldap_binddn; 960 char *ldap_secret; 961 int ldap_method; 962 963 /* args for ldap_search */ 964 char *ldap_base; 965 int ldap_scope; 966 char *ldap_filter; 967 char *ldap_attr[LDAPMAP_MAX_ATTR + 1]; 968 bool ldap_attrsonly; 969 970 /* args for ldap_result */ 971 struct timeval ldap_timeout; 972 LDAPMessage *ldap_res; 973 974 /* Linked list of maps sharing the same LDAP binding */ 975 MAP *ldap_next; 976 }; 977 978 typedef struct ldapmap_struct LDAPMAP_STRUCT; 979 980 /* struct defining LDAP Auth Methods */ 981 struct lamvalues 982 { 983 char *lam_name; /* name of LDAP auth method */ 984 int lam_code; /* numeric code */ 985 }; 986 987 /* struct defining LDAP Alias Dereferencing */ 988 struct ladvalues 989 { 990 char *lad_name; /* name of LDAP alias dereferencing method */ 991 int lad_code; /* numeric code */ 992 }; 993 994 /* struct defining LDAP Search Scope */ 995 struct lssvalues 996 { 997 char *lss_name; /* name of LDAP search scope */ 998 int lss_code; /* numeric code */ 999 }; 1000 1001 /* functions */ 1002 extern bool ldapmap_parseargs __P((MAP *, char *)); 1003 extern void ldapmap_set_defaults __P((char *)); 1004 #endif /* LDAPMAP */ 1005 1006 /* 1007 ** PH related items 1008 */ 1009 1010 #ifdef PH_MAP 1011 struct ph_map_struct 1012 { 1013 char *ph_servers; /* list of ph servers */ 1014 char *ph_field_list; /* list of fields to search for match */ 1015 FILE *ph_to_server; 1016 FILE *ph_from_server; 1017 int ph_sockfd; 1018 time_t ph_timeout; 1019 }; 1020 typedef struct ph_map_struct PH_MAP_STRUCT; 1021 1022 # define DEFAULT_PH_MAP_FIELDS "alias callsign name spacedname" 1023 #endif /* PH_MAP */ 1024 /* 1025 ** Process List (proclist) 1026 */ 1027 1028 struct procs 1029 { 1030 pid_t proc_pid; 1031 char *proc_task; 1032 int proc_type; 1033 }; 1034 1035 #define NO_PID ((pid_t) 0) 1036 #ifndef PROC_LIST_SEG 1037 # define PROC_LIST_SEG 32 /* number of pids to alloc at a time */ 1038 #endif /* ! PROC_LIST_SEG */ 1039 1040 /* process types */ 1041 #define PROC_NONE 0 1042 #define PROC_DAEMON 1 1043 #define PROC_DAEMON_CHILD 2 1044 #define PROC_QUEUE 3 1045 #define PROC_QUEUE_CHILD 3 1046 #define PROC_CONTROL 4 1047 #define PROC_CONTROL_CHILD 5 1048 1049 /* functions */ 1050 extern void proc_list_add __P((pid_t, char *, int)); 1051 extern void proc_list_clear __P((void)); 1052 extern void proc_list_display __P((FILE *)); 1053 extern int proc_list_drop __P((pid_t)); 1054 extern void proc_list_probe __P((void)); 1055 extern void proc_list_set __P((pid_t, char *)); 1056 1057 /* 1058 ** Symbol table definitions 1059 */ 1060 1061 struct symtab 1062 { 1063 char *s_name; /* name to be entered */ 1064 short s_type; /* general type (see below) */ 1065 short s_len; /* length of this entry */ 1066 struct symtab *s_next; /* pointer to next in chain */ 1067 union 1068 { 1069 BITMAP256 sv_class; /* bit-map of word classes */ 1070 ADDRESS *sv_addr; /* pointer to address header */ 1071 MAILER *sv_mailer; /* pointer to mailer */ 1072 char *sv_alias; /* alias */ 1073 MAPCLASS sv_mapclass; /* mapping function class */ 1074 MAP sv_map; /* mapping function */ 1075 char *sv_hostsig; /* host signature */ 1076 MCI sv_mci; /* mailer connection info */ 1077 NAMECANON sv_namecanon; /* canonical name cache */ 1078 int sv_macro; /* macro name => id mapping */ 1079 int sv_ruleset; /* ruleset index */ 1080 struct hdrinfo sv_header; /* header metainfo */ 1081 char *sv_service[MAXMAPSTACK]; /* service switch */ 1082 #ifdef LDAPMAP 1083 MAP *sv_lmap; /* Maps for LDAP connection */ 1084 #endif /* LDAPMAP */ 1085 #if _FFR_MILTER 1086 struct milter *sv_milter; /* milter filter name */ 1087 #endif /* _FFR_MILTER */ 1088 } s_value; 1089 }; 1090 1091 typedef struct symtab STAB; 1092 1093 /* symbol types */ 1094 #define ST_UNDEF 0 /* undefined type */ 1095 #define ST_CLASS 1 /* class map */ 1096 #define ST_ADDRESS 2 /* an address in parsed format */ 1097 #define ST_MAILER 3 /* a mailer header */ 1098 #define ST_ALIAS 4 /* an alias */ 1099 #define ST_MAPCLASS 5 /* mapping function class */ 1100 #define ST_MAP 6 /* mapping function */ 1101 #define ST_HOSTSIG 7 /* host signature */ 1102 #define ST_NAMECANON 8 /* cached canonical name */ 1103 #define ST_MACRO 9 /* macro name to id mapping */ 1104 #define ST_RULESET 10 /* ruleset index */ 1105 #define ST_SERVICE 11 /* service switch entry */ 1106 #define ST_HEADER 12 /* special header flags */ 1107 #ifdef LDAPMAP 1108 # define ST_LMAP 13 /* List head of maps for LDAP connection */ 1109 #endif /* LDAPMAP */ 1110 #if _FFR_MILTER 1111 # define ST_MILTER 14 /* milter filter */ 1112 #endif /* _FFR_MILTER */ 1113 #define ST_MCI 16 /* mailer connection info (offset) */ 1114 1115 #define s_class s_value.sv_class 1116 #define s_address s_value.sv_addr 1117 #define s_mailer s_value.sv_mailer 1118 #define s_alias s_value.sv_alias 1119 #define s_mci s_value.sv_mci 1120 #define s_mapclass s_value.sv_mapclass 1121 #define s_hostsig s_value.sv_hostsig 1122 #define s_map s_value.sv_map 1123 #define s_namecanon s_value.sv_namecanon 1124 #define s_macro s_value.sv_macro 1125 #define s_ruleset s_value.sv_ruleset 1126 #define s_service s_value.sv_service 1127 #define s_header s_value.sv_header 1128 #ifdef LDAPMAP 1129 # define s_lmap s_value.sv_lmap 1130 #endif /* LDAPMAP */ 1131 #if _FFR_MILTER 1132 # define s_milter s_value.sv_milter 1133 #endif /* _FFR_MILTER */ 1134 1135 /* opcodes to stab */ 1136 #define ST_FIND 0 /* find entry */ 1137 #define ST_ENTER 1 /* enter if not there */ 1138 1139 /* functions */ 1140 extern STAB *stab __P((char *, int, int)); 1141 extern void stabapply __P((void (*)(STAB *, int), int)); 1142 1143 /* 1144 ** STRUCT EVENT -- event queue. 1145 ** 1146 ** Maintained in sorted order. 1147 ** 1148 ** We store the pid of the process that set this event to insure 1149 ** that when we fork we will not take events intended for the parent. 1150 */ 1151 1152 struct event 1153 { 1154 time_t ev_time; /* time of the function call */ 1155 void (*ev_func)__P((int)); 1156 /* function to call */ 1157 int ev_arg; /* argument to ev_func */ 1158 pid_t ev_pid; /* pid that set this event */ 1159 struct event *ev_link; /* link to next item */ 1160 }; 1161 1162 typedef struct event EVENT; 1163 1164 /* functions */ 1165 extern void clrevent __P((EVENT *)); 1166 extern void clear_events __P((void)); 1167 extern EVENT *setevent __P((time_t, void(*)(), int)); 1168 extern EVENT *sigsafe_setevent __P((time_t, void(*)(), int)); 1169 1170 /* 1171 ** Operation, send, error, and MIME modes 1172 ** 1173 ** The operation mode describes the basic operation of sendmail. 1174 ** This can be set from the command line, and is "send mail" by 1175 ** default. 1176 ** 1177 ** The send mode tells how to send mail. It can be set in the 1178 ** configuration file. It's setting determines how quickly the 1179 ** mail will be delivered versus the load on your system. If the 1180 ** -v (verbose) flag is given, it will be forced to SM_DELIVER 1181 ** mode. 1182 ** 1183 ** The error mode tells how to return errors. 1184 */ 1185 1186 #define MD_DELIVER 'm' /* be a mail sender */ 1187 #define MD_SMTP 's' /* run SMTP on standard input */ 1188 #define MD_ARPAFTP 'a' /* obsolete ARPANET mode (Grey Book) */ 1189 #define MD_DAEMON 'd' /* run as a daemon */ 1190 #define MD_FGDAEMON 'D' /* run daemon in foreground */ 1191 #define MD_VERIFY 'v' /* verify: don't collect or deliver */ 1192 #define MD_TEST 't' /* test mode: resolve addrs only */ 1193 #define MD_INITALIAS 'i' /* initialize alias database */ 1194 #define MD_PRINT 'p' /* print the queue */ 1195 #define MD_FREEZE 'z' /* freeze the configuration file */ 1196 #define MD_HOSTSTAT 'h' /* print persistent host stat info */ 1197 #define MD_PURGESTAT 'H' /* purge persistent host stat info */ 1198 #define MD_QUEUERUN 'q' /* queue run */ 1199 1200 /* values for e_sendmode -- send modes */ 1201 #define SM_DELIVER 'i' /* interactive delivery */ 1202 #define SM_FORK 'b' /* deliver in background */ 1203 #define SM_QUEUE 'q' /* queue, don't deliver */ 1204 #define SM_DEFER 'd' /* defer map lookups as well as queue */ 1205 #define SM_VERIFY 'v' /* verify only (used internally) */ 1206 1207 1208 /* used only as a parameter to sendall */ 1209 #define SM_DEFAULT '\0' /* unspecified, use SendMode */ 1210 1211 /* functions */ 1212 extern void set_delivery_mode __P((int, ENVELOPE *)); 1213 1214 /* values for e_errormode -- error handling modes */ 1215 #define EM_PRINT 'p' /* print errors */ 1216 #define EM_MAIL 'm' /* mail back errors */ 1217 #define EM_WRITE 'w' /* write back errors */ 1218 #define EM_BERKNET 'e' /* special berknet processing */ 1219 #define EM_QUIET 'q' /* don't print messages (stat only) */ 1220 1221 1222 /* bit values for MimeMode */ 1223 #define MM_CVTMIME 0x0001 /* convert 8 to 7 bit MIME */ 1224 #define MM_PASS8BIT 0x0002 /* just send 8 bit data blind */ 1225 #define MM_MIME8BIT 0x0004 /* convert 8-bit data to MIME */ 1226 1227 1228 /* how to handle messages without any recipient addresses */ 1229 #define NRA_NO_ACTION 0 /* just leave it as is */ 1230 #define NRA_ADD_TO 1 /* add To: header */ 1231 #define NRA_ADD_APPARENTLY_TO 2 /* add Apparently-To: header */ 1232 #define NRA_ADD_BCC 3 /* add empty Bcc: header */ 1233 #define NRA_ADD_TO_UNDISCLOSED 4 /* add To: undisclosed:; header */ 1234 1235 1236 /* flags to putxline */ 1237 #define PXLF_NOTHINGSPECIAL 0 /* no special mapping */ 1238 #define PXLF_MAPFROM 0x0001 /* map From_ to >From_ */ 1239 #define PXLF_STRIP8BIT 0x0002 /* strip 8th bit */ 1240 #define PXLF_HEADER 0x0004 /* map newlines in headers */ 1241 1242 /* 1243 ** Privacy flags 1244 ** These are bit values for the PrivacyFlags word. 1245 */ 1246 1247 #define PRIV_PUBLIC 0 /* what have I got to hide? */ 1248 #define PRIV_NEEDMAILHELO 0x0001 /* insist on HELO for MAIL, at least */ 1249 #define PRIV_NEEDEXPNHELO 0x0002 /* insist on HELO for EXPN */ 1250 #define PRIV_NEEDVRFYHELO 0x0004 /* insist on HELO for VRFY */ 1251 #define PRIV_NOEXPN 0x0008 /* disallow EXPN command entirely */ 1252 #define PRIV_NOVRFY 0x0010 /* disallow VRFY command entirely */ 1253 #define PRIV_AUTHWARNINGS 0x0020 /* flag possible authorization probs */ 1254 #define PRIV_NORECEIPTS 0x0040 /* disallow return receipts */ 1255 #define PRIV_NOVERB 0x0100 /* disallow VERB command entirely */ 1256 #define PRIV_RESTRICTMAILQ 0x1000 /* restrict mailq command */ 1257 #define PRIV_RESTRICTQRUN 0x2000 /* restrict queue run */ 1258 #define PRIV_NOETRN 0x4000 /* disallow ETRN command entirely */ 1259 #define PRIV_NOBODYRETN 0x8000 /* do not return bodies on bounces */ 1260 1261 /* don't give no info, anyway, anyhow */ 1262 #define PRIV_GOAWAY (0x0fff & ~PRIV_NORECEIPTS) 1263 1264 /* struct defining such things */ 1265 struct prival 1266 { 1267 char *pv_name; /* name of privacy flag */ 1268 u_short pv_flag; /* numeric level */ 1269 }; 1270 1271 1272 /* 1273 ** Flags passed to remotename, parseaddr, allocaddr, and buildaddr. 1274 */ 1275 1276 #define RF_SENDERADDR 0x001 /* this is a sender address */ 1277 #define RF_HEADERADDR 0x002 /* this is a header address */ 1278 #define RF_CANONICAL 0x004 /* strip comment information */ 1279 #define RF_ADDDOMAIN 0x008 /* OK to do domain extension */ 1280 #define RF_COPYPARSE 0x010 /* copy parsed user & host */ 1281 #define RF_COPYPADDR 0x020 /* copy print address */ 1282 #define RF_COPYALL (RF_COPYPARSE|RF_COPYPADDR) 1283 #define RF_COPYNONE 0 1284 1285 1286 /* 1287 ** Flags passed to mime8to7 and putheader. 1288 */ 1289 1290 #define M87F_OUTER 0 /* outer context */ 1291 #define M87F_NO8BIT 0x0001 /* can't have 8-bit in this section */ 1292 #define M87F_DIGEST 0x0002 /* processing multipart/digest */ 1293 #define M87F_NO8TO7 0x0004 /* don't do 8->7 bit conversions */ 1294 1295 /* functions */ 1296 extern void mime7to8 __P((MCI *, HDR *, ENVELOPE *)); 1297 extern int mime8to7 __P((MCI *, HDR *, ENVELOPE *, char **, int)); 1298 1299 /* 1300 ** Flags passed to returntosender. 1301 */ 1302 1303 #define RTSF_NO_BODY 0 /* send headers only */ 1304 #define RTSF_SEND_BODY 0x0001 /* include body of message in return */ 1305 #define RTSF_PM_BOUNCE 0x0002 /* this is a postmaster bounce */ 1306 1307 /* functions */ 1308 extern int returntosender __P((char *, ADDRESS *, int, ENVELOPE *)); 1309 1310 /* 1311 ** Regular UNIX sockaddrs are too small to handle ISO addresses, so 1312 ** we are forced to declare a supertype here. 1313 */ 1314 1315 #if NETINET || NETINET6 || NETUNIX || NETISO || NETNS || NETX25 1316 union bigsockaddr 1317 { 1318 struct sockaddr sa; /* general version */ 1319 # if NETUNIX 1320 struct sockaddr_un sunix; /* UNIX family */ 1321 # endif /* NETUNIX */ 1322 # if NETINET 1323 struct sockaddr_in sin; /* INET family */ 1324 # endif /* NETINET */ 1325 # if NETINET6 1326 struct sockaddr_in6 sin6; /* INET/IPv6 */ 1327 # endif /* NETINET6 */ 1328 # if NETISO 1329 struct sockaddr_iso siso; /* ISO family */ 1330 # endif /* NETISO */ 1331 # if NETNS 1332 struct sockaddr_ns sns; /* XNS family */ 1333 # endif /* NETNS */ 1334 # if NETX25 1335 struct sockaddr_x25 sx25; /* X.25 family */ 1336 # endif /* NETX25 */ 1337 }; 1338 1339 # define SOCKADDR union bigsockaddr 1340 1341 /* functions */ 1342 extern char *anynet_ntoa __P((SOCKADDR *)); 1343 # if NETINET6 1344 extern char *anynet_ntop __P((struct in6_addr *, char *, size_t)); 1345 # endif /* NETINET6 */ 1346 extern char *hostnamebyanyaddr __P((SOCKADDR *)); 1347 # if DAEMON 1348 extern char *validate_connection __P((SOCKADDR *, char *, ENVELOPE *)); 1349 # endif /* DAEMON */ 1350 1351 #endif /* NETINET || NETINET6 || NETUNIX || NETISO || NETNS || NETX25 */ 1352 1353 #if _FFR_MILTER 1354 /* 1355 ** Mail Filters (milter) 1356 */ 1357 1358 #include <libmilter/milter.h> 1359 1360 #define SMFTO_WRITE 0 /* Timeout for sending information */ 1361 #define SMFTO_READ 1 /* Timeout waiting for a response */ 1362 #define SMFTO_EOM 2 /* Timeout for ACK/NAK to EOM */ 1363 #define SMFTO_CONNECT 3 /* Timeout for connect() */ 1364 1365 #define SMFTO_NUM_TO 4 /* Total number of timeouts */ 1366 1367 struct milter 1368 { 1369 char *mf_name; /* filter name */ 1370 BITMAP256 mf_flags; /* MTA flags */ 1371 u_long mf_fvers; /* filter version */ 1372 u_long mf_fflags; /* filter flags */ 1373 u_long mf_pflags; /* protocol flags */ 1374 char *mf_conn; /* connection info */ 1375 int mf_sock; /* connected socket */ 1376 char mf_state; /* state of filter */ 1377 time_t mf_timeout[SMFTO_NUM_TO]; /* timeouts */ 1378 }; 1379 1380 /* MTA flags */ 1381 # define SMF_REJECT 'R' /* Reject connection on filter fail */ 1382 # define SMF_TEMPFAIL 'T' /* tempfail connection on failure */ 1383 1384 /* states */ 1385 # define SMFS_CLOSED 'C' /* closed for all further actions */ 1386 # define SMFS_OPEN 'O' /* connected to remote milter filter */ 1387 # define SMFS_INMSG 'M' /* currently servicing a message */ 1388 # define SMFS_DONE 'D' /* done with current message */ 1389 # define SMFS_CLOSABLE 'Q' /* done with current connection */ 1390 # define SMFS_ERROR 'E' /* error state */ 1391 # define SMFS_READY 'R' /* ready for action */ 1392 1393 /* 32-bit type used by milter */ 1394 typedef SM_INT32 mi_int32; 1395 1396 EXTERN struct milter *InputFilters[MAXFILTERS]; 1397 EXTERN char *InputFilterList; 1398 #endif /* _FFR_MILTER */ 1399 1400 /* 1401 ** Vendor codes 1402 ** 1403 ** Vendors can customize sendmail to add special behaviour, 1404 ** generally for back compatibility. Ideally, this should 1405 ** be set up in the .cf file using the "V" command. However, 1406 ** it's quite reasonable for some vendors to want the default 1407 ** be their old version; this can be set using 1408 ** -DVENDOR_DEFAULT=VENDOR_xxx 1409 ** in the Makefile. 1410 ** 1411 ** Vendors should apply to sendmail@sendmail.org for 1412 ** unique vendor codes. 1413 */ 1414 1415 #define VENDOR_BERKELEY 1 /* Berkeley-native configuration file */ 1416 #define VENDOR_SUN 2 /* Sun-native configuration file */ 1417 #define VENDOR_HP 3 /* Hewlett-Packard specific config syntax */ 1418 #define VENDOR_IBM 4 /* IBM specific config syntax */ 1419 #define VENDOR_SENDMAIL 5 /* Sendmail, Inc. specific config syntax */ 1420 1421 /* prototypes for vendor-specific hook routines */ 1422 extern void vendor_daemon_setup __P((ENVELOPE *)); 1423 extern void vendor_set_uid __P((UID_T)); 1424 1425 1426 /* 1427 ** Terminal escape codes. 1428 ** 1429 ** To make debugging output clearer. 1430 */ 1431 1432 struct termescape 1433 { 1434 char *te_rv_on; /* turn reverse-video on */ 1435 char *te_rv_off; /* turn reverse-video off */ 1436 }; 1437 1438 /* 1439 ** Additional definitions 1440 */ 1441 1442 /* d_flags, see daemon.c */ 1443 /* general rule: lower case: required, upper case: No */ 1444 #define D_AUTHREQ 'a' /* authentication required */ 1445 #define D_BINDIF 'b' /* use if_addr for outgoing connection */ 1446 #define D_CANONREQ 'c' /* canonification required (cf) */ 1447 #define D_IFNHELO 'h' /* use if name for HELO */ 1448 #define D_FQMAIL 'f' /* fq sender address required (cf) */ 1449 #if _FFR_TLS_CLT1 1450 #define D_CLTNOTLS 'S' /* don't use STARTTLS in client */ 1451 #endif /* _FFR_TLS_CLT1 */ 1452 #define D_FQRCPT 'r' /* fq recipient address required (cf) */ 1453 #define D_UNQUALOK 'u' /* unqualified address is ok (cf) */ 1454 #define D_NOCANON 'C' /* no canonification (cf) */ 1455 #define D_NOETRN 'E' /* no ETRN (MSA) */ 1456 #define D_ETRNONLY ((char)0x01) /* allow only ETRN (disk low) */ 1457 1458 /* Flags for submitmode */ 1459 #define SUBMIT_UNKNOWN 0x0000 /* unknown agent type */ 1460 #define SUBMIT_MTA 0x0001 /* act like a message transfer agent */ 1461 #define SUBMIT_MSA 0x0002 /* act like a message submission agent */ 1462 1463 #if SASL 1464 /* 1465 ** SASL 1466 */ 1467 1468 /* authenticated? */ 1469 # define SASL_NOT_AUTH 0 /* not authenticated */ 1470 # define SASL_PROC_AUTH 1 /* in process of authenticating */ 1471 # define SASL_IS_AUTH 2 /* authenticated */ 1472 1473 /* SASL options */ 1474 # define SASL_AUTH_AUTH 0x1000 /* use auth= only if authenticated */ 1475 # if _FFR_SASL_OPTS 1476 # define SASL_SEC_MASK 0x0fff /* mask for SASL_SEC_* values: sasl.h */ 1477 # if (SASL_SEC_NOPLAINTEXT & SASL_SEC_MASK) == 0 || \ 1478 (SASL_SEC_NOACTIVE & SASL_SEC_MASK) == 0 || \ 1479 (SASL_SEC_NODICTIONARY & SASL_SEC_MASK) == 0 || \ 1480 (SASL_SEC_FORWARD_SECRECY & SASL_SEC_MASK) == 0 || \ 1481 (SASL_SEC_NOANONYMOUS & SASL_SEC_MASK) == 0 || \ 1482 (SASL_SEC_PASS_CREDENTIALS & SASL_SEC_MASK) == 0 1483 ERROR: change SASL_SEC_MASK_ notify sendmail.org! 1484 # endif 1485 # endif /* _FFR_SASL_OPTS */ 1486 1487 # define MAXOUTLEN 1024 /* length of output buffer */ 1488 #endif /* SASL */ 1489 1490 #if STARTTLS 1491 /* 1492 ** TLS 1493 */ 1494 1495 /* what to do in the TLS initialization */ 1496 #define TLS_I_NONE 0x00000000 /* no requirements... */ 1497 #define TLS_I_CERT_EX 0x00000001 /* CERT must exist */ 1498 #define TLS_I_CERT_UNR 0x00000002 /* CERT must be g/o unreadable */ 1499 #define TLS_I_KEY_EX 0x00000004 /* KEY must exist */ 1500 #define TLS_I_KEY_UNR 0x00000008 /* KEY must be g/o unreadable */ 1501 #define TLS_I_CERTP_EX 0x00000010 /* CA CERT PATH must exist */ 1502 #define TLS_I_CERTP_UNR 0x00000020 /* CA CERT PATH must be g/o unreadable */ 1503 #define TLS_I_CERTF_EX 0x00000040 /* CA CERT FILE must exist */ 1504 #define TLS_I_CERTF_UNR 0x00000080 /* CA CERT FILE must be g/o unreadable */ 1505 #define TLS_I_RSA_TMP 0x00000100 /* RSA TMP must be generated */ 1506 #define TLS_I_USE_KEY 0x00000200 /* private key must usable */ 1507 #define TLS_I_USE_CERT 0x00000400 /* certificate must be usable */ 1508 #define TLS_I_VRFY_PATH 0x00000800 /* load verify path must succeed */ 1509 #define TLS_I_VRFY_LOC 0x00001000 /* load verify default must succeed */ 1510 #define TLS_I_CACHE 0x00002000 /* require cache */ 1511 #define TLS_I_TRY_DH 0x00004000 /* try DH certificate */ 1512 #define TLS_I_REQ_DH 0x00008000 /* require DH certificate */ 1513 #define TLS_I_DHPAR_EX 0x00010000 /* require DH parameters */ 1514 #define TLS_I_DHPAR_UNR 0x00020000 /* DH param. must be g/o unreadable */ 1515 #define TLS_I_DH512 0x00040000 /* generate 512bit DH param */ 1516 #define TLS_I_DH1024 0x00080000 /* generate 1024bit DH param */ 1517 #define TLS_I_DH2048 0x00100000 /* generate 2048bit DH param */ 1518 1519 /* server requirements */ 1520 #define TLS_I_SRV (TLS_I_CERT_EX | TLS_I_KEY_EX | TLS_I_KEY_UNR | \ 1521 TLS_I_CERTP_EX | TLS_I_CERTF_EX | TLS_I_RSA_TMP | \ 1522 TLS_I_USE_KEY | TLS_I_USE_CERT | TLS_I_VRFY_PATH | \ 1523 TLS_I_VRFY_LOC | TLS_I_TRY_DH | \ 1524 TLS_I_DH512) 1525 1526 /* client requirements */ 1527 #define TLS_I_CLT (TLS_I_KEY_UNR) 1528 1529 #define TLS_AUTH_OK 0 1530 #define TLS_AUTH_NO 1 1531 #define TLS_AUTH_FAIL (-1) 1532 #endif /* STARTTLS */ 1533 1534 1535 /* 1536 ** Queue related items 1537 */ 1538 1539 /* queue sort order */ 1540 #define QSO_BYPRIORITY 0 /* sort by message priority */ 1541 #define QSO_BYHOST 1 /* sort by first host name */ 1542 #define QSO_BYTIME 2 /* sort by submission time */ 1543 #define QSO_BYFILENAME 3 /* sort by file name only */ 1544 1545 #if _FFR_QUEUEDELAY 1546 #define QD_LINEAR 0 /* linear (old) delay alg */ 1547 #define QD_EXP 1 /* exponential delay alg */ 1548 #endif /* _FFR_QUEUEDELAY */ 1549 1550 #define NOQDIR (-1) /* no queue directory (yet) */ 1551 1552 #define NOW ((time_t) (-1)) /* queue return: now */ 1553 1554 /* Queue Run Limitations */ 1555 struct queue_char 1556 { 1557 char *queue_match; /* string to match */ 1558 struct queue_char *queue_next; 1559 }; 1560 1561 typedef struct queue_char QUEUE_CHAR; 1562 1563 /* functions */ 1564 extern void assign_queueid __P((ENVELOPE *)); 1565 extern ADDRESS *copyqueue __P((ADDRESS *)); 1566 extern void initsys __P((ENVELOPE *)); 1567 extern void loseqfile __P((ENVELOPE *, char *)); 1568 extern void multiqueue_cache __P((void)); 1569 extern char *qid_printname __P((ENVELOPE *)); 1570 extern char *qid_printqueue __P((int)); 1571 extern char *queuename __P((ENVELOPE *, int)); 1572 extern void queueup __P((ENVELOPE *, bool)); 1573 extern bool runqueue __P((bool, bool)); 1574 extern void setnewqueue __P((ENVELOPE *)); 1575 extern bool shouldqueue __P((long, time_t)); 1576 extern void sync_queue_time __P((void)); 1577 1578 /* 1579 ** Timeouts 1580 ** 1581 ** Indicated values are the MINIMUM per RFC 1123 section 5.3.2. 1582 */ 1583 1584 EXTERN struct 1585 { 1586 /* RFC 1123-specified timeouts [minimum value] */ 1587 time_t to_initial; /* initial greeting timeout [5m] */ 1588 time_t to_mail; /* MAIL command [5m] */ 1589 time_t to_rcpt; /* RCPT command [5m] */ 1590 time_t to_datainit; /* DATA initiation [2m] */ 1591 time_t to_datablock; /* DATA block [3m] */ 1592 time_t to_datafinal; /* DATA completion [10m] */ 1593 time_t to_nextcommand; /* next command [5m] */ 1594 /* following timeouts are not mentioned in RFC 1123 */ 1595 time_t to_iconnect; /* initial connection timeout (first try) */ 1596 time_t to_connect; /* initial connection timeout (later tries) */ 1597 time_t to_rset; /* RSET command */ 1598 time_t to_helo; /* HELO command */ 1599 time_t to_quit; /* QUIT command */ 1600 time_t to_miscshort; /* misc short commands (NOOP, VERB, etc) */ 1601 time_t to_ident; /* IDENT protocol requests */ 1602 time_t to_fileopen; /* opening :include: and .forward files */ 1603 time_t to_control; /* process a control socket command */ 1604 /* following are per message */ 1605 time_t to_q_return[MAXTOCLASS]; /* queue return timeouts */ 1606 time_t to_q_warning[MAXTOCLASS]; /* queue warning timeouts */ 1607 time_t res_retrans[MAXRESTOTYPES]; /* resolver retransmit */ 1608 int res_retry[MAXRESTOTYPES]; /* resolver retry */ 1609 } TimeOuts; 1610 1611 /* timeout classes for return and warning timeouts */ 1612 #define TOC_NORMAL 0 /* normal delivery */ 1613 #define TOC_URGENT 1 /* urgent delivery */ 1614 #define TOC_NONURGENT 2 /* non-urgent delivery */ 1615 1616 /* resolver timeout specifiers */ 1617 #define RES_TO_FIRST 0 /* first attempt */ 1618 #define RES_TO_NORMAL 1 /* subsequent attempts */ 1619 #define RES_TO_DEFAULT 2 /* default value */ 1620 1621 /* functions */ 1622 extern void inittimeouts __P((char *, bool)); 1623 1624 /* 1625 ** Trace information 1626 */ 1627 1628 /* macros for debugging flags */ 1629 #define tTd(flag, level) (tTdvect[flag] >= (u_char)level) 1630 #define tTdlevel(flag) (tTdvect[flag]) 1631 1632 /* variables */ 1633 extern u_char tTdvect[100]; /* trace vector */ 1634 /* 1635 ** Critical signal sections 1636 */ 1637 1638 #define PEND_SIGHUP 0x0001 1639 #define PEND_SIGINT 0x0002 1640 #define PEND_SIGTERM 0x0004 1641 #define PEND_SIGUSR1 0x0008 1642 1643 #define ENTER_CRITICAL() InCriticalSection++ 1644 1645 #define LEAVE_CRITICAL() \ 1646 do \ 1647 { \ 1648 if (InCriticalSection > 0) \ 1649 InCriticalSection--; \ 1650 } while (0) 1651 1652 #define CHECK_CRITICAL(sig) \ 1653 do \ 1654 { \ 1655 if (InCriticalSection > 0 && (sig) != 0) \ 1656 { \ 1657 pend_signal((sig)); \ 1658 return SIGFUNC_RETURN; \ 1659 } \ 1660 } while (0) 1661 1662 /* reset signal in case System V semantics */ 1663 #ifdef SYS5SIGNALS 1664 # define FIX_SYSV_SIGNAL(sig, handler) \ 1665 { \ 1666 if ((sig) != 0) \ 1667 (void) setsignal((sig), (handler)); \ 1668 } 1669 #else /* SYS5SIGNALS */ 1670 # define FIX_SYSV_SIGNAL(sig, handler) { /* EMPTY */ } 1671 #endif /* SYS5SIGNALS */ 1672 1673 /* variables */ 1674 EXTERN u_int volatile InCriticalSection; /* >0 if in a critical section */ 1675 EXTERN int volatile PendingSignal; /* pending signal to resend */ 1676 1677 /* functions */ 1678 extern void pend_signal __P((int)); 1679 1680 /* 1681 ** Miscellaneous information. 1682 */ 1683 1684 /* 1685 ** The "no queue id" queue id for sm_syslog 1686 */ 1687 1688 #define NOQID "*~*" 1689 1690 1691 /* 1692 ** Some in-line functions 1693 */ 1694 1695 /* set exit status */ 1696 #define setstat(s) { \ 1697 if (ExitStat == EX_OK || ExitStat == EX_TEMPFAIL) \ 1698 ExitStat = s; \ 1699 } 1700 1701 /* make a copy of a string */ 1702 #define newstr(s) strcpy(xalloc(strlen(s) + 1), s) 1703 1704 #define STRUCTCOPY(s, d) d = s 1705 /* 1706 ** Global variables. 1707 */ 1708 1709 EXTERN bool AllowBogusHELO; /* allow syntax errors on HELO command */ 1710 #if !_FFR_REMOVE_AUTOREBUILD 1711 EXTERN bool AutoRebuild; /* auto-rebuild the alias database as needed */ 1712 #endif /* !_FFR_REMOVE_AUTOREBUILD */ 1713 EXTERN bool CheckAliases; /* parse addresses during newaliases */ 1714 EXTERN bool ChownAlwaysSafe; /* treat chown(2) as safe */ 1715 EXTERN bool ColonOkInAddr; /* single colon legal in address */ 1716 EXTERN bool ConfigFileRead; /* configuration file has been read */ 1717 EXTERN bool volatile DataProgress; /* have we sent anything since last check */ 1718 EXTERN bool DisConnected; /* running with OutChannel redirected to xf */ 1719 EXTERN bool volatile DoQueueRun; /* non-interrupt time queue run needed */ 1720 EXTERN bool DontExpandCnames; /* do not $[...$] expand CNAMEs */ 1721 EXTERN bool DontInitGroups; /* avoid initgroups() because of NIS cost */ 1722 EXTERN bool DontLockReadFiles; /* don't read lock support files */ 1723 EXTERN bool DontProbeInterfaces; /* don't probe interfaces for names */ 1724 EXTERN bool DontPruneRoutes; /* don't prune source routes */ 1725 EXTERN bool ForkQueueRuns; /* fork for each job when running the queue */ 1726 EXTERN bool FromFlag; /* if set, "From" person is explicit */ 1727 EXTERN bool GrabTo; /* if set, get recipients from msg */ 1728 EXTERN bool HasEightBits; /* has at least one eight bit input byte */ 1729 EXTERN bool HasWildcardMX; /* don't use MX records when canonifying */ 1730 EXTERN bool HoldErrs; /* only output errors to transcript */ 1731 EXTERN bool IgnoreHostStatus; /* ignore long term host status files */ 1732 EXTERN bool IgnrDot; /* don't let dot end messages */ 1733 EXTERN bool InChild; /* true if running in an SMTP subprocess */ 1734 EXTERN bool LogUsrErrs; /* syslog user errors (e.g., SMTP RCPT cmd) */ 1735 EXTERN bool MapOpenErr; /* error opening a non-optional map */ 1736 EXTERN bool MatchGecos; /* look for user names in gecos field */ 1737 EXTERN bool MeToo; /* send to the sender also */ 1738 EXTERN bool NoAlias; /* suppress aliasing */ 1739 EXTERN bool NoConnect; /* don't connect to non-local mailers */ 1740 EXTERN bool OnlyOneError; /* .... or only want to give one SMTP reply */ 1741 EXTERN bool QuickAbort; /* .... but only if we want a quick abort */ 1742 EXTERN bool RrtImpliesDsn; /* turn Return-Receipt-To: into DSN */ 1743 EXTERN bool SaveFrom; /* save leading "From" lines */ 1744 EXTERN bool SendMIMEErrors; /* send error messages in MIME format */ 1745 EXTERN bool SevenBitInput; /* force 7-bit data on input */ 1746 EXTERN bool SingleLineFromHeader; /* force From: header to be one line */ 1747 EXTERN bool SingleThreadDelivery; /* single thread hosts on delivery */ 1748 EXTERN bool volatile StopRequest; /* stop sending output */ 1749 EXTERN bool SuperSafe; /* be extra careful, even if expensive */ 1750 EXTERN bool SuprErrs; /* set if we are suppressing errors */ 1751 EXTERN bool TryNullMXList; /* if we are the best MX, try host directly */ 1752 #if _FFR_WORKAROUND_BROKEN_NAMESERVERS 1753 EXTERN bool WorkAroundBrokenAAAA; /* some nameservers return SERVFAIL on AAAA queries */ 1754 #endif /* _FFR_WORKAROUND_BROKEN_NAMESERVERS */ 1755 EXTERN bool UseErrorsTo; /* use Errors-To: header (back compat) */ 1756 EXTERN bool UseHesiod; /* using Hesiod -- interpret Hesiod errors */ 1757 EXTERN bool UseNameServer; /* using DNS -- interpret h_errno & MX RRs */ 1758 EXTERN char InetMode; /* default network for daemon mode */ 1759 EXTERN char OpMode; /* operation mode, see below */ 1760 EXTERN char SpaceSub; /* substitution for <lwsp> */ 1761 EXTERN int CheckpointInterval; /* queue file checkpoint interval */ 1762 EXTERN int ConfigLevel; /* config file level */ 1763 EXTERN int ConnRateThrottle; /* throttle for SMTP connection rate */ 1764 EXTERN int volatile CurChildren; /* current number of daemonic children */ 1765 EXTERN int CurrentLA; /* current load average */ 1766 EXTERN int DefaultNotify; /* default DSN notification flags */ 1767 EXTERN int Errors; /* set if errors (local to single pass) */ 1768 EXTERN int ExitStat; /* exit status code */ 1769 EXTERN int FileMode; /* mode on files */ 1770 EXTERN int LineNumber; /* line number in current input */ 1771 EXTERN int LogLevel; /* level of logging to perform */ 1772 EXTERN int MaxAliasRecursion; /* maximum depth of alias recursion */ 1773 EXTERN int MaxChildren; /* maximum number of daemonic children */ 1774 EXTERN int MaxForwardEntries; /* maximum number of forward entries */ 1775 EXTERN int MaxHeadersLength; /* max length of headers */ 1776 EXTERN int MaxHopCount; /* max # of hops until bounce */ 1777 EXTERN int MaxMacroRecursion; /* maximum depth of macro recursion */ 1778 EXTERN int MaxMciCache; /* maximum entries in MCI cache */ 1779 EXTERN int MaxMimeFieldLength; /* maximum MIME field length */ 1780 EXTERN int MaxMimeHeaderLength; /* maximum MIME header length */ 1781 1782 1783 EXTERN int MaxQueueRun; /* maximum number of jobs in one queue run */ 1784 EXTERN int MaxRcptPerMsg; /* max recipients per SMTP message */ 1785 EXTERN int MaxRuleRecursion; /* maximum depth of ruleset recursion */ 1786 EXTERN int MimeMode; /* MIME processing mode */ 1787 EXTERN int NoRecipientAction; 1788 EXTERN int NumPriorities; /* pointer into Priorities */ 1789 EXTERN u_short PrivacyFlags; /* privacy flags */ 1790 #if _FFR_QUEUE_FILE_MODE 1791 EXTERN int QueueFileMode; /* mode on qf/tf/df files */ 1792 #endif /* _FFR_QUEUE_FILE_MODE */ 1793 EXTERN int QueueLA; /* load average starting forced queueing */ 1794 EXTERN int QueueSortOrder; /* queue sorting order algorithm */ 1795 EXTERN int RefuseLA; /* load average refusing connections are */ 1796 EXTERN int VendorCode; /* vendor-specific operation enhancements */ 1797 EXTERN int Verbose; /* set if blow-by-blow desired */ 1798 EXTERN gid_t DefGid; /* default gid to run as */ 1799 EXTERN gid_t RealGid; /* real gid of caller */ 1800 EXTERN gid_t RunAsGid; /* GID to become for bulk of run */ 1801 EXTERN uid_t DefUid; /* default uid to run as */ 1802 EXTERN uid_t RealUid; /* real uid of caller */ 1803 EXTERN uid_t RunAsUid; /* UID to become for bulk of run */ 1804 EXTERN uid_t TrustedUid; /* uid of trusted user for files and startup */ 1805 EXTERN size_t DataFileBufferSize; /* size of buffer for in-core df */ 1806 EXTERN size_t XscriptFileBufferSize; /* size of buffer for in-core xf */ 1807 EXTERN time_t DialDelay; /* delay between dial-on-demand tries */ 1808 EXTERN time_t MciCacheTimeout; /* maximum idle time on connections */ 1809 EXTERN time_t MciInfoTimeout; /* how long 'til we retry down hosts */ 1810 EXTERN time_t MinQueueAge; /* min delivery interval */ 1811 EXTERN time_t QueueIntvl; /* intervals between running the queue */ 1812 EXTERN time_t SafeAlias; /* interval to wait until @:@ in alias file */ 1813 EXTERN time_t ServiceCacheMaxAge; /* refresh interval for cache */ 1814 EXTERN time_t ServiceCacheTime; /* time service switch was cached */ 1815 EXTERN MODE_T OldUmask; /* umask when sendmail starts up */ 1816 EXTERN long MaxMessageSize; /* advertised max size we will accept */ 1817 EXTERN long MinBlocksFree; /* min # of blocks free on queue fs */ 1818 EXTERN long QueueFactor; /* slope of queue function */ 1819 EXTERN long WkClassFact; /* multiplier for message class -> priority */ 1820 EXTERN long WkRecipFact; /* multiplier for # of recipients -> priority */ 1821 EXTERN long WkTimeFact; /* priority offset each time this job is run */ 1822 #if SASL 1823 EXTERN char *AuthMechanisms; /* AUTH mechanisms */ 1824 EXTERN char *SASLInfo; /* file with AUTH info */ 1825 #endif /* SASL */ 1826 EXTERN int SASLOpts; /* options for SASL */ 1827 #if STARTTLS 1828 EXTERN char *CACERTpath; /* path to CA certificates (dir. with hashes) */ 1829 EXTERN char *CACERTfile; /* file with CA certificate */ 1830 EXTERN char *SrvCERTfile; /* file with server certificate */ 1831 EXTERN char *Srvkeyfile; /* file with server private key */ 1832 EXTERN char *CltCERTfile; /* file with client certificate */ 1833 EXTERN char *Cltkeyfile; /* file with client private key */ 1834 EXTERN char *DHParams; /* file with DH parameters */ 1835 EXTERN char *RandFile; /* source of random data */ 1836 # if _FFR_TLS_1 1837 EXTERN char *DHParams5; /* file with DH parameters (512) */ 1838 EXTERN char *CipherList; /* list of ciphers */ 1839 # endif /* _FFR_TLS_1 */ 1840 #endif /* STARTTLS */ 1841 EXTERN char *ConfFile; /* location of configuration file [conf.c] */ 1842 EXTERN char *ControlSocketName; /* control socket filename [control.c] */ 1843 EXTERN char *CurHostName; /* current host we are dealing with */ 1844 EXTERN char *DeadLetterDrop; /* path to dead letter office */ 1845 EXTERN char *DefUser; /* default user to run as (from DefUid) */ 1846 EXTERN char *DefaultCharSet; /* default character set for MIME */ 1847 EXTERN char *DoubleBounceAddr; /* where to send double bounces */ 1848 EXTERN char *ErrMsgFile; /* file to prepend to all error messages */ 1849 EXTERN char *FallBackMX; /* fall back MX host */ 1850 EXTERN char *FileName; /* name to print on error messages */ 1851 EXTERN char *ForwardPath; /* path to search for .forward files */ 1852 EXTERN char *HelpFile; /* location of SMTP help file */ 1853 EXTERN char *HostStatDir; /* location of host status information */ 1854 EXTERN char *HostsFile; /* path to /etc/hosts file */ 1855 EXTERN char *MustQuoteChars; /* quote these characters in phrases */ 1856 EXTERN char *MyHostName; /* name of this host for SMTP messages */ 1857 EXTERN char *OperatorChars; /* operators (old $o macro) */ 1858 EXTERN char *PidFile; /* location of proc id file [conf.c] */ 1859 EXTERN char *PostMasterCopy; /* address to get errs cc's */ 1860 EXTERN char *ProcTitlePrefix; /* process title prefix */ 1861 EXTERN char *QueueDir; /* location of queue directory */ 1862 #if _FFR_QUEUEDELAY 1863 EXTERN int QueueAlg; /* algorithm for queue delays */ 1864 EXTERN time_t QueueInitDelay; /* initial queue delay */ 1865 EXTERN time_t QueueMaxDelay; /* maximum queue delay */ 1866 #endif /* _FFR_QUEUEDELAY */ 1867 EXTERN char *RealHostName; /* name of host we are talking to */ 1868 EXTERN char *RealUserName; /* real user name of caller */ 1869 EXTERN char *volatile RestartRequest;/* a sendmail restart has been requested */ 1870 EXTERN char *RunAsUserName; /* user to become for bulk of run */ 1871 EXTERN char *SafeFileEnv; /* chroot location for file delivery */ 1872 EXTERN char *ServiceSwitchFile; /* backup service switch */ 1873 EXTERN char *volatile ShutdownRequest;/* a sendmail shutdown has been requested */ 1874 EXTERN char *SmtpGreeting; /* SMTP greeting message (old $e macro) */ 1875 EXTERN char *SmtpPhase; /* current phase in SMTP processing */ 1876 EXTERN char SmtpError[MAXLINE]; /* save failure error messages */ 1877 EXTERN char *StatFile; /* location of statistics summary */ 1878 EXTERN char *TimeZoneSpec; /* override time zone specification */ 1879 EXTERN char *UdbSpec; /* user database source spec */ 1880 EXTERN char *UnixFromLine; /* UNIX From_ line (old $l macro) */ 1881 EXTERN char **ExternalEnviron; /* input environment */ 1882 /* saved user environment */ 1883 EXTERN char **SaveArgv; /* argument vector for re-execing */ 1884 EXTERN BITMAP256 DontBlameSendmail; /* DontBlameSendmail bits */ 1885 #if SFIO 1886 EXTERN Sfio_t *InChannel; /* input connection */ 1887 EXTERN Sfio_t *OutChannel; /* output connection */ 1888 #else /* SFIO */ 1889 EXTERN FILE *InChannel; /* input connection */ 1890 EXTERN FILE *OutChannel; /* output connection */ 1891 #endif /* SFIO */ 1892 EXTERN FILE *TrafficLogFile; /* file in which to log all traffic */ 1893 #ifdef HESIOD 1894 EXTERN void *HesiodContext; 1895 #endif /* HESIOD */ 1896 EXTERN ENVELOPE *CurEnv; /* envelope currently being processed */ 1897 EXTERN MAILER *LocalMailer; /* ptr to local mailer */ 1898 EXTERN MAILER *ProgMailer; /* ptr to program mailer */ 1899 EXTERN MAILER *FileMailer; /* ptr to *file* mailer */ 1900 EXTERN MAILER *InclMailer; /* ptr to *include* mailer */ 1901 EXTERN QUEUE_CHAR *QueueLimitRecipient; /* limit queue run to rcpt */ 1902 EXTERN QUEUE_CHAR *QueueLimitSender; /* limit queue run to sender */ 1903 EXTERN QUEUE_CHAR *QueueLimitId; /* limit queue run to id */ 1904 EXTERN MAILER *Mailer[MAXMAILERS + 1]; 1905 EXTERN struct rewrite *RewriteRules[MAXRWSETS]; 1906 EXTERN char *RuleSetNames[MAXRWSETS]; /* ruleset number to name */ 1907 EXTERN char *UserEnviron[MAXUSERENVIRON + 1]; 1908 EXTERN struct priority Priorities[MAXPRIORITIES]; 1909 EXTERN struct termescape TermEscape; /* terminal escape codes */ 1910 EXTERN SOCKADDR ConnectOnlyTo; /* override connection address (for testing) */ 1911 EXTERN SOCKADDR RealHostAddr; /* address of host we are talking to */ 1912 EXTERN jmp_buf TopFrame; /* branch-to-top-of-loop-on-error frame */ 1913 EXTERN TIMERS Timers; 1914 1915 /* 1916 ** Declarations of useful functions 1917 */ 1918 1919 #if SASL 1920 extern char *intersect __P((char *, char *)); 1921 extern char *iteminlist __P((char *, char *, char *)); 1922 extern int proxy_policy __P((void *, const char *, const char *, const char **, const char **)); 1923 # if SASL > 10515 1924 extern int safesaslfile __P((void *, char *, int)); 1925 # else /* SASL > 10515 */ 1926 extern int safesaslfile __P((void *, char *)); 1927 # endif /* SASL > 10515 */ 1928 extern int sasl_decode64 __P((const char *, unsigned, char *, unsigned *)); 1929 extern int sasl_encode64 __P((const char *, unsigned, char *, unsigned, unsigned *)); 1930 #endif /* SASL */ 1931 1932 #if STARTTLS 1933 extern void apps_ssl_info_cb __P((SSL *, int , int)); 1934 extern bool init_tls_library __P((void)); 1935 extern bool inittls __P((SSL_CTX **, u_long, bool, char *, char *, char *, char *, char *)); 1936 extern bool initclttls __P((void)); 1937 extern bool initsrvtls __P((void)); 1938 extern int tls_get_info __P((SSL *, ENVELOPE *, bool, char *, bool)); 1939 extern int endtls __P((SSL *, char *)); 1940 extern int endtlsclt __P((MCI *)); 1941 extern void tlslogerr __P((void)); 1942 extern bool tls_rand_init __P((char *, int)); 1943 #endif /* STARTTLS */ 1944 1945 /* Transcript file */ 1946 extern void closexscript __P((ENVELOPE *)); 1947 extern void openxscript __P((ENVELOPE *)); 1948 1949 /* error related */ 1950 extern void buffer_errors __P((void)); 1951 extern void flush_errors __P((bool)); 1952 extern void message __P((const char *, ...)); 1953 extern void nmessage __P((const char *, ...)); 1954 extern void syserr __P((const char *, ...)); 1955 extern void usrerrenh __P((char *, const char *, ...)); 1956 extern void usrerr __P((const char *, ...)); 1957 extern int isenhsc __P((const char *, int)); 1958 extern int extenhsc __P((const char *, int, char *)); 1959 1960 /* alias file */ 1961 extern void alias __P((ADDRESS *, ADDRESS **, int, ENVELOPE *)); 1962 extern bool aliaswait __P((MAP *, char *, bool)); 1963 extern void forward __P((ADDRESS *, ADDRESS **, int, ENVELOPE *)); 1964 extern void readaliases __P((MAP *, FILE *, bool, bool)); 1965 extern bool rebuildaliases __P((MAP *, bool)); 1966 extern void setalias __P((char *)); 1967 1968 /* logging */ 1969 extern void logdelivery __P((MAILER *, MCI *, char *, const char *, ADDRESS *, time_t, ENVELOPE *)); 1970 extern void logsender __P((ENVELOPE *, char *)); 1971 extern void sm_syslog __P((int, const char *, const char *, ...)); 1972 1973 /* SMTP */ 1974 extern void giveresponse __P((int, char *, MAILER *, MCI *, ADDRESS *, time_t, ENVELOPE *)); 1975 extern int reply __P((MAILER *, MCI *, ENVELOPE *, time_t, void (*)(), char **)); 1976 extern void smtp __P((char *volatile, BITMAP256, ENVELOPE *volatile)); 1977 #if SASL 1978 extern int smtpauth __P((MAILER *, MCI *, ENVELOPE *)); 1979 #endif /* SASL */ 1980 extern int smtpdata __P((MAILER *, MCI *, ENVELOPE *)); 1981 extern int smtpgetstat __P((MAILER *, MCI *, ENVELOPE *)); 1982 extern int smtpmailfrom __P((MAILER *, MCI *, ENVELOPE *)); 1983 extern void smtpmessage __P((char *, MAILER *, MCI *, ...)); 1984 extern void smtpinit __P((MAILER *, MCI *, ENVELOPE *, bool)); 1985 extern char *smtptodsn __P((int)); 1986 extern int smtpprobe __P((MCI *)); 1987 extern void smtpquit __P((MAILER *, MCI *, ENVELOPE *)); 1988 extern int smtprcpt __P((ADDRESS *, MAILER *, MCI *, ENVELOPE *)); 1989 extern void smtprset __P((MAILER *, MCI *, ENVELOPE *)); 1990 1991 #define ISSMTPCODE(c) (isascii(c[0]) && isdigit(c[0]) && \ 1992 isascii(c[1]) && isdigit(c[1]) && \ 1993 isascii(c[2]) && isdigit(c[2])) 1994 #define ISSMTPREPLY(c) (ISSMTPCODE(c) && \ 1995 (c[3] == ' ' || c[3] == '-' || c[3] == '\0')) 1996 1997 /* delivery */ 1998 extern pid_t dowork __P((int, char *, bool, bool, ENVELOPE *)); 1999 extern int endmailer __P((MCI *, ENVELOPE *, char **)); 2000 extern int mailfile __P((char *volatile, MAILER *volatile, ADDRESS *, volatile long, ENVELOPE *)); 2001 extern void sendall __P((ENVELOPE *, int)); 2002 2003 /* stats */ 2004 extern void markstats __P((ENVELOPE *, ADDRESS *, bool)); 2005 extern void clearstats __P((void)); 2006 extern void poststats __P((char *)); 2007 2008 /* control socket */ 2009 extern void closecontrolsocket __P((bool)); 2010 extern void clrcontrol __P((void)); 2011 extern void control_command __P((int, ENVELOPE *)); 2012 extern int opencontrolsocket __P((void)); 2013 2014 #if _FFR_MILTER 2015 /* milter functions */ 2016 extern void milter_parse_list __P((char *, struct milter **, int)); 2017 extern void milter_setup __P((char *)); 2018 extern void milter_set_option __P((char *, char *, bool)); 2019 extern bool milter_can_delrcpts __P((void)); 2020 extern void milter_init __P((ENVELOPE *, char *)); 2021 extern void milter_quit __P((ENVELOPE *)); 2022 extern void milter_abort __P((ENVELOPE *)); 2023 extern char *milter_connect __P((char *, SOCKADDR, ENVELOPE *, char *)); 2024 extern char *milter_helo __P((char *, ENVELOPE *, char *)); 2025 extern char *milter_envfrom __P((char **, ENVELOPE *, char *)); 2026 extern char *milter_envrcpt __P((char **, ENVELOPE *, char *)); 2027 extern char *milter_data __P((ENVELOPE *, char *)); 2028 #endif /* _FFR_MILTER */ 2029 2030 extern char *addquotes __P((char *)); 2031 extern void allsignals __P((bool)); 2032 extern char *arpadate __P((char *)); 2033 extern bool atobool __P((char *)); 2034 extern int atooct __P((char *)); 2035 extern void auth_warning __P((ENVELOPE *, const char *, ...)); 2036 extern int blocksignal __P((int)); 2037 extern bool bitintersect __P((BITMAP256, BITMAP256)); 2038 extern bool bitzerop __P((BITMAP256)); 2039 extern void buildfname __P((char *, char *, char *, int)); 2040 extern int checkcompat __P((ADDRESS *, ENVELOPE *)); 2041 #ifdef XDEBUG 2042 extern void checkfd012 __P((char *)); 2043 extern void checkfdopen __P((int, char *)); 2044 #endif /* XDEBUG */ 2045 extern void checkfds __P((char *)); 2046 extern bool chownsafe __P((int, bool)); 2047 extern void cleanstrcpy __P((char *, char *, int)); 2048 extern void clrdaemon __P((void)); 2049 extern void collect __P((FILE *, bool, HDR **, ENVELOPE *)); 2050 extern time_t convtime __P((char *, int)); 2051 extern char **copyplist __P((char **, bool)); 2052 extern void copy_class __P((int, int)); 2053 extern time_t curtime __P((void)); 2054 extern char *defcharset __P((ENVELOPE *)); 2055 extern char *denlstring __P((char *, bool, bool)); 2056 extern void disconnect __P((int, ENVELOPE *)); 2057 extern bool dns_getcanonname __P((char *, int, bool, int *)); 2058 extern pid_t dofork __P((void)); 2059 extern int drop_privileges __P((bool)); 2060 extern int dsntoexitstat __P((char *)); 2061 extern void dumpfd __P((int, bool, bool)); 2062 extern void dumpstate __P((char *)); 2063 extern bool enoughdiskspace __P((long, bool)); 2064 extern char *exitstat __P((char *)); 2065 extern char *fgetfolded __P((char *, int, FILE *)); 2066 extern void fill_fd __P((int, char *)); 2067 extern char *find_character __P((char *, int)); 2068 extern struct passwd *finduser __P((char *, bool *)); 2069 extern void finis __P((bool, volatile int)); 2070 extern void fixcrlf __P((char *, bool)); 2071 extern long freediskspace __P((char *, long *)); 2072 #if NETINET6 && NEEDSGETIPNODE 2073 # if _FFR_FREEHOSTENT 2074 extern void freehostent __P((struct hostent *)); 2075 # endif /* _FFR_FREEHOSTENT */ 2076 #endif /* NEEDSGETIPNODE && NETINET6 */ 2077 extern char *get_column __P((char *, int, int, char *, int)); 2078 extern char *getauthinfo __P((int, bool *)); 2079 extern char *getcfname __P((void)); 2080 extern char *getextenv __P((const char *)); 2081 extern int getdtsize __P((void)); 2082 extern BITMAP256 *getrequests __P((ENVELOPE *)); 2083 extern char *getvendor __P((int)); 2084 extern void help __P((char *, ENVELOPE *)); 2085 extern void init_md __P((int, char **)); 2086 extern void initdaemon __P((void)); 2087 extern void inithostmaps __P((void)); 2088 extern void initmacros __P((ENVELOPE *)); 2089 extern void initsetproctitle __P((int, char **, char **)); 2090 extern void init_vendor_macros __P((ENVELOPE *)); 2091 extern SIGFUNC_DECL intsig __P((int)); 2092 extern bool isloopback __P((SOCKADDR sa)); 2093 extern void load_if_names __P((void)); 2094 extern bool lockfile __P((int, char *, char *, int)); 2095 extern void log_sendmail_pid __P((ENVELOPE *)); 2096 extern char lower __P((int)); 2097 extern void makelower __P((char *)); 2098 extern int makeconnection_ds __P((char *, MCI *)); 2099 extern int makeconnection __P((char *, volatile u_int, MCI *, ENVELOPE *)); 2100 extern char * munchstring __P((char *, char **, int)); 2101 extern struct hostent *myhostname __P((char *, int)); 2102 extern char *nisplus_default_domain __P((void)); /* extern for Sun */ 2103 extern bool path_is_dir __P((char *, bool)); 2104 extern char *pintvl __P((time_t, bool)); 2105 extern void printav __P((char **)); 2106 extern void printmailer __P((MAILER *)); 2107 extern void printopenfds __P((bool)); 2108 extern void printqueue __P((void)); 2109 extern void printrules __P((void)); 2110 extern pid_t prog_open __P((char **, int *, ENVELOPE *)); 2111 extern void putline __P((char *, MCI *)); 2112 extern void putxline __P((char *, size_t, MCI *, int)); 2113 extern void queueup_macros __P((int, FILE *, ENVELOPE *)); 2114 extern void readcf __P((char *, bool, ENVELOPE *)); 2115 extern SIGFUNC_DECL reapchild __P((int)); 2116 extern int releasesignal __P((int)); 2117 extern void resetlimits __P((void)); 2118 extern bool rfc822_string __P((char *)); 2119 extern FILE *safefopen __P((char *, int, int, long)); 2120 extern void savemail __P((ENVELOPE *, bool)); 2121 extern void seed_random __P((void)); 2122 extern void sendtoargv __P((char **, ENVELOPE *)); 2123 extern void setclientoptions __P((char *)); 2124 extern bool setdaemonoptions __P((char *)); 2125 extern void setdefaults __P((ENVELOPE *)); 2126 extern void setdefuser __P((void)); 2127 extern bool setvendor __P((char *)); 2128 extern void setoption __P((int, char *, bool, bool, ENVELOPE *)); 2129 extern sigfunc_t setsignal __P((int, sigfunc_t)); 2130 extern void setuserenv __P((const char *, const char *)); 2131 extern void settime __P((ENVELOPE *)); 2132 extern char *sfgets __P((char *, int, FILE *, time_t, char *)); 2133 extern char *shortenstring __P((const char *, int)); 2134 extern char *shorten_hostname __P((char [])); 2135 extern bool shorten_rfc822_string __P((char *, size_t)); 2136 extern void shutdown_daemon __P((void)); 2137 extern void sm_dopr __P((char *, const char *, va_list)); 2138 extern void sm_free __P((void *)); 2139 extern struct hostent *sm_gethostbyname __P((char *, int)); 2140 extern struct hostent *sm_gethostbyaddr __P((char *, int, int)); 2141 extern int sm_getla __P((ENVELOPE *)); 2142 extern struct passwd *sm_getpwnam __P((char *)); 2143 extern struct passwd *sm_getpwuid __P((UID_T)); 2144 extern void sm_setproctitle __P((bool, ENVELOPE *, const char *, ...)); 2145 extern SIGFUNC_DECL sm_signal_noop __P((int)); 2146 extern int sm_strcasecmp __P((const char *, const char *)); 2147 extern void stop_sendmail __P((void)); 2148 extern bool strcontainedin __P((char *, char *)); 2149 extern void stripquotes __P((char *)); 2150 extern int switch_map_find __P((char *, char *[], short [])); 2151 extern bool transienterror __P((int)); 2152 extern void tTflag __P((char *)); 2153 extern void tTsetup __P((u_char *, int, char *)); 2154 extern char *ttypath __P((void)); 2155 extern void unlockqueue __P((ENVELOPE *)); 2156 #if !HASUNSETENV 2157 extern void unsetenv __P((char *)); 2158 #endif /* !HASUNSETENV */ 2159 extern char *username __P((void)); 2160 extern bool usershellok __P((char *, char *)); 2161 extern void vendor_post_defaults __P((ENVELOPE *)); 2162 extern void vendor_pre_defaults __P((ENVELOPE *)); 2163 extern int waitfor __P((pid_t)); 2164 extern bool writable __P((char *, ADDRESS *, long)); 2165 extern char *xalloc __P((int)); 2166 extern char *xcalloc __P((size_t, size_t)); 2167 extern char *xrealloc __P((void *, size_t)); 2168 extern void xputs __P((const char *)); 2169 extern char *xtextify __P((char *, char *)); 2170 extern bool xtextok __P((char *)); 2171 extern void xunlink __P((char *)); 2172 extern char *xuntextify __P((char *)); 2173 #endif /* _SENDMAIL_H */ 2174