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