17c478bd9Sstevel@tonic-gate /* 2*7800901eSjbeck * Copyright (c) 1998-2007 Sendmail, Inc. and its suppliers. 37c478bd9Sstevel@tonic-gate * All rights reserved. 47c478bd9Sstevel@tonic-gate * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. 57c478bd9Sstevel@tonic-gate * Copyright (c) 1988, 1993 67c478bd9Sstevel@tonic-gate * The Regents of the University of California. All rights reserved. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * By using this file, you agree to the terms and conditions set 97c478bd9Sstevel@tonic-gate * forth in the LICENSE file which can be found at the top level of 107c478bd9Sstevel@tonic-gate * the sendmail distribution. 117c478bd9Sstevel@tonic-gate */ 127c478bd9Sstevel@tonic-gate 137c478bd9Sstevel@tonic-gate /* 147c478bd9Sstevel@tonic-gate ** SENDMAIL.H -- MTA-specific definitions for sendmail. 157c478bd9Sstevel@tonic-gate */ 167c478bd9Sstevel@tonic-gate 177c478bd9Sstevel@tonic-gate #ifndef _SENDMAIL_H 187c478bd9Sstevel@tonic-gate # define _SENDMAIL_H 1 197c478bd9Sstevel@tonic-gate 207c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 217c478bd9Sstevel@tonic-gate 227c478bd9Sstevel@tonic-gate #ifndef MILTER 237c478bd9Sstevel@tonic-gate # define MILTER 1 /* turn on MILTER by default */ 247c478bd9Sstevel@tonic-gate #endif /* MILTER */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifdef _DEFINE 277c478bd9Sstevel@tonic-gate # define EXTERN 287c478bd9Sstevel@tonic-gate #else /* _DEFINE */ 297c478bd9Sstevel@tonic-gate # define EXTERN extern 307c478bd9Sstevel@tonic-gate #endif /* _DEFINE */ 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include <unistd.h> 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #include <stddef.h> 367c478bd9Sstevel@tonic-gate #include <stdlib.h> 377c478bd9Sstevel@tonic-gate #include <stdio.h> 387c478bd9Sstevel@tonic-gate #include <ctype.h> 397c478bd9Sstevel@tonic-gate #include <setjmp.h> 407c478bd9Sstevel@tonic-gate #include <string.h> 417c478bd9Sstevel@tonic-gate #include <time.h> 427c478bd9Sstevel@tonic-gate # ifdef EX_OK 437c478bd9Sstevel@tonic-gate # undef EX_OK /* for SVr4.2 SMP */ 447c478bd9Sstevel@tonic-gate # endif /* EX_OK */ 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate #include "sendmail/sendmail.h" 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate /* profiling? */ 497c478bd9Sstevel@tonic-gate #if MONCONTROL 507c478bd9Sstevel@tonic-gate # define SM_PROF(x) moncontrol(x) 517c478bd9Sstevel@tonic-gate #else /* MONCONTROL */ 527c478bd9Sstevel@tonic-gate # define SM_PROF(x) 537c478bd9Sstevel@tonic-gate #endif /* MONCONTROL */ 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate #ifdef _DEFINE 567c478bd9Sstevel@tonic-gate # ifndef lint 57*7800901eSjbeck SM_UNUSED(static char SmailId[]) = "@(#)$Id: sendmail.h,v 8.1052 2007/10/05 23:06:30 ca Exp $"; 587c478bd9Sstevel@tonic-gate # endif /* ! lint */ 597c478bd9Sstevel@tonic-gate #endif /* _DEFINE */ 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate #include "bf.h" 627c478bd9Sstevel@tonic-gate #include "timers.h" 637c478bd9Sstevel@tonic-gate #include <sm/exc.h> 647c478bd9Sstevel@tonic-gate #include <sm/heap.h> 657c478bd9Sstevel@tonic-gate #include <sm/debug.h> 667c478bd9Sstevel@tonic-gate #include <sm/rpool.h> 677c478bd9Sstevel@tonic-gate #include <sm/io.h> 687c478bd9Sstevel@tonic-gate #include <sm/path.h> 697c478bd9Sstevel@tonic-gate #include <sm/signal.h> 707c478bd9Sstevel@tonic-gate #include <sm/clock.h> 717c478bd9Sstevel@tonic-gate #include <sm/mbdb.h> 727c478bd9Sstevel@tonic-gate #include <sm/errstring.h> 737c478bd9Sstevel@tonic-gate #include <sm/sysexits.h> 747c478bd9Sstevel@tonic-gate #include <sm/shm.h> 75058561cbSjbeck #include <sm/misc.h> 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate #ifdef LOG 787c478bd9Sstevel@tonic-gate # include <syslog.h> 797c478bd9Sstevel@tonic-gate #endif /* LOG */ 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate # if NETINET || NETINET6 || NETUNIX || NETISO || NETNS || NETX25 847c478bd9Sstevel@tonic-gate # include <sys/socket.h> 857c478bd9Sstevel@tonic-gate # endif /* NETINET || NETINET6 || NETUNIX || NETISO || NETNS || NETX25 */ 867c478bd9Sstevel@tonic-gate # if NETUNIX 877c478bd9Sstevel@tonic-gate # include <sys/un.h> 887c478bd9Sstevel@tonic-gate # endif /* NETUNIX */ 897c478bd9Sstevel@tonic-gate # if NETINET || NETINET6 907c478bd9Sstevel@tonic-gate # include <netinet/in.h> 917c478bd9Sstevel@tonic-gate # endif /* NETINET || NETINET6 */ 927c478bd9Sstevel@tonic-gate # if NETINET6 937c478bd9Sstevel@tonic-gate /* 947c478bd9Sstevel@tonic-gate ** There is no standard yet for IPv6 includes. 957c478bd9Sstevel@tonic-gate ** Specify OS specific implementation in conf.h 967c478bd9Sstevel@tonic-gate */ 977c478bd9Sstevel@tonic-gate # endif /* NETINET6 */ 987c478bd9Sstevel@tonic-gate # if NETISO 997c478bd9Sstevel@tonic-gate # include <netiso/iso.h> 1007c478bd9Sstevel@tonic-gate # endif /* NETISO */ 1017c478bd9Sstevel@tonic-gate # if NETNS 1027c478bd9Sstevel@tonic-gate # include <netns/ns.h> 1037c478bd9Sstevel@tonic-gate # endif /* NETNS */ 1047c478bd9Sstevel@tonic-gate # if NETX25 1057c478bd9Sstevel@tonic-gate # include <netccitt/x25.h> 1067c478bd9Sstevel@tonic-gate # endif /* NETX25 */ 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate # if NAMED_BIND 1097c478bd9Sstevel@tonic-gate # include <arpa/nameser.h> 1107c478bd9Sstevel@tonic-gate # ifdef NOERROR 1117c478bd9Sstevel@tonic-gate # undef NOERROR /* avoid <sys/streams.h> conflict */ 1127c478bd9Sstevel@tonic-gate # endif /* NOERROR */ 1137c478bd9Sstevel@tonic-gate # include <resolv.h> 1147c478bd9Sstevel@tonic-gate # else /* NAMED_BIND */ 1157c478bd9Sstevel@tonic-gate # undef SM_SET_H_ERRNO 1167c478bd9Sstevel@tonic-gate # define SM_SET_H_ERRNO(err) 1177c478bd9Sstevel@tonic-gate # endif /* NAMED_BIND */ 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate # if HESIOD 1207c478bd9Sstevel@tonic-gate # include <hesiod.h> 1217c478bd9Sstevel@tonic-gate # if !defined(HES_ER_OK) || defined(HESIOD_INTERFACES) 1227c478bd9Sstevel@tonic-gate # define HESIOD_INIT /* support for the new interface */ 1237c478bd9Sstevel@tonic-gate # endif /* !defined(HES_ER_OK) || defined(HESIOD_INTERFACES) */ 1247c478bd9Sstevel@tonic-gate # endif /* HESIOD */ 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate #if STARTTLS 1277c478bd9Sstevel@tonic-gate # include <openssl/ssl.h> 1287c478bd9Sstevel@tonic-gate # if !TLS_NO_RSA 1297c478bd9Sstevel@tonic-gate # define RSA_KEYLENGTH 512 1307c478bd9Sstevel@tonic-gate # endif /* !TLS_NO_RSA */ 1317c478bd9Sstevel@tonic-gate #endif /* STARTTLS */ 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate #if SASL /* include the sasl include files if we have them */ 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate # if SASL == 2 || SASL >= 20000 1377c478bd9Sstevel@tonic-gate # include <sasl/sasl.h> 1387c478bd9Sstevel@tonic-gate # include <sasl/saslutil.h> 1397c478bd9Sstevel@tonic-gate # else /* SASL == 2 || SASL >= 20000 */ 1407c478bd9Sstevel@tonic-gate # include <sasl.h> 1417c478bd9Sstevel@tonic-gate # include <saslutil.h> 1427c478bd9Sstevel@tonic-gate # endif /* SASL == 2 || SASL >= 20000 */ 1437c478bd9Sstevel@tonic-gate # if defined(SASL_VERSION_MAJOR) && defined(SASL_VERSION_MINOR) && defined(SASL_VERSION_STEP) 1447c478bd9Sstevel@tonic-gate # define SASL_VERSION (SASL_VERSION_MAJOR * 10000) + (SASL_VERSION_MINOR * 100) + SASL_VERSION_STEP 1457c478bd9Sstevel@tonic-gate # if SASL == 1 || SASL == 2 1467c478bd9Sstevel@tonic-gate # undef SASL 1477c478bd9Sstevel@tonic-gate # define SASL SASL_VERSION 1487c478bd9Sstevel@tonic-gate # else /* SASL == 1 || SASL == 2 */ 1497c478bd9Sstevel@tonic-gate # if SASL != SASL_VERSION 1507c478bd9Sstevel@tonic-gate ERROR README: -DSASL (SASL) does not agree with the version of the CYRUS_SASL library (SASL_VERSION) 1517c478bd9Sstevel@tonic-gate ERROR README: see README! 1527c478bd9Sstevel@tonic-gate # endif /* SASL != SASL_VERSION */ 1537c478bd9Sstevel@tonic-gate # endif /* SASL == 1 || SASL == 2 */ 1547c478bd9Sstevel@tonic-gate # else /* defined(SASL_VERSION_MAJOR) && defined(SASL_VERSION_MINOR) && defined(SASL_VERSION_STEP) */ 1557c478bd9Sstevel@tonic-gate # if SASL == 1 1567c478bd9Sstevel@tonic-gate ERROR README: please set -DSASL to the version of the CYRUS_SASL library 1577c478bd9Sstevel@tonic-gate ERROR README: see README! 1587c478bd9Sstevel@tonic-gate # endif /* SASL == 1 */ 1597c478bd9Sstevel@tonic-gate # endif /* defined(SASL_VERSION_MAJOR) && defined(SASL_VERSION_MINOR) && defined(SASL_VERSION_STEP) */ 1607c478bd9Sstevel@tonic-gate #endif /* SASL */ 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate /* 1637c478bd9Sstevel@tonic-gate ** Following are "sort of" configuration constants, but they should 1647c478bd9Sstevel@tonic-gate ** be pretty solid on most architectures today. They have to be 1657c478bd9Sstevel@tonic-gate ** defined after <arpa/nameser.h> because some versions of that 1667c478bd9Sstevel@tonic-gate ** file also define them. In all cases, we can't use sizeof because 1677c478bd9Sstevel@tonic-gate ** some systems (e.g., Crays) always treat everything as being at 1687c478bd9Sstevel@tonic-gate ** least 64 bits. 1697c478bd9Sstevel@tonic-gate */ 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate #ifndef INADDRSZ 1727c478bd9Sstevel@tonic-gate # define INADDRSZ 4 /* size of an IPv4 address in bytes */ 1737c478bd9Sstevel@tonic-gate #endif /* ! INADDRSZ */ 1747c478bd9Sstevel@tonic-gate #ifndef IN6ADDRSZ 1757c478bd9Sstevel@tonic-gate # define IN6ADDRSZ 16 /* size of an IPv6 address in bytes */ 1767c478bd9Sstevel@tonic-gate #endif /* ! IN6ADDRSZ */ 1777c478bd9Sstevel@tonic-gate #ifndef INT16SZ 1787c478bd9Sstevel@tonic-gate # define INT16SZ 2 /* size of a 16 bit integer in bytes */ 1797c478bd9Sstevel@tonic-gate #endif /* ! INT16SZ */ 1807c478bd9Sstevel@tonic-gate #ifndef INT32SZ 1817c478bd9Sstevel@tonic-gate # define INT32SZ 4 /* size of a 32 bit integer in bytes */ 1827c478bd9Sstevel@tonic-gate #endif /* ! INT32SZ */ 1837c478bd9Sstevel@tonic-gate #ifndef INADDR_LOOPBACK 1847c478bd9Sstevel@tonic-gate # define INADDR_LOOPBACK 0x7f000001 /* loopback address */ 1857c478bd9Sstevel@tonic-gate #endif /* ! INADDR_LOOPBACK */ 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate /* 1887c478bd9Sstevel@tonic-gate ** Error return from inet_addr(3), in case not defined in /usr/include. 1897c478bd9Sstevel@tonic-gate */ 1907c478bd9Sstevel@tonic-gate 1917c478bd9Sstevel@tonic-gate #ifndef INADDR_NONE 1927c478bd9Sstevel@tonic-gate # define INADDR_NONE 0xffffffff 1937c478bd9Sstevel@tonic-gate #endif /* ! INADDR_NONE */ 1947c478bd9Sstevel@tonic-gate 1957c478bd9Sstevel@tonic-gate 1967c478bd9Sstevel@tonic-gate /* (f)open() modes for queue files */ 1977c478bd9Sstevel@tonic-gate # define QF_O_EXTRA 0 1987c478bd9Sstevel@tonic-gate 1997c478bd9Sstevel@tonic-gate 2007c478bd9Sstevel@tonic-gate /* 2017c478bd9Sstevel@tonic-gate ** An 'argument class' describes the storage allocation status 2027c478bd9Sstevel@tonic-gate ** of an object pointed to by an argument to a function. 2037c478bd9Sstevel@tonic-gate */ 2047c478bd9Sstevel@tonic-gate 2057c478bd9Sstevel@tonic-gate typedef enum 2067c478bd9Sstevel@tonic-gate { 2077c478bd9Sstevel@tonic-gate A_HEAP, /* the storage was allocated by malloc, and the 2087c478bd9Sstevel@tonic-gate * ownership of the storage is ceded by the caller 2097c478bd9Sstevel@tonic-gate * to the called function. */ 2107c478bd9Sstevel@tonic-gate A_TEMP, /* The storage is temporary, and is only guaranteed 2117c478bd9Sstevel@tonic-gate * to be valid for the duration of the function call. */ 2127c478bd9Sstevel@tonic-gate A_PERM /* The storage is 'permanent': this might mean static 2137c478bd9Sstevel@tonic-gate * storage, or rpool storage. */ 2147c478bd9Sstevel@tonic-gate } ARGCLASS_T; 2157c478bd9Sstevel@tonic-gate 2167c478bd9Sstevel@tonic-gate /* forward references for prototypes */ 2177c478bd9Sstevel@tonic-gate typedef struct envelope ENVELOPE; 2187c478bd9Sstevel@tonic-gate typedef struct mailer MAILER; 2197c478bd9Sstevel@tonic-gate typedef struct queuegrp QUEUEGRP; 2207c478bd9Sstevel@tonic-gate 2217c478bd9Sstevel@tonic-gate /* 2227c478bd9Sstevel@tonic-gate ** Address structure. 2237c478bd9Sstevel@tonic-gate ** Addresses are stored internally in this structure. 2247c478bd9Sstevel@tonic-gate */ 2257c478bd9Sstevel@tonic-gate 2267c478bd9Sstevel@tonic-gate struct address 2277c478bd9Sstevel@tonic-gate { 2287c478bd9Sstevel@tonic-gate char *q_paddr; /* the printname for the address */ 2297c478bd9Sstevel@tonic-gate char *q_user; /* user name */ 2307c478bd9Sstevel@tonic-gate char *q_ruser; /* real user name, or NULL if q_user */ 2317c478bd9Sstevel@tonic-gate char *q_host; /* host name */ 2327c478bd9Sstevel@tonic-gate struct mailer *q_mailer; /* mailer to use */ 2337c478bd9Sstevel@tonic-gate unsigned long q_flags; /* status flags, see below */ 2347c478bd9Sstevel@tonic-gate uid_t q_uid; /* user-id of receiver (if known) */ 2357c478bd9Sstevel@tonic-gate gid_t q_gid; /* group-id of receiver (if known) */ 2367c478bd9Sstevel@tonic-gate char *q_home; /* home dir (local mailer only) */ 2377c478bd9Sstevel@tonic-gate char *q_fullname; /* full name if known */ 2387c478bd9Sstevel@tonic-gate struct address *q_next; /* chain */ 2397c478bd9Sstevel@tonic-gate struct address *q_alias; /* address this results from */ 2407c478bd9Sstevel@tonic-gate char *q_owner; /* owner of q_alias */ 2417c478bd9Sstevel@tonic-gate struct address *q_tchain; /* temporary use chain */ 2427c478bd9Sstevel@tonic-gate #if PIPELINING 2437c478bd9Sstevel@tonic-gate struct address *q_pchain; /* chain for pipelining */ 2447c478bd9Sstevel@tonic-gate #endif /* PIPELINING */ 2457c478bd9Sstevel@tonic-gate char *q_finalrcpt; /* Final-Recipient: DSN header */ 2467c478bd9Sstevel@tonic-gate char *q_orcpt; /* ORCPT parameter from RCPT TO: line */ 2477c478bd9Sstevel@tonic-gate char *q_status; /* status code for DSNs */ 2487c478bd9Sstevel@tonic-gate char *q_rstatus; /* remote status message for DSNs */ 2497c478bd9Sstevel@tonic-gate time_t q_statdate; /* date of status messages */ 2507c478bd9Sstevel@tonic-gate char *q_statmta; /* MTA generating q_rstatus */ 2517c478bd9Sstevel@tonic-gate short q_state; /* address state, see below */ 2527c478bd9Sstevel@tonic-gate char *q_signature; /* MX-based sorting value */ 2537c478bd9Sstevel@tonic-gate int q_qgrp; /* index into queue groups */ 2547c478bd9Sstevel@tonic-gate int q_qdir; /* queue directory inside group */ 2557c478bd9Sstevel@tonic-gate char *q_message; /* error message */ 2567c478bd9Sstevel@tonic-gate }; 2577c478bd9Sstevel@tonic-gate 2587c478bd9Sstevel@tonic-gate typedef struct address ADDRESS; 2597c478bd9Sstevel@tonic-gate 2607c478bd9Sstevel@tonic-gate /* bit values for q_flags */ 2617c478bd9Sstevel@tonic-gate #define QGOODUID 0x00000001 /* the q_uid q_gid fields are good */ 2627c478bd9Sstevel@tonic-gate #define QPRIMARY 0x00000002 /* set from RCPT or argv */ 2637c478bd9Sstevel@tonic-gate #define QNOTREMOTE 0x00000004 /* address not for remote forwarding */ 2647c478bd9Sstevel@tonic-gate #define QSELFREF 0x00000008 /* this address references itself */ 2657c478bd9Sstevel@tonic-gate #define QBOGUSSHELL 0x00000010 /* user has no valid shell listed */ 2667c478bd9Sstevel@tonic-gate #define QUNSAFEADDR 0x00000020 /* address acquired via unsafe path */ 2677c478bd9Sstevel@tonic-gate #define QPINGONSUCCESS 0x00000040 /* give return on successful delivery */ 2687c478bd9Sstevel@tonic-gate #define QPINGONFAILURE 0x00000080 /* give return on failure */ 2697c478bd9Sstevel@tonic-gate #define QPINGONDELAY 0x00000100 /* give return on message delay */ 2707c478bd9Sstevel@tonic-gate #define QHASNOTIFY 0x00000200 /* propagate notify parameter */ 2717c478bd9Sstevel@tonic-gate #define QRELAYED 0x00000400 /* DSN: relayed to non-DSN aware sys */ 2727c478bd9Sstevel@tonic-gate #define QEXPANDED 0x00000800 /* DSN: undergone list expansion */ 2737c478bd9Sstevel@tonic-gate #define QDELIVERED 0x00001000 /* DSN: successful final delivery */ 2747c478bd9Sstevel@tonic-gate #define QDELAYED 0x00002000 /* DSN: message delayed */ 2757c478bd9Sstevel@tonic-gate #define QALIAS 0x00004000 /* expanded alias */ 2767c478bd9Sstevel@tonic-gate #define QBYTRACE 0x00008000 /* DeliverBy: trace */ 2777c478bd9Sstevel@tonic-gate #define QBYNDELAY 0x00010000 /* DeliverBy: notify, delay */ 2787c478bd9Sstevel@tonic-gate #define QBYNRELAY 0x00020000 /* DeliverBy: notify, relayed */ 2797c478bd9Sstevel@tonic-gate #define QTHISPASS 0x40000000 /* temp: address set this pass */ 2807c478bd9Sstevel@tonic-gate #define QRCPTOK 0x80000000 /* recipient() processed address */ 2817c478bd9Sstevel@tonic-gate 2827c478bd9Sstevel@tonic-gate #define Q_PINGFLAGS (QPINGONSUCCESS|QPINGONFAILURE|QPINGONDELAY) 2837c478bd9Sstevel@tonic-gate 2847c478bd9Sstevel@tonic-gate /* values for q_state */ 2857c478bd9Sstevel@tonic-gate #define QS_OK 0 /* address ok (for now)/not yet tried */ 2867c478bd9Sstevel@tonic-gate #define QS_SENT 1 /* good address, delivery complete */ 2877c478bd9Sstevel@tonic-gate #define QS_BADADDR 2 /* illegal address */ 2887c478bd9Sstevel@tonic-gate #define QS_QUEUEUP 3 /* save address in queue */ 2897c478bd9Sstevel@tonic-gate #define QS_RETRY 4 /* retry delivery for next MX */ 2907c478bd9Sstevel@tonic-gate #define QS_VERIFIED 5 /* verified, but not expanded */ 2917c478bd9Sstevel@tonic-gate 2927c478bd9Sstevel@tonic-gate /* 2937c478bd9Sstevel@tonic-gate ** Notice: all of the following values are variations of QS_DONTSEND. 2947c478bd9Sstevel@tonic-gate ** If new states are added, they must be inserted in the proper place! 2957c478bd9Sstevel@tonic-gate ** See the macro definition of QS_IS_DEAD() down below. 2967c478bd9Sstevel@tonic-gate */ 2977c478bd9Sstevel@tonic-gate 2987c478bd9Sstevel@tonic-gate #define QS_DONTSEND 6 /* don't send to this address */ 2997c478bd9Sstevel@tonic-gate #define QS_EXPANDED 7 /* expanded */ 3007c478bd9Sstevel@tonic-gate #define QS_SENDER 8 /* message sender (MeToo) */ 3017c478bd9Sstevel@tonic-gate #define QS_CLONED 9 /* addr cloned to split envelope */ 3027c478bd9Sstevel@tonic-gate #define QS_DISCARDED 10 /* rcpt discarded (EF_DISCARD) */ 3037c478bd9Sstevel@tonic-gate #define QS_REPLACED 11 /* maplocaluser()/UserDB replaced */ 3047c478bd9Sstevel@tonic-gate #define QS_REMOVED 12 /* removed (removefromlist()) */ 3057c478bd9Sstevel@tonic-gate #define QS_DUPLICATE 13 /* duplicate suppressed */ 3067c478bd9Sstevel@tonic-gate #define QS_INCLUDED 14 /* :include: delivery */ 3077c478bd9Sstevel@tonic-gate #define QS_FATALERR 15 /* fatal error, don't deliver */ 3087c478bd9Sstevel@tonic-gate 3097c478bd9Sstevel@tonic-gate /* address state testing primitives */ 3107c478bd9Sstevel@tonic-gate #define QS_IS_OK(s) ((s) == QS_OK) 3117c478bd9Sstevel@tonic-gate #define QS_IS_SENT(s) ((s) == QS_SENT) 3127c478bd9Sstevel@tonic-gate #define QS_IS_BADADDR(s) ((s) == QS_BADADDR) 3137c478bd9Sstevel@tonic-gate #define QS_IS_QUEUEUP(s) ((s) == QS_QUEUEUP) 3147c478bd9Sstevel@tonic-gate #define QS_IS_RETRY(s) ((s) == QS_RETRY) 3157c478bd9Sstevel@tonic-gate #define QS_IS_VERIFIED(s) ((s) == QS_VERIFIED) 3167c478bd9Sstevel@tonic-gate #define QS_IS_EXPANDED(s) ((s) == QS_EXPANDED) 3177c478bd9Sstevel@tonic-gate #define QS_IS_REMOVED(s) ((s) == QS_REMOVED) 3187c478bd9Sstevel@tonic-gate #define QS_IS_UNDELIVERED(s) ((s) == QS_OK || \ 3197c478bd9Sstevel@tonic-gate (s) == QS_QUEUEUP || \ 3207c478bd9Sstevel@tonic-gate (s) == QS_RETRY || \ 3217c478bd9Sstevel@tonic-gate (s) == QS_VERIFIED) 3227c478bd9Sstevel@tonic-gate #define QS_IS_UNMARKED(s) ((s) == QS_OK || \ 3237c478bd9Sstevel@tonic-gate (s) == QS_RETRY) 3247c478bd9Sstevel@tonic-gate #define QS_IS_SENDABLE(s) ((s) == QS_OK || \ 3257c478bd9Sstevel@tonic-gate (s) == QS_QUEUEUP || \ 3267c478bd9Sstevel@tonic-gate (s) == QS_RETRY) 3277c478bd9Sstevel@tonic-gate #define QS_IS_ATTEMPTED(s) ((s) == QS_QUEUEUP || \ 3287c478bd9Sstevel@tonic-gate (s) == QS_RETRY || \ 329*7800901eSjbeck (s) == QS_SENT || \ 330*7800901eSjbeck (s) == QS_DISCARDED) 3317c478bd9Sstevel@tonic-gate #define QS_IS_DEAD(s) ((s) >= QS_DONTSEND) 3327c478bd9Sstevel@tonic-gate 3337c478bd9Sstevel@tonic-gate 3347c478bd9Sstevel@tonic-gate #define NULLADDR ((ADDRESS *) NULL) 3357c478bd9Sstevel@tonic-gate 3367c478bd9Sstevel@tonic-gate extern ADDRESS NullAddress; /* a null (template) address [main.c] */ 3377c478bd9Sstevel@tonic-gate 3387c478bd9Sstevel@tonic-gate /* functions */ 339058561cbSjbeck extern void cataddr __P((char **, char **, char *, int, int, bool)); 3407c478bd9Sstevel@tonic-gate extern char *crackaddr __P((char *, ENVELOPE *)); 3417c478bd9Sstevel@tonic-gate extern bool emptyaddr __P((ADDRESS *)); 3427c478bd9Sstevel@tonic-gate extern ADDRESS *getctladdr __P((ADDRESS *)); 3437c478bd9Sstevel@tonic-gate extern int include __P((char *, bool, ADDRESS *, ADDRESS **, int, ENVELOPE *)); 3447c478bd9Sstevel@tonic-gate extern bool invalidaddr __P((char *, char *, bool)); 3457c478bd9Sstevel@tonic-gate extern ADDRESS *parseaddr __P((char *, ADDRESS *, int, int, char **, 3467c478bd9Sstevel@tonic-gate ENVELOPE *, bool)); 3477c478bd9Sstevel@tonic-gate extern char **prescan __P((char *, int, char[], int, char **, unsigned char *, bool)); 3487c478bd9Sstevel@tonic-gate extern void printaddr __P((SM_FILE_T *, ADDRESS *, bool)); 3497c478bd9Sstevel@tonic-gate extern ADDRESS *recipient __P((ADDRESS *, ADDRESS **, int, ENVELOPE *)); 3507c478bd9Sstevel@tonic-gate extern char *remotename __P((char *, MAILER *, int, int *, ENVELOPE *)); 3517c478bd9Sstevel@tonic-gate extern int rewrite __P((char **, int, int, ENVELOPE *, int)); 3527c478bd9Sstevel@tonic-gate extern bool sameaddr __P((ADDRESS *, ADDRESS *)); 3537c478bd9Sstevel@tonic-gate extern int sendtolist __P((char *, ADDRESS *, ADDRESS **, int, ENVELOPE *)); 3547c478bd9Sstevel@tonic-gate #if MILTER 3557c478bd9Sstevel@tonic-gate extern int removefromlist __P((char *, ADDRESS **, ENVELOPE *)); 3567c478bd9Sstevel@tonic-gate #endif /* MILTER */ 3577c478bd9Sstevel@tonic-gate extern void setsender __P((char *, ENVELOPE *, char **, int, bool)); 358058561cbSjbeck typedef void esmtp_args_F __P((ADDRESS *, char *, char *, ENVELOPE *)); 359058561cbSjbeck extern void parse_esmtp_args __P((ENVELOPE *, ADDRESS *, char *, char *, 360058561cbSjbeck char *, char *args[], esmtp_args_F)); 361058561cbSjbeck extern esmtp_args_F mail_esmtp_args; 362058561cbSjbeck extern esmtp_args_F rcpt_esmtp_args; 363058561cbSjbeck extern void reset_mail_esmtp_args __P((ENVELOPE *)); 3647c478bd9Sstevel@tonic-gate 3657c478bd9Sstevel@tonic-gate /* macro to simplify the common call to rewrite() */ 3667c478bd9Sstevel@tonic-gate #define REWRITE(pvp, rs, env) rewrite(pvp, rs, 0, env, MAXATOM) 3677c478bd9Sstevel@tonic-gate 368058561cbSjbeck /* 369058561cbSjbeck ** Token Tables for prescan 370058561cbSjbeck */ 371058561cbSjbeck 372058561cbSjbeck extern unsigned char ExtTokenTab[256]; /* external strings */ 373058561cbSjbeck extern unsigned char IntTokenTab[256]; /* internal strings */ 374058561cbSjbeck 375058561cbSjbeck 3767c478bd9Sstevel@tonic-gate /* 3777c478bd9Sstevel@tonic-gate ** Mailer definition structure. 3787c478bd9Sstevel@tonic-gate ** Every mailer known to the system is declared in this 3797c478bd9Sstevel@tonic-gate ** structure. It defines the pathname of the mailer, some 3807c478bd9Sstevel@tonic-gate ** flags associated with it, and the argument vector to 3817c478bd9Sstevel@tonic-gate ** pass to it. The flags are defined in conf.c 3827c478bd9Sstevel@tonic-gate ** 3837c478bd9Sstevel@tonic-gate ** The argument vector is expanded before actual use. All 3847c478bd9Sstevel@tonic-gate ** words except the first are passed through the macro 3857c478bd9Sstevel@tonic-gate ** processor. 3867c478bd9Sstevel@tonic-gate */ 3877c478bd9Sstevel@tonic-gate 3887c478bd9Sstevel@tonic-gate struct mailer 3897c478bd9Sstevel@tonic-gate { 3907c478bd9Sstevel@tonic-gate char *m_name; /* symbolic name of this mailer */ 3917c478bd9Sstevel@tonic-gate char *m_mailer; /* pathname of the mailer to use */ 3927c478bd9Sstevel@tonic-gate char *m_mtatype; /* type of this MTA */ 3937c478bd9Sstevel@tonic-gate char *m_addrtype; /* type for addresses */ 3947c478bd9Sstevel@tonic-gate char *m_diagtype; /* type for diagnostics */ 3957c478bd9Sstevel@tonic-gate BITMAP256 m_flags; /* status flags, see below */ 3967c478bd9Sstevel@tonic-gate short m_mno; /* mailer number internally */ 3977c478bd9Sstevel@tonic-gate short m_nice; /* niceness to run at (mostly for prog) */ 3987c478bd9Sstevel@tonic-gate char **m_argv; /* template argument vector */ 3997c478bd9Sstevel@tonic-gate short m_sh_rwset; /* rewrite set: sender header addresses */ 4007c478bd9Sstevel@tonic-gate short m_se_rwset; /* rewrite set: sender envelope addresses */ 4017c478bd9Sstevel@tonic-gate short m_rh_rwset; /* rewrite set: recipient header addresses */ 4027c478bd9Sstevel@tonic-gate short m_re_rwset; /* rewrite set: recipient envelope addresses */ 4037c478bd9Sstevel@tonic-gate char *m_eol; /* end of line string */ 4047c478bd9Sstevel@tonic-gate long m_maxsize; /* size limit on message to this mailer */ 4057c478bd9Sstevel@tonic-gate int m_linelimit; /* max # characters per line */ 4067c478bd9Sstevel@tonic-gate int m_maxdeliveries; /* max deliveries per mailer connection */ 4077c478bd9Sstevel@tonic-gate char *m_execdir; /* directory to chdir to before execv */ 4087c478bd9Sstevel@tonic-gate char *m_rootdir; /* directory to chroot to before execv */ 4097c478bd9Sstevel@tonic-gate uid_t m_uid; /* UID to run as */ 4107c478bd9Sstevel@tonic-gate gid_t m_gid; /* GID to run as */ 4117c478bd9Sstevel@tonic-gate char *m_defcharset; /* default character set */ 4127c478bd9Sstevel@tonic-gate time_t m_wait; /* timeout to wait for end */ 4137c478bd9Sstevel@tonic-gate int m_maxrcpt; /* max recipients per envelope client-side */ 4147c478bd9Sstevel@tonic-gate short m_qgrp; /* queue group for this mailer */ 4157c478bd9Sstevel@tonic-gate }; 4167c478bd9Sstevel@tonic-gate 4177c478bd9Sstevel@tonic-gate /* bits for m_flags */ 4187c478bd9Sstevel@tonic-gate #define M_ESMTP 'a' /* run Extended SMTP */ 4197c478bd9Sstevel@tonic-gate #define M_ALIASABLE 'A' /* user can be LHS of an alias */ 4207c478bd9Sstevel@tonic-gate #define M_BLANKEND 'b' /* ensure blank line at end of message */ 4217c478bd9Sstevel@tonic-gate #define M_STRIPBACKSL 'B' /* strip all leading backslashes from user */ 4227c478bd9Sstevel@tonic-gate #define M_NOCOMMENT 'c' /* don't include comment part of address */ 4237c478bd9Sstevel@tonic-gate #define M_CANONICAL 'C' /* make addresses canonical "u@dom" */ 4247c478bd9Sstevel@tonic-gate #define M_NOBRACKET 'd' /* never angle bracket envelope route-addrs */ 4257c478bd9Sstevel@tonic-gate /* 'D' CF: include Date: */ 4267c478bd9Sstevel@tonic-gate #define M_EXPENSIVE 'e' /* it costs to use this mailer.... */ 4277c478bd9Sstevel@tonic-gate #define M_ESCFROM 'E' /* escape From lines to >From */ 4287c478bd9Sstevel@tonic-gate #define M_FOPT 'f' /* mailer takes picky -f flag */ 4297c478bd9Sstevel@tonic-gate /* 'F' CF: include From: or Resent-From: */ 4307c478bd9Sstevel@tonic-gate #define M_NO_NULL_FROM 'g' /* sender of errors should be $g */ 4317c478bd9Sstevel@tonic-gate #define M_HST_UPPER 'h' /* preserve host case distinction */ 4327c478bd9Sstevel@tonic-gate #define M_PREHEAD 'H' /* MAIL11V3: preview headers */ 4337c478bd9Sstevel@tonic-gate #define M_UDBENVELOPE 'i' /* do udbsender rewriting on envelope */ 4347c478bd9Sstevel@tonic-gate #define M_INTERNAL 'I' /* SMTP to another sendmail site */ 4357c478bd9Sstevel@tonic-gate #define M_UDBRECIPIENT 'j' /* do udbsender rewriting on recipient lines */ 4367c478bd9Sstevel@tonic-gate #define M_NOLOOPCHECK 'k' /* don't check for loops in HELO command */ 4377c478bd9Sstevel@tonic-gate #define M_CHUNKING 'K' /* CHUNKING: reserved for future use */ 4387c478bd9Sstevel@tonic-gate #define M_LOCALMAILER 'l' /* delivery is to this host */ 4397c478bd9Sstevel@tonic-gate #define M_LIMITS 'L' /* must enforce SMTP line limits */ 4407c478bd9Sstevel@tonic-gate #define M_MUSER 'm' /* can handle multiple users at once */ 4417c478bd9Sstevel@tonic-gate /* 'M' CF: include Message-Id: */ 4427c478bd9Sstevel@tonic-gate #define M_NHDR 'n' /* don't insert From line */ 4437c478bd9Sstevel@tonic-gate #define M_MANYSTATUS 'N' /* MAIL11V3: DATA returns multi-status */ 4447c478bd9Sstevel@tonic-gate #define M_RUNASRCPT 'o' /* always run mailer as recipient */ 4457c478bd9Sstevel@tonic-gate #define M_FROMPATH 'p' /* use reverse-path in MAIL FROM: */ 4467c478bd9Sstevel@tonic-gate /* 'P' CF: include Return-Path: */ 4477c478bd9Sstevel@tonic-gate #define M_VRFY250 'q' /* VRFY command returns 250 instead of 252 */ 4487c478bd9Sstevel@tonic-gate #define M_ROPT 'r' /* mailer takes picky -r flag */ 4497c478bd9Sstevel@tonic-gate #define M_SECURE_PORT 'R' /* try to send on a reserved TCP port */ 4507c478bd9Sstevel@tonic-gate #define M_STRIPQ 's' /* strip quote chars from user/host */ 4517c478bd9Sstevel@tonic-gate #define M_SPECIFIC_UID 'S' /* run as specific uid/gid */ 4527c478bd9Sstevel@tonic-gate #define M_USR_UPPER 'u' /* preserve user case distinction */ 4537c478bd9Sstevel@tonic-gate #define M_UGLYUUCP 'U' /* this wants an ugly UUCP from line */ 4547c478bd9Sstevel@tonic-gate #define M_CONTENT_LEN 'v' /* add Content-Length: header (SVr4) */ 4557c478bd9Sstevel@tonic-gate /* 'V' UIUC: !-relativize all addresses */ 4567c478bd9Sstevel@tonic-gate #define M_HASPWENT 'w' /* check for /etc/passwd entry */ 4577c478bd9Sstevel@tonic-gate #define M_NOHOSTSTAT 'W' /* ignore long term host status information */ 4587c478bd9Sstevel@tonic-gate /* 'x' CF: include Full-Name: */ 4597c478bd9Sstevel@tonic-gate #define M_XDOT 'X' /* use hidden-dot algorithm */ 4607c478bd9Sstevel@tonic-gate #define M_LMTP 'z' /* run Local Mail Transport Protocol */ 4617c478bd9Sstevel@tonic-gate #define M_DIALDELAY 'Z' /* apply dial delay sleeptime */ 4627c478bd9Sstevel@tonic-gate #define M_NOMX '0' /* turn off MX lookups */ 4637c478bd9Sstevel@tonic-gate #define M_NONULLS '1' /* don't send null bytes */ 4647c478bd9Sstevel@tonic-gate #define M_FSMTP '2' /* force SMTP (no ESMTP even if offered) */ 4657c478bd9Sstevel@tonic-gate #define M_EBCDIC '3' /* extend Q-P encoding for EBCDIC */ 4667c478bd9Sstevel@tonic-gate #define M_TRYRULESET5 '5' /* use ruleset 5 after local aliasing */ 4677c478bd9Sstevel@tonic-gate #define M_7BITHDRS '6' /* strip headers to 7 bits even in 8 bit path */ 4687c478bd9Sstevel@tonic-gate #define M_7BITS '7' /* use 7-bit path */ 4697c478bd9Sstevel@tonic-gate #define M_8BITS '8' /* force "just send 8" behaviour */ 4707c478bd9Sstevel@tonic-gate #define M_MAKE8BIT '9' /* convert 7 -> 8 bit if appropriate */ 4717c478bd9Sstevel@tonic-gate #define M_CHECKINCLUDE ':' /* check for :include: files */ 4727c478bd9Sstevel@tonic-gate #define M_CHECKPROG '|' /* check for |program addresses */ 4737c478bd9Sstevel@tonic-gate #define M_CHECKFILE '/' /* check for /file addresses */ 4747c478bd9Sstevel@tonic-gate #define M_CHECKUDB '@' /* user can be user database key */ 4757c478bd9Sstevel@tonic-gate #define M_CHECKHDIR '~' /* SGI: check for valid home directory */ 4767c478bd9Sstevel@tonic-gate #define M_HOLD '%' /* Hold delivery until ETRN/-qI/-qR/-qS */ 4777c478bd9Sstevel@tonic-gate #define M_PLUS '+' /* Reserved: Used in mc for adding new flags */ 4787c478bd9Sstevel@tonic-gate #define M_MINUS '-' /* Reserved: Used in mc for removing flags */ 4797c478bd9Sstevel@tonic-gate 4807c478bd9Sstevel@tonic-gate /* functions */ 4817c478bd9Sstevel@tonic-gate extern void initerrmailers __P((void)); 4827c478bd9Sstevel@tonic-gate extern void makemailer __P((char *)); 4837c478bd9Sstevel@tonic-gate extern void makequeue __P((char *, bool)); 4847c478bd9Sstevel@tonic-gate extern void runqueueevent __P((int)); 4857c478bd9Sstevel@tonic-gate #if _FFR_QUEUE_RUN_PARANOIA 4867c478bd9Sstevel@tonic-gate extern bool checkqueuerunner __P((void)); 4877c478bd9Sstevel@tonic-gate #endif /* _FFR_QUEUE_RUN_PARANOIA */ 4887c478bd9Sstevel@tonic-gate 4897c478bd9Sstevel@tonic-gate EXTERN MAILER *FileMailer; /* ptr to *file* mailer */ 4907c478bd9Sstevel@tonic-gate EXTERN MAILER *InclMailer; /* ptr to *include* mailer */ 4917c478bd9Sstevel@tonic-gate EXTERN MAILER *LocalMailer; /* ptr to local mailer */ 4927c478bd9Sstevel@tonic-gate EXTERN MAILER *ProgMailer; /* ptr to program mailer */ 4937c478bd9Sstevel@tonic-gate EXTERN MAILER *Mailer[MAXMAILERS + 1]; 4947c478bd9Sstevel@tonic-gate 4957c478bd9Sstevel@tonic-gate /* 4967c478bd9Sstevel@tonic-gate ** Queue group definition structure. 4977c478bd9Sstevel@tonic-gate ** Every queue group known to the system is declared in this structure. 4987c478bd9Sstevel@tonic-gate ** It defines the basic pathname of the queue group, some flags 4997c478bd9Sstevel@tonic-gate ** associated with it, and the argument vector to pass to it. 5007c478bd9Sstevel@tonic-gate */ 5017c478bd9Sstevel@tonic-gate 5027c478bd9Sstevel@tonic-gate struct qpaths_s 5037c478bd9Sstevel@tonic-gate { 5047c478bd9Sstevel@tonic-gate char *qp_name; /* name of queue dir, relative path */ 5057c478bd9Sstevel@tonic-gate short qp_subdirs; /* use subdirs? */ 5067c478bd9Sstevel@tonic-gate short qp_fsysidx; /* file system index of this directory */ 5077c478bd9Sstevel@tonic-gate # if SM_CONF_SHM 5087c478bd9Sstevel@tonic-gate int qp_idx; /* index into array for queue information */ 5097c478bd9Sstevel@tonic-gate # endif /* SM_CONF_SHM */ 5107c478bd9Sstevel@tonic-gate }; 5117c478bd9Sstevel@tonic-gate 5127c478bd9Sstevel@tonic-gate typedef struct qpaths_s QPATHS; 5137c478bd9Sstevel@tonic-gate 5147c478bd9Sstevel@tonic-gate struct queuegrp 5157c478bd9Sstevel@tonic-gate { 5167c478bd9Sstevel@tonic-gate char *qg_name; /* symbolic name of this queue group */ 5177c478bd9Sstevel@tonic-gate 5187c478bd9Sstevel@tonic-gate /* 5197c478bd9Sstevel@tonic-gate ** For now this is the same across all queue groups. 5207c478bd9Sstevel@tonic-gate ** Otherwise we have to play around with chdir(). 5217c478bd9Sstevel@tonic-gate */ 5227c478bd9Sstevel@tonic-gate 5237c478bd9Sstevel@tonic-gate char *qg_qdir; /* common component of queue directory */ 5247c478bd9Sstevel@tonic-gate short qg_index; /* queue number internally, index in Queue[] */ 5257c478bd9Sstevel@tonic-gate int qg_maxqrun; /* max # of jobs in 1 queuerun */ 5267c478bd9Sstevel@tonic-gate int qg_numqueues; /* number of queues in this queue */ 5277c478bd9Sstevel@tonic-gate 5287c478bd9Sstevel@tonic-gate /* 5297c478bd9Sstevel@tonic-gate ** qg_queueintvl == 0 denotes that no individual value is used. 5307c478bd9Sstevel@tonic-gate ** Whatever accesses this must deal with "<= 0" as 5317c478bd9Sstevel@tonic-gate ** "not set, use appropriate default". 5327c478bd9Sstevel@tonic-gate */ 5337c478bd9Sstevel@tonic-gate 5347c478bd9Sstevel@tonic-gate time_t qg_queueintvl; /* interval for queue runs */ 5357c478bd9Sstevel@tonic-gate QPATHS *qg_qpaths; /* list of queue directories */ 5367c478bd9Sstevel@tonic-gate BITMAP256 qg_flags; /* status flags, see below */ 5377c478bd9Sstevel@tonic-gate short qg_nice; /* niceness for queue run */ 5387c478bd9Sstevel@tonic-gate int qg_wgrp; /* Assigned to this work group */ 5397c478bd9Sstevel@tonic-gate int qg_maxlist; /* max items in work queue for this group */ 5407c478bd9Sstevel@tonic-gate int qg_curnum; /* current number of queue for queue runs */ 5417c478bd9Sstevel@tonic-gate int qg_maxrcpt; /* max recipients per envelope, 0==no limit */ 5427c478bd9Sstevel@tonic-gate 5437c478bd9Sstevel@tonic-gate time_t qg_nextrun; /* time for next queue runs */ 5447c478bd9Sstevel@tonic-gate #if _FFR_QUEUE_GROUP_SORTORDER 5457c478bd9Sstevel@tonic-gate short qg_sortorder; /* how do we sort this queuerun */ 5467c478bd9Sstevel@tonic-gate #endif /* _FFR_QUEUE_GROUP_SORTORDER */ 5477c478bd9Sstevel@tonic-gate #if 0 5487c478bd9Sstevel@tonic-gate long qg_wkrcptfact; /* multiplier for # recipients -> priority */ 5497c478bd9Sstevel@tonic-gate long qg_qfactor; /* slope of queue function */ 5507c478bd9Sstevel@tonic-gate bool qg_doqueuerun; /* XXX flag is it time to do a queuerun */ 5517c478bd9Sstevel@tonic-gate #endif /* 0 */ 5527c478bd9Sstevel@tonic-gate }; 5537c478bd9Sstevel@tonic-gate 5547c478bd9Sstevel@tonic-gate /* bits for qg_flags (XXX: unused as of now) */ 5557c478bd9Sstevel@tonic-gate #define QD_DEFINED ((char) 1) /* queue group has been defined */ 5567c478bd9Sstevel@tonic-gate #define QD_FORK 'f' /* fork queue runs */ 5577c478bd9Sstevel@tonic-gate 5587c478bd9Sstevel@tonic-gate extern void filesys_update __P((void)); 5597c478bd9Sstevel@tonic-gate #if _FFR_ANY_FREE_FS 5607c478bd9Sstevel@tonic-gate extern bool filesys_free __P((long)); 5617c478bd9Sstevel@tonic-gate #endif /* _FFR_ANY_FREE_FS */ 5627c478bd9Sstevel@tonic-gate 5637c478bd9Sstevel@tonic-gate #if SASL 5647c478bd9Sstevel@tonic-gate /* 5657c478bd9Sstevel@tonic-gate ** SASL 5667c478bd9Sstevel@tonic-gate */ 5677c478bd9Sstevel@tonic-gate 5687c478bd9Sstevel@tonic-gate /* lines in authinfo file or index into SASL_AI_T */ 5697c478bd9Sstevel@tonic-gate # define SASL_WRONG (-1) 5707c478bd9Sstevel@tonic-gate # define SASL_USER 0 /* authorization id (user) */ 5717c478bd9Sstevel@tonic-gate # define SASL_AUTHID 1 /* authentication id */ 5727c478bd9Sstevel@tonic-gate # define SASL_PASSWORD 2 /* password fuer authid */ 5737c478bd9Sstevel@tonic-gate # define SASL_DEFREALM 3 /* realm to use */ 5747c478bd9Sstevel@tonic-gate # define SASL_MECHLIST 4 /* list of mechanisms to try */ 5757c478bd9Sstevel@tonic-gate # define SASL_ID_REALM 5 /* authid@defrealm */ 5767c478bd9Sstevel@tonic-gate 5777c478bd9Sstevel@tonic-gate /* 5787c478bd9Sstevel@tonic-gate ** Current mechanism; this is just used to convey information between 5797c478bd9Sstevel@tonic-gate ** invocation of SASL callback functions. 5807c478bd9Sstevel@tonic-gate ** It must be last in the list, because it's not allocated by us 5817c478bd9Sstevel@tonic-gate ** and hence we don't free() it. 5827c478bd9Sstevel@tonic-gate */ 5837c478bd9Sstevel@tonic-gate # define SASL_MECH 6 5847c478bd9Sstevel@tonic-gate # define SASL_ENTRIES 7 /* number of entries in array */ 5857c478bd9Sstevel@tonic-gate 5867c478bd9Sstevel@tonic-gate # define SASL_USER_BIT (1 << SASL_USER) 5877c478bd9Sstevel@tonic-gate # define SASL_AUTHID_BIT (1 << SASL_AUTHID) 5887c478bd9Sstevel@tonic-gate # define SASL_PASSWORD_BIT (1 << SASL_PASSWORD) 5897c478bd9Sstevel@tonic-gate # define SASL_DEFREALM_BIT (1 << SASL_DEFREALM) 5907c478bd9Sstevel@tonic-gate # define SASL_MECHLIST_BIT (1 << SASL_MECHLIST) 5917c478bd9Sstevel@tonic-gate 5927c478bd9Sstevel@tonic-gate /* authenticated? */ 5937c478bd9Sstevel@tonic-gate # define SASL_NOT_AUTH 0 /* not authenticated */ 5947c478bd9Sstevel@tonic-gate # define SASL_PROC_AUTH 1 /* in process of authenticating */ 5957c478bd9Sstevel@tonic-gate # define SASL_IS_AUTH 2 /* authenticated */ 5967c478bd9Sstevel@tonic-gate 5977c478bd9Sstevel@tonic-gate /* SASL options */ 5987c478bd9Sstevel@tonic-gate # define SASL_AUTH_AUTH 0x1000 /* use auth= only if authenticated */ 5997c478bd9Sstevel@tonic-gate # if SASL >= 20101 6007c478bd9Sstevel@tonic-gate # define SASL_SEC_MASK SASL_SEC_MAXIMUM /* mask for SASL_SEC_* values: sasl.h */ 6017c478bd9Sstevel@tonic-gate # else /* SASL >= 20101 */ 6027c478bd9Sstevel@tonic-gate # define SASL_SEC_MASK 0x0fff /* mask for SASL_SEC_* values: sasl.h */ 6037c478bd9Sstevel@tonic-gate # if (SASL_SEC_NOPLAINTEXT & SASL_SEC_MASK) == 0 || \ 6047c478bd9Sstevel@tonic-gate (SASL_SEC_NOACTIVE & SASL_SEC_MASK) == 0 || \ 6057c478bd9Sstevel@tonic-gate (SASL_SEC_NODICTIONARY & SASL_SEC_MASK) == 0 || \ 6067c478bd9Sstevel@tonic-gate (SASL_SEC_FORWARD_SECRECY & SASL_SEC_MASK) == 0 || \ 6077c478bd9Sstevel@tonic-gate (SASL_SEC_NOANONYMOUS & SASL_SEC_MASK) == 0 || \ 6087c478bd9Sstevel@tonic-gate (SASL_SEC_PASS_CREDENTIALS & SASL_SEC_MASK) == 0 6097c478bd9Sstevel@tonic-gate ERROR: change SASL_SEC_MASK_ notify sendmail.org! 6107c478bd9Sstevel@tonic-gate # endif /* SASL_SEC_NOPLAINTEXT & SASL_SEC_MASK) == 0 ... */ 6117c478bd9Sstevel@tonic-gate # endif /* SASL >= 20101 */ 6127c478bd9Sstevel@tonic-gate # define MAXOUTLEN 8192 /* length of output buffer */ 6137c478bd9Sstevel@tonic-gate 6147c478bd9Sstevel@tonic-gate /* functions */ 6157c478bd9Sstevel@tonic-gate extern char *intersect __P((char *, char *, SM_RPOOL_T *)); 6167c478bd9Sstevel@tonic-gate extern char *iteminlist __P((char *, char *, char *)); 6177c478bd9Sstevel@tonic-gate # if SASL >= 20000 6187c478bd9Sstevel@tonic-gate extern int proxy_policy __P((sasl_conn_t *, void *, const char *, unsigned, const char *, unsigned, const char *, unsigned, struct propctx *)); 6197c478bd9Sstevel@tonic-gate extern int safesaslfile __P((void *, const char *, sasl_verify_type_t)); 6207c478bd9Sstevel@tonic-gate # else /* SASL >= 20000 */ 6217c478bd9Sstevel@tonic-gate extern int proxy_policy __P((void *, const char *, const char *, const char **, const char **)); 6227c478bd9Sstevel@tonic-gate # if SASL > 10515 6237c478bd9Sstevel@tonic-gate extern int safesaslfile __P((void *, char *, int)); 6247c478bd9Sstevel@tonic-gate # else /* SASL > 10515 */ 6257c478bd9Sstevel@tonic-gate extern int safesaslfile __P((void *, char *)); 6267c478bd9Sstevel@tonic-gate # endif /* SASL > 10515 */ 6277c478bd9Sstevel@tonic-gate # endif /* SASL >= 20000 */ 6287c478bd9Sstevel@tonic-gate extern void stop_sasl_client __P((void)); 6297c478bd9Sstevel@tonic-gate 6307c478bd9Sstevel@tonic-gate /* structure to store authinfo */ 6317c478bd9Sstevel@tonic-gate typedef char *SASL_AI_T[SASL_ENTRIES]; 6327c478bd9Sstevel@tonic-gate 6337c478bd9Sstevel@tonic-gate EXTERN char *AuthMechanisms; /* AUTH mechanisms */ 6347c478bd9Sstevel@tonic-gate EXTERN char *AuthRealm; /* AUTH realm */ 6357c478bd9Sstevel@tonic-gate EXTERN char *SASLInfo; /* file with AUTH info */ 6367c478bd9Sstevel@tonic-gate EXTERN int SASLOpts; /* options for SASL */ 6377c478bd9Sstevel@tonic-gate EXTERN int MaxSLBits; /* max. encryption bits for SASL */ 6387c478bd9Sstevel@tonic-gate #endif /* SASL */ 6397c478bd9Sstevel@tonic-gate 6407c478bd9Sstevel@tonic-gate /* 6417c478bd9Sstevel@tonic-gate ** Structure to store macros. 6427c478bd9Sstevel@tonic-gate */ 6437c478bd9Sstevel@tonic-gate typedef struct 6447c478bd9Sstevel@tonic-gate { 6457c478bd9Sstevel@tonic-gate SM_RPOOL_T *mac_rpool; /* resource pool */ 6467c478bd9Sstevel@tonic-gate BITMAP256 mac_allocated; /* storage has been alloc()? */ 6477c478bd9Sstevel@tonic-gate char *mac_table[MAXMACROID + 1]; /* macros */ 6487c478bd9Sstevel@tonic-gate } MACROS_T; 6497c478bd9Sstevel@tonic-gate 6507c478bd9Sstevel@tonic-gate EXTERN MACROS_T GlobalMacros; 6517c478bd9Sstevel@tonic-gate 6527c478bd9Sstevel@tonic-gate /* 6537c478bd9Sstevel@tonic-gate ** Information about currently open connections to mailers, or to 6547c478bd9Sstevel@tonic-gate ** hosts that we have looked up recently. 6557c478bd9Sstevel@tonic-gate */ 6567c478bd9Sstevel@tonic-gate 6577c478bd9Sstevel@tonic-gate #define MCI struct mailer_con_info 6587c478bd9Sstevel@tonic-gate 6597c478bd9Sstevel@tonic-gate MCI 6607c478bd9Sstevel@tonic-gate { 6617c478bd9Sstevel@tonic-gate unsigned long mci_flags; /* flag bits, see below */ 6627c478bd9Sstevel@tonic-gate short mci_errno; /* error number on last connection */ 6637c478bd9Sstevel@tonic-gate short mci_herrno; /* h_errno from last DNS lookup */ 6647c478bd9Sstevel@tonic-gate short mci_exitstat; /* exit status from last connection */ 6657c478bd9Sstevel@tonic-gate short mci_state; /* SMTP state */ 6667c478bd9Sstevel@tonic-gate int mci_deliveries; /* delivery attempts for connection */ 6677c478bd9Sstevel@tonic-gate long mci_maxsize; /* max size this server will accept */ 6687c478bd9Sstevel@tonic-gate SM_FILE_T *mci_in; /* input side of connection */ 6697c478bd9Sstevel@tonic-gate SM_FILE_T *mci_out; /* output side of connection */ 6707c478bd9Sstevel@tonic-gate pid_t mci_pid; /* process id of subordinate proc */ 6717c478bd9Sstevel@tonic-gate char *mci_phase; /* SMTP phase string */ 6727c478bd9Sstevel@tonic-gate struct mailer *mci_mailer; /* ptr to the mailer for this conn */ 6737c478bd9Sstevel@tonic-gate char *mci_host; /* host name */ 6747c478bd9Sstevel@tonic-gate char *mci_status; /* DSN status to be copied to addrs */ 6757c478bd9Sstevel@tonic-gate char *mci_rstatus; /* SMTP status to be copied to addrs */ 6767c478bd9Sstevel@tonic-gate time_t mci_lastuse; /* last usage time */ 6777c478bd9Sstevel@tonic-gate SM_FILE_T *mci_statfile; /* long term status file */ 6787c478bd9Sstevel@tonic-gate char *mci_heloname; /* name to use as HELO arg */ 6797c478bd9Sstevel@tonic-gate long mci_min_by; /* minimum DELIVERBY */ 6807c478bd9Sstevel@tonic-gate bool mci_retryrcpt; /* tempfail for at least one rcpt */ 6817c478bd9Sstevel@tonic-gate char *mci_tolist; /* list of valid recipients */ 6827c478bd9Sstevel@tonic-gate SM_RPOOL_T *mci_rpool; /* resource pool */ 6837c478bd9Sstevel@tonic-gate #if PIPELINING 6847c478bd9Sstevel@tonic-gate int mci_okrcpts; /* number of valid recipients */ 6857c478bd9Sstevel@tonic-gate ADDRESS *mci_nextaddr; /* next address for pipelined status */ 6867c478bd9Sstevel@tonic-gate #endif /* PIPELINING */ 6877c478bd9Sstevel@tonic-gate #if SASL 6887c478bd9Sstevel@tonic-gate SASL_AI_T mci_sai; /* authentication info */ 6897c478bd9Sstevel@tonic-gate bool mci_sasl_auth; /* authenticated? */ 6907c478bd9Sstevel@tonic-gate int mci_sasl_string_len; 6917c478bd9Sstevel@tonic-gate char *mci_sasl_string; /* sasl reply string */ 6927c478bd9Sstevel@tonic-gate char *mci_saslcap; /* SASL list of mechanisms */ 6937c478bd9Sstevel@tonic-gate sasl_conn_t *mci_conn; /* SASL connection */ 6947c478bd9Sstevel@tonic-gate #endif /* SASL */ 6957c478bd9Sstevel@tonic-gate #if STARTTLS 6967c478bd9Sstevel@tonic-gate SSL *mci_ssl; /* SSL connection */ 6977c478bd9Sstevel@tonic-gate #endif /* STARTTLS */ 6987c478bd9Sstevel@tonic-gate MACROS_T mci_macro; /* macro definitions */ 6997c478bd9Sstevel@tonic-gate }; 7007c478bd9Sstevel@tonic-gate 7017c478bd9Sstevel@tonic-gate 7027c478bd9Sstevel@tonic-gate /* flag bits */ 7037c478bd9Sstevel@tonic-gate #define MCIF_VALID 0x00000001 /* this entry is valid */ 7047c478bd9Sstevel@tonic-gate /* 0x00000002 unused, was MCIF_TEMP */ 7057c478bd9Sstevel@tonic-gate #define MCIF_CACHED 0x00000004 /* currently in open cache */ 7067c478bd9Sstevel@tonic-gate #define MCIF_ESMTP 0x00000008 /* this host speaks ESMTP */ 7077c478bd9Sstevel@tonic-gate #define MCIF_EXPN 0x00000010 /* EXPN command supported */ 7087c478bd9Sstevel@tonic-gate #define MCIF_SIZE 0x00000020 /* SIZE option supported */ 7097c478bd9Sstevel@tonic-gate #define MCIF_8BITMIME 0x00000040 /* BODY=8BITMIME supported */ 7107c478bd9Sstevel@tonic-gate #define MCIF_7BIT 0x00000080 /* strip this message to 7 bits */ 7117c478bd9Sstevel@tonic-gate /* 0x00000100 unused, was MCIF_MULTSTAT: MAIL11V3: handles MULT status */ 7127c478bd9Sstevel@tonic-gate #define MCIF_INHEADER 0x00000200 /* currently outputing header */ 7137c478bd9Sstevel@tonic-gate #define MCIF_CVT8TO7 0x00000400 /* convert from 8 to 7 bits */ 7147c478bd9Sstevel@tonic-gate #define MCIF_DSN 0x00000800 /* DSN extension supported */ 7157c478bd9Sstevel@tonic-gate #define MCIF_8BITOK 0x00001000 /* OK to send 8 bit characters */ 7167c478bd9Sstevel@tonic-gate #define MCIF_CVT7TO8 0x00002000 /* convert from 7 to 8 bits */ 7177c478bd9Sstevel@tonic-gate #define MCIF_INMIME 0x00004000 /* currently reading MIME header */ 7187c478bd9Sstevel@tonic-gate #define MCIF_AUTH 0x00008000 /* AUTH= supported */ 7197c478bd9Sstevel@tonic-gate #define MCIF_AUTHACT 0x00010000 /* SASL (AUTH) active */ 7207c478bd9Sstevel@tonic-gate #define MCIF_ENHSTAT 0x00020000 /* ENHANCEDSTATUSCODES supported */ 7217c478bd9Sstevel@tonic-gate #define MCIF_PIPELINED 0x00040000 /* PIPELINING supported */ 7227c478bd9Sstevel@tonic-gate #define MCIF_VERB 0x00080000 /* VERB supported */ 7237c478bd9Sstevel@tonic-gate #if STARTTLS 7247c478bd9Sstevel@tonic-gate #define MCIF_TLS 0x00100000 /* STARTTLS supported */ 7257c478bd9Sstevel@tonic-gate #define MCIF_TLSACT 0x00200000 /* STARTTLS active */ 7267c478bd9Sstevel@tonic-gate #define MCIF_EXTENS (MCIF_EXPN | MCIF_SIZE | MCIF_8BITMIME | MCIF_DSN | MCIF_8BITOK | MCIF_AUTH | MCIF_ENHSTAT | MCIF_TLS) 7277c478bd9Sstevel@tonic-gate #else /* STARTTLS */ 7287c478bd9Sstevel@tonic-gate #define MCIF_EXTENS (MCIF_EXPN | MCIF_SIZE | MCIF_8BITMIME | MCIF_DSN | MCIF_8BITOK | MCIF_AUTH | MCIF_ENHSTAT) 7297c478bd9Sstevel@tonic-gate #endif /* STARTTLS */ 7307c478bd9Sstevel@tonic-gate #define MCIF_DLVR_BY 0x00400000 /* DELIVERBY */ 7317c478bd9Sstevel@tonic-gate #if _FFR_IGNORE_EXT_ON_HELO 7327c478bd9Sstevel@tonic-gate # define MCIF_HELO 0x00800000 /* we used HELO: ignore extensions */ 7337c478bd9Sstevel@tonic-gate #endif /* _FFR_IGNORE_EXT_ON_HELO */ 734*7800901eSjbeck #define MCIF_INLONGLINE 0x01000000 /* in the middle of a long line */ 7357c478bd9Sstevel@tonic-gate #define MCIF_ONLY_EHLO 0x10000000 /* use only EHLO in smtpinit */ 7367c478bd9Sstevel@tonic-gate 7377c478bd9Sstevel@tonic-gate /* states */ 7387c478bd9Sstevel@tonic-gate #define MCIS_CLOSED 0 /* no traffic on this connection */ 7397c478bd9Sstevel@tonic-gate #define MCIS_OPENING 1 /* sending initial protocol */ 7407c478bd9Sstevel@tonic-gate #define MCIS_OPEN 2 /* open, initial protocol sent */ 7417c478bd9Sstevel@tonic-gate #define MCIS_MAIL 3 /* MAIL command sent */ 7427c478bd9Sstevel@tonic-gate #define MCIS_RCPT 4 /* RCPT commands being sent */ 7437c478bd9Sstevel@tonic-gate #define MCIS_DATA 5 /* DATA command sent */ 7447c478bd9Sstevel@tonic-gate #define MCIS_QUITING 6 /* running quit protocol */ 7457c478bd9Sstevel@tonic-gate #define MCIS_SSD 7 /* service shutting down */ 7467c478bd9Sstevel@tonic-gate #define MCIS_ERROR 8 /* I/O error on connection */ 7477c478bd9Sstevel@tonic-gate 7487c478bd9Sstevel@tonic-gate /* functions */ 7497c478bd9Sstevel@tonic-gate extern void mci_cache __P((MCI *)); 7507c478bd9Sstevel@tonic-gate extern void mci_close __P((MCI *, char *where)); 7517c478bd9Sstevel@tonic-gate extern void mci_dump __P((SM_FILE_T *, MCI *, bool)); 7527c478bd9Sstevel@tonic-gate extern void mci_dump_all __P((SM_FILE_T *, bool)); 7537c478bd9Sstevel@tonic-gate extern void mci_flush __P((bool, MCI *)); 7547c478bd9Sstevel@tonic-gate extern MCI *mci_get __P((char *, MAILER *)); 7557c478bd9Sstevel@tonic-gate extern int mci_lock_host __P((MCI *)); 7567c478bd9Sstevel@tonic-gate extern bool mci_match __P((char *, MAILER *)); 7577c478bd9Sstevel@tonic-gate extern int mci_print_persistent __P((char *, char *)); 7587c478bd9Sstevel@tonic-gate extern int mci_purge_persistent __P((char *, char *)); 7597c478bd9Sstevel@tonic-gate extern MCI **mci_scan __P((MCI *)); 7607c478bd9Sstevel@tonic-gate extern void mci_setstat __P((MCI *, int, char *, char *)); 7617c478bd9Sstevel@tonic-gate extern void mci_store_persistent __P((MCI *)); 762058561cbSjbeck extern int mci_traverse_persistent __P((int (*)(char *, char *), char *)); 7637c478bd9Sstevel@tonic-gate extern void mci_unlock_host __P((MCI *)); 7647c478bd9Sstevel@tonic-gate 7657c478bd9Sstevel@tonic-gate EXTERN int MaxMciCache; /* maximum entries in MCI cache */ 7667c478bd9Sstevel@tonic-gate EXTERN time_t MciCacheTimeout; /* maximum idle time on connections */ 7677c478bd9Sstevel@tonic-gate EXTERN time_t MciInfoTimeout; /* how long 'til we retry down hosts */ 7687c478bd9Sstevel@tonic-gate 7697c478bd9Sstevel@tonic-gate /* 7707c478bd9Sstevel@tonic-gate ** Header structure. 7717c478bd9Sstevel@tonic-gate ** This structure is used internally to store header items. 7727c478bd9Sstevel@tonic-gate */ 7737c478bd9Sstevel@tonic-gate 7747c478bd9Sstevel@tonic-gate struct header 7757c478bd9Sstevel@tonic-gate { 7767c478bd9Sstevel@tonic-gate char *h_field; /* the name of the field */ 7777c478bd9Sstevel@tonic-gate char *h_value; /* the value of that field */ 7787c478bd9Sstevel@tonic-gate struct header *h_link; /* the next header */ 7797c478bd9Sstevel@tonic-gate unsigned char h_macro; /* include header if macro defined */ 7807c478bd9Sstevel@tonic-gate unsigned long h_flags; /* status bits, see below */ 7817c478bd9Sstevel@tonic-gate BITMAP256 h_mflags; /* m_flags bits needed */ 7827c478bd9Sstevel@tonic-gate }; 7837c478bd9Sstevel@tonic-gate 7847c478bd9Sstevel@tonic-gate typedef struct header HDR; 7857c478bd9Sstevel@tonic-gate 7867c478bd9Sstevel@tonic-gate /* 7877c478bd9Sstevel@tonic-gate ** Header information structure. 7887c478bd9Sstevel@tonic-gate ** Defined in conf.c, this struct declares the header fields 7897c478bd9Sstevel@tonic-gate ** that have some magic meaning. 7907c478bd9Sstevel@tonic-gate */ 7917c478bd9Sstevel@tonic-gate 7927c478bd9Sstevel@tonic-gate struct hdrinfo 7937c478bd9Sstevel@tonic-gate { 7947c478bd9Sstevel@tonic-gate char *hi_field; /* the name of the field */ 7957c478bd9Sstevel@tonic-gate unsigned long hi_flags; /* status bits, see below */ 7967c478bd9Sstevel@tonic-gate char *hi_ruleset; /* validity check ruleset */ 7977c478bd9Sstevel@tonic-gate }; 7987c478bd9Sstevel@tonic-gate 7997c478bd9Sstevel@tonic-gate extern struct hdrinfo HdrInfo[]; 8007c478bd9Sstevel@tonic-gate 8017c478bd9Sstevel@tonic-gate /* bits for h_flags and hi_flags */ 8027c478bd9Sstevel@tonic-gate #define H_EOH 0x00000001 /* field terminates header */ 8037c478bd9Sstevel@tonic-gate #define H_RCPT 0x00000002 /* contains recipient addresses */ 8047c478bd9Sstevel@tonic-gate #define H_DEFAULT 0x00000004 /* if another value is found, drop this */ 8057c478bd9Sstevel@tonic-gate #define H_RESENT 0x00000008 /* this address is a "Resent-..." address */ 8067c478bd9Sstevel@tonic-gate #define H_CHECK 0x00000010 /* check h_mflags against m_flags */ 8077c478bd9Sstevel@tonic-gate #define H_ACHECK 0x00000020 /* ditto, but always (not just default) */ 8087c478bd9Sstevel@tonic-gate #define H_FORCE 0x00000040 /* force this field, even if default */ 8097c478bd9Sstevel@tonic-gate #define H_TRACE 0x00000080 /* this field contains trace information */ 8107c478bd9Sstevel@tonic-gate #define H_FROM 0x00000100 /* this is a from-type field */ 8117c478bd9Sstevel@tonic-gate #define H_VALID 0x00000200 /* this field has a validated value */ 8127c478bd9Sstevel@tonic-gate #define H_RECEIPTTO 0x00000400 /* field has return receipt info */ 8137c478bd9Sstevel@tonic-gate #define H_ERRORSTO 0x00000800 /* field has error address info */ 8147c478bd9Sstevel@tonic-gate #define H_CTE 0x00001000 /* field is a content-transfer-encoding */ 8157c478bd9Sstevel@tonic-gate #define H_CTYPE 0x00002000 /* this is a content-type field */ 8167c478bd9Sstevel@tonic-gate #define H_BCC 0x00004000 /* Bcc: header: strip value or delete */ 8177c478bd9Sstevel@tonic-gate #define H_ENCODABLE 0x00008000 /* field can be RFC 1522 encoded */ 8187c478bd9Sstevel@tonic-gate #define H_STRIPCOMM 0x00010000 /* header check: strip comments */ 8197c478bd9Sstevel@tonic-gate #define H_BINDLATE 0x00020000 /* only expand macros at deliver */ 8207c478bd9Sstevel@tonic-gate #define H_USER 0x00040000 /* header came from the user/SMTP */ 8217c478bd9Sstevel@tonic-gate 8227c478bd9Sstevel@tonic-gate /* bits for chompheader() */ 8237c478bd9Sstevel@tonic-gate #define CHHDR_DEF 0x0001 /* default header */ 8247c478bd9Sstevel@tonic-gate #define CHHDR_CHECK 0x0002 /* call ruleset for header */ 8257c478bd9Sstevel@tonic-gate #define CHHDR_USER 0x0004 /* header from user */ 8267c478bd9Sstevel@tonic-gate #define CHHDR_QUEUE 0x0008 /* header from queue file */ 8277c478bd9Sstevel@tonic-gate 8287c478bd9Sstevel@tonic-gate /* functions */ 829058561cbSjbeck extern void addheader __P((char *, char *, int, ENVELOPE *, bool)); 8307c478bd9Sstevel@tonic-gate extern unsigned long chompheader __P((char *, int, HDR **, ENVELOPE *)); 831*7800901eSjbeck extern bool commaize __P((HDR *, char *, bool, MCI *, ENVELOPE *, int)); 8327c478bd9Sstevel@tonic-gate extern HDR *copyheader __P((HDR *, SM_RPOOL_T *)); 8337c478bd9Sstevel@tonic-gate extern void eatheader __P((ENVELOPE *, bool, bool)); 8347c478bd9Sstevel@tonic-gate extern char *hvalue __P((char *, HDR *)); 835058561cbSjbeck extern void insheader __P((int, char *, char *, int, ENVELOPE *, bool)); 8367c478bd9Sstevel@tonic-gate extern bool isheader __P((char *)); 837445f2479Sjbeck extern bool putfromline __P((MCI *, ENVELOPE *)); 8387c478bd9Sstevel@tonic-gate extern void setupheaders __P((void)); 8397c478bd9Sstevel@tonic-gate 8407c478bd9Sstevel@tonic-gate /* 8417c478bd9Sstevel@tonic-gate ** Performance monitoring 8427c478bd9Sstevel@tonic-gate */ 8437c478bd9Sstevel@tonic-gate 8447c478bd9Sstevel@tonic-gate #define TIMERS struct sm_timers 8457c478bd9Sstevel@tonic-gate 8467c478bd9Sstevel@tonic-gate TIMERS 8477c478bd9Sstevel@tonic-gate { 8487c478bd9Sstevel@tonic-gate TIMER ti_overall; /* the whole process */ 8497c478bd9Sstevel@tonic-gate }; 8507c478bd9Sstevel@tonic-gate 8517c478bd9Sstevel@tonic-gate 8527c478bd9Sstevel@tonic-gate #define PUSHTIMER(l, t) { if (tTd(98, l)) pushtimer(&t); } 8537c478bd9Sstevel@tonic-gate #define POPTIMER(l, t) { if (tTd(98, l)) poptimer(&t); } 8547c478bd9Sstevel@tonic-gate 8557c478bd9Sstevel@tonic-gate /* 8567c478bd9Sstevel@tonic-gate ** Envelope structure. 8577c478bd9Sstevel@tonic-gate ** This structure defines the message itself. There is usually 8587c478bd9Sstevel@tonic-gate ** only one of these -- for the message that we originally read 8597c478bd9Sstevel@tonic-gate ** and which is our primary interest -- but other envelopes can 8607c478bd9Sstevel@tonic-gate ** be generated during processing. For example, error messages 8617c478bd9Sstevel@tonic-gate ** will have their own envelope. 8627c478bd9Sstevel@tonic-gate */ 8637c478bd9Sstevel@tonic-gate 8647c478bd9Sstevel@tonic-gate struct envelope 8657c478bd9Sstevel@tonic-gate { 8667c478bd9Sstevel@tonic-gate HDR *e_header; /* head of header list */ 8677c478bd9Sstevel@tonic-gate long e_msgpriority; /* adjusted priority of this message */ 8687c478bd9Sstevel@tonic-gate time_t e_ctime; /* time message appeared in the queue */ 8697c478bd9Sstevel@tonic-gate char *e_to; /* (list of) target person(s) */ 8707c478bd9Sstevel@tonic-gate ADDRESS e_from; /* the person it is from */ 8717c478bd9Sstevel@tonic-gate char *e_sender; /* e_from.q_paddr w comments stripped */ 8727c478bd9Sstevel@tonic-gate char **e_fromdomain; /* the domain part of the sender */ 8737c478bd9Sstevel@tonic-gate ADDRESS *e_sendqueue; /* list of message recipients */ 8747c478bd9Sstevel@tonic-gate ADDRESS *e_errorqueue; /* the queue for error responses */ 8757c478bd9Sstevel@tonic-gate 8767c478bd9Sstevel@tonic-gate /* 8777c478bd9Sstevel@tonic-gate ** Overflow detection is based on < 0, so don't change this 8787c478bd9Sstevel@tonic-gate ** to unsigned. We don't use unsigned and == ULONG_MAX because 8797c478bd9Sstevel@tonic-gate ** some libc's don't have strtoul(), see mail_esmtp_args(). 8807c478bd9Sstevel@tonic-gate */ 8817c478bd9Sstevel@tonic-gate 8827c478bd9Sstevel@tonic-gate long e_msgsize; /* size of the message in bytes */ 8837c478bd9Sstevel@tonic-gate char *e_msgid; /* message id (for logging) */ 8847c478bd9Sstevel@tonic-gate unsigned long e_flags; /* flags, see below */ 8857c478bd9Sstevel@tonic-gate int e_nrcpts; /* number of recipients */ 8867c478bd9Sstevel@tonic-gate short e_class; /* msg class (priority, junk, etc.) */ 8877c478bd9Sstevel@tonic-gate short e_hopcount; /* number of times processed */ 8887c478bd9Sstevel@tonic-gate short e_nsent; /* number of sends since checkpoint */ 8897c478bd9Sstevel@tonic-gate short e_sendmode; /* message send mode */ 8907c478bd9Sstevel@tonic-gate short e_errormode; /* error return mode */ 8917c478bd9Sstevel@tonic-gate short e_timeoutclass; /* message timeout class */ 892445f2479Sjbeck bool (*e_puthdr)__P((MCI *, HDR *, ENVELOPE *, int)); 8937c478bd9Sstevel@tonic-gate /* function to put header of message */ 894445f2479Sjbeck bool (*e_putbody)__P((MCI *, ENVELOPE *, char *)); 8957c478bd9Sstevel@tonic-gate /* function to put body of message */ 8967c478bd9Sstevel@tonic-gate ENVELOPE *e_parent; /* the message this one encloses */ 8977c478bd9Sstevel@tonic-gate ENVELOPE *e_sibling; /* the next envelope of interest */ 8987c478bd9Sstevel@tonic-gate char *e_bodytype; /* type of message body */ 8997c478bd9Sstevel@tonic-gate SM_FILE_T *e_dfp; /* data file */ 9007c478bd9Sstevel@tonic-gate char *e_id; /* code for this entry in queue */ 901*7800901eSjbeck #if _FFR_SESSID 902*7800901eSjbeck char *e_sessid; /* session ID for this envelope */ 903*7800901eSjbeck #endif /* _FFR_SESSID */ 9047c478bd9Sstevel@tonic-gate int e_qgrp; /* queue group (index into queues) */ 9057c478bd9Sstevel@tonic-gate int e_qdir; /* index into queue directories */ 9067c478bd9Sstevel@tonic-gate int e_dfqgrp; /* data file queue group index */ 9077c478bd9Sstevel@tonic-gate int e_dfqdir; /* data file queue directory index */ 9087c478bd9Sstevel@tonic-gate int e_xfqgrp; /* queue group (index into queues) */ 9097c478bd9Sstevel@tonic-gate int e_xfqdir; /* index into queue directories (xf) */ 9107c478bd9Sstevel@tonic-gate SM_FILE_T *e_xfp; /* transcript file */ 9117c478bd9Sstevel@tonic-gate SM_FILE_T *e_lockfp; /* the lock file for this message */ 912058561cbSjbeck char *e_message; /* error message; readonly; NULL, 913058561cbSjbeck * or allocated from e_rpool */ 9147c478bd9Sstevel@tonic-gate char *e_statmsg; /* stat msg (changes per delivery). 9157c478bd9Sstevel@tonic-gate * readonly. NULL or allocated from 9167c478bd9Sstevel@tonic-gate * e_rpool. */ 9177c478bd9Sstevel@tonic-gate char *e_quarmsg; /* why envelope is quarantined */ 9187c478bd9Sstevel@tonic-gate char e_qfletter; /* queue file letter on disk */ 9197c478bd9Sstevel@tonic-gate char *e_msgboundary; /* MIME-style message part boundary */ 9207c478bd9Sstevel@tonic-gate char *e_origrcpt; /* original recipient (one only) */ 9217c478bd9Sstevel@tonic-gate char *e_envid; /* envelope id from MAIL FROM: line */ 9227c478bd9Sstevel@tonic-gate char *e_status; /* DSN status for this message */ 9237c478bd9Sstevel@tonic-gate time_t e_dtime; /* time of last delivery attempt */ 9247c478bd9Sstevel@tonic-gate int e_ntries; /* number of delivery attempts */ 9257c478bd9Sstevel@tonic-gate dev_t e_dfdev; /* data file device (crash recovery) */ 9267c478bd9Sstevel@tonic-gate ino_t e_dfino; /* data file inode (crash recovery) */ 9277c478bd9Sstevel@tonic-gate MACROS_T e_macro; /* macro definitions */ 9287c478bd9Sstevel@tonic-gate MCI *e_mci; /* connection info */ 9297c478bd9Sstevel@tonic-gate char *e_auth_param; /* readonly; NULL or static storage or 9307c478bd9Sstevel@tonic-gate * allocated from e_rpool */ 9317c478bd9Sstevel@tonic-gate TIMERS e_timers; /* per job timers */ 9327c478bd9Sstevel@tonic-gate long e_deliver_by; /* deliver by */ 9337c478bd9Sstevel@tonic-gate int e_dlvr_flag; /* deliver by flag */ 9347c478bd9Sstevel@tonic-gate SM_RPOOL_T *e_rpool; /* resource pool for this envelope */ 935058561cbSjbeck unsigned int e_features; /* server features */ 9367c478bd9Sstevel@tonic-gate }; 9377c478bd9Sstevel@tonic-gate 9387c478bd9Sstevel@tonic-gate /* values for e_flags */ 9397c478bd9Sstevel@tonic-gate #define EF_OLDSTYLE 0x00000001L /* use spaces (not commas) in hdrs */ 9407c478bd9Sstevel@tonic-gate #define EF_INQUEUE 0x00000002L /* this message is fully queued */ 9417c478bd9Sstevel@tonic-gate #define EF_NO_BODY_RETN 0x00000004L /* omit message body on error */ 9427c478bd9Sstevel@tonic-gate #define EF_CLRQUEUE 0x00000008L /* disk copy is no longer needed */ 9437c478bd9Sstevel@tonic-gate #define EF_SENDRECEIPT 0x00000010L /* send a return receipt */ 9447c478bd9Sstevel@tonic-gate #define EF_FATALERRS 0x00000020L /* fatal errors occurred */ 9457c478bd9Sstevel@tonic-gate #define EF_DELETE_BCC 0x00000040L /* delete Bcc: headers entirely */ 9467c478bd9Sstevel@tonic-gate #define EF_RESPONSE 0x00000080L /* this is an error or return receipt */ 9477c478bd9Sstevel@tonic-gate #define EF_RESENT 0x00000100L /* this message is being forwarded */ 9487c478bd9Sstevel@tonic-gate #define EF_VRFYONLY 0x00000200L /* verify only (don't expand aliases) */ 9497c478bd9Sstevel@tonic-gate #define EF_WARNING 0x00000400L /* warning message has been sent */ 9507c478bd9Sstevel@tonic-gate #define EF_QUEUERUN 0x00000800L /* this envelope is from queue */ 9517c478bd9Sstevel@tonic-gate #define EF_GLOBALERRS 0x00001000L /* treat errors as global */ 9527c478bd9Sstevel@tonic-gate #define EF_PM_NOTIFY 0x00002000L /* send return mail to postmaster */ 9537c478bd9Sstevel@tonic-gate #define EF_METOO 0x00004000L /* send to me too */ 9547c478bd9Sstevel@tonic-gate #define EF_LOGSENDER 0x00008000L /* need to log the sender */ 9557c478bd9Sstevel@tonic-gate #define EF_NORECEIPT 0x00010000L /* suppress all return-receipts */ 9567c478bd9Sstevel@tonic-gate #define EF_HAS8BIT 0x00020000L /* at least one 8-bit char in body */ 9577c478bd9Sstevel@tonic-gate #define EF_NL_NOT_EOL 0x00040000L /* don't accept raw NL as EOLine */ 9587c478bd9Sstevel@tonic-gate #define EF_CRLF_NOT_EOL 0x00080000L /* don't accept CR-LF as EOLine */ 9597c478bd9Sstevel@tonic-gate #define EF_RET_PARAM 0x00100000L /* RCPT command had RET argument */ 9607c478bd9Sstevel@tonic-gate #define EF_HAS_DF 0x00200000L /* set when data file is instantiated */ 9617c478bd9Sstevel@tonic-gate #define EF_IS_MIME 0x00400000L /* really is a MIME message */ 9627c478bd9Sstevel@tonic-gate #define EF_DONT_MIME 0x00800000L /* never MIME this message */ 9637c478bd9Sstevel@tonic-gate #define EF_DISCARD 0x01000000L /* discard the message */ 9647c478bd9Sstevel@tonic-gate #define EF_TOOBIG 0x02000000L /* message is too big */ 9657c478bd9Sstevel@tonic-gate #define EF_SPLIT 0x04000000L /* envelope has been split */ 9667c478bd9Sstevel@tonic-gate #define EF_UNSAFE 0x08000000L /* unsafe: read from untrusted source */ 9673ee0e492Sjbeck #define EF_TOODEEP 0x10000000L /* message is nested too deep */ 9687c478bd9Sstevel@tonic-gate 9697c478bd9Sstevel@tonic-gate #define DLVR_NOTIFY 0x01 9707c478bd9Sstevel@tonic-gate #define DLVR_RETURN 0x02 9717c478bd9Sstevel@tonic-gate #define DLVR_TRACE 0x10 9727c478bd9Sstevel@tonic-gate #define IS_DLVR_NOTIFY(e) (((e)->e_dlvr_flag & DLVR_NOTIFY) != 0) 9737c478bd9Sstevel@tonic-gate #define IS_DLVR_RETURN(e) (((e)->e_dlvr_flag & DLVR_RETURN) != 0) 9747c478bd9Sstevel@tonic-gate #define IS_DLVR_TRACE(e) (((e)->e_dlvr_flag & DLVR_TRACE) != 0) 9757c478bd9Sstevel@tonic-gate #define IS_DLVR_BY(e) ((e)->e_dlvr_flag != 0) 9767c478bd9Sstevel@tonic-gate 9777c478bd9Sstevel@tonic-gate #define BODYTYPE_NONE (0) 9787c478bd9Sstevel@tonic-gate #define BODYTYPE_7BIT (1) 9797c478bd9Sstevel@tonic-gate #define BODYTYPE_8BITMIME (2) 9807c478bd9Sstevel@tonic-gate #define BODYTYPE_ILLEGAL (-1) 9817c478bd9Sstevel@tonic-gate #define BODYTYPE_VALID(b) ((b) == BODYTYPE_7BIT || (b) == BODYTYPE_8BITMIME) 9827c478bd9Sstevel@tonic-gate 9837c478bd9Sstevel@tonic-gate extern ENVELOPE BlankEnvelope; 9847c478bd9Sstevel@tonic-gate 9857c478bd9Sstevel@tonic-gate /* functions */ 9867c478bd9Sstevel@tonic-gate extern void clearenvelope __P((ENVELOPE *, bool, SM_RPOOL_T *)); 9877c478bd9Sstevel@tonic-gate extern void dropenvelope __P((ENVELOPE *, bool, bool)); 9887c478bd9Sstevel@tonic-gate extern ENVELOPE *newenvelope __P((ENVELOPE *, ENVELOPE *, SM_RPOOL_T *)); 9897c478bd9Sstevel@tonic-gate extern void clrsessenvelope __P((ENVELOPE *)); 9907c478bd9Sstevel@tonic-gate extern void printenvflags __P((ENVELOPE *)); 991445f2479Sjbeck extern bool putbody __P((MCI *, ENVELOPE *, char *)); 992445f2479Sjbeck extern bool putheader __P((MCI *, HDR *, ENVELOPE *, int)); 9937c478bd9Sstevel@tonic-gate 9947c478bd9Sstevel@tonic-gate /* 9957c478bd9Sstevel@tonic-gate ** Message priority classes. 9967c478bd9Sstevel@tonic-gate ** 9977c478bd9Sstevel@tonic-gate ** The message class is read directly from the Priority: header 9987c478bd9Sstevel@tonic-gate ** field in the message. 9997c478bd9Sstevel@tonic-gate ** 10007c478bd9Sstevel@tonic-gate ** CurEnv->e_msgpriority is the number of bytes in the message plus 10017c478bd9Sstevel@tonic-gate ** the creation time (so that jobs ``tend'' to be ordered correctly), 10027c478bd9Sstevel@tonic-gate ** adjusted by the message class, the number of recipients, and the 10037c478bd9Sstevel@tonic-gate ** amount of time the message has been sitting around. This number 10047c478bd9Sstevel@tonic-gate ** is used to order the queue. Higher values mean LOWER priority. 10057c478bd9Sstevel@tonic-gate ** 10067c478bd9Sstevel@tonic-gate ** Each priority class point is worth WkClassFact priority points; 10077c478bd9Sstevel@tonic-gate ** each recipient is worth WkRecipFact priority points. Each time 10087c478bd9Sstevel@tonic-gate ** we reprocess a message the priority is adjusted by WkTimeFact. 10097c478bd9Sstevel@tonic-gate ** WkTimeFact should normally decrease the priority so that jobs 10107c478bd9Sstevel@tonic-gate ** that have historically failed will be run later; thanks go to 10117c478bd9Sstevel@tonic-gate ** Jay Lepreau at Utah for pointing out the error in my thinking. 10127c478bd9Sstevel@tonic-gate ** 10137c478bd9Sstevel@tonic-gate ** The "class" is this number, unadjusted by the age or size of 10147c478bd9Sstevel@tonic-gate ** this message. Classes with negative representations will have 10157c478bd9Sstevel@tonic-gate ** error messages thrown away if they are not local. 10167c478bd9Sstevel@tonic-gate */ 10177c478bd9Sstevel@tonic-gate 10187c478bd9Sstevel@tonic-gate struct priority 10197c478bd9Sstevel@tonic-gate { 10207c478bd9Sstevel@tonic-gate char *pri_name; /* external name of priority */ 10217c478bd9Sstevel@tonic-gate int pri_val; /* internal value for same */ 10227c478bd9Sstevel@tonic-gate }; 10237c478bd9Sstevel@tonic-gate 10247c478bd9Sstevel@tonic-gate EXTERN int NumPriorities; /* pointer into Priorities */ 10257c478bd9Sstevel@tonic-gate EXTERN struct priority Priorities[MAXPRIORITIES]; 10267c478bd9Sstevel@tonic-gate 10277c478bd9Sstevel@tonic-gate /* 10287c478bd9Sstevel@tonic-gate ** Rewrite rules. 10297c478bd9Sstevel@tonic-gate */ 10307c478bd9Sstevel@tonic-gate 10317c478bd9Sstevel@tonic-gate struct rewrite 10327c478bd9Sstevel@tonic-gate { 10337c478bd9Sstevel@tonic-gate char **r_lhs; /* pattern match */ 10347c478bd9Sstevel@tonic-gate char **r_rhs; /* substitution value */ 10357c478bd9Sstevel@tonic-gate struct rewrite *r_next;/* next in chain */ 10367c478bd9Sstevel@tonic-gate int r_line; /* rule line in sendmail.cf */ 10377c478bd9Sstevel@tonic-gate }; 10387c478bd9Sstevel@tonic-gate 10397c478bd9Sstevel@tonic-gate /* 10407c478bd9Sstevel@tonic-gate ** Special characters in rewriting rules. 10417c478bd9Sstevel@tonic-gate ** These are used internally only. 10427c478bd9Sstevel@tonic-gate ** The COND* rules are actually used in macros rather than in 10437c478bd9Sstevel@tonic-gate ** rewriting rules, but are given here because they 10447c478bd9Sstevel@tonic-gate ** cannot conflict. 10457c478bd9Sstevel@tonic-gate */ 10467c478bd9Sstevel@tonic-gate 1047058561cbSjbeck /* "out of band" indicator */ 1048058561cbSjbeck /* sm/sendmail.h #define METAQUOTE ((unsigned char)0377) quotes the next octet */ 1049058561cbSjbeck 10507c478bd9Sstevel@tonic-gate /* left hand side items */ 10517c478bd9Sstevel@tonic-gate #define MATCHZANY ((unsigned char)0220) /* match zero or more tokens */ 10527c478bd9Sstevel@tonic-gate #define MATCHANY ((unsigned char)0221) /* match one or more tokens */ 10537c478bd9Sstevel@tonic-gate #define MATCHONE ((unsigned char)0222) /* match exactly one token */ 10547c478bd9Sstevel@tonic-gate #define MATCHCLASS ((unsigned char)0223) /* match one token in a class */ 1055058561cbSjbeck #define MATCHNCLASS ((unsigned char)0224) /* match tokens not in class */ 10567c478bd9Sstevel@tonic-gate 10577c478bd9Sstevel@tonic-gate /* right hand side items */ 1058058561cbSjbeck #define MATCHREPL ((unsigned char)0225) /* RHS replacement for above */ 10597c478bd9Sstevel@tonic-gate #define CANONNET ((unsigned char)0226) /* canonical net, next token */ 10607c478bd9Sstevel@tonic-gate #define CANONHOST ((unsigned char)0227) /* canonical host, next token */ 10617c478bd9Sstevel@tonic-gate #define CANONUSER ((unsigned char)0230) /* canonical user, next N tokens */ 10627c478bd9Sstevel@tonic-gate #define CALLSUBR ((unsigned char)0231) /* call another rewriting set */ 10637c478bd9Sstevel@tonic-gate 1064058561cbSjbeck /* conditionals in macros (anywhere) */ 10657c478bd9Sstevel@tonic-gate #define CONDIF ((unsigned char)0232) /* conditional if-then */ 10667c478bd9Sstevel@tonic-gate #define CONDELSE ((unsigned char)0233) /* conditional else */ 10677c478bd9Sstevel@tonic-gate #define CONDFI ((unsigned char)0234) /* conditional fi */ 10687c478bd9Sstevel@tonic-gate 1069058561cbSjbeck /* bracket characters for RHS host name lookup */ 10707c478bd9Sstevel@tonic-gate #define HOSTBEGIN ((unsigned char)0235) /* hostname lookup begin */ 1071058561cbSjbeck #define HOSTEND ((unsigned char)0236) /* hostname lookup end */ 10727c478bd9Sstevel@tonic-gate 1073058561cbSjbeck /* bracket characters for RHS generalized lookup */ 10747c478bd9Sstevel@tonic-gate #define LOOKUPBEGIN ((unsigned char)0205) /* generalized lookup begin */ 10757c478bd9Sstevel@tonic-gate #define LOOKUPEND ((unsigned char)0206) /* generalized lookup end */ 10767c478bd9Sstevel@tonic-gate 1077058561cbSjbeck /* macro substitution characters (anywhere) */ 10787c478bd9Sstevel@tonic-gate #define MACROEXPAND ((unsigned char)0201) /* macro expansion */ 10797c478bd9Sstevel@tonic-gate #define MACRODEXPAND ((unsigned char)0202) /* deferred macro expansion */ 10807c478bd9Sstevel@tonic-gate 10817c478bd9Sstevel@tonic-gate /* to make the code clearer */ 10827c478bd9Sstevel@tonic-gate #define MATCHZERO CANONHOST 10837c478bd9Sstevel@tonic-gate 10847c478bd9Sstevel@tonic-gate #define MAXMATCH 9 /* max params per rewrite */ 10857c478bd9Sstevel@tonic-gate #define MAX_MAP_ARGS 10 /* max arguments for map */ 10867c478bd9Sstevel@tonic-gate 10877c478bd9Sstevel@tonic-gate /* external <==> internal mapping table */ 10887c478bd9Sstevel@tonic-gate struct metamac 10897c478bd9Sstevel@tonic-gate { 10907c478bd9Sstevel@tonic-gate char metaname; /* external code (after $) */ 10917c478bd9Sstevel@tonic-gate unsigned char metaval; /* internal code (as above) */ 10927c478bd9Sstevel@tonic-gate }; 10937c478bd9Sstevel@tonic-gate 10947c478bd9Sstevel@tonic-gate /* values for macros with external names only */ 10957c478bd9Sstevel@tonic-gate #define MID_OPMODE 0202 /* operation mode */ 10967c478bd9Sstevel@tonic-gate 10977c478bd9Sstevel@tonic-gate /* functions */ 10987c478bd9Sstevel@tonic-gate #if SM_HEAP_CHECK 10997c478bd9Sstevel@tonic-gate extern void 11007c478bd9Sstevel@tonic-gate macdefine_tagged __P(( 11017c478bd9Sstevel@tonic-gate MACROS_T *_mac, 11027c478bd9Sstevel@tonic-gate ARGCLASS_T _vclass, 11037c478bd9Sstevel@tonic-gate int _id, 11047c478bd9Sstevel@tonic-gate char *_value, 11057c478bd9Sstevel@tonic-gate char *_file, 11067c478bd9Sstevel@tonic-gate int _line, 11077c478bd9Sstevel@tonic-gate int _group)); 11087c478bd9Sstevel@tonic-gate # define macdefine(mac,c,id,v) \ 11097c478bd9Sstevel@tonic-gate macdefine_tagged(mac,c,id,v,__FILE__,__LINE__,sm_heap_group()) 11107c478bd9Sstevel@tonic-gate #else /* SM_HEAP_CHECK */ 11117c478bd9Sstevel@tonic-gate extern void 11127c478bd9Sstevel@tonic-gate macdefine __P(( 11137c478bd9Sstevel@tonic-gate MACROS_T *_mac, 11147c478bd9Sstevel@tonic-gate ARGCLASS_T _vclass, 11157c478bd9Sstevel@tonic-gate int _id, 11167c478bd9Sstevel@tonic-gate char *_value)); 11177c478bd9Sstevel@tonic-gate # define macdefine_tagged(mac,c,id,v,file,line,grp) macdefine(mac,c,id,v) 11187c478bd9Sstevel@tonic-gate #endif /* SM_HEAP_CHECK */ 11197c478bd9Sstevel@tonic-gate extern void macset __P((MACROS_T *, int, char *)); 11207c478bd9Sstevel@tonic-gate #define macget(mac, i) (mac)->mac_table[i] 11217c478bd9Sstevel@tonic-gate extern void expand __P((char *, char *, size_t, ENVELOPE *)); 11227c478bd9Sstevel@tonic-gate extern int macid_parse __P((char *, char **)); 11237c478bd9Sstevel@tonic-gate #define macid(name) macid_parse(name, NULL) 11247c478bd9Sstevel@tonic-gate extern char *macname __P((int)); 11257c478bd9Sstevel@tonic-gate extern char *macvalue __P((int, ENVELOPE *)); 1126058561cbSjbeck extern int rscheck __P((char *, char *, char *, ENVELOPE *, int, int, char *, char *, ADDRESS *)); 11277c478bd9Sstevel@tonic-gate extern int rscap __P((char *, char *, char *, ENVELOPE *, char ***, char *, int)); 11287c478bd9Sstevel@tonic-gate extern void setclass __P((int, char *)); 11297c478bd9Sstevel@tonic-gate extern int strtorwset __P((char *, char **, int)); 1130058561cbSjbeck extern char *translate_dollars __P((char *, char *, int *)); 11317c478bd9Sstevel@tonic-gate extern bool wordinclass __P((char *, int)); 11327c478bd9Sstevel@tonic-gate 11337c478bd9Sstevel@tonic-gate /* 11347c478bd9Sstevel@tonic-gate ** Name canonification short circuit. 11357c478bd9Sstevel@tonic-gate ** 11367c478bd9Sstevel@tonic-gate ** If the name server for a host is down, the process of trying to 11377c478bd9Sstevel@tonic-gate ** canonify the name can hang. This is similar to (but alas, not 11387c478bd9Sstevel@tonic-gate ** identical to) looking up the name for delivery. This stab type 11397c478bd9Sstevel@tonic-gate ** caches the result of the name server lookup so we don't hang 11407c478bd9Sstevel@tonic-gate ** multiple times. 11417c478bd9Sstevel@tonic-gate */ 11427c478bd9Sstevel@tonic-gate 11437c478bd9Sstevel@tonic-gate #define NAMECANON struct _namecanon 11447c478bd9Sstevel@tonic-gate 11457c478bd9Sstevel@tonic-gate NAMECANON 11467c478bd9Sstevel@tonic-gate { 11477c478bd9Sstevel@tonic-gate short nc_errno; /* cached errno */ 11487c478bd9Sstevel@tonic-gate short nc_herrno; /* cached h_errno */ 11497c478bd9Sstevel@tonic-gate short nc_stat; /* cached exit status code */ 11507c478bd9Sstevel@tonic-gate short nc_flags; /* flag bits */ 11517c478bd9Sstevel@tonic-gate char *nc_cname; /* the canonical name */ 11527c478bd9Sstevel@tonic-gate time_t nc_exp; /* entry expires at */ 11537c478bd9Sstevel@tonic-gate }; 11547c478bd9Sstevel@tonic-gate 11557c478bd9Sstevel@tonic-gate /* values for nc_flags */ 11567c478bd9Sstevel@tonic-gate #define NCF_VALID 0x0001 /* entry valid */ 11577c478bd9Sstevel@tonic-gate 11587c478bd9Sstevel@tonic-gate /* hostsignature structure */ 11597c478bd9Sstevel@tonic-gate 11607c478bd9Sstevel@tonic-gate struct hostsig_t 11617c478bd9Sstevel@tonic-gate { 11627c478bd9Sstevel@tonic-gate char *hs_sig; /* hostsignature */ 11637c478bd9Sstevel@tonic-gate time_t hs_exp; /* entry expires at */ 11647c478bd9Sstevel@tonic-gate }; 11657c478bd9Sstevel@tonic-gate 11667c478bd9Sstevel@tonic-gate typedef struct hostsig_t HOSTSIG_T; 11677c478bd9Sstevel@tonic-gate 11687c478bd9Sstevel@tonic-gate /* functions */ 11697c478bd9Sstevel@tonic-gate extern bool getcanonname __P((char *, int, bool, int *)); 11707c478bd9Sstevel@tonic-gate extern int getmxrr __P((char *, char **, unsigned short *, bool, int *, bool, int *)); 11717c478bd9Sstevel@tonic-gate extern char *hostsignature __P((MAILER *, char *)); 11727c478bd9Sstevel@tonic-gate extern int getfallbackmxrr __P((char *)); 11737c478bd9Sstevel@tonic-gate 11747c478bd9Sstevel@tonic-gate /* 11757c478bd9Sstevel@tonic-gate ** Mapping functions 11767c478bd9Sstevel@tonic-gate ** 11777c478bd9Sstevel@tonic-gate ** These allow arbitrary mappings in the config file. The idea 11787c478bd9Sstevel@tonic-gate ** (albeit not the implementation) comes from IDA sendmail. 11797c478bd9Sstevel@tonic-gate */ 11807c478bd9Sstevel@tonic-gate 11817c478bd9Sstevel@tonic-gate #define MAPCLASS struct _mapclass 11827c478bd9Sstevel@tonic-gate #define MAP struct _map 11837c478bd9Sstevel@tonic-gate #define MAXMAPACTIONS 5 /* size of map_actions array */ 11847c478bd9Sstevel@tonic-gate 11857c478bd9Sstevel@tonic-gate 11867c478bd9Sstevel@tonic-gate /* 11877c478bd9Sstevel@tonic-gate ** An actual map. 11887c478bd9Sstevel@tonic-gate */ 11897c478bd9Sstevel@tonic-gate 11907c478bd9Sstevel@tonic-gate MAP 11917c478bd9Sstevel@tonic-gate { 11927c478bd9Sstevel@tonic-gate MAPCLASS *map_class; /* the class of this map */ 11937c478bd9Sstevel@tonic-gate MAPCLASS *map_orgclass; /* the original class of this map */ 11947c478bd9Sstevel@tonic-gate char *map_mname; /* name of this map */ 11957c478bd9Sstevel@tonic-gate long map_mflags; /* flags, see below */ 11967c478bd9Sstevel@tonic-gate char *map_file; /* the (nominal) filename */ 11977c478bd9Sstevel@tonic-gate ARBPTR_T map_db1; /* the open database ptr */ 11987c478bd9Sstevel@tonic-gate ARBPTR_T map_db2; /* an "extra" database pointer */ 11997c478bd9Sstevel@tonic-gate char *map_keycolnm; /* key column name */ 12007c478bd9Sstevel@tonic-gate char *map_valcolnm; /* value column name */ 12017c478bd9Sstevel@tonic-gate unsigned char map_keycolno; /* key column number */ 12027c478bd9Sstevel@tonic-gate unsigned char map_valcolno; /* value column number */ 12037c478bd9Sstevel@tonic-gate char map_coldelim; /* column delimiter */ 12047c478bd9Sstevel@tonic-gate char map_spacesub; /* spacesub */ 12057c478bd9Sstevel@tonic-gate char *map_app; /* to append to successful matches */ 12067c478bd9Sstevel@tonic-gate char *map_tapp; /* to append to "tempfail" matches */ 12077c478bd9Sstevel@tonic-gate char *map_domain; /* the (nominal) NIS domain */ 12087c478bd9Sstevel@tonic-gate char *map_rebuild; /* program to run to do auto-rebuild */ 12097c478bd9Sstevel@tonic-gate time_t map_mtime; /* last database modification time */ 12107c478bd9Sstevel@tonic-gate time_t map_timeout; /* timeout for map accesses */ 12117c478bd9Sstevel@tonic-gate int map_retry; /* # of retries for map accesses */ 12127c478bd9Sstevel@tonic-gate pid_t map_pid; /* PID of process which opened map */ 12137c478bd9Sstevel@tonic-gate int map_lockfd; /* auxiliary lock file descriptor */ 12147c478bd9Sstevel@tonic-gate short map_specificity; /* specificity of aliases */ 12157c478bd9Sstevel@tonic-gate MAP *map_stack[MAXMAPSTACK]; /* list for stacked maps */ 12167c478bd9Sstevel@tonic-gate short map_return[MAXMAPACTIONS]; /* return bitmaps for stacked maps */ 12177c478bd9Sstevel@tonic-gate }; 12187c478bd9Sstevel@tonic-gate 12197c478bd9Sstevel@tonic-gate 12207c478bd9Sstevel@tonic-gate /* bit values for map_mflags */ 12217c478bd9Sstevel@tonic-gate #define MF_VALID 0x00000001 /* this entry is valid */ 12227c478bd9Sstevel@tonic-gate #define MF_INCLNULL 0x00000002 /* include null byte in key */ 12237c478bd9Sstevel@tonic-gate #define MF_OPTIONAL 0x00000004 /* don't complain if map not found */ 12247c478bd9Sstevel@tonic-gate #define MF_NOFOLDCASE 0x00000008 /* don't fold case in keys */ 12257c478bd9Sstevel@tonic-gate #define MF_MATCHONLY 0x00000010 /* don't use the map value */ 12267c478bd9Sstevel@tonic-gate #define MF_OPEN 0x00000020 /* this entry is open */ 12277c478bd9Sstevel@tonic-gate #define MF_WRITABLE 0x00000040 /* open for writing */ 12287c478bd9Sstevel@tonic-gate #define MF_ALIAS 0x00000080 /* this is an alias file */ 12297c478bd9Sstevel@tonic-gate #define MF_TRY0NULL 0x00000100 /* try with no null byte */ 12307c478bd9Sstevel@tonic-gate #define MF_TRY1NULL 0x00000200 /* try with the null byte */ 12317c478bd9Sstevel@tonic-gate #define MF_LOCKED 0x00000400 /* this map is currently locked */ 12327c478bd9Sstevel@tonic-gate #define MF_ALIASWAIT 0x00000800 /* alias map in aliaswait state */ 12337c478bd9Sstevel@tonic-gate #define MF_IMPL_HASH 0x00001000 /* implicit: underlying hash database */ 12347c478bd9Sstevel@tonic-gate #define MF_IMPL_NDBM 0x00002000 /* implicit: underlying NDBM database */ 12357c478bd9Sstevel@tonic-gate /* 0x00004000 */ 12367c478bd9Sstevel@tonic-gate #define MF_APPEND 0x00008000 /* append new entry on rebuild */ 12377c478bd9Sstevel@tonic-gate #define MF_KEEPQUOTES 0x00010000 /* don't dequote key before lookup */ 12387c478bd9Sstevel@tonic-gate #define MF_NODEFER 0x00020000 /* don't defer if map lookup fails */ 12397c478bd9Sstevel@tonic-gate #define MF_REGEX_NOT 0x00040000 /* regular expression negation */ 12407c478bd9Sstevel@tonic-gate #define MF_DEFER 0x00080000 /* don't lookup map in defer mode */ 12417c478bd9Sstevel@tonic-gate #define MF_SINGLEMATCH 0x00100000 /* successful only if match one key */ 124249218d4fSjbeck #define MF_SINGLEDN 0x00200000 /* only one match, but multi values */ 12437c478bd9Sstevel@tonic-gate #define MF_FILECLASS 0x00400000 /* this is a file class map */ 12447c478bd9Sstevel@tonic-gate #define MF_OPENBOGUS 0x00800000 /* open failed, don't call map_close */ 12457c478bd9Sstevel@tonic-gate #define MF_CLOSING 0x01000000 /* map is being closed */ 12467c478bd9Sstevel@tonic-gate 12477c478bd9Sstevel@tonic-gate #define DYNOPENMAP(map) if (!bitset(MF_OPEN, (map)->map_mflags)) \ 12487c478bd9Sstevel@tonic-gate { \ 12497c478bd9Sstevel@tonic-gate if (!openmap(map)) \ 12507c478bd9Sstevel@tonic-gate return NULL; \ 12517c478bd9Sstevel@tonic-gate } 12527c478bd9Sstevel@tonic-gate 12537c478bd9Sstevel@tonic-gate 12547c478bd9Sstevel@tonic-gate /* indices for map_actions */ 12557c478bd9Sstevel@tonic-gate #define MA_NOTFOUND 0 /* member map returned "not found" */ 12567c478bd9Sstevel@tonic-gate #define MA_UNAVAIL 1 /* member map is not available */ 12577c478bd9Sstevel@tonic-gate #define MA_TRYAGAIN 2 /* member map returns temp failure */ 12587c478bd9Sstevel@tonic-gate 12597c478bd9Sstevel@tonic-gate /* macros to handle MapTempFail */ 12607c478bd9Sstevel@tonic-gate #define BIT_IS_MTP 0x01 /* temp.failure occurred */ 12617c478bd9Sstevel@tonic-gate #define BIT_ASK_MTP 0x02 /* do we care about MapTempFail? */ 12627c478bd9Sstevel@tonic-gate #define RESET_MAPTEMPFAIL MapTempFail = 0 12637c478bd9Sstevel@tonic-gate #define INIT_MAPTEMPFAIL MapTempFail = BIT_ASK_MTP 12647c478bd9Sstevel@tonic-gate #define SET_MAPTEMPFAIL MapTempFail |= BIT_IS_MTP 12657c478bd9Sstevel@tonic-gate #define IS_MAPTEMPFAIL bitset(BIT_IS_MTP, MapTempFail) 12667c478bd9Sstevel@tonic-gate #define ASK_MAPTEMPFAIL bitset(BIT_ASK_MTP, MapTempFail) 12677c478bd9Sstevel@tonic-gate 12687c478bd9Sstevel@tonic-gate /* 12697c478bd9Sstevel@tonic-gate ** The class of a map -- essentially the functions to call 12707c478bd9Sstevel@tonic-gate */ 12717c478bd9Sstevel@tonic-gate 12727c478bd9Sstevel@tonic-gate MAPCLASS 12737c478bd9Sstevel@tonic-gate { 12747c478bd9Sstevel@tonic-gate char *map_cname; /* name of this map class */ 12757c478bd9Sstevel@tonic-gate char *map_ext; /* extension for database file */ 12767c478bd9Sstevel@tonic-gate short map_cflags; /* flag bits, see below */ 12777c478bd9Sstevel@tonic-gate bool (*map_parse)__P((MAP *, char *)); 12787c478bd9Sstevel@tonic-gate /* argument parsing function */ 12797c478bd9Sstevel@tonic-gate char *(*map_lookup)__P((MAP *, char *, char **, int *)); 12807c478bd9Sstevel@tonic-gate /* lookup function */ 12817c478bd9Sstevel@tonic-gate void (*map_store)__P((MAP *, char *, char *)); 12827c478bd9Sstevel@tonic-gate /* store function */ 12837c478bd9Sstevel@tonic-gate bool (*map_open)__P((MAP *, int)); 12847c478bd9Sstevel@tonic-gate /* open function */ 12857c478bd9Sstevel@tonic-gate void (*map_close)__P((MAP *)); 12867c478bd9Sstevel@tonic-gate /* close function */ 12877c478bd9Sstevel@tonic-gate }; 12887c478bd9Sstevel@tonic-gate 12897c478bd9Sstevel@tonic-gate /* bit values for map_cflags */ 12907c478bd9Sstevel@tonic-gate #define MCF_ALIASOK 0x0001 /* can be used for aliases */ 12917c478bd9Sstevel@tonic-gate #define MCF_ALIASONLY 0x0002 /* usable only for aliases */ 12927c478bd9Sstevel@tonic-gate #define MCF_REBUILDABLE 0x0004 /* can rebuild alias files */ 12937c478bd9Sstevel@tonic-gate #define MCF_OPTFILE 0x0008 /* file name is optional */ 12947c478bd9Sstevel@tonic-gate #define MCF_NOTPERSIST 0x0010 /* don't keep map open all the time */ 12957c478bd9Sstevel@tonic-gate 12967c478bd9Sstevel@tonic-gate /* functions */ 12977c478bd9Sstevel@tonic-gate extern void closemaps __P((bool)); 12987c478bd9Sstevel@tonic-gate extern bool impl_map_open __P((MAP *, int)); 12997c478bd9Sstevel@tonic-gate extern void initmaps __P((void)); 13007c478bd9Sstevel@tonic-gate extern MAP *makemapentry __P((char *)); 13017c478bd9Sstevel@tonic-gate extern void maplocaluser __P((ADDRESS *, ADDRESS **, int, ENVELOPE *)); 13027c478bd9Sstevel@tonic-gate extern char *map_rewrite __P((MAP *, const char *, size_t, char **)); 13037c478bd9Sstevel@tonic-gate #if NETINFO 13047c478bd9Sstevel@tonic-gate extern char *ni_propval __P((char *, char *, char *, char *, int)); 13057c478bd9Sstevel@tonic-gate #endif /* NETINFO */ 13067c478bd9Sstevel@tonic-gate extern bool openmap __P((MAP *)); 1307058561cbSjbeck extern int udbexpand __P((ADDRESS *, ADDRESS **, int, ENVELOPE *)); 13087c478bd9Sstevel@tonic-gate #if USERDB 13097c478bd9Sstevel@tonic-gate extern void _udbx_close __P((void)); 13107c478bd9Sstevel@tonic-gate extern char *udbsender __P((char *, SM_RPOOL_T *)); 13117c478bd9Sstevel@tonic-gate #endif /* USERDB */ 13127c478bd9Sstevel@tonic-gate 13137c478bd9Sstevel@tonic-gate /* 13147c478bd9Sstevel@tonic-gate ** LDAP related items 13157c478bd9Sstevel@tonic-gate */ 13167c478bd9Sstevel@tonic-gate #if LDAPMAP 13177c478bd9Sstevel@tonic-gate /* struct defining LDAP Auth Methods */ 13187c478bd9Sstevel@tonic-gate struct lamvalues 13197c478bd9Sstevel@tonic-gate { 13207c478bd9Sstevel@tonic-gate char *lam_name; /* name of LDAP auth method */ 13217c478bd9Sstevel@tonic-gate int lam_code; /* numeric code */ 13227c478bd9Sstevel@tonic-gate }; 13237c478bd9Sstevel@tonic-gate 13247c478bd9Sstevel@tonic-gate /* struct defining LDAP Alias Dereferencing */ 13257c478bd9Sstevel@tonic-gate struct ladvalues 13267c478bd9Sstevel@tonic-gate { 13277c478bd9Sstevel@tonic-gate char *lad_name; /* name of LDAP alias dereferencing method */ 13287c478bd9Sstevel@tonic-gate int lad_code; /* numeric code */ 13297c478bd9Sstevel@tonic-gate }; 13307c478bd9Sstevel@tonic-gate 13317c478bd9Sstevel@tonic-gate /* struct defining LDAP Search Scope */ 13327c478bd9Sstevel@tonic-gate struct lssvalues 13337c478bd9Sstevel@tonic-gate { 13347c478bd9Sstevel@tonic-gate char *lss_name; /* name of LDAP search scope */ 13357c478bd9Sstevel@tonic-gate int lss_code; /* numeric code */ 13367c478bd9Sstevel@tonic-gate }; 13377c478bd9Sstevel@tonic-gate 13387c478bd9Sstevel@tonic-gate /* functions */ 13397c478bd9Sstevel@tonic-gate extern bool ldapmap_parseargs __P((MAP *, char *)); 13407c478bd9Sstevel@tonic-gate extern void ldapmap_set_defaults __P((char *)); 13417c478bd9Sstevel@tonic-gate #endif /* LDAPMAP */ 13427c478bd9Sstevel@tonic-gate 13437c478bd9Sstevel@tonic-gate /* 13447c478bd9Sstevel@tonic-gate ** PH related items 13457c478bd9Sstevel@tonic-gate */ 13467c478bd9Sstevel@tonic-gate 13477c478bd9Sstevel@tonic-gate #if PH_MAP 13487c478bd9Sstevel@tonic-gate 13497c478bd9Sstevel@tonic-gate # include <phclient.h> 13507c478bd9Sstevel@tonic-gate 13517c478bd9Sstevel@tonic-gate struct ph_map_struct 13527c478bd9Sstevel@tonic-gate { 13537c478bd9Sstevel@tonic-gate char *ph_servers; /* list of ph servers */ 13547c478bd9Sstevel@tonic-gate char *ph_field_list; /* list of fields to search for match */ 13557c478bd9Sstevel@tonic-gate PH *ph; /* PH server handle */ 13567c478bd9Sstevel@tonic-gate int ph_fastclose; /* send "quit" command on close */ 13577c478bd9Sstevel@tonic-gate time_t ph_timeout; /* timeout interval */ 13587c478bd9Sstevel@tonic-gate }; 13597c478bd9Sstevel@tonic-gate typedef struct ph_map_struct PH_MAP_STRUCT; 13607c478bd9Sstevel@tonic-gate 13617c478bd9Sstevel@tonic-gate #endif /* PH_MAP */ 13627c478bd9Sstevel@tonic-gate 13637c478bd9Sstevel@tonic-gate /* 13647c478bd9Sstevel@tonic-gate ** Regular UNIX sockaddrs are too small to handle ISO addresses, so 13657c478bd9Sstevel@tonic-gate ** we are forced to declare a supertype here. 13667c478bd9Sstevel@tonic-gate */ 13677c478bd9Sstevel@tonic-gate 13687c478bd9Sstevel@tonic-gate #if NETINET || NETINET6 || NETUNIX || NETISO || NETNS || NETX25 13697c478bd9Sstevel@tonic-gate union bigsockaddr 13707c478bd9Sstevel@tonic-gate { 13717c478bd9Sstevel@tonic-gate struct sockaddr sa; /* general version */ 13727c478bd9Sstevel@tonic-gate # if NETUNIX 13737c478bd9Sstevel@tonic-gate struct sockaddr_un sunix; /* UNIX family */ 13747c478bd9Sstevel@tonic-gate # endif /* NETUNIX */ 13757c478bd9Sstevel@tonic-gate # if NETINET 13767c478bd9Sstevel@tonic-gate struct sockaddr_in sin; /* INET family */ 13777c478bd9Sstevel@tonic-gate # endif /* NETINET */ 13787c478bd9Sstevel@tonic-gate # if NETINET6 13797c478bd9Sstevel@tonic-gate struct sockaddr_in6 sin6; /* INET/IPv6 */ 13807c478bd9Sstevel@tonic-gate # endif /* NETINET6 */ 13817c478bd9Sstevel@tonic-gate # if NETISO 13827c478bd9Sstevel@tonic-gate struct sockaddr_iso siso; /* ISO family */ 13837c478bd9Sstevel@tonic-gate # endif /* NETISO */ 13847c478bd9Sstevel@tonic-gate # if NETNS 13857c478bd9Sstevel@tonic-gate struct sockaddr_ns sns; /* XNS family */ 13867c478bd9Sstevel@tonic-gate # endif /* NETNS */ 13877c478bd9Sstevel@tonic-gate # if NETX25 13887c478bd9Sstevel@tonic-gate struct sockaddr_x25 sx25; /* X.25 family */ 13897c478bd9Sstevel@tonic-gate # endif /* NETX25 */ 13907c478bd9Sstevel@tonic-gate }; 13917c478bd9Sstevel@tonic-gate 13927c478bd9Sstevel@tonic-gate # define SOCKADDR union bigsockaddr 13937c478bd9Sstevel@tonic-gate 13947c478bd9Sstevel@tonic-gate /* functions */ 13957c478bd9Sstevel@tonic-gate extern char *anynet_ntoa __P((SOCKADDR *)); 13967c478bd9Sstevel@tonic-gate # if NETINET6 13977c478bd9Sstevel@tonic-gate extern char *anynet_ntop __P((struct in6_addr *, char *, size_t)); 13987c478bd9Sstevel@tonic-gate extern int anynet_pton __P((int, const char *, void *)); 13997c478bd9Sstevel@tonic-gate # endif /* NETINET6 */ 14007c478bd9Sstevel@tonic-gate extern char *hostnamebyanyaddr __P((SOCKADDR *)); 14017c478bd9Sstevel@tonic-gate extern char *validate_connection __P((SOCKADDR *, char *, ENVELOPE *)); 14027c478bd9Sstevel@tonic-gate # if SASL >= 20000 14037c478bd9Sstevel@tonic-gate extern bool iptostring __P((SOCKADDR *, SOCKADDR_LEN_T, char *, unsigned)); 14047c478bd9Sstevel@tonic-gate # endif /* SASL >= 20000 */ 14057c478bd9Sstevel@tonic-gate 14067c478bd9Sstevel@tonic-gate #endif /* NETINET || NETINET6 || NETUNIX || NETISO || NETNS || NETX25 */ 14077c478bd9Sstevel@tonic-gate 14087c478bd9Sstevel@tonic-gate /* 14097c478bd9Sstevel@tonic-gate ** Process List (proclist) 14107c478bd9Sstevel@tonic-gate */ 14117c478bd9Sstevel@tonic-gate 14127c478bd9Sstevel@tonic-gate #define NO_PID ((pid_t) 0) 14137c478bd9Sstevel@tonic-gate #ifndef PROC_LIST_SEG 14147c478bd9Sstevel@tonic-gate # define PROC_LIST_SEG 32 /* number of pids to alloc at a time */ 14157c478bd9Sstevel@tonic-gate #endif /* ! PROC_LIST_SEG */ 14167c478bd9Sstevel@tonic-gate 14177c478bd9Sstevel@tonic-gate /* process types */ 14187c478bd9Sstevel@tonic-gate #define PROC_NONE 0 14197c478bd9Sstevel@tonic-gate #define PROC_DAEMON 1 14207c478bd9Sstevel@tonic-gate #define PROC_DAEMON_CHILD 2 14217c478bd9Sstevel@tonic-gate #define PROC_QUEUE 3 14227c478bd9Sstevel@tonic-gate #define PROC_QUEUE_CHILD 3 14237c478bd9Sstevel@tonic-gate #define PROC_CONTROL 4 14247c478bd9Sstevel@tonic-gate #define PROC_CONTROL_CHILD 5 14257c478bd9Sstevel@tonic-gate 14267c478bd9Sstevel@tonic-gate /* functions */ 14277c478bd9Sstevel@tonic-gate extern void proc_list_add __P((pid_t, char *, int, int, int, SOCKADDR *)); 14287c478bd9Sstevel@tonic-gate extern void proc_list_clear __P((void)); 14297c478bd9Sstevel@tonic-gate extern void proc_list_display __P((SM_FILE_T *, char *)); 14307c478bd9Sstevel@tonic-gate extern void proc_list_drop __P((pid_t, int, int *)); 14317c478bd9Sstevel@tonic-gate extern void proc_list_probe __P((void)); 14327c478bd9Sstevel@tonic-gate extern void proc_list_set __P((pid_t, char *)); 14337c478bd9Sstevel@tonic-gate extern void proc_list_signal __P((int, int)); 14347c478bd9Sstevel@tonic-gate 14357c478bd9Sstevel@tonic-gate /* 14367c478bd9Sstevel@tonic-gate ** Symbol table definitions 14377c478bd9Sstevel@tonic-gate */ 14387c478bd9Sstevel@tonic-gate 14397c478bd9Sstevel@tonic-gate struct symtab 14407c478bd9Sstevel@tonic-gate { 14417c478bd9Sstevel@tonic-gate char *s_name; /* name to be entered */ 14427c478bd9Sstevel@tonic-gate short s_symtype; /* general type (see below) */ 14437c478bd9Sstevel@tonic-gate struct symtab *s_next; /* pointer to next in chain */ 14447c478bd9Sstevel@tonic-gate union 14457c478bd9Sstevel@tonic-gate { 14467c478bd9Sstevel@tonic-gate BITMAP256 sv_class; /* bit-map of word classes */ 14477c478bd9Sstevel@tonic-gate ADDRESS *sv_addr; /* pointer to address header */ 14487c478bd9Sstevel@tonic-gate MAILER *sv_mailer; /* pointer to mailer */ 14497c478bd9Sstevel@tonic-gate char *sv_alias; /* alias */ 14507c478bd9Sstevel@tonic-gate MAPCLASS sv_mapclass; /* mapping function class */ 14517c478bd9Sstevel@tonic-gate MAP sv_map; /* mapping function */ 14527c478bd9Sstevel@tonic-gate HOSTSIG_T sv_hostsig; /* host signature */ 14537c478bd9Sstevel@tonic-gate MCI sv_mci; /* mailer connection info */ 14547c478bd9Sstevel@tonic-gate NAMECANON sv_namecanon; /* canonical name cache */ 14557c478bd9Sstevel@tonic-gate int sv_macro; /* macro name => id mapping */ 14567c478bd9Sstevel@tonic-gate int sv_ruleset; /* ruleset index */ 14577c478bd9Sstevel@tonic-gate struct hdrinfo sv_header; /* header metainfo */ 14587c478bd9Sstevel@tonic-gate char *sv_service[MAXMAPSTACK]; /* service switch */ 14597c478bd9Sstevel@tonic-gate #if LDAPMAP 14607c478bd9Sstevel@tonic-gate MAP *sv_lmap; /* Maps for LDAP connection */ 14617c478bd9Sstevel@tonic-gate #endif /* LDAPMAP */ 14627c478bd9Sstevel@tonic-gate #if SOCKETMAP 14637c478bd9Sstevel@tonic-gate MAP *sv_socketmap; /* Maps for SOCKET connection */ 14647c478bd9Sstevel@tonic-gate #endif /* SOCKETMAP */ 14657c478bd9Sstevel@tonic-gate #if MILTER 14667c478bd9Sstevel@tonic-gate struct milter *sv_milter; /* milter filter name */ 14677c478bd9Sstevel@tonic-gate #endif /* MILTER */ 14687c478bd9Sstevel@tonic-gate QUEUEGRP *sv_queue; /* pointer to queue */ 14697c478bd9Sstevel@tonic-gate } s_value; 14707c478bd9Sstevel@tonic-gate }; 14717c478bd9Sstevel@tonic-gate 14727c478bd9Sstevel@tonic-gate typedef struct symtab STAB; 14737c478bd9Sstevel@tonic-gate 14747c478bd9Sstevel@tonic-gate /* symbol types */ 14757c478bd9Sstevel@tonic-gate #define ST_UNDEF 0 /* undefined type */ 14767c478bd9Sstevel@tonic-gate #define ST_CLASS 1 /* class map */ 14777c478bd9Sstevel@tonic-gate #define ST_ADDRESS 2 /* an address in parsed format */ 14787c478bd9Sstevel@tonic-gate #define ST_MAILER 3 /* a mailer header */ 14797c478bd9Sstevel@tonic-gate #define ST_ALIAS 4 /* an alias */ 14807c478bd9Sstevel@tonic-gate #define ST_MAPCLASS 5 /* mapping function class */ 14817c478bd9Sstevel@tonic-gate #define ST_MAP 6 /* mapping function */ 14827c478bd9Sstevel@tonic-gate #define ST_HOSTSIG 7 /* host signature */ 14837c478bd9Sstevel@tonic-gate #define ST_NAMECANON 8 /* cached canonical name */ 14847c478bd9Sstevel@tonic-gate #define ST_MACRO 9 /* macro name to id mapping */ 14857c478bd9Sstevel@tonic-gate #define ST_RULESET 10 /* ruleset index */ 14867c478bd9Sstevel@tonic-gate #define ST_SERVICE 11 /* service switch entry */ 14877c478bd9Sstevel@tonic-gate #define ST_HEADER 12 /* special header flags */ 14887c478bd9Sstevel@tonic-gate #if LDAPMAP 14897c478bd9Sstevel@tonic-gate # define ST_LMAP 13 /* List head of maps for LDAP connection */ 14907c478bd9Sstevel@tonic-gate #endif /* LDAPMAP */ 14917c478bd9Sstevel@tonic-gate #if MILTER 14927c478bd9Sstevel@tonic-gate # define ST_MILTER 14 /* milter filter */ 14937c478bd9Sstevel@tonic-gate #endif /* MILTER */ 14947c478bd9Sstevel@tonic-gate #define ST_QUEUE 15 /* a queue entry */ 14957c478bd9Sstevel@tonic-gate 14967c478bd9Sstevel@tonic-gate #if SOCKETMAP 14977c478bd9Sstevel@tonic-gate # define ST_SOCKETMAP 16 /* List head of maps for SOCKET connection */ 14987c478bd9Sstevel@tonic-gate #endif /* SOCKETMAP */ 14997c478bd9Sstevel@tonic-gate 15007c478bd9Sstevel@tonic-gate /* This entry must be last */ 15017c478bd9Sstevel@tonic-gate #define ST_MCI 17 /* mailer connection info (offset) */ 15027c478bd9Sstevel@tonic-gate 15037c478bd9Sstevel@tonic-gate #define s_class s_value.sv_class 15047c478bd9Sstevel@tonic-gate #define s_address s_value.sv_addr 15057c478bd9Sstevel@tonic-gate #define s_mailer s_value.sv_mailer 15067c478bd9Sstevel@tonic-gate #define s_alias s_value.sv_alias 15077c478bd9Sstevel@tonic-gate #define s_mci s_value.sv_mci 15087c478bd9Sstevel@tonic-gate #define s_mapclass s_value.sv_mapclass 15097c478bd9Sstevel@tonic-gate #define s_hostsig s_value.sv_hostsig 15107c478bd9Sstevel@tonic-gate #define s_map s_value.sv_map 15117c478bd9Sstevel@tonic-gate #define s_namecanon s_value.sv_namecanon 15127c478bd9Sstevel@tonic-gate #define s_macro s_value.sv_macro 15137c478bd9Sstevel@tonic-gate #define s_ruleset s_value.sv_ruleset 15147c478bd9Sstevel@tonic-gate #define s_service s_value.sv_service 15157c478bd9Sstevel@tonic-gate #define s_header s_value.sv_header 15167c478bd9Sstevel@tonic-gate #if LDAPMAP 15177c478bd9Sstevel@tonic-gate # define s_lmap s_value.sv_lmap 15187c478bd9Sstevel@tonic-gate #endif /* LDAPMAP */ 15197c478bd9Sstevel@tonic-gate #if SOCKETMAP 15207c478bd9Sstevel@tonic-gate # define s_socketmap s_value.sv_socketmap 15217c478bd9Sstevel@tonic-gate #endif /* SOCKETMAP */ 15227c478bd9Sstevel@tonic-gate #if MILTER 15237c478bd9Sstevel@tonic-gate # define s_milter s_value.sv_milter 15247c478bd9Sstevel@tonic-gate #endif /* MILTER */ 15257c478bd9Sstevel@tonic-gate #define s_quegrp s_value.sv_queue 15267c478bd9Sstevel@tonic-gate 15277c478bd9Sstevel@tonic-gate /* opcodes to stab */ 15287c478bd9Sstevel@tonic-gate #define ST_FIND 0 /* find entry */ 15297c478bd9Sstevel@tonic-gate #define ST_ENTER 1 /* enter if not there */ 15307c478bd9Sstevel@tonic-gate 15317c478bd9Sstevel@tonic-gate /* functions */ 15327c478bd9Sstevel@tonic-gate extern STAB *stab __P((char *, int, int)); 15337c478bd9Sstevel@tonic-gate extern void stabapply __P((void (*)(STAB *, int), int)); 15347c478bd9Sstevel@tonic-gate 15357c478bd9Sstevel@tonic-gate /* 15367c478bd9Sstevel@tonic-gate ** Operation, send, error, and MIME modes 15377c478bd9Sstevel@tonic-gate ** 15387c478bd9Sstevel@tonic-gate ** The operation mode describes the basic operation of sendmail. 15397c478bd9Sstevel@tonic-gate ** This can be set from the command line, and is "send mail" by 15407c478bd9Sstevel@tonic-gate ** default. 15417c478bd9Sstevel@tonic-gate ** 15427c478bd9Sstevel@tonic-gate ** The send mode tells how to send mail. It can be set in the 15437c478bd9Sstevel@tonic-gate ** configuration file. Its setting determines how quickly the 15447c478bd9Sstevel@tonic-gate ** mail will be delivered versus the load on your system. If the 15457c478bd9Sstevel@tonic-gate ** -v (verbose) flag is given, it will be forced to SM_DELIVER 15467c478bd9Sstevel@tonic-gate ** mode. 15477c478bd9Sstevel@tonic-gate ** 15487c478bd9Sstevel@tonic-gate ** The error mode tells how to return errors. 15497c478bd9Sstevel@tonic-gate */ 15507c478bd9Sstevel@tonic-gate 15517c478bd9Sstevel@tonic-gate #define MD_DELIVER 'm' /* be a mail sender */ 15527c478bd9Sstevel@tonic-gate #define MD_SMTP 's' /* run SMTP on standard input */ 15537c478bd9Sstevel@tonic-gate #define MD_ARPAFTP 'a' /* obsolete ARPANET mode (Grey Book) */ 15547c478bd9Sstevel@tonic-gate #define MD_DAEMON 'd' /* run as a daemon */ 15557c478bd9Sstevel@tonic-gate #define MD_FGDAEMON 'D' /* run daemon in foreground */ 15567c478bd9Sstevel@tonic-gate #define MD_VERIFY 'v' /* verify: don't collect or deliver */ 15577c478bd9Sstevel@tonic-gate #define MD_TEST 't' /* test mode: resolve addrs only */ 15587c478bd9Sstevel@tonic-gate #define MD_INITALIAS 'i' /* initialize alias database */ 15597c478bd9Sstevel@tonic-gate #define MD_PRINT 'p' /* print the queue */ 15607c478bd9Sstevel@tonic-gate #define MD_PRINTNQE 'P' /* print number of entries in queue */ 15617c478bd9Sstevel@tonic-gate #define MD_FREEZE 'z' /* freeze the configuration file */ 15627c478bd9Sstevel@tonic-gate #define MD_HOSTSTAT 'h' /* print persistent host stat info */ 15637c478bd9Sstevel@tonic-gate #define MD_PURGESTAT 'H' /* purge persistent host stat info */ 15647c478bd9Sstevel@tonic-gate #define MD_QUEUERUN 'q' /* queue run */ 15657c478bd9Sstevel@tonic-gate 15667c478bd9Sstevel@tonic-gate /* Note: see also include/sendmail/pathnames.h: GET_CLIENT_CF */ 15677c478bd9Sstevel@tonic-gate 15687c478bd9Sstevel@tonic-gate /* values for e_sendmode -- send modes */ 15697c478bd9Sstevel@tonic-gate #define SM_DELIVER 'i' /* interactive delivery */ 15707c478bd9Sstevel@tonic-gate #define SM_FORK 'b' /* deliver in background */ 1571445f2479Sjbeck #if _FFR_DM_ONE 1572445f2479Sjbeck #define SM_DM_ONE 'o' /* deliver first TA in background, then queue */ 1573445f2479Sjbeck #endif /* _FFR_DM_ONE */ 15747c478bd9Sstevel@tonic-gate #define SM_QUEUE 'q' /* queue, don't deliver */ 15757c478bd9Sstevel@tonic-gate #define SM_DEFER 'd' /* defer map lookups as well as queue */ 15767c478bd9Sstevel@tonic-gate #define SM_VERIFY 'v' /* verify only (used internally) */ 157749218d4fSjbeck #define DM_NOTSET (-1) /* DeliveryMode (per daemon) option not set */ 15787c478bd9Sstevel@tonic-gate 15797c478bd9Sstevel@tonic-gate #define WILL_BE_QUEUED(m) ((m) == SM_QUEUE || (m) == SM_DEFER) 15807c478bd9Sstevel@tonic-gate 15817c478bd9Sstevel@tonic-gate /* used only as a parameter to sendall */ 15827c478bd9Sstevel@tonic-gate #define SM_DEFAULT '\0' /* unspecified, use SendMode */ 15837c478bd9Sstevel@tonic-gate 15847c478bd9Sstevel@tonic-gate /* functions */ 15857c478bd9Sstevel@tonic-gate extern void set_delivery_mode __P((int, ENVELOPE *)); 15867c478bd9Sstevel@tonic-gate 15877c478bd9Sstevel@tonic-gate /* values for e_errormode -- error handling modes */ 15887c478bd9Sstevel@tonic-gate #define EM_PRINT 'p' /* print errors */ 15897c478bd9Sstevel@tonic-gate #define EM_MAIL 'm' /* mail back errors */ 15907c478bd9Sstevel@tonic-gate #define EM_WRITE 'w' /* write back errors */ 15917c478bd9Sstevel@tonic-gate #define EM_BERKNET 'e' /* special berknet processing */ 15927c478bd9Sstevel@tonic-gate #define EM_QUIET 'q' /* don't print messages (stat only) */ 15937c478bd9Sstevel@tonic-gate 15947c478bd9Sstevel@tonic-gate 15957c478bd9Sstevel@tonic-gate /* bit values for MimeMode */ 15967c478bd9Sstevel@tonic-gate #define MM_CVTMIME 0x0001 /* convert 8 to 7 bit MIME */ 15977c478bd9Sstevel@tonic-gate #define MM_PASS8BIT 0x0002 /* just send 8 bit data blind */ 15987c478bd9Sstevel@tonic-gate #define MM_MIME8BIT 0x0004 /* convert 8-bit data to MIME */ 15997c478bd9Sstevel@tonic-gate 16007c478bd9Sstevel@tonic-gate 16017c478bd9Sstevel@tonic-gate /* how to handle messages without any recipient addresses */ 16027c478bd9Sstevel@tonic-gate #define NRA_NO_ACTION 0 /* just leave it as is */ 16037c478bd9Sstevel@tonic-gate #define NRA_ADD_TO 1 /* add To: header */ 16047c478bd9Sstevel@tonic-gate #define NRA_ADD_APPARENTLY_TO 2 /* add Apparently-To: header */ 16057c478bd9Sstevel@tonic-gate #define NRA_ADD_BCC 3 /* add empty Bcc: header */ 16067c478bd9Sstevel@tonic-gate #define NRA_ADD_TO_UNDISCLOSED 4 /* add To: undisclosed:; header */ 16077c478bd9Sstevel@tonic-gate 16087c478bd9Sstevel@tonic-gate 16097c478bd9Sstevel@tonic-gate /* flags to putxline */ 16107c478bd9Sstevel@tonic-gate #define PXLF_NOTHINGSPECIAL 0 /* no special mapping */ 16117c478bd9Sstevel@tonic-gate #define PXLF_MAPFROM 0x0001 /* map From_ to >From_ */ 16127c478bd9Sstevel@tonic-gate #define PXLF_STRIP8BIT 0x0002 /* strip 8th bit */ 16137c478bd9Sstevel@tonic-gate #define PXLF_HEADER 0x0004 /* map newlines in headers */ 16147c478bd9Sstevel@tonic-gate #define PXLF_NOADDEOL 0x0008 /* if EOL not present, don't add one */ 1615058561cbSjbeck #define PXLF_STRIPMQUOTE 0x0010 /* strip METAQUOTEs */ 16167c478bd9Sstevel@tonic-gate 16177c478bd9Sstevel@tonic-gate /* 16187c478bd9Sstevel@tonic-gate ** Privacy flags 16197c478bd9Sstevel@tonic-gate ** These are bit values for the PrivacyFlags word. 16207c478bd9Sstevel@tonic-gate */ 16217c478bd9Sstevel@tonic-gate 16227c478bd9Sstevel@tonic-gate #define PRIV_PUBLIC 0 /* what have I got to hide? */ 16237c478bd9Sstevel@tonic-gate #define PRIV_NEEDMAILHELO 0x00000001 /* insist on HELO for MAIL */ 16247c478bd9Sstevel@tonic-gate #define PRIV_NEEDEXPNHELO 0x00000002 /* insist on HELO for EXPN */ 16257c478bd9Sstevel@tonic-gate #define PRIV_NEEDVRFYHELO 0x00000004 /* insist on HELO for VRFY */ 16267c478bd9Sstevel@tonic-gate #define PRIV_NOEXPN 0x00000008 /* disallow EXPN command */ 16277c478bd9Sstevel@tonic-gate #define PRIV_NOVRFY 0x00000010 /* disallow VRFY command */ 16287c478bd9Sstevel@tonic-gate #define PRIV_AUTHWARNINGS 0x00000020 /* flag possible auth probs */ 16297c478bd9Sstevel@tonic-gate #define PRIV_NOVERB 0x00000040 /* disallow VERB command */ 16307c478bd9Sstevel@tonic-gate #define PRIV_RESTRICTMAILQ 0x00010000 /* restrict mailq command */ 16317c478bd9Sstevel@tonic-gate #define PRIV_RESTRICTQRUN 0x00020000 /* restrict queue run */ 16327c478bd9Sstevel@tonic-gate #define PRIV_RESTRICTEXPAND 0x00040000 /* restrict alias/forward expansion */ 16337c478bd9Sstevel@tonic-gate #define PRIV_NOETRN 0x00080000 /* disallow ETRN command */ 16347c478bd9Sstevel@tonic-gate #define PRIV_NOBODYRETN 0x00100000 /* do not return bodies on bounces */ 16357c478bd9Sstevel@tonic-gate #define PRIV_NORECEIPTS 0x00200000 /* disallow return receipts */ 1636058561cbSjbeck #define PRIV_NOACTUALRECIPIENT 0x00400000 /* no X-Actual-Recipient in DSNs */ 16377c478bd9Sstevel@tonic-gate 16384aac33d3Sjbeck /* don't give no info, anyway, anyhow (in the main SMTP transaction) */ 16397c478bd9Sstevel@tonic-gate #define PRIV_GOAWAY 0x0000ffff 16407c478bd9Sstevel@tonic-gate 16417c478bd9Sstevel@tonic-gate /* struct defining such things */ 16427c478bd9Sstevel@tonic-gate struct prival 16437c478bd9Sstevel@tonic-gate { 16447c478bd9Sstevel@tonic-gate char *pv_name; /* name of privacy flag */ 16457c478bd9Sstevel@tonic-gate unsigned long pv_flag; /* numeric level */ 16467c478bd9Sstevel@tonic-gate }; 16477c478bd9Sstevel@tonic-gate 16487c478bd9Sstevel@tonic-gate EXTERN unsigned long PrivacyFlags; /* privacy flags */ 16497c478bd9Sstevel@tonic-gate 16507c478bd9Sstevel@tonic-gate 16517c478bd9Sstevel@tonic-gate /* 16527c478bd9Sstevel@tonic-gate ** Flags passed to remotename, parseaddr, allocaddr, and buildaddr. 16537c478bd9Sstevel@tonic-gate */ 16547c478bd9Sstevel@tonic-gate 16557c478bd9Sstevel@tonic-gate #define RF_SENDERADDR 0x001 /* this is a sender address */ 16567c478bd9Sstevel@tonic-gate #define RF_HEADERADDR 0x002 /* this is a header address */ 16577c478bd9Sstevel@tonic-gate #define RF_CANONICAL 0x004 /* strip comment information */ 16587c478bd9Sstevel@tonic-gate #define RF_ADDDOMAIN 0x008 /* OK to do domain extension */ 16597c478bd9Sstevel@tonic-gate #define RF_COPYPARSE 0x010 /* copy parsed user & host */ 16607c478bd9Sstevel@tonic-gate #define RF_COPYPADDR 0x020 /* copy print address */ 16617c478bd9Sstevel@tonic-gate #define RF_COPYALL (RF_COPYPARSE|RF_COPYPADDR) 16627c478bd9Sstevel@tonic-gate #define RF_COPYNONE 0 1663058561cbSjbeck #define RF_RM_ADDR 0x040 /* address to be removed */ 16647c478bd9Sstevel@tonic-gate 16657c478bd9Sstevel@tonic-gate /* 16667c478bd9Sstevel@tonic-gate ** Flags passed to rscheck 16677c478bd9Sstevel@tonic-gate */ 16687c478bd9Sstevel@tonic-gate 16697c478bd9Sstevel@tonic-gate #define RSF_RMCOMM 0x0001 /* strip comments */ 16707c478bd9Sstevel@tonic-gate #define RSF_UNSTRUCTURED 0x0002 /* unstructured, ignore syntax errors */ 16717c478bd9Sstevel@tonic-gate #define RSF_COUNT 0x0004 /* count rejections (statistics)? */ 16727c478bd9Sstevel@tonic-gate 16737c478bd9Sstevel@tonic-gate /* 16747c478bd9Sstevel@tonic-gate ** Flags passed to mime8to7 and putheader. 16757c478bd9Sstevel@tonic-gate */ 16767c478bd9Sstevel@tonic-gate 16777c478bd9Sstevel@tonic-gate #define M87F_OUTER 0 /* outer context */ 16787c478bd9Sstevel@tonic-gate #define M87F_NO8BIT 0x0001 /* can't have 8-bit in this section */ 16797c478bd9Sstevel@tonic-gate #define M87F_DIGEST 0x0002 /* processing multipart/digest */ 16807c478bd9Sstevel@tonic-gate #define M87F_NO8TO7 0x0004 /* don't do 8->7 bit conversions */ 16817c478bd9Sstevel@tonic-gate 16827c478bd9Sstevel@tonic-gate /* functions */ 1683445f2479Sjbeck extern bool mime7to8 __P((MCI *, HDR *, ENVELOPE *)); 16843ee0e492Sjbeck extern int mime8to7 __P((MCI *, HDR *, ENVELOPE *, char **, int, int)); 16857c478bd9Sstevel@tonic-gate 16867c478bd9Sstevel@tonic-gate /* 16877c478bd9Sstevel@tonic-gate ** Flags passed to returntosender. 16887c478bd9Sstevel@tonic-gate */ 16897c478bd9Sstevel@tonic-gate 16907c478bd9Sstevel@tonic-gate #define RTSF_NO_BODY 0 /* send headers only */ 16917c478bd9Sstevel@tonic-gate #define RTSF_SEND_BODY 0x0001 /* include body of message in return */ 16927c478bd9Sstevel@tonic-gate #define RTSF_PM_BOUNCE 0x0002 /* this is a postmaster bounce */ 16937c478bd9Sstevel@tonic-gate 16947c478bd9Sstevel@tonic-gate /* functions */ 16957c478bd9Sstevel@tonic-gate extern int returntosender __P((char *, ADDRESS *, int, ENVELOPE *)); 16967c478bd9Sstevel@tonic-gate 16977c478bd9Sstevel@tonic-gate /* 16987c478bd9Sstevel@tonic-gate ** Mail Filters (milter) 16997c478bd9Sstevel@tonic-gate */ 17007c478bd9Sstevel@tonic-gate 17017c478bd9Sstevel@tonic-gate /* 17027c478bd9Sstevel@tonic-gate ** 32-bit type used by milter 17037c478bd9Sstevel@tonic-gate ** (needed by libmilter even if MILTER isn't defined) 17047c478bd9Sstevel@tonic-gate */ 17057c478bd9Sstevel@tonic-gate 17067c478bd9Sstevel@tonic-gate typedef SM_INT32 mi_int32; 17077c478bd9Sstevel@tonic-gate 17087c478bd9Sstevel@tonic-gate #if MILTER 17097c478bd9Sstevel@tonic-gate # define SMFTO_WRITE 0 /* Timeout for sending information */ 17107c478bd9Sstevel@tonic-gate # define SMFTO_READ 1 /* Timeout waiting for a response */ 17117c478bd9Sstevel@tonic-gate # define SMFTO_EOM 2 /* Timeout for ACK/NAK to EOM */ 17127c478bd9Sstevel@tonic-gate # define SMFTO_CONNECT 3 /* Timeout for connect() */ 17137c478bd9Sstevel@tonic-gate 17147c478bd9Sstevel@tonic-gate # define SMFTO_NUM_TO 4 /* Total number of timeouts */ 17157c478bd9Sstevel@tonic-gate 17167c478bd9Sstevel@tonic-gate struct milter 17177c478bd9Sstevel@tonic-gate { 17187c478bd9Sstevel@tonic-gate char *mf_name; /* filter name */ 17197c478bd9Sstevel@tonic-gate BITMAP256 mf_flags; /* MTA flags */ 17207c478bd9Sstevel@tonic-gate mi_int32 mf_fvers; /* filter version */ 17217c478bd9Sstevel@tonic-gate mi_int32 mf_fflags; /* filter flags */ 17227c478bd9Sstevel@tonic-gate mi_int32 mf_pflags; /* protocol flags */ 17237c478bd9Sstevel@tonic-gate char *mf_conn; /* connection info */ 17247c478bd9Sstevel@tonic-gate int mf_sock; /* connected socket */ 17257c478bd9Sstevel@tonic-gate char mf_state; /* state of filter */ 17267c478bd9Sstevel@tonic-gate time_t mf_timeout[SMFTO_NUM_TO]; /* timeouts */ 17274aac33d3Sjbeck #if _FFR_MILTER_CHECK 1728058561cbSjbeck /* for testing only */ 1729058561cbSjbeck mi_int32 mf_mta_prot_version; 1730058561cbSjbeck mi_int32 mf_mta_prot_flags; 1731058561cbSjbeck mi_int32 mf_mta_actions; 17324aac33d3Sjbeck #endif /* _FFR_MILTER_CHECK */ 17337c478bd9Sstevel@tonic-gate }; 17347c478bd9Sstevel@tonic-gate 1735*7800901eSjbeck struct milters 1736*7800901eSjbeck { 1737*7800901eSjbeck mi_int32 mis_flags; /* filter flags */ 1738*7800901eSjbeck }; 1739*7800901eSjbeck typedef struct milters milters_T; 1740*7800901eSjbeck 1741*7800901eSjbeck #define MIS_FL_NONE 0x00000000 /* no requirements... */ 1742*7800901eSjbeck #define MIS_FL_DEL_RCPT 0x00000001 /* can delete rcpt */ 1743*7800901eSjbeck #define MIS_FL_REJ_RCPT 0x00000002 /* can reject rcpt */ 1744*7800901eSjbeck 1745*7800901eSjbeck 17467c478bd9Sstevel@tonic-gate /* MTA flags */ 17477c478bd9Sstevel@tonic-gate # define SMF_REJECT 'R' /* Reject connection on filter fail */ 17487c478bd9Sstevel@tonic-gate # define SMF_TEMPFAIL 'T' /* tempfail connection on failure */ 17497c478bd9Sstevel@tonic-gate # define SMF_TEMPDROP '4' /* 421 connection on failure */ 17507c478bd9Sstevel@tonic-gate 17517c478bd9Sstevel@tonic-gate EXTERN struct milter *InputFilters[MAXFILTERS]; 17527c478bd9Sstevel@tonic-gate EXTERN char *InputFilterList; 17537c478bd9Sstevel@tonic-gate EXTERN int MilterLogLevel; 17547c478bd9Sstevel@tonic-gate 17557c478bd9Sstevel@tonic-gate /* functions */ 17567c478bd9Sstevel@tonic-gate extern void setup_daemon_milters __P((void)); 17577c478bd9Sstevel@tonic-gate #endif /* MILTER */ 17587c478bd9Sstevel@tonic-gate 17597c478bd9Sstevel@tonic-gate /* 17607c478bd9Sstevel@tonic-gate ** Vendor codes 17617c478bd9Sstevel@tonic-gate ** 17627c478bd9Sstevel@tonic-gate ** Vendors can customize sendmail to add special behaviour, 17637c478bd9Sstevel@tonic-gate ** generally for back compatibility. Ideally, this should 17647c478bd9Sstevel@tonic-gate ** be set up in the .cf file using the "V" command. However, 17657c478bd9Sstevel@tonic-gate ** it's quite reasonable for some vendors to want the default 17667c478bd9Sstevel@tonic-gate ** be their old version; this can be set using 17677c478bd9Sstevel@tonic-gate ** -DVENDOR_DEFAULT=VENDOR_xxx 17687c478bd9Sstevel@tonic-gate ** in the Makefile. 17697c478bd9Sstevel@tonic-gate ** 17707c478bd9Sstevel@tonic-gate ** Vendors should apply to sendmail@sendmail.org for 17717c478bd9Sstevel@tonic-gate ** unique vendor codes. 17727c478bd9Sstevel@tonic-gate */ 17737c478bd9Sstevel@tonic-gate 17747c478bd9Sstevel@tonic-gate #define VENDOR_BERKELEY 1 /* Berkeley-native configuration file */ 17757c478bd9Sstevel@tonic-gate #define VENDOR_SUN 2 /* Sun-native configuration file */ 17767c478bd9Sstevel@tonic-gate #define VENDOR_HP 3 /* Hewlett-Packard specific config syntax */ 17777c478bd9Sstevel@tonic-gate #define VENDOR_IBM 4 /* IBM specific config syntax */ 17787c478bd9Sstevel@tonic-gate #define VENDOR_SENDMAIL 5 /* Sendmail, Inc. specific config syntax */ 17797c478bd9Sstevel@tonic-gate #define VENDOR_DEC 6 /* Compaq, DEC, Digital */ 17807c478bd9Sstevel@tonic-gate 17817c478bd9Sstevel@tonic-gate /* prototypes for vendor-specific hook routines */ 17827c478bd9Sstevel@tonic-gate extern void vendor_daemon_setup __P((ENVELOPE *)); 17837c478bd9Sstevel@tonic-gate extern void vendor_set_uid __P((UID_T)); 17847c478bd9Sstevel@tonic-gate 17857c478bd9Sstevel@tonic-gate 17867c478bd9Sstevel@tonic-gate /* 17877c478bd9Sstevel@tonic-gate ** Terminal escape codes. 17887c478bd9Sstevel@tonic-gate ** 17897c478bd9Sstevel@tonic-gate ** To make debugging output clearer. 17907c478bd9Sstevel@tonic-gate */ 17917c478bd9Sstevel@tonic-gate 17927c478bd9Sstevel@tonic-gate struct termescape 17937c478bd9Sstevel@tonic-gate { 17947c478bd9Sstevel@tonic-gate char *te_rv_on; /* turn reverse-video on */ 1795058561cbSjbeck char *te_under_on; /* turn underlining on */ 1796058561cbSjbeck char *te_normal; /* revert to normal output */ 17977c478bd9Sstevel@tonic-gate }; 17987c478bd9Sstevel@tonic-gate 17997c478bd9Sstevel@tonic-gate /* 18007c478bd9Sstevel@tonic-gate ** Additional definitions 18017c478bd9Sstevel@tonic-gate */ 18027c478bd9Sstevel@tonic-gate 18037c478bd9Sstevel@tonic-gate /* 18047c478bd9Sstevel@tonic-gate ** d_flags, see daemon.c 18057c478bd9Sstevel@tonic-gate ** general rule: lower case: required, upper case: No 18067c478bd9Sstevel@tonic-gate */ 18077c478bd9Sstevel@tonic-gate 18087c478bd9Sstevel@tonic-gate #define D_AUTHREQ 'a' /* authentication required */ 18097c478bd9Sstevel@tonic-gate #define D_BINDIF 'b' /* use if_addr for outgoing connection */ 18107c478bd9Sstevel@tonic-gate #define D_CANONREQ 'c' /* canonification required (cf) */ 18117c478bd9Sstevel@tonic-gate #define D_IFNHELO 'h' /* use if name for HELO */ 18127c478bd9Sstevel@tonic-gate #define D_FQMAIL 'f' /* fq sender address required (cf) */ 18137c478bd9Sstevel@tonic-gate #define D_FQRCPT 'r' /* fq recipient address required (cf) */ 18147c478bd9Sstevel@tonic-gate #define D_SMTPS 's' /* SMTP over SSL (smtps) */ 18157c478bd9Sstevel@tonic-gate #define D_UNQUALOK 'u' /* unqualified address is ok (cf) */ 18167c478bd9Sstevel@tonic-gate #define D_NOAUTH 'A' /* no AUTH */ 18177c478bd9Sstevel@tonic-gate #define D_NOCANON 'C' /* no canonification (cf) */ 18187c478bd9Sstevel@tonic-gate #define D_NOETRN 'E' /* no ETRN (MSA) */ 18197c478bd9Sstevel@tonic-gate #define D_NOTLS 'S' /* don't use STARTTLS */ 18207c478bd9Sstevel@tonic-gate #define D_ETRNONLY ((char)0x01) /* allow only ETRN (disk low) */ 18217c478bd9Sstevel@tonic-gate #define D_OPTIONAL 'O' /* optional socket */ 18227c478bd9Sstevel@tonic-gate #define D_DISABLE ((char)0x02) /* optional socket disabled */ 18237c478bd9Sstevel@tonic-gate #define D_ISSET ((char)0x03) /* this client struct is set */ 18247c478bd9Sstevel@tonic-gate 18257c478bd9Sstevel@tonic-gate #if STARTTLS 18267c478bd9Sstevel@tonic-gate /* 18277c478bd9Sstevel@tonic-gate ** TLS 18287c478bd9Sstevel@tonic-gate */ 18297c478bd9Sstevel@tonic-gate 18307c478bd9Sstevel@tonic-gate /* what to do in the TLS initialization */ 18317c478bd9Sstevel@tonic-gate #define TLS_I_NONE 0x00000000 /* no requirements... */ 18327c478bd9Sstevel@tonic-gate #define TLS_I_CERT_EX 0x00000001 /* cert must exist */ 18337c478bd9Sstevel@tonic-gate #define TLS_I_CERT_UNR 0x00000002 /* cert must be g/o unreadable */ 18347c478bd9Sstevel@tonic-gate #define TLS_I_KEY_EX 0x00000004 /* key must exist */ 18357c478bd9Sstevel@tonic-gate #define TLS_I_KEY_UNR 0x00000008 /* key must be g/o unreadable */ 18367c478bd9Sstevel@tonic-gate #define TLS_I_CERTP_EX 0x00000010 /* CA cert path must exist */ 18377c478bd9Sstevel@tonic-gate #define TLS_I_CERTP_UNR 0x00000020 /* CA cert path must be g/o unreadable */ 18387c478bd9Sstevel@tonic-gate #define TLS_I_CERTF_EX 0x00000040 /* CA cert file must exist */ 18397c478bd9Sstevel@tonic-gate #define TLS_I_CERTF_UNR 0x00000080 /* CA cert file must be g/o unreadable */ 18407c478bd9Sstevel@tonic-gate #define TLS_I_RSA_TMP 0x00000100 /* RSA TMP must be generated */ 18417c478bd9Sstevel@tonic-gate #define TLS_I_USE_KEY 0x00000200 /* private key must usable */ 18427c478bd9Sstevel@tonic-gate #define TLS_I_USE_CERT 0x00000400 /* certificate must be usable */ 18437c478bd9Sstevel@tonic-gate #define TLS_I_VRFY_PATH 0x00000800 /* load verify path must succeed */ 18447c478bd9Sstevel@tonic-gate #define TLS_I_VRFY_LOC 0x00001000 /* load verify default must succeed */ 18457c478bd9Sstevel@tonic-gate #define TLS_I_CACHE 0x00002000 /* require cache */ 18467c478bd9Sstevel@tonic-gate #define TLS_I_TRY_DH 0x00004000 /* try DH certificate */ 18477c478bd9Sstevel@tonic-gate #define TLS_I_REQ_DH 0x00008000 /* require DH certificate */ 18487c478bd9Sstevel@tonic-gate #define TLS_I_DHPAR_EX 0x00010000 /* require DH parameters */ 18497c478bd9Sstevel@tonic-gate #define TLS_I_DHPAR_UNR 0x00020000 /* DH param. must be g/o unreadable */ 18507c478bd9Sstevel@tonic-gate #define TLS_I_DH512 0x00040000 /* generate 512bit DH param */ 18517c478bd9Sstevel@tonic-gate #define TLS_I_DH1024 0x00080000 /* generate 1024bit DH param */ 18527c478bd9Sstevel@tonic-gate #define TLS_I_DH2048 0x00100000 /* generate 2048bit DH param */ 18537c478bd9Sstevel@tonic-gate #define TLS_I_NO_VRFY 0x00200000 /* do not require authentication */ 18547c478bd9Sstevel@tonic-gate #define TLS_I_KEY_OUNR 0x00400000 /* Key must be other unreadable */ 18557c478bd9Sstevel@tonic-gate #define TLS_I_CRLF_EX 0x00800000 /* CRL file must exist */ 18567c478bd9Sstevel@tonic-gate #define TLS_I_CRLF_UNR 0x01000000 /* CRL file must be g/o unreadable */ 18577c478bd9Sstevel@tonic-gate 18587c478bd9Sstevel@tonic-gate /* require server cert */ 18597c478bd9Sstevel@tonic-gate #define TLS_I_SRV_CERT (TLS_I_CERT_EX | TLS_I_KEY_EX | \ 18607c478bd9Sstevel@tonic-gate TLS_I_KEY_UNR | TLS_I_KEY_OUNR | \ 18617c478bd9Sstevel@tonic-gate TLS_I_CERTP_EX | TLS_I_CERTF_EX | \ 1862445f2479Sjbeck TLS_I_USE_KEY | TLS_I_USE_CERT | TLS_I_CACHE) 18637c478bd9Sstevel@tonic-gate 18647c478bd9Sstevel@tonic-gate /* server requirements */ 18657c478bd9Sstevel@tonic-gate #define TLS_I_SRV (TLS_I_SRV_CERT | TLS_I_RSA_TMP | TLS_I_VRFY_PATH | \ 1866445f2479Sjbeck TLS_I_VRFY_LOC | TLS_I_TRY_DH | TLS_I_DH512 | \ 1867445f2479Sjbeck TLS_I_CACHE) 18687c478bd9Sstevel@tonic-gate 18697c478bd9Sstevel@tonic-gate /* client requirements */ 18707c478bd9Sstevel@tonic-gate #define TLS_I_CLT (TLS_I_KEY_UNR | TLS_I_KEY_OUNR) 18717c478bd9Sstevel@tonic-gate 18727c478bd9Sstevel@tonic-gate #define TLS_AUTH_OK 0 18737c478bd9Sstevel@tonic-gate #define TLS_AUTH_NO 1 18747c478bd9Sstevel@tonic-gate #define TLS_AUTH_FAIL (-1) 18757c478bd9Sstevel@tonic-gate 18767c478bd9Sstevel@tonic-gate /* functions */ 18777c478bd9Sstevel@tonic-gate extern bool init_tls_library __P((void)); 18787c478bd9Sstevel@tonic-gate extern bool inittls __P((SSL_CTX **, unsigned long, bool, char *, char *, char *, char *, char *)); 18797c478bd9Sstevel@tonic-gate extern bool initclttls __P((bool)); 18807c478bd9Sstevel@tonic-gate extern void setclttls __P((bool)); 18817c478bd9Sstevel@tonic-gate extern bool initsrvtls __P((bool)); 18827c478bd9Sstevel@tonic-gate extern int tls_get_info __P((SSL *, bool, char *, MACROS_T *, bool)); 18837c478bd9Sstevel@tonic-gate extern int endtls __P((SSL *, char *)); 1884445f2479Sjbeck extern void tlslogerr __P((const char *)); 18857c478bd9Sstevel@tonic-gate 18867c478bd9Sstevel@tonic-gate 18877c478bd9Sstevel@tonic-gate EXTERN char *CACertPath; /* path to CA certificates (dir. with hashes) */ 18887c478bd9Sstevel@tonic-gate EXTERN char *CACertFile; /* file with CA certificate */ 18897c478bd9Sstevel@tonic-gate EXTERN char *CltCertFile; /* file with client certificate */ 18907c478bd9Sstevel@tonic-gate EXTERN char *CltKeyFile; /* file with client private key */ 18917c478bd9Sstevel@tonic-gate # if _FFR_TLS_1 18927c478bd9Sstevel@tonic-gate EXTERN char *CipherList; /* list of ciphers */ 18937c478bd9Sstevel@tonic-gate EXTERN char *DHParams5; /* file with DH parameters (512) */ 18947c478bd9Sstevel@tonic-gate # endif /* _FFR_TLS_1 */ 18957c478bd9Sstevel@tonic-gate EXTERN char *DHParams; /* file with DH parameters */ 18967c478bd9Sstevel@tonic-gate EXTERN char *RandFile; /* source of random data */ 18977c478bd9Sstevel@tonic-gate EXTERN char *SrvCertFile; /* file with server certificate */ 18987c478bd9Sstevel@tonic-gate EXTERN char *SrvKeyFile; /* file with server private key */ 18997c478bd9Sstevel@tonic-gate EXTERN char *CRLFile; /* file CRLs */ 19007c478bd9Sstevel@tonic-gate #if _FFR_CRLPATH 19017c478bd9Sstevel@tonic-gate EXTERN char *CRLPath; /* path to CRLs (dir. with hashes) */ 19027c478bd9Sstevel@tonic-gate #endif /* _FFR_CRLPATH */ 19037c478bd9Sstevel@tonic-gate EXTERN unsigned long TLS_Srv_Opts; /* TLS server options */ 19047c478bd9Sstevel@tonic-gate #endif /* STARTTLS */ 19057c478bd9Sstevel@tonic-gate 19067c478bd9Sstevel@tonic-gate /* 19077c478bd9Sstevel@tonic-gate ** Queue related items 19087c478bd9Sstevel@tonic-gate */ 19097c478bd9Sstevel@tonic-gate 19107c478bd9Sstevel@tonic-gate /* queue file names */ 19117c478bd9Sstevel@tonic-gate #define ANYQFL_LETTER '?' 19127c478bd9Sstevel@tonic-gate #define QUARQF_LETTER 'h' 19137c478bd9Sstevel@tonic-gate #define DATAFL_LETTER 'd' 19147c478bd9Sstevel@tonic-gate #define XSCRPT_LETTER 'x' 19157c478bd9Sstevel@tonic-gate #define NORMQF_LETTER 'q' 19167c478bd9Sstevel@tonic-gate #define NEWQFL_LETTER 't' 19177c478bd9Sstevel@tonic-gate 19187c478bd9Sstevel@tonic-gate # define TEMPQF_LETTER 'T' 19197c478bd9Sstevel@tonic-gate # define LOSEQF_LETTER 'Q' 19207c478bd9Sstevel@tonic-gate 19217c478bd9Sstevel@tonic-gate /* queue sort order */ 19227c478bd9Sstevel@tonic-gate #define QSO_BYPRIORITY 0 /* sort by message priority */ 19237c478bd9Sstevel@tonic-gate #define QSO_BYHOST 1 /* sort by first host name */ 19247c478bd9Sstevel@tonic-gate #define QSO_BYTIME 2 /* sort by submission time */ 19257c478bd9Sstevel@tonic-gate #define QSO_BYFILENAME 3 /* sort by file name only */ 19267c478bd9Sstevel@tonic-gate #define QSO_RANDOM 4 /* sort in random order */ 19277c478bd9Sstevel@tonic-gate #define QSO_BYMODTIME 5 /* sort by modification time */ 19287c478bd9Sstevel@tonic-gate #define QSO_NONE 6 /* do not sort */ 19297c478bd9Sstevel@tonic-gate #if _FFR_RHS 19307c478bd9Sstevel@tonic-gate # define QSO_BYSHUFFLE 7 /* sort by shuffled host name */ 19317c478bd9Sstevel@tonic-gate #endif /* _FFR_RHS */ 19327c478bd9Sstevel@tonic-gate 19337c478bd9Sstevel@tonic-gate #define NOQGRP (-1) /* no queue group (yet) */ 19347c478bd9Sstevel@tonic-gate #define ENVQGRP (-2) /* use queue group of envelope */ 19357c478bd9Sstevel@tonic-gate #define NOAQGRP (-3) /* no queue group in addr (yet) */ 19367c478bd9Sstevel@tonic-gate #define ISVALIDQGRP(x) ((x) >= 0) /* valid queue group? */ 19377c478bd9Sstevel@tonic-gate #define NOQDIR (-1) /* no queue directory (yet) */ 19387c478bd9Sstevel@tonic-gate #define ENVQDIR (-2) /* use queue directory of envelope */ 19397c478bd9Sstevel@tonic-gate #define NOAQDIR (-3) /* no queue directory in addr (yet) */ 19407c478bd9Sstevel@tonic-gate #define ISVALIDQDIR(x) ((x) >= 0) /* valid queue directory? */ 19417c478bd9Sstevel@tonic-gate #define RS_QUEUEGROUP "queuegroup" /* ruleset for queue group selection */ 19427c478bd9Sstevel@tonic-gate 19437c478bd9Sstevel@tonic-gate #define NOW ((time_t) (-1)) /* queue return: now */ 19447c478bd9Sstevel@tonic-gate 19457c478bd9Sstevel@tonic-gate /* SuperSafe values */ 19467c478bd9Sstevel@tonic-gate #define SAFE_NO 0 /* no fsync(): don't use... */ 19477c478bd9Sstevel@tonic-gate #define SAFE_INTERACTIVE 1 /* limit fsync() in -odi */ 19487c478bd9Sstevel@tonic-gate #define SAFE_REALLY 2 /* always fsync() */ 19497c478bd9Sstevel@tonic-gate #define SAFE_REALLY_POSTMILTER 3 /* fsync() if milter says OK */ 19507c478bd9Sstevel@tonic-gate 19517c478bd9Sstevel@tonic-gate /* QueueMode bits */ 19527c478bd9Sstevel@tonic-gate #define QM_NORMAL ' ' 19537c478bd9Sstevel@tonic-gate #define QM_QUARANTINE 'Q' 19547c478bd9Sstevel@tonic-gate #define QM_LOST 'L' 19557c478bd9Sstevel@tonic-gate 19567c478bd9Sstevel@tonic-gate /* Queue Run Limitations */ 19577c478bd9Sstevel@tonic-gate struct queue_char 19587c478bd9Sstevel@tonic-gate { 19597c478bd9Sstevel@tonic-gate char *queue_match; /* string to match */ 19607c478bd9Sstevel@tonic-gate bool queue_negate; /* or not match, if set */ 19617c478bd9Sstevel@tonic-gate struct queue_char *queue_next; 19627c478bd9Sstevel@tonic-gate }; 19637c478bd9Sstevel@tonic-gate 19647c478bd9Sstevel@tonic-gate /* run_work_group() flags */ 19657c478bd9Sstevel@tonic-gate #define RWG_NONE 0x0000 19667c478bd9Sstevel@tonic-gate #define RWG_FORK 0x0001 19677c478bd9Sstevel@tonic-gate #define RWG_VERBOSE 0x0002 19687c478bd9Sstevel@tonic-gate #define RWG_PERSISTENT 0x0004 19697c478bd9Sstevel@tonic-gate #define RWG_FORCE 0x0008 19707c478bd9Sstevel@tonic-gate #define RWG_RUNALL 0x0010 19717c478bd9Sstevel@tonic-gate 19727c478bd9Sstevel@tonic-gate typedef struct queue_char QUEUE_CHAR; 19737c478bd9Sstevel@tonic-gate 19747c478bd9Sstevel@tonic-gate EXTERN int volatile CurRunners; /* current number of runner children */ 19757c478bd9Sstevel@tonic-gate EXTERN int MaxQueueRun; /* maximum number of jobs in one queue run */ 19767c478bd9Sstevel@tonic-gate EXTERN int MaxQueueChildren; /* max # of forked queue children */ 19777c478bd9Sstevel@tonic-gate EXTERN int MaxRunnersPerQueue; /* max # proc's active in queue group */ 19787c478bd9Sstevel@tonic-gate EXTERN int NiceQueueRun; /* nice queue runs to this value */ 19797c478bd9Sstevel@tonic-gate EXTERN int NumQueue; /* number of queue groups */ 19807c478bd9Sstevel@tonic-gate EXTERN int QueueFileMode; /* mode on files in mail queue */ 19817c478bd9Sstevel@tonic-gate EXTERN int QueueMode; /* which queue items to act upon */ 19827c478bd9Sstevel@tonic-gate EXTERN int QueueSortOrder; /* queue sorting order algorithm */ 19837c478bd9Sstevel@tonic-gate EXTERN time_t MinQueueAge; /* min delivery interval */ 19847c478bd9Sstevel@tonic-gate EXTERN time_t QueueIntvl; /* intervals between running the queue */ 19857c478bd9Sstevel@tonic-gate EXTERN char *QueueDir; /* location of queue directory */ 19867c478bd9Sstevel@tonic-gate EXTERN QUEUE_CHAR *QueueLimitId; /* limit queue run to id */ 19877c478bd9Sstevel@tonic-gate EXTERN QUEUE_CHAR *QueueLimitQuarantine; /* limit queue run to quarantine reason */ 19887c478bd9Sstevel@tonic-gate EXTERN QUEUE_CHAR *QueueLimitRecipient; /* limit queue run to rcpt */ 19897c478bd9Sstevel@tonic-gate EXTERN QUEUE_CHAR *QueueLimitSender; /* limit queue run to sender */ 19907c478bd9Sstevel@tonic-gate EXTERN QUEUEGRP *Queue[MAXQUEUEGROUPS + 1]; /* queue groups */ 19917c478bd9Sstevel@tonic-gate 19927c478bd9Sstevel@tonic-gate /* functions */ 19937c478bd9Sstevel@tonic-gate extern void assign_queueid __P((ENVELOPE *)); 19947c478bd9Sstevel@tonic-gate extern ADDRESS *copyqueue __P((ADDRESS *, SM_RPOOL_T *)); 19957c478bd9Sstevel@tonic-gate extern void cleanup_queues __P((void)); 19967c478bd9Sstevel@tonic-gate extern bool doqueuerun __P((void)); 19977c478bd9Sstevel@tonic-gate extern void initsys __P((ENVELOPE *)); 19987c478bd9Sstevel@tonic-gate extern void loseqfile __P((ENVELOPE *, char *)); 19997c478bd9Sstevel@tonic-gate extern int name2qid __P((char *)); 20007c478bd9Sstevel@tonic-gate extern char *qid_printname __P((ENVELOPE *)); 20017c478bd9Sstevel@tonic-gate extern char *qid_printqueue __P((int, int)); 20027c478bd9Sstevel@tonic-gate extern void quarantine_queue __P((char *, int)); 20037c478bd9Sstevel@tonic-gate extern char *queuename __P((ENVELOPE *, int)); 20047c478bd9Sstevel@tonic-gate extern void queueup __P((ENVELOPE *, bool, bool)); 20057c478bd9Sstevel@tonic-gate extern bool runqueue __P((bool, bool, bool, bool)); 20067c478bd9Sstevel@tonic-gate extern bool run_work_group __P((int, int)); 20077c478bd9Sstevel@tonic-gate extern void set_def_queueval __P((QUEUEGRP *, bool)); 20087c478bd9Sstevel@tonic-gate extern void setup_queues __P((bool)); 20097c478bd9Sstevel@tonic-gate extern bool setnewqueue __P((ENVELOPE *)); 20107c478bd9Sstevel@tonic-gate extern bool shouldqueue __P((long, time_t)); 20117c478bd9Sstevel@tonic-gate extern void sync_queue_time __P((void)); 20127c478bd9Sstevel@tonic-gate extern void init_qid_alg __P((void)); 20137c478bd9Sstevel@tonic-gate extern int print_single_queue __P((int, int)); 20147c478bd9Sstevel@tonic-gate #if REQUIRES_DIR_FSYNC 20157c478bd9Sstevel@tonic-gate # define SYNC_DIR(path, panic) sync_dir(path, panic) 20167c478bd9Sstevel@tonic-gate extern void sync_dir __P((char *, bool)); 20177c478bd9Sstevel@tonic-gate #else /* REQUIRES_DIR_FSYNC */ 20187c478bd9Sstevel@tonic-gate # define SYNC_DIR(path, panic) ((void) 0) 20197c478bd9Sstevel@tonic-gate #endif /* REQUIRES_DIR_FSYNC */ 20207c478bd9Sstevel@tonic-gate 20217c478bd9Sstevel@tonic-gate /* 20227c478bd9Sstevel@tonic-gate ** Timeouts 20237c478bd9Sstevel@tonic-gate ** 20247c478bd9Sstevel@tonic-gate ** Indicated values are the MINIMUM per RFC 1123 section 5.3.2. 20257c478bd9Sstevel@tonic-gate */ 20267c478bd9Sstevel@tonic-gate 20277c478bd9Sstevel@tonic-gate EXTERN struct 20287c478bd9Sstevel@tonic-gate { 20297c478bd9Sstevel@tonic-gate /* RFC 1123-specified timeouts [minimum value] */ 20307c478bd9Sstevel@tonic-gate time_t to_initial; /* initial greeting timeout [5m] */ 20317c478bd9Sstevel@tonic-gate time_t to_mail; /* MAIL command [5m] */ 20327c478bd9Sstevel@tonic-gate time_t to_rcpt; /* RCPT command [5m] */ 20337c478bd9Sstevel@tonic-gate time_t to_datainit; /* DATA initiation [2m] */ 20347c478bd9Sstevel@tonic-gate time_t to_datablock; /* DATA block [3m] */ 20357c478bd9Sstevel@tonic-gate time_t to_datafinal; /* DATA completion [10m] */ 20367c478bd9Sstevel@tonic-gate time_t to_nextcommand; /* next command [5m] */ 20377c478bd9Sstevel@tonic-gate /* following timeouts are not mentioned in RFC 1123 */ 20387c478bd9Sstevel@tonic-gate time_t to_iconnect; /* initial connection timeout (first try) */ 20397c478bd9Sstevel@tonic-gate time_t to_connect; /* initial connection timeout (later tries) */ 20407c478bd9Sstevel@tonic-gate time_t to_aconnect; /* all connections timeout (MX and A records) */ 20417c478bd9Sstevel@tonic-gate time_t to_rset; /* RSET command */ 20427c478bd9Sstevel@tonic-gate time_t to_helo; /* HELO command */ 20437c478bd9Sstevel@tonic-gate time_t to_quit; /* QUIT command */ 20447c478bd9Sstevel@tonic-gate time_t to_miscshort; /* misc short commands (NOOP, VERB, etc) */ 20457c478bd9Sstevel@tonic-gate time_t to_ident; /* IDENT protocol requests */ 20467c478bd9Sstevel@tonic-gate time_t to_fileopen; /* opening :include: and .forward files */ 20477c478bd9Sstevel@tonic-gate time_t to_control; /* process a control socket command */ 20487c478bd9Sstevel@tonic-gate time_t to_lhlo; /* LMTP: LHLO command */ 20497c478bd9Sstevel@tonic-gate #if SASL 20507c478bd9Sstevel@tonic-gate time_t to_auth; /* AUTH dialogue [10m] */ 20517c478bd9Sstevel@tonic-gate #endif /* SASL */ 20527c478bd9Sstevel@tonic-gate #if STARTTLS 20537c478bd9Sstevel@tonic-gate time_t to_starttls; /* STARTTLS dialogue [10m] */ 20547c478bd9Sstevel@tonic-gate #endif /* STARTTLS */ 20557c478bd9Sstevel@tonic-gate /* following are per message */ 20567c478bd9Sstevel@tonic-gate time_t to_q_return[MAXTOCLASS]; /* queue return timeouts */ 20577c478bd9Sstevel@tonic-gate time_t to_q_warning[MAXTOCLASS]; /* queue warning timeouts */ 20587c478bd9Sstevel@tonic-gate time_t res_retrans[MAXRESTOTYPES]; /* resolver retransmit */ 20597c478bd9Sstevel@tonic-gate int res_retry[MAXRESTOTYPES]; /* resolver retry */ 20607c478bd9Sstevel@tonic-gate } TimeOuts; 20617c478bd9Sstevel@tonic-gate 20627c478bd9Sstevel@tonic-gate /* timeout classes for return and warning timeouts */ 20637c478bd9Sstevel@tonic-gate #define TOC_NORMAL 0 /* normal delivery */ 20647c478bd9Sstevel@tonic-gate #define TOC_URGENT 1 /* urgent delivery */ 20657c478bd9Sstevel@tonic-gate #define TOC_NONURGENT 2 /* non-urgent delivery */ 20667c478bd9Sstevel@tonic-gate #define TOC_DSN 3 /* DSN delivery */ 20677c478bd9Sstevel@tonic-gate 20687c478bd9Sstevel@tonic-gate /* resolver timeout specifiers */ 20697c478bd9Sstevel@tonic-gate #define RES_TO_FIRST 0 /* first attempt */ 20707c478bd9Sstevel@tonic-gate #define RES_TO_NORMAL 1 /* subsequent attempts */ 20717c478bd9Sstevel@tonic-gate #define RES_TO_DEFAULT 2 /* default value */ 20727c478bd9Sstevel@tonic-gate 20737c478bd9Sstevel@tonic-gate /* functions */ 20747c478bd9Sstevel@tonic-gate extern void inittimeouts __P((char *, bool)); 20757c478bd9Sstevel@tonic-gate 20767c478bd9Sstevel@tonic-gate /* 20777c478bd9Sstevel@tonic-gate ** Interface probing 20787c478bd9Sstevel@tonic-gate */ 20797c478bd9Sstevel@tonic-gate 20807c478bd9Sstevel@tonic-gate #define DPI_PROBENONE 0 /* Don't probe any interfaces */ 20817c478bd9Sstevel@tonic-gate #define DPI_PROBEALL 1 /* Probe all interfaces */ 20827c478bd9Sstevel@tonic-gate #define DPI_SKIPLOOPBACK 2 /* Don't probe loopback interfaces */ 20837c478bd9Sstevel@tonic-gate 20847c478bd9Sstevel@tonic-gate /* 20857c478bd9Sstevel@tonic-gate ** Trace information 20867c478bd9Sstevel@tonic-gate */ 20877c478bd9Sstevel@tonic-gate 20887c478bd9Sstevel@tonic-gate /* macros for debugging flags */ 20897c478bd9Sstevel@tonic-gate #define tTd(flag, level) (tTdvect[flag] >= (unsigned char)level) 20907c478bd9Sstevel@tonic-gate #define tTdlevel(flag) (tTdvect[flag]) 20917c478bd9Sstevel@tonic-gate 20927c478bd9Sstevel@tonic-gate /* variables */ 20937c478bd9Sstevel@tonic-gate extern unsigned char tTdvect[100]; /* trace vector */ 20947c478bd9Sstevel@tonic-gate 20957c478bd9Sstevel@tonic-gate /* 20967c478bd9Sstevel@tonic-gate ** Miscellaneous information. 20977c478bd9Sstevel@tonic-gate */ 20987c478bd9Sstevel@tonic-gate 20997c478bd9Sstevel@tonic-gate /* 21007c478bd9Sstevel@tonic-gate ** The "no queue id" queue id for sm_syslog 21017c478bd9Sstevel@tonic-gate */ 21027c478bd9Sstevel@tonic-gate 2103*7800901eSjbeck #define NOQID "" 21047c478bd9Sstevel@tonic-gate 21057c478bd9Sstevel@tonic-gate #define CURHOSTNAME (CurHostName == NULL ? "local" : CurHostName) 21067c478bd9Sstevel@tonic-gate 21077c478bd9Sstevel@tonic-gate /* 21087c478bd9Sstevel@tonic-gate ** Some in-line functions 21097c478bd9Sstevel@tonic-gate */ 21107c478bd9Sstevel@tonic-gate 21117c478bd9Sstevel@tonic-gate /* set exit status */ 21127c478bd9Sstevel@tonic-gate #define setstat(s) { \ 21137c478bd9Sstevel@tonic-gate if (ExitStat == EX_OK || ExitStat == EX_TEMPFAIL) \ 21147c478bd9Sstevel@tonic-gate ExitStat = s; \ 21157c478bd9Sstevel@tonic-gate } 21167c478bd9Sstevel@tonic-gate 21177c478bd9Sstevel@tonic-gate 21187c478bd9Sstevel@tonic-gate #define STRUCTCOPY(s, d) d = s 21197c478bd9Sstevel@tonic-gate 21207c478bd9Sstevel@tonic-gate /* free a pointer if it isn't NULL and set it to NULL */ 21217c478bd9Sstevel@tonic-gate #define SM_FREE_CLR(p) \ 21227c478bd9Sstevel@tonic-gate if ((p) != NULL) \ 21237c478bd9Sstevel@tonic-gate { \ 21247c478bd9Sstevel@tonic-gate sm_free(p); \ 21257c478bd9Sstevel@tonic-gate (p) = NULL; \ 21267c478bd9Sstevel@tonic-gate } \ 21277c478bd9Sstevel@tonic-gate else 21287c478bd9Sstevel@tonic-gate 21297c478bd9Sstevel@tonic-gate /* 21307c478bd9Sstevel@tonic-gate ** Update a permanent string variable with a new value. 21317c478bd9Sstevel@tonic-gate ** The old value is freed, the new value is strdup'ed. 21327c478bd9Sstevel@tonic-gate ** 21337c478bd9Sstevel@tonic-gate ** We use sm_pstrdup_x to duplicate the string because it raises 21347c478bd9Sstevel@tonic-gate ** an exception on error, and because it allocates "permanent storage" 21357c478bd9Sstevel@tonic-gate ** which is not expected to be freed before process exit. 21367c478bd9Sstevel@tonic-gate ** The latter is important for memory leak analysis. 21377c478bd9Sstevel@tonic-gate ** 21387c478bd9Sstevel@tonic-gate ** If an exception occurs while strdup'ing the new value, 21397c478bd9Sstevel@tonic-gate ** then the variable remains set to the old value. 21407c478bd9Sstevel@tonic-gate ** That's why the strdup must occur before we free the old value. 21417c478bd9Sstevel@tonic-gate ** 21427c478bd9Sstevel@tonic-gate ** The macro uses a do loop so that this idiom will work: 21437c478bd9Sstevel@tonic-gate ** if (...) 21447c478bd9Sstevel@tonic-gate ** PSTRSET(var, val1); 21457c478bd9Sstevel@tonic-gate ** else 21467c478bd9Sstevel@tonic-gate ** PSTRSET(var, val2); 21477c478bd9Sstevel@tonic-gate */ 21487c478bd9Sstevel@tonic-gate #define PSTRSET(var, val) \ 21497c478bd9Sstevel@tonic-gate do \ 21507c478bd9Sstevel@tonic-gate { \ 21517c478bd9Sstevel@tonic-gate char *_newval = sm_pstrdup_x(val); \ 21527c478bd9Sstevel@tonic-gate if (var != NULL) \ 21537c478bd9Sstevel@tonic-gate sm_free(var); \ 21547c478bd9Sstevel@tonic-gate var = _newval; \ 21557c478bd9Sstevel@tonic-gate } while (0) 21567c478bd9Sstevel@tonic-gate 21577c478bd9Sstevel@tonic-gate #define _CHECK_RESTART \ 21587c478bd9Sstevel@tonic-gate do \ 21597c478bd9Sstevel@tonic-gate { \ 21607c478bd9Sstevel@tonic-gate if (ShutdownRequest != NULL) \ 21617c478bd9Sstevel@tonic-gate shutdown_daemon(); \ 21627c478bd9Sstevel@tonic-gate else if (RestartRequest != NULL) \ 21637c478bd9Sstevel@tonic-gate restart_daemon(); \ 21647c478bd9Sstevel@tonic-gate else if (RestartWorkGroup) \ 21657c478bd9Sstevel@tonic-gate restart_marked_work_groups(); \ 21667c478bd9Sstevel@tonic-gate } while (0) 21677c478bd9Sstevel@tonic-gate 21687c478bd9Sstevel@tonic-gate # define CHECK_RESTART _CHECK_RESTART 21697c478bd9Sstevel@tonic-gate 21707c478bd9Sstevel@tonic-gate /* reply types (text in SmtpMsgBuffer) */ 21717c478bd9Sstevel@tonic-gate #define XS_DEFAULT 0 21727c478bd9Sstevel@tonic-gate #define XS_STARTTLS 1 21737c478bd9Sstevel@tonic-gate #define XS_AUTH 2 21747c478bd9Sstevel@tonic-gate 21757c478bd9Sstevel@tonic-gate /* 21767c478bd9Sstevel@tonic-gate ** Global variables. 21777c478bd9Sstevel@tonic-gate */ 21787c478bd9Sstevel@tonic-gate 2179*7800901eSjbeck #if _FFR_ADDR_TYPE_MODES 2180*7800901eSjbeck EXTERN bool AddrTypeModes; /* addr_type: extra "mode" information */ 2181*7800901eSjbeck #endif /* _FFR_ADDR_TYPE_MODES */ 21827c478bd9Sstevel@tonic-gate EXTERN bool AllowBogusHELO; /* allow syntax errors on HELO command */ 21837c478bd9Sstevel@tonic-gate EXTERN bool CheckAliases; /* parse addresses during newaliases */ 2184445f2479Sjbeck #if _FFR_QUEUE_RUN_PARANOIA 2185445f2479Sjbeck EXTERN int CheckQueueRunners; /* check whether queue runners are OK */ 2186445f2479Sjbeck #endif /* _FFR_QUEUE_RUN_PARANOIA */ 21877c478bd9Sstevel@tonic-gate EXTERN bool ColonOkInAddr; /* single colon legal in address */ 21887c478bd9Sstevel@tonic-gate #if !defined(_USE_SUN_NSSWITCH_) && !defined(_USE_DEC_SVC_CONF_) 21897c478bd9Sstevel@tonic-gate EXTERN bool ConfigFileRead; /* configuration file has been read */ 21907c478bd9Sstevel@tonic-gate #endif /* !defined(_USE_SUN_NSSWITCH_) && !defined(_USE_DEC_SVC_CONF_) */ 21917c478bd9Sstevel@tonic-gate EXTERN bool DisConnected; /* running with OutChannel redirect to transcript file */ 21927c478bd9Sstevel@tonic-gate EXTERN bool DontExpandCnames; /* do not $[...$] expand CNAMEs */ 21937c478bd9Sstevel@tonic-gate EXTERN bool DontInitGroups; /* avoid initgroups() because of NIS cost */ 21947c478bd9Sstevel@tonic-gate EXTERN bool DontLockReadFiles; /* don't read lock support files */ 21957c478bd9Sstevel@tonic-gate EXTERN bool DontPruneRoutes; /* don't prune source routes */ 21967c478bd9Sstevel@tonic-gate EXTERN bool ForkQueueRuns; /* fork for each job when running the queue */ 21977c478bd9Sstevel@tonic-gate EXTERN bool FromFlag; /* if set, "From" person is explicit */ 21987c478bd9Sstevel@tonic-gate EXTERN bool GrabTo; /* if set, get recipients from msg */ 2199058561cbSjbeck EXTERN bool EightBitAddrOK; /* we'll let 8-bit addresses through */ 22007c478bd9Sstevel@tonic-gate EXTERN bool HasEightBits; /* has at least one eight bit input byte */ 22017c478bd9Sstevel@tonic-gate EXTERN bool HasWildcardMX; /* don't use MX records when canonifying */ 22027c478bd9Sstevel@tonic-gate EXTERN bool HoldErrs; /* only output errors to transcript */ 22037c478bd9Sstevel@tonic-gate EXTERN bool IgnoreHostStatus; /* ignore long term host status files */ 22047c478bd9Sstevel@tonic-gate EXTERN bool IgnrDot; /* don't let dot end messages */ 22057c478bd9Sstevel@tonic-gate EXTERN bool LogUsrErrs; /* syslog user errors (e.g., SMTP RCPT cmd) */ 22067c478bd9Sstevel@tonic-gate EXTERN bool MatchGecos; /* look for user names in gecos field */ 22077c478bd9Sstevel@tonic-gate EXTERN bool MeToo; /* send to the sender also */ 22087c478bd9Sstevel@tonic-gate EXTERN bool NoAlias; /* suppress aliasing */ 22097c478bd9Sstevel@tonic-gate EXTERN bool NoConnect; /* don't connect to non-local mailers */ 22107c478bd9Sstevel@tonic-gate EXTERN bool OnlyOneError; /* .... or only want to give one SMTP reply */ 22117c478bd9Sstevel@tonic-gate EXTERN bool QuickAbort; /* .... but only if we want a quick abort */ 22127c478bd9Sstevel@tonic-gate #if REQUIRES_DIR_FSYNC 22137c478bd9Sstevel@tonic-gate EXTERN bool RequiresDirfsync; /* requires fsync() for directory */ 22147c478bd9Sstevel@tonic-gate #endif /* REQUIRES_DIR_FSYNC */ 22157c478bd9Sstevel@tonic-gate EXTERN bool volatile RestartWorkGroup; /* daemon needs to restart some work groups */ 22167c478bd9Sstevel@tonic-gate EXTERN bool RrtImpliesDsn; /* turn Return-Receipt-To: into DSN */ 22177c478bd9Sstevel@tonic-gate EXTERN bool SaveFrom; /* save leading "From" lines */ 22187c478bd9Sstevel@tonic-gate EXTERN bool SendMIMEErrors; /* send error messages in MIME format */ 22197c478bd9Sstevel@tonic-gate EXTERN bool SevenBitInput; /* force 7-bit data on input */ 22207c478bd9Sstevel@tonic-gate EXTERN bool SingleLineFromHeader; /* force From: header to be one line */ 22217c478bd9Sstevel@tonic-gate EXTERN bool SingleThreadDelivery; /* single thread hosts on delivery */ 22227c478bd9Sstevel@tonic-gate EXTERN bool SoftBounce; /* replace 5xy by 4xy (for testing) */ 22237c478bd9Sstevel@tonic-gate EXTERN bool volatile StopRequest; /* stop sending output */ 22247c478bd9Sstevel@tonic-gate EXTERN bool SuprErrs; /* set if we are suppressing errors */ 22257c478bd9Sstevel@tonic-gate EXTERN bool TryNullMXList; /* if we are the best MX, try host directly */ 22267c478bd9Sstevel@tonic-gate EXTERN bool UseMSP; /* mail submission: group writable queue ok? */ 22277c478bd9Sstevel@tonic-gate EXTERN bool WorkAroundBrokenAAAA; /* some nameservers return SERVFAIL on AAAA queries */ 22287c478bd9Sstevel@tonic-gate EXTERN bool UseErrorsTo; /* use Errors-To: header (back compat) */ 22297c478bd9Sstevel@tonic-gate EXTERN bool UseNameServer; /* using DNS -- interpret h_errno & MX RRs */ 22307c478bd9Sstevel@tonic-gate EXTERN char InetMode; /* default network for daemon mode */ 22317c478bd9Sstevel@tonic-gate EXTERN char OpMode; /* operation mode, see below */ 22327c478bd9Sstevel@tonic-gate EXTERN char SpaceSub; /* substitution for <lwsp> */ 22337c478bd9Sstevel@tonic-gate EXTERN int BadRcptThrottle; /* Throttle rejected RCPTs per SMTP message */ 22347c478bd9Sstevel@tonic-gate EXTERN int CheckpointInterval; /* queue file checkpoint interval */ 22357c478bd9Sstevel@tonic-gate EXTERN int ConfigLevel; /* config file level */ 22367c478bd9Sstevel@tonic-gate EXTERN int ConnRateThrottle; /* throttle for SMTP connection rate */ 22377c478bd9Sstevel@tonic-gate EXTERN int volatile CurChildren; /* current number of daemonic children */ 22387c478bd9Sstevel@tonic-gate EXTERN int CurrentLA; /* current load average */ 22397c478bd9Sstevel@tonic-gate EXTERN int DefaultNotify; /* default DSN notification flags */ 22407c478bd9Sstevel@tonic-gate EXTERN int DelayLA; /* load average to delay connections */ 22417c478bd9Sstevel@tonic-gate EXTERN int DontProbeInterfaces; /* don't probe interfaces for names */ 22427c478bd9Sstevel@tonic-gate EXTERN int Errors; /* set if errors (local to single pass) */ 22437c478bd9Sstevel@tonic-gate EXTERN int ExitStat; /* exit status code */ 22447c478bd9Sstevel@tonic-gate EXTERN int FastSplit; /* fast initial splitting of envelopes */ 22457c478bd9Sstevel@tonic-gate EXTERN int FileMode; /* mode on files */ 22467c478bd9Sstevel@tonic-gate EXTERN int LineNumber; /* line number in current input */ 22477c478bd9Sstevel@tonic-gate EXTERN int LogLevel; /* level of logging to perform */ 22487c478bd9Sstevel@tonic-gate EXTERN int MaxAliasRecursion; /* maximum depth of alias recursion */ 22497c478bd9Sstevel@tonic-gate EXTERN int MaxChildren; /* maximum number of daemonic children */ 22507c478bd9Sstevel@tonic-gate EXTERN int MaxForwardEntries; /* maximum number of forward entries */ 22517c478bd9Sstevel@tonic-gate EXTERN int MaxHeadersLength; /* max length of headers */ 22527c478bd9Sstevel@tonic-gate EXTERN int MaxHopCount; /* max # of hops until bounce */ 22537c478bd9Sstevel@tonic-gate EXTERN int MaxMacroRecursion; /* maximum depth of macro recursion */ 22547c478bd9Sstevel@tonic-gate EXTERN int MaxMimeFieldLength; /* maximum MIME field length */ 22557c478bd9Sstevel@tonic-gate EXTERN int MaxMimeHeaderLength; /* maximum MIME header length */ 2256445f2479Sjbeck EXTERN int MaxNOOPCommands; /* max "noise" commands before slowdown */ 22577c478bd9Sstevel@tonic-gate 22587c478bd9Sstevel@tonic-gate EXTERN int MaxRcptPerMsg; /* max recipients per SMTP message */ 22597c478bd9Sstevel@tonic-gate EXTERN int MaxRuleRecursion; /* maximum depth of ruleset recursion */ 2260445f2479Sjbeck #if _FFR_MSG_ACCEPT 22613ee0e492Sjbeck EXTERN char *MessageAccept; /* "Message accepted for delivery" reply text */ 2262445f2479Sjbeck #endif /* _FFR_MSG_ACCEPT */ 2263445f2479Sjbeck 22647c478bd9Sstevel@tonic-gate EXTERN int MimeMode; /* MIME processing mode */ 22657c478bd9Sstevel@tonic-gate EXTERN int NoRecipientAction; 22667c478bd9Sstevel@tonic-gate 22677c478bd9Sstevel@tonic-gate #if SM_CONF_SHM 22687c478bd9Sstevel@tonic-gate EXTERN int Numfilesys; /* number of queue file systems */ 22697c478bd9Sstevel@tonic-gate EXTERN int *PNumFileSys; 22707c478bd9Sstevel@tonic-gate # define NumFileSys (*PNumFileSys) 22717c478bd9Sstevel@tonic-gate # else /* SM_CONF_SHM */ 22727c478bd9Sstevel@tonic-gate EXTERN int NumFileSys; /* number of queue file systems */ 22737c478bd9Sstevel@tonic-gate # endif /* SM_CONF_SHM */ 22747c478bd9Sstevel@tonic-gate 22757c478bd9Sstevel@tonic-gate EXTERN int QueueLA; /* load average starting forced queueing */ 22767c478bd9Sstevel@tonic-gate EXTERN int RefuseLA; /* load average refusing connections */ 22777c478bd9Sstevel@tonic-gate EXTERN time_t RejectLogInterval; /* time btwn log msgs while refusing */ 2278445f2479Sjbeck #if _FFR_MEMSTAT 2279445f2479Sjbeck EXTERN long QueueLowMem; /* low memory starting forced queueing */ 2280445f2479Sjbeck EXTERN long RefuseLowMem; /* low memory refusing connections */ 2281445f2479Sjbeck EXTERN char *MemoryResource;/* memory resource to look up */ 2282445f2479Sjbeck #endif /* _FFR_MEMSTAT */ 22837c478bd9Sstevel@tonic-gate EXTERN int SuperSafe; /* be extra careful, even if expensive */ 22847c478bd9Sstevel@tonic-gate EXTERN int VendorCode; /* vendor-specific operation enhancements */ 22857c478bd9Sstevel@tonic-gate EXTERN int Verbose; /* set if blow-by-blow desired */ 22867c478bd9Sstevel@tonic-gate EXTERN gid_t DefGid; /* default gid to run as */ 22877c478bd9Sstevel@tonic-gate EXTERN gid_t RealGid; /* real gid of caller */ 22887c478bd9Sstevel@tonic-gate EXTERN gid_t RunAsGid; /* GID to become for bulk of run */ 22897c478bd9Sstevel@tonic-gate EXTERN gid_t EffGid; /* effective gid */ 22907c478bd9Sstevel@tonic-gate #if SM_CONF_SHM 22917c478bd9Sstevel@tonic-gate EXTERN key_t ShmKey; /* shared memory key */ 22927c478bd9Sstevel@tonic-gate EXTERN char *ShmKeyFile; /* shared memory key file */ 22937c478bd9Sstevel@tonic-gate #endif /* SM_CONF_SHM */ 22947c478bd9Sstevel@tonic-gate EXTERN pid_t CurrentPid; /* current process id */ 22957c478bd9Sstevel@tonic-gate EXTERN pid_t DaemonPid; /* process id of daemon */ 22967c478bd9Sstevel@tonic-gate EXTERN pid_t PidFilePid; /* daemon/queue runner who wrote pid file */ 22977c478bd9Sstevel@tonic-gate EXTERN uid_t DefUid; /* default uid to run as */ 22987c478bd9Sstevel@tonic-gate EXTERN uid_t RealUid; /* real uid of caller */ 22997c478bd9Sstevel@tonic-gate EXTERN uid_t RunAsUid; /* UID to become for bulk of run */ 23007c478bd9Sstevel@tonic-gate EXTERN uid_t TrustedUid; /* uid of trusted user for files and startup */ 23017c478bd9Sstevel@tonic-gate EXTERN size_t DataFileBufferSize; /* size of buf for in-core data file */ 23027c478bd9Sstevel@tonic-gate EXTERN time_t DeliverByMin; /* deliver by minimum time */ 23037c478bd9Sstevel@tonic-gate EXTERN time_t DialDelay; /* delay between dial-on-demand tries */ 23047c478bd9Sstevel@tonic-gate EXTERN time_t SafeAlias; /* interval to wait until @:@ in alias file */ 23057c478bd9Sstevel@tonic-gate EXTERN time_t ServiceCacheMaxAge; /* refresh interval for cache */ 23067c478bd9Sstevel@tonic-gate EXTERN size_t XscriptFileBufferSize; /* size of buf for in-core transcript file */ 23077c478bd9Sstevel@tonic-gate EXTERN MODE_T OldUmask; /* umask when sendmail starts up */ 23087c478bd9Sstevel@tonic-gate EXTERN long MaxMessageSize; /* advertised max size we will accept */ 23097c478bd9Sstevel@tonic-gate EXTERN long MinBlocksFree; /* min # of blocks free on queue fs */ 23107c478bd9Sstevel@tonic-gate EXTERN long QueueFactor; /* slope of queue function */ 23117c478bd9Sstevel@tonic-gate EXTERN long WkClassFact; /* multiplier for message class -> priority */ 23127c478bd9Sstevel@tonic-gate EXTERN long WkRecipFact; /* multiplier for # of recipients -> priority */ 23137c478bd9Sstevel@tonic-gate EXTERN long WkTimeFact; /* priority offset each time this job is run */ 23147c478bd9Sstevel@tonic-gate EXTERN char *ControlSocketName; /* control socket filename [control.c] */ 23157c478bd9Sstevel@tonic-gate EXTERN char *CurHostName; /* current host we are dealing with */ 23167c478bd9Sstevel@tonic-gate EXTERN char *DeadLetterDrop; /* path to dead letter office */ 23177c478bd9Sstevel@tonic-gate EXTERN char *DefUser; /* default user to run as (from DefUid) */ 23187c478bd9Sstevel@tonic-gate EXTERN char *DefaultCharSet; /* default character set for MIME */ 23197c478bd9Sstevel@tonic-gate EXTERN char *DoubleBounceAddr; /* where to send double bounces */ 23207c478bd9Sstevel@tonic-gate EXTERN char *ErrMsgFile; /* file to prepend to all error messages */ 23217c478bd9Sstevel@tonic-gate EXTERN char *FallbackMX; /* fall back MX host */ 23227c478bd9Sstevel@tonic-gate EXTERN char *FallbackSmartHost; /* fall back smart host */ 23237c478bd9Sstevel@tonic-gate EXTERN char *FileName; /* name to print on error messages */ 23247c478bd9Sstevel@tonic-gate EXTERN char *ForwardPath; /* path to search for .forward files */ 23257c478bd9Sstevel@tonic-gate EXTERN char *HeloName; /* hostname to announce in HELO */ 23267c478bd9Sstevel@tonic-gate EXTERN char *HelpFile; /* location of SMTP help file */ 23277c478bd9Sstevel@tonic-gate EXTERN char *HostStatDir; /* location of host status information */ 23287c478bd9Sstevel@tonic-gate EXTERN char *HostsFile; /* path to /etc/hosts file */ 23297c478bd9Sstevel@tonic-gate extern char *Mbdb; /* mailbox database type */ 23307c478bd9Sstevel@tonic-gate EXTERN char *MustQuoteChars; /* quote these characters in phrases */ 23317c478bd9Sstevel@tonic-gate EXTERN char *MyHostName; /* name of this host for SMTP messages */ 23327c478bd9Sstevel@tonic-gate EXTERN char *OperatorChars; /* operators (old $o macro) */ 23337c478bd9Sstevel@tonic-gate EXTERN char *PidFile; /* location of proc id file [conf.c] */ 23347c478bd9Sstevel@tonic-gate EXTERN char *PostMasterCopy; /* address to get errs cc's */ 23357c478bd9Sstevel@tonic-gate EXTERN char *ProcTitlePrefix; /* process title prefix */ 23367c478bd9Sstevel@tonic-gate EXTERN char *RealHostName; /* name of host we are talking to */ 23377c478bd9Sstevel@tonic-gate EXTERN char *RealUserName; /* real user name of caller */ 23387c478bd9Sstevel@tonic-gate EXTERN char *volatile RestartRequest;/* a sendmail restart has been requested */ 23397c478bd9Sstevel@tonic-gate EXTERN char *RunAsUserName; /* user to become for bulk of run */ 23407c478bd9Sstevel@tonic-gate EXTERN char *SafeFileEnv; /* chroot location for file delivery */ 23417c478bd9Sstevel@tonic-gate EXTERN char *ServiceSwitchFile; /* backup service switch */ 23427c478bd9Sstevel@tonic-gate EXTERN char *volatile ShutdownRequest;/* a sendmail shutdown has been requested */ 23437c478bd9Sstevel@tonic-gate EXTERN char *SmtpGreeting; /* SMTP greeting message (old $e macro) */ 23447c478bd9Sstevel@tonic-gate EXTERN char *SmtpPhase; /* current phase in SMTP processing */ 23457c478bd9Sstevel@tonic-gate EXTERN char SmtpError[MAXLINE]; /* save failure error messages */ 23467c478bd9Sstevel@tonic-gate EXTERN char *StatFile; /* location of statistics summary */ 23477c478bd9Sstevel@tonic-gate EXTERN char *TimeZoneSpec; /* override time zone specification */ 23487c478bd9Sstevel@tonic-gate EXTERN char *UdbSpec; /* user database source spec */ 23497c478bd9Sstevel@tonic-gate EXTERN char *UnixFromLine; /* UNIX From_ line (old $l macro) */ 23507c478bd9Sstevel@tonic-gate EXTERN char **ExternalEnviron; /* saved user (input) environment */ 23517c478bd9Sstevel@tonic-gate EXTERN char **SaveArgv; /* argument vector for re-execing */ 23527c478bd9Sstevel@tonic-gate EXTERN BITMAP256 DontBlameSendmail; /* DontBlameSendmail bits */ 23537c478bd9Sstevel@tonic-gate EXTERN SM_FILE_T *InChannel; /* input connection */ 23547c478bd9Sstevel@tonic-gate EXTERN SM_FILE_T *OutChannel; /* output connection */ 23557c478bd9Sstevel@tonic-gate EXTERN SM_FILE_T *TrafficLogFile; /* file in which to log all traffic */ 23567c478bd9Sstevel@tonic-gate #if HESIOD 23577c478bd9Sstevel@tonic-gate EXTERN void *HesiodContext; 23587c478bd9Sstevel@tonic-gate #endif /* HESIOD */ 23597c478bd9Sstevel@tonic-gate EXTERN ENVELOPE *CurEnv; /* envelope currently being processed */ 23607c478bd9Sstevel@tonic-gate EXTERN char *RuleSetNames[MAXRWSETS]; /* ruleset number to name */ 23617c478bd9Sstevel@tonic-gate EXTERN char *UserEnviron[MAXUSERENVIRON + 1]; 23627c478bd9Sstevel@tonic-gate EXTERN struct rewrite *RewriteRules[MAXRWSETS]; 23637c478bd9Sstevel@tonic-gate EXTERN struct termescape TermEscape; /* terminal escape codes */ 23647c478bd9Sstevel@tonic-gate EXTERN SOCKADDR ConnectOnlyTo; /* override connection address (for testing) */ 23657c478bd9Sstevel@tonic-gate EXTERN SOCKADDR RealHostAddr; /* address of host we are talking to */ 23667c478bd9Sstevel@tonic-gate extern const SM_EXC_TYPE_T EtypeQuickAbort; /* type of a QuickAbort exception */ 23677c478bd9Sstevel@tonic-gate 23687c478bd9Sstevel@tonic-gate 23697c478bd9Sstevel@tonic-gate EXTERN int ConnectionRateWindowSize; 23707c478bd9Sstevel@tonic-gate 23717c478bd9Sstevel@tonic-gate /* 23727c478bd9Sstevel@tonic-gate ** Declarations of useful functions 23737c478bd9Sstevel@tonic-gate */ 23747c478bd9Sstevel@tonic-gate 23757c478bd9Sstevel@tonic-gate /* Transcript file */ 23767c478bd9Sstevel@tonic-gate extern void closexscript __P((ENVELOPE *)); 23777c478bd9Sstevel@tonic-gate extern void openxscript __P((ENVELOPE *)); 23787c478bd9Sstevel@tonic-gate 23797c478bd9Sstevel@tonic-gate /* error related */ 23807c478bd9Sstevel@tonic-gate extern void buffer_errors __P((void)); 23817c478bd9Sstevel@tonic-gate extern void flush_errors __P((bool)); 23827c478bd9Sstevel@tonic-gate extern void PRINTFLIKE(1, 2) message __P((const char *, ...)); 23837c478bd9Sstevel@tonic-gate extern void PRINTFLIKE(1, 2) nmessage __P((const char *, ...)); 23847c478bd9Sstevel@tonic-gate extern void PRINTFLIKE(1, 2) syserr __P((const char *, ...)); 23857c478bd9Sstevel@tonic-gate extern void PRINTFLIKE(2, 3) usrerrenh __P((char *, const char *, ...)); 23867c478bd9Sstevel@tonic-gate extern void PRINTFLIKE(1, 2) usrerr __P((const char *, ...)); 23877c478bd9Sstevel@tonic-gate extern int isenhsc __P((const char *, int)); 23887c478bd9Sstevel@tonic-gate extern int extenhsc __P((const char *, int, char *)); 23897c478bd9Sstevel@tonic-gate 23907c478bd9Sstevel@tonic-gate /* alias file */ 23917c478bd9Sstevel@tonic-gate extern void alias __P((ADDRESS *, ADDRESS **, int, ENVELOPE *)); 23927c478bd9Sstevel@tonic-gate extern bool aliaswait __P((MAP *, char *, bool)); 23937c478bd9Sstevel@tonic-gate extern void forward __P((ADDRESS *, ADDRESS **, int, ENVELOPE *)); 23947c478bd9Sstevel@tonic-gate extern void readaliases __P((MAP *, SM_FILE_T *, bool, bool)); 23957c478bd9Sstevel@tonic-gate extern bool rebuildaliases __P((MAP *, bool)); 23967c478bd9Sstevel@tonic-gate extern void setalias __P((char *)); 23977c478bd9Sstevel@tonic-gate 23987c478bd9Sstevel@tonic-gate /* logging */ 23997c478bd9Sstevel@tonic-gate extern void logdelivery __P((MAILER *, MCI *, char *, const char *, ADDRESS *, time_t, ENVELOPE *)); 24007c478bd9Sstevel@tonic-gate extern void logsender __P((ENVELOPE *, char *)); 24017c478bd9Sstevel@tonic-gate extern void PRINTFLIKE(3, 4) sm_syslog __P((int, const char *, const char *, ...)); 24027c478bd9Sstevel@tonic-gate 24037c478bd9Sstevel@tonic-gate /* SMTP */ 24047c478bd9Sstevel@tonic-gate extern void giveresponse __P((int, char *, MAILER *, MCI *, ADDRESS *, time_t, ENVELOPE *, ADDRESS *)); 24057c478bd9Sstevel@tonic-gate extern int reply __P((MAILER *, MCI *, ENVELOPE *, time_t, void (*)__P((char *, bool, MAILER *, MCI *, ENVELOPE *)), char **, int)); 24067c478bd9Sstevel@tonic-gate extern void smtp __P((char *volatile, BITMAP256, ENVELOPE *volatile)); 24077c478bd9Sstevel@tonic-gate #if SASL 24087c478bd9Sstevel@tonic-gate extern int smtpauth __P((MAILER *, MCI *, ENVELOPE *)); 24097c478bd9Sstevel@tonic-gate #endif /* SASL */ 24107c478bd9Sstevel@tonic-gate extern int smtpdata __P((MAILER *, MCI *, ENVELOPE *, ADDRESS *, time_t)); 24117c478bd9Sstevel@tonic-gate extern int smtpgetstat __P((MAILER *, MCI *, ENVELOPE *)); 24127c478bd9Sstevel@tonic-gate extern int smtpmailfrom __P((MAILER *, MCI *, ENVELOPE *)); 24137c478bd9Sstevel@tonic-gate extern void smtpmessage __P((char *, MAILER *, MCI *, ...)); 24147c478bd9Sstevel@tonic-gate extern void smtpinit __P((MAILER *, MCI *, ENVELOPE *, bool)); 24157c478bd9Sstevel@tonic-gate extern char *smtptodsn __P((int)); 24167c478bd9Sstevel@tonic-gate extern int smtpprobe __P((MCI *)); 24177c478bd9Sstevel@tonic-gate extern void smtpquit __P((MAILER *, MCI *, ENVELOPE *)); 24187c478bd9Sstevel@tonic-gate extern int smtprcpt __P((ADDRESS *, MAILER *, MCI *, ENVELOPE *, ADDRESS *, time_t)); 24197c478bd9Sstevel@tonic-gate extern void smtprset __P((MAILER *, MCI *, ENVELOPE *)); 24207c478bd9Sstevel@tonic-gate 2421445f2479Sjbeck #define REPLYTYPE(r) ((r) / 100) /* first digit of reply code */ 24227c478bd9Sstevel@tonic-gate #define ISSMTPCODE(c) (isascii(c[0]) && isdigit(c[0]) && \ 24237c478bd9Sstevel@tonic-gate isascii(c[1]) && isdigit(c[1]) && \ 24247c478bd9Sstevel@tonic-gate isascii(c[2]) && isdigit(c[2])) 24257c478bd9Sstevel@tonic-gate #define ISSMTPREPLY(c) (ISSMTPCODE(c) && \ 24267c478bd9Sstevel@tonic-gate (c[3] == ' ' || c[3] == '-' || c[3] == '\0')) 24277c478bd9Sstevel@tonic-gate 24287c478bd9Sstevel@tonic-gate /* delivery */ 24297c478bd9Sstevel@tonic-gate extern pid_t dowork __P((int, int, char *, bool, bool, ENVELOPE *)); 24307c478bd9Sstevel@tonic-gate extern pid_t doworklist __P((ENVELOPE *, bool, bool)); 24317c478bd9Sstevel@tonic-gate extern int endmailer __P((MCI *, ENVELOPE *, char **)); 24327c478bd9Sstevel@tonic-gate extern int mailfile __P((char *volatile, MAILER *volatile, ADDRESS *, volatile long, ENVELOPE *)); 24337c478bd9Sstevel@tonic-gate extern void sendall __P((ENVELOPE *, int)); 24347c478bd9Sstevel@tonic-gate 24357c478bd9Sstevel@tonic-gate /* stats */ 24367c478bd9Sstevel@tonic-gate #define STATS_NORMAL 'n' 24377c478bd9Sstevel@tonic-gate #define STATS_QUARANTINE 'q' 24387c478bd9Sstevel@tonic-gate #define STATS_REJECT 'r' 24397c478bd9Sstevel@tonic-gate #define STATS_CONNECT 'c' 24407c478bd9Sstevel@tonic-gate 24417c478bd9Sstevel@tonic-gate extern void markstats __P((ENVELOPE *, ADDRESS *, int)); 24427c478bd9Sstevel@tonic-gate extern void clearstats __P((void)); 24437c478bd9Sstevel@tonic-gate extern void poststats __P((char *)); 24447c478bd9Sstevel@tonic-gate 24457c478bd9Sstevel@tonic-gate /* control socket */ 24467c478bd9Sstevel@tonic-gate extern void closecontrolsocket __P((bool)); 24477c478bd9Sstevel@tonic-gate extern void clrcontrol __P((void)); 24487c478bd9Sstevel@tonic-gate extern void control_command __P((int, ENVELOPE *)); 24497c478bd9Sstevel@tonic-gate extern int opencontrolsocket __P((void)); 24507c478bd9Sstevel@tonic-gate 24517c478bd9Sstevel@tonic-gate #if MILTER 24527c478bd9Sstevel@tonic-gate /* milter functions */ 24537c478bd9Sstevel@tonic-gate extern void milter_config __P((char *, struct milter **, int)); 24547c478bd9Sstevel@tonic-gate extern void milter_setup __P((char *)); 24557c478bd9Sstevel@tonic-gate extern void milter_set_option __P((char *, char *, bool)); 2456*7800901eSjbeck extern bool milter_init __P((ENVELOPE *, char *, milters_T *)); 24577c478bd9Sstevel@tonic-gate extern void milter_quit __P((ENVELOPE *)); 24587c478bd9Sstevel@tonic-gate extern void milter_abort __P((ENVELOPE *)); 24597c478bd9Sstevel@tonic-gate extern char *milter_connect __P((char *, SOCKADDR, ENVELOPE *, char *)); 24607c478bd9Sstevel@tonic-gate extern char *milter_helo __P((char *, ENVELOPE *, char *)); 24617c478bd9Sstevel@tonic-gate extern char *milter_envfrom __P((char **, ENVELOPE *, char *)); 24627c478bd9Sstevel@tonic-gate extern char *milter_data_cmd __P((ENVELOPE *, char *)); 2463058561cbSjbeck extern char *milter_envrcpt __P((char **, ENVELOPE *, char *, bool)); 24647c478bd9Sstevel@tonic-gate extern char *milter_data __P((ENVELOPE *, char *)); 24657c478bd9Sstevel@tonic-gate extern char *milter_unknown __P((char *, ENVELOPE *, char *)); 24667c478bd9Sstevel@tonic-gate #endif /* MILTER */ 24677c478bd9Sstevel@tonic-gate 24687c478bd9Sstevel@tonic-gate extern char *addquotes __P((char *, SM_RPOOL_T *)); 24697c478bd9Sstevel@tonic-gate extern char *arpadate __P((char *)); 24707c478bd9Sstevel@tonic-gate extern bool atobool __P((char *)); 24717c478bd9Sstevel@tonic-gate extern int atooct __P((char *)); 24727c478bd9Sstevel@tonic-gate extern void auth_warning __P((ENVELOPE *, const char *, ...)); 24737c478bd9Sstevel@tonic-gate extern int blocksignal __P((int)); 24747c478bd9Sstevel@tonic-gate extern bool bitintersect __P((BITMAP256, BITMAP256)); 24757c478bd9Sstevel@tonic-gate extern bool bitzerop __P((BITMAP256)); 24767c478bd9Sstevel@tonic-gate extern int check_bodytype __P((char *)); 24777c478bd9Sstevel@tonic-gate extern void buildfname __P((char *, char *, char *, int)); 24787c478bd9Sstevel@tonic-gate extern bool chkclientmodifiers __P((int)); 24797c478bd9Sstevel@tonic-gate extern bool chkdaemonmodifiers __P((int)); 24807c478bd9Sstevel@tonic-gate extern int checkcompat __P((ADDRESS *, ENVELOPE *)); 24817c478bd9Sstevel@tonic-gate #ifdef XDEBUG 24827c478bd9Sstevel@tonic-gate extern void checkfd012 __P((char *)); 24837c478bd9Sstevel@tonic-gate extern void checkfdopen __P((int, char *)); 24847c478bd9Sstevel@tonic-gate #endif /* XDEBUG */ 24857c478bd9Sstevel@tonic-gate extern void checkfds __P((char *)); 24867c478bd9Sstevel@tonic-gate extern bool chownsafe __P((int, bool)); 24877c478bd9Sstevel@tonic-gate extern void cleanstrcpy __P((char *, char *, int)); 24887c478bd9Sstevel@tonic-gate #if SM_CONF_SHM 24897c478bd9Sstevel@tonic-gate extern void cleanup_shm __P((bool)); 24907c478bd9Sstevel@tonic-gate #endif /* SM_CONF_SHM */ 24917c478bd9Sstevel@tonic-gate extern void close_sendmail_pid __P((void)); 24927c478bd9Sstevel@tonic-gate extern void clrdaemon __P((void)); 24937c478bd9Sstevel@tonic-gate extern void collect __P((SM_FILE_T *, bool, HDR **, ENVELOPE *, bool)); 24947c478bd9Sstevel@tonic-gate extern bool connection_rate_check __P((SOCKADDR *, ENVELOPE *)); 24957c478bd9Sstevel@tonic-gate extern time_t convtime __P((char *, int)); 24967c478bd9Sstevel@tonic-gate extern char **copyplist __P((char **, bool, SM_RPOOL_T *)); 24977c478bd9Sstevel@tonic-gate extern void copy_class __P((int, int)); 24987c478bd9Sstevel@tonic-gate extern int count_open_connections __P((SOCKADDR *)); 24997c478bd9Sstevel@tonic-gate extern time_t curtime __P((void)); 25007c478bd9Sstevel@tonic-gate extern char *defcharset __P((ENVELOPE *)); 25017c478bd9Sstevel@tonic-gate extern char *denlstring __P((char *, bool, bool)); 25027c478bd9Sstevel@tonic-gate extern void dferror __P((SM_FILE_T *volatile, char *, ENVELOPE *)); 25037c478bd9Sstevel@tonic-gate extern void disconnect __P((int, ENVELOPE *)); 25047c478bd9Sstevel@tonic-gate extern void disk_status __P((SM_FILE_T *, char *)); 25057c478bd9Sstevel@tonic-gate extern bool dns_getcanonname __P((char *, int, bool, int *, int *)); 25067c478bd9Sstevel@tonic-gate extern pid_t dofork __P((void)); 25077c478bd9Sstevel@tonic-gate extern int drop_privileges __P((bool)); 25087c478bd9Sstevel@tonic-gate extern int dsntoexitstat __P((char *)); 25097c478bd9Sstevel@tonic-gate extern void dumpfd __P((int, bool, bool)); 2510058561cbSjbeck #if SM_HEAP_CHECK 2511058561cbSjbeck extern void dumpstab __P((void)); 2512058561cbSjbeck #endif /* SM_HEAP_CHECK */ 25137c478bd9Sstevel@tonic-gate extern void dumpstate __P((char *)); 25147c478bd9Sstevel@tonic-gate extern bool enoughdiskspace __P((long, ENVELOPE *)); 25157c478bd9Sstevel@tonic-gate extern char *exitstat __P((char *)); 25167c478bd9Sstevel@tonic-gate extern void fatal_error __P((SM_EXC_T *)); 2517058561cbSjbeck extern char *fgetfolded __P((char *, int *, SM_FILE_T *)); 25187c478bd9Sstevel@tonic-gate extern void fill_fd __P((int, char *)); 25197c478bd9Sstevel@tonic-gate extern char *find_character __P((char *, int)); 25207c478bd9Sstevel@tonic-gate extern int finduser __P((char *, bool *, SM_MBDB_T *)); 25217c478bd9Sstevel@tonic-gate extern void finis __P((bool, bool, volatile int)); 25227c478bd9Sstevel@tonic-gate extern void fixcrlf __P((char *, bool)); 2523058561cbSjbeck extern long freediskspace __P((const char *, long *)); 25247c478bd9Sstevel@tonic-gate #if NETINET6 && NEEDSGETIPNODE 25257c478bd9Sstevel@tonic-gate extern void freehostent __P((struct hostent *)); 25267c478bd9Sstevel@tonic-gate #endif /* NETINET6 && NEEDSGETIPNODE */ 25277c478bd9Sstevel@tonic-gate extern char *get_column __P((char *, int, int, char *, int)); 25287c478bd9Sstevel@tonic-gate extern char *getauthinfo __P((int, bool *)); 25297c478bd9Sstevel@tonic-gate extern int getdtsize __P((void)); 25307c478bd9Sstevel@tonic-gate extern int getla __P((void)); 25317c478bd9Sstevel@tonic-gate extern char *getmodifiers __P((char *, BITMAP256)); 25327c478bd9Sstevel@tonic-gate extern BITMAP256 *getrequests __P((ENVELOPE *)); 25337c478bd9Sstevel@tonic-gate extern char *getvendor __P((int)); 25347c478bd9Sstevel@tonic-gate extern void help __P((char *, ENVELOPE *)); 25357c478bd9Sstevel@tonic-gate extern void init_md __P((int, char **)); 25367c478bd9Sstevel@tonic-gate extern void initdaemon __P((void)); 25377c478bd9Sstevel@tonic-gate extern void inithostmaps __P((void)); 25387c478bd9Sstevel@tonic-gate extern void initmacros __P((ENVELOPE *)); 25397c478bd9Sstevel@tonic-gate extern void initsetproctitle __P((int, char **, char **)); 25407c478bd9Sstevel@tonic-gate extern void init_vendor_macros __P((ENVELOPE *)); 25417c478bd9Sstevel@tonic-gate extern SIGFUNC_DECL intsig __P((int)); 25427c478bd9Sstevel@tonic-gate extern bool isloopback __P((SOCKADDR sa)); 25437c478bd9Sstevel@tonic-gate extern void load_if_names __P((void)); 25447c478bd9Sstevel@tonic-gate extern bool lockfile __P((int, char *, char *, int)); 25457c478bd9Sstevel@tonic-gate extern void log_sendmail_pid __P((ENVELOPE *)); 25467c478bd9Sstevel@tonic-gate extern void logundelrcpts __P((ENVELOPE *, char *, int, bool)); 25477c478bd9Sstevel@tonic-gate extern char lower __P((int)); 25487c478bd9Sstevel@tonic-gate extern void makelower __P((char *)); 25497c478bd9Sstevel@tonic-gate extern int makeconnection_ds __P((char *, MCI *)); 25507c478bd9Sstevel@tonic-gate extern int makeconnection __P((char *, volatile unsigned int, MCI *, ENVELOPE *, time_t)); 25517c478bd9Sstevel@tonic-gate extern void makeworkgroups __P((void)); 25527c478bd9Sstevel@tonic-gate extern void markfailure __P((ENVELOPE *, ADDRESS *, MCI *, int, bool)); 25537c478bd9Sstevel@tonic-gate extern void mark_work_group_restart __P((int, int)); 2554058561cbSjbeck extern MCI *mci_new __P((SM_RPOOL_T *)); 2555058561cbSjbeck extern char *munchstring __P((char *, char **, int)); 25567c478bd9Sstevel@tonic-gate extern struct hostent *myhostname __P((char *, int)); 25577c478bd9Sstevel@tonic-gate extern char *newstr __P((const char *)); 25587c478bd9Sstevel@tonic-gate #if NISPLUS 25597c478bd9Sstevel@tonic-gate extern char *nisplus_default_domain __P((void)); /* extern for Sun */ 25607c478bd9Sstevel@tonic-gate #endif /* NISPLUS */ 25617c478bd9Sstevel@tonic-gate extern bool path_is_dir __P((char *, bool)); 25627c478bd9Sstevel@tonic-gate extern int pickqdir __P((QUEUEGRP *qg, long fsize, ENVELOPE *e)); 25637c478bd9Sstevel@tonic-gate extern char *pintvl __P((time_t, bool)); 25647c478bd9Sstevel@tonic-gate extern void printav __P((SM_FILE_T *, char **)); 25657c478bd9Sstevel@tonic-gate extern void printmailer __P((SM_FILE_T *, MAILER *)); 25667c478bd9Sstevel@tonic-gate extern void printnqe __P((SM_FILE_T *, char *)); 25677c478bd9Sstevel@tonic-gate extern void printopenfds __P((bool)); 25687c478bd9Sstevel@tonic-gate extern void printqueue __P((void)); 25697c478bd9Sstevel@tonic-gate extern void printrules __P((void)); 25707c478bd9Sstevel@tonic-gate extern pid_t prog_open __P((char **, int *, ENVELOPE *)); 2571445f2479Sjbeck extern bool putline __P((char *, MCI *)); 2572445f2479Sjbeck extern bool putxline __P((char *, size_t, MCI *, int)); 25737c478bd9Sstevel@tonic-gate extern void queueup_macros __P((int, SM_FILE_T *, ENVELOPE *)); 25747c478bd9Sstevel@tonic-gate extern void readcf __P((char *, bool, ENVELOPE *)); 25757c478bd9Sstevel@tonic-gate extern SIGFUNC_DECL reapchild __P((int)); 25767c478bd9Sstevel@tonic-gate extern int releasesignal __P((int)); 25777c478bd9Sstevel@tonic-gate extern void resetlimits __P((void)); 25787c478bd9Sstevel@tonic-gate extern void restart_daemon __P((void)); 25797c478bd9Sstevel@tonic-gate extern void restart_marked_work_groups __P((void)); 25807c478bd9Sstevel@tonic-gate extern bool rfc822_string __P((char *)); 2581058561cbSjbeck extern void rmexpstab __P((void)); 25827c478bd9Sstevel@tonic-gate extern bool savemail __P((ENVELOPE *, bool)); 25837c478bd9Sstevel@tonic-gate extern void seed_random __P((void)); 25847c478bd9Sstevel@tonic-gate extern void sendtoargv __P((char **, ENVELOPE *)); 25857c478bd9Sstevel@tonic-gate extern void setclientoptions __P((char *)); 25867c478bd9Sstevel@tonic-gate extern bool setdaemonoptions __P((char *)); 25877c478bd9Sstevel@tonic-gate extern void setdefaults __P((ENVELOPE *)); 25887c478bd9Sstevel@tonic-gate extern void setdefuser __P((void)); 25897c478bd9Sstevel@tonic-gate extern bool setvendor __P((char *)); 25907c478bd9Sstevel@tonic-gate extern void set_op_mode __P((int)); 25917c478bd9Sstevel@tonic-gate extern void setoption __P((int, char *, bool, bool, ENVELOPE *)); 25927c478bd9Sstevel@tonic-gate extern sigfunc_t setsignal __P((int, sigfunc_t)); 2593445f2479Sjbeck extern void sm_setuserenv __P((const char *, const char *)); 25947c478bd9Sstevel@tonic-gate extern void settime __P((ENVELOPE *)); 25957c478bd9Sstevel@tonic-gate extern char *sfgets __P((char *, int, SM_FILE_T *, time_t, char *)); 25967c478bd9Sstevel@tonic-gate extern char *shortenstring __P((const char *, size_t)); 25977c478bd9Sstevel@tonic-gate extern char *shorten_hostname __P((char [])); 25987c478bd9Sstevel@tonic-gate extern bool shorten_rfc822_string __P((char *, size_t)); 25997c478bd9Sstevel@tonic-gate extern void shutdown_daemon __P((void)); 26007c478bd9Sstevel@tonic-gate extern void sm_closefrom __P((int lowest, int highest)); 26017c478bd9Sstevel@tonic-gate extern void sm_close_on_exec __P((int lowest, int highest)); 26027c478bd9Sstevel@tonic-gate extern struct hostent *sm_gethostbyname __P((char *, int)); 26037c478bd9Sstevel@tonic-gate extern struct hostent *sm_gethostbyaddr __P((char *, int, int)); 26047c478bd9Sstevel@tonic-gate extern void sm_getla __P((void)); 26057c478bd9Sstevel@tonic-gate extern struct passwd *sm_getpwnam __P((char *)); 26067c478bd9Sstevel@tonic-gate extern struct passwd *sm_getpwuid __P((UID_T)); 26077c478bd9Sstevel@tonic-gate extern void sm_setproctitle __P((bool, ENVELOPE *, const char *, ...)); 26087c478bd9Sstevel@tonic-gate extern pid_t sm_wait __P((int *)); 26097c478bd9Sstevel@tonic-gate extern bool split_by_recipient __P((ENVELOPE *e)); 26107c478bd9Sstevel@tonic-gate extern void stop_sendmail __P((void)); 26117c478bd9Sstevel@tonic-gate extern void stripbackslash __P((char *)); 26127c478bd9Sstevel@tonic-gate extern bool strreplnonprt __P((char *, int)); 26137c478bd9Sstevel@tonic-gate extern bool strcontainedin __P((bool, char *, char *)); 26147c478bd9Sstevel@tonic-gate extern int switch_map_find __P((char *, char *[], short [])); 2615058561cbSjbeck #if STARTTLS 2616058561cbSjbeck extern void tls_set_verify __P((SSL_CTX *, SSL *, bool)); 2617058561cbSjbeck #endif /* STARTTLS */ 26187c478bd9Sstevel@tonic-gate extern bool transienterror __P((int)); 26197c478bd9Sstevel@tonic-gate extern void truncate_at_delim __P((char *, size_t, int)); 26207c478bd9Sstevel@tonic-gate extern void tTflag __P((char *)); 26217c478bd9Sstevel@tonic-gate extern void tTsetup __P((unsigned char *, unsigned int, char *)); 26227c478bd9Sstevel@tonic-gate extern SIGFUNC_DECL tick __P((int)); 26237c478bd9Sstevel@tonic-gate extern char *ttypath __P((void)); 26247c478bd9Sstevel@tonic-gate extern void unlockqueue __P((ENVELOPE *)); 26257c478bd9Sstevel@tonic-gate #if !HASUNSETENV 26267c478bd9Sstevel@tonic-gate extern void unsetenv __P((char *)); 26277c478bd9Sstevel@tonic-gate #endif /* !HASUNSETENV */ 26287c478bd9Sstevel@tonic-gate 26297c478bd9Sstevel@tonic-gate /* update file system information: +/- some blocks */ 26307c478bd9Sstevel@tonic-gate #if SM_CONF_SHM 26317c478bd9Sstevel@tonic-gate extern void upd_qs __P((ENVELOPE *, bool, bool, char *)); 26327c478bd9Sstevel@tonic-gate # define updfs(e, count, space, where) upd_qs(e, count, space, where) 26337c478bd9Sstevel@tonic-gate #else /* SM_CONF_SHM */ 26347c478bd9Sstevel@tonic-gate # define updfs(e, count, space, where) 26357c478bd9Sstevel@tonic-gate # define upd_qs(e, count, space, where) 26367c478bd9Sstevel@tonic-gate #endif /* SM_CONF_SHM */ 26377c478bd9Sstevel@tonic-gate 26387c478bd9Sstevel@tonic-gate extern char *username __P((void)); 26397c478bd9Sstevel@tonic-gate extern bool usershellok __P((char *, char *)); 26407c478bd9Sstevel@tonic-gate extern void vendor_post_defaults __P((ENVELOPE *)); 26417c478bd9Sstevel@tonic-gate extern void vendor_pre_defaults __P((ENVELOPE *)); 26427c478bd9Sstevel@tonic-gate extern int waitfor __P((pid_t)); 26437c478bd9Sstevel@tonic-gate extern bool writable __P((char *, ADDRESS *, long)); 26447c478bd9Sstevel@tonic-gate #if SM_HEAP_CHECK 26457c478bd9Sstevel@tonic-gate # define xalloc(size) xalloc_tagged(size, __FILE__, __LINE__) 26467c478bd9Sstevel@tonic-gate extern char *xalloc_tagged __P((int, char*, int)); 26477c478bd9Sstevel@tonic-gate #else /* SM_HEAP_CHECK */ 26487c478bd9Sstevel@tonic-gate extern char *xalloc __P((int)); 26497c478bd9Sstevel@tonic-gate #endif /* SM_HEAP_CHECK */ 26507c478bd9Sstevel@tonic-gate extern void xputs __P((SM_FILE_T *, const char *)); 26517c478bd9Sstevel@tonic-gate extern char *xtextify __P((char *, char *)); 26527c478bd9Sstevel@tonic-gate extern bool xtextok __P((char *)); 26537c478bd9Sstevel@tonic-gate extern int xunlink __P((char *)); 26547c478bd9Sstevel@tonic-gate extern char *xuntextify __P((char *)); 26557c478bd9Sstevel@tonic-gate 26567c478bd9Sstevel@tonic-gate 2657058561cbSjbeck #undef EXTERN 26587c478bd9Sstevel@tonic-gate #endif /* ! _SENDMAIL_H */ 2659