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