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