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