17c478bd9Sstevel@tonic-gate /* 2*e9af4bc0SJohn Beck * Copyright (c) 1998-2009 Sendmail, Inc. and its suppliers. 37c478bd9Sstevel@tonic-gate * All rights reserved. 47c478bd9Sstevel@tonic-gate * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. 57c478bd9Sstevel@tonic-gate * Copyright (c) 1988, 1993 67c478bd9Sstevel@tonic-gate * The Regents of the University of California. All rights reserved. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * By using this file, you agree to the terms and conditions set 97c478bd9Sstevel@tonic-gate * forth in the LICENSE file which can be found at the top level of 107c478bd9Sstevel@tonic-gate * the sendmail distribution. 117c478bd9Sstevel@tonic-gate */ 127c478bd9Sstevel@tonic-gate 137c478bd9Sstevel@tonic-gate /* 147c478bd9Sstevel@tonic-gate ** SENDMAIL.H -- MTA-specific definitions for sendmail. 157c478bd9Sstevel@tonic-gate */ 167c478bd9Sstevel@tonic-gate 177c478bd9Sstevel@tonic-gate #ifndef _SENDMAIL_H 187c478bd9Sstevel@tonic-gate # define _SENDMAIL_H 1 197c478bd9Sstevel@tonic-gate 207c478bd9Sstevel@tonic-gate #ifndef MILTER 217c478bd9Sstevel@tonic-gate # define MILTER 1 /* turn on MILTER by default */ 227c478bd9Sstevel@tonic-gate #endif /* MILTER */ 237c478bd9Sstevel@tonic-gate 247c478bd9Sstevel@tonic-gate #ifdef _DEFINE 257c478bd9Sstevel@tonic-gate # define EXTERN 267c478bd9Sstevel@tonic-gate #else /* _DEFINE */ 277c478bd9Sstevel@tonic-gate # define EXTERN extern 287c478bd9Sstevel@tonic-gate #endif /* _DEFINE */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #include <unistd.h> 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include <stddef.h> 347c478bd9Sstevel@tonic-gate #include <stdlib.h> 357c478bd9Sstevel@tonic-gate #include <stdio.h> 367c478bd9Sstevel@tonic-gate #include <ctype.h> 377c478bd9Sstevel@tonic-gate #include <setjmp.h> 387c478bd9Sstevel@tonic-gate #include <string.h> 397c478bd9Sstevel@tonic-gate #include <time.h> 407c478bd9Sstevel@tonic-gate # ifdef EX_OK 417c478bd9Sstevel@tonic-gate # undef EX_OK /* for SVr4.2 SMP */ 427c478bd9Sstevel@tonic-gate # endif /* EX_OK */ 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate #include "sendmail/sendmail.h" 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate /* profiling? */ 477c478bd9Sstevel@tonic-gate #if MONCONTROL 487c478bd9Sstevel@tonic-gate # define SM_PROF(x) moncontrol(x) 497c478bd9Sstevel@tonic-gate #else /* MONCONTROL */ 507c478bd9Sstevel@tonic-gate # define SM_PROF(x) 517c478bd9Sstevel@tonic-gate #endif /* MONCONTROL */ 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate #ifdef _DEFINE 547c478bd9Sstevel@tonic-gate # ifndef lint 55*e9af4bc0SJohn Beck SM_UNUSED(static char SmailId[]) = "@(#)$Id: sendmail.h,v 8.1068 2009/12/18 17:08:01 ca Exp $"; 567c478bd9Sstevel@tonic-gate # endif /* ! lint */ 577c478bd9Sstevel@tonic-gate #endif /* _DEFINE */ 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate #include "bf.h" 607c478bd9Sstevel@tonic-gate #include "timers.h" 617c478bd9Sstevel@tonic-gate #include <sm/exc.h> 627c478bd9Sstevel@tonic-gate #include <sm/heap.h> 637c478bd9Sstevel@tonic-gate #include <sm/debug.h> 647c478bd9Sstevel@tonic-gate #include <sm/rpool.h> 657c478bd9Sstevel@tonic-gate #include <sm/io.h> 667c478bd9Sstevel@tonic-gate #include <sm/path.h> 677c478bd9Sstevel@tonic-gate #include <sm/signal.h> 687c478bd9Sstevel@tonic-gate #include <sm/clock.h> 697c478bd9Sstevel@tonic-gate #include <sm/mbdb.h> 707c478bd9Sstevel@tonic-gate #include <sm/errstring.h> 717c478bd9Sstevel@tonic-gate #include <sm/sysexits.h> 727c478bd9Sstevel@tonic-gate #include <sm/shm.h> 73058561cbSjbeck #include <sm/misc.h> 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate #ifdef LOG 767c478bd9Sstevel@tonic-gate # include <syslog.h> 777c478bd9Sstevel@tonic-gate #endif /* LOG */ 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate # if NETINET || NETINET6 || NETUNIX || NETISO || NETNS || NETX25 827c478bd9Sstevel@tonic-gate # include <sys/socket.h> 837c478bd9Sstevel@tonic-gate # endif /* NETINET || NETINET6 || NETUNIX || NETISO || NETNS || NETX25 */ 847c478bd9Sstevel@tonic-gate # if NETUNIX 857c478bd9Sstevel@tonic-gate # include <sys/un.h> 867c478bd9Sstevel@tonic-gate # endif /* NETUNIX */ 877c478bd9Sstevel@tonic-gate # if NETINET || NETINET6 887c478bd9Sstevel@tonic-gate # include <netinet/in.h> 897c478bd9Sstevel@tonic-gate # endif /* NETINET || NETINET6 */ 907c478bd9Sstevel@tonic-gate # if NETINET6 917c478bd9Sstevel@tonic-gate /* 927c478bd9Sstevel@tonic-gate ** There is no standard yet for IPv6 includes. 937c478bd9Sstevel@tonic-gate ** Specify OS specific implementation in conf.h 947c478bd9Sstevel@tonic-gate */ 957c478bd9Sstevel@tonic-gate # endif /* NETINET6 */ 967c478bd9Sstevel@tonic-gate # if NETISO 977c478bd9Sstevel@tonic-gate # include <netiso/iso.h> 987c478bd9Sstevel@tonic-gate # endif /* NETISO */ 997c478bd9Sstevel@tonic-gate # if NETNS 1007c478bd9Sstevel@tonic-gate # include <netns/ns.h> 1017c478bd9Sstevel@tonic-gate # endif /* NETNS */ 1027c478bd9Sstevel@tonic-gate # if NETX25 1037c478bd9Sstevel@tonic-gate # include <netccitt/x25.h> 1047c478bd9Sstevel@tonic-gate # endif /* NETX25 */ 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate # if NAMED_BIND 1077c478bd9Sstevel@tonic-gate # include <arpa/nameser.h> 1087c478bd9Sstevel@tonic-gate # ifdef NOERROR 1097c478bd9Sstevel@tonic-gate # undef NOERROR /* avoid <sys/streams.h> conflict */ 1107c478bd9Sstevel@tonic-gate # endif /* NOERROR */ 1117c478bd9Sstevel@tonic-gate # include <resolv.h> 1127c478bd9Sstevel@tonic-gate # else /* NAMED_BIND */ 1137c478bd9Sstevel@tonic-gate # undef SM_SET_H_ERRNO 1147c478bd9Sstevel@tonic-gate # define SM_SET_H_ERRNO(err) 1157c478bd9Sstevel@tonic-gate # endif /* NAMED_BIND */ 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate # if HESIOD 1187c478bd9Sstevel@tonic-gate # include <hesiod.h> 1197c478bd9Sstevel@tonic-gate # if !defined(HES_ER_OK) || defined(HESIOD_INTERFACES) 1207c478bd9Sstevel@tonic-gate # define HESIOD_INIT /* support for the new interface */ 1217c478bd9Sstevel@tonic-gate # endif /* !defined(HES_ER_OK) || defined(HESIOD_INTERFACES) */ 1227c478bd9Sstevel@tonic-gate # endif /* HESIOD */ 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate #if STARTTLS 1257c478bd9Sstevel@tonic-gate # include <openssl/ssl.h> 1267c478bd9Sstevel@tonic-gate # if !TLS_NO_RSA 1277c478bd9Sstevel@tonic-gate # define RSA_KEYLENGTH 512 1287c478bd9Sstevel@tonic-gate # endif /* !TLS_NO_RSA */ 1297c478bd9Sstevel@tonic-gate #endif /* STARTTLS */ 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate #if SASL /* include the sasl include files if we have them */ 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate # if SASL == 2 || SASL >= 20000 1357c478bd9Sstevel@tonic-gate # include <sasl/sasl.h> 1367c478bd9Sstevel@tonic-gate # include <sasl/saslutil.h> 1377c478bd9Sstevel@tonic-gate # else /* SASL == 2 || SASL >= 20000 */ 1387c478bd9Sstevel@tonic-gate # include <sasl.h> 1397c478bd9Sstevel@tonic-gate # include <saslutil.h> 1407c478bd9Sstevel@tonic-gate # endif /* SASL == 2 || SASL >= 20000 */ 1417c478bd9Sstevel@tonic-gate # if defined(SASL_VERSION_MAJOR) && defined(SASL_VERSION_MINOR) && defined(SASL_VERSION_STEP) 1427c478bd9Sstevel@tonic-gate # define SASL_VERSION (SASL_VERSION_MAJOR * 10000) + (SASL_VERSION_MINOR * 100) + SASL_VERSION_STEP 1437c478bd9Sstevel@tonic-gate # if SASL == 1 || SASL == 2 1447c478bd9Sstevel@tonic-gate # undef SASL 1457c478bd9Sstevel@tonic-gate # define SASL SASL_VERSION 1467c478bd9Sstevel@tonic-gate # else /* SASL == 1 || SASL == 2 */ 1477c478bd9Sstevel@tonic-gate # if SASL != SASL_VERSION 1487c478bd9Sstevel@tonic-gate ERROR README: -DSASL (SASL) does not agree with the version of the CYRUS_SASL library (SASL_VERSION) 1497c478bd9Sstevel@tonic-gate ERROR README: see README! 1507c478bd9Sstevel@tonic-gate # endif /* SASL != SASL_VERSION */ 1517c478bd9Sstevel@tonic-gate # endif /* SASL == 1 || SASL == 2 */ 1527c478bd9Sstevel@tonic-gate # else /* defined(SASL_VERSION_MAJOR) && defined(SASL_VERSION_MINOR) && defined(SASL_VERSION_STEP) */ 1537c478bd9Sstevel@tonic-gate # if SASL == 1 1547c478bd9Sstevel@tonic-gate ERROR README: please set -DSASL to the version of the CYRUS_SASL library 1557c478bd9Sstevel@tonic-gate ERROR README: see README! 1567c478bd9Sstevel@tonic-gate # endif /* SASL == 1 */ 1577c478bd9Sstevel@tonic-gate # endif /* defined(SASL_VERSION_MAJOR) && defined(SASL_VERSION_MINOR) && defined(SASL_VERSION_STEP) */ 1587c478bd9Sstevel@tonic-gate #endif /* SASL */ 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate /* 1617c478bd9Sstevel@tonic-gate ** Following are "sort of" configuration constants, but they should 1627c478bd9Sstevel@tonic-gate ** be pretty solid on most architectures today. They have to be 1637c478bd9Sstevel@tonic-gate ** defined after <arpa/nameser.h> because some versions of that 1647c478bd9Sstevel@tonic-gate ** file also define them. In all cases, we can't use sizeof because 1657c478bd9Sstevel@tonic-gate ** some systems (e.g., Crays) always treat everything as being at 1667c478bd9Sstevel@tonic-gate ** least 64 bits. 1677c478bd9Sstevel@tonic-gate */ 1687c478bd9Sstevel@tonic-gate 1697c478bd9Sstevel@tonic-gate #ifndef INADDRSZ 1707c478bd9Sstevel@tonic-gate # define INADDRSZ 4 /* size of an IPv4 address in bytes */ 1717c478bd9Sstevel@tonic-gate #endif /* ! INADDRSZ */ 1727c478bd9Sstevel@tonic-gate #ifndef IN6ADDRSZ 1737c478bd9Sstevel@tonic-gate # define IN6ADDRSZ 16 /* size of an IPv6 address in bytes */ 1747c478bd9Sstevel@tonic-gate #endif /* ! IN6ADDRSZ */ 1757c478bd9Sstevel@tonic-gate #ifndef INT16SZ 1767c478bd9Sstevel@tonic-gate # define INT16SZ 2 /* size of a 16 bit integer in bytes */ 1777c478bd9Sstevel@tonic-gate #endif /* ! INT16SZ */ 1787c478bd9Sstevel@tonic-gate #ifndef INT32SZ 1797c478bd9Sstevel@tonic-gate # define INT32SZ 4 /* size of a 32 bit integer in bytes */ 1807c478bd9Sstevel@tonic-gate #endif /* ! INT32SZ */ 1817c478bd9Sstevel@tonic-gate #ifndef INADDR_LOOPBACK 1827c478bd9Sstevel@tonic-gate # define INADDR_LOOPBACK 0x7f000001 /* loopback address */ 1837c478bd9Sstevel@tonic-gate #endif /* ! INADDR_LOOPBACK */ 1847c478bd9Sstevel@tonic-gate 1857c478bd9Sstevel@tonic-gate /* 1867c478bd9Sstevel@tonic-gate ** Error return from inet_addr(3), in case not defined in /usr/include. 1877c478bd9Sstevel@tonic-gate */ 1887c478bd9Sstevel@tonic-gate 1897c478bd9Sstevel@tonic-gate #ifndef INADDR_NONE 1907c478bd9Sstevel@tonic-gate # define INADDR_NONE 0xffffffff 1917c478bd9Sstevel@tonic-gate #endif /* ! INADDR_NONE */ 1927c478bd9Sstevel@tonic-gate 1937c478bd9Sstevel@tonic-gate 1947c478bd9Sstevel@tonic-gate /* (f)open() modes for queue files */ 1957c478bd9Sstevel@tonic-gate # define QF_O_EXTRA 0 1967c478bd9Sstevel@tonic-gate 1977c478bd9Sstevel@tonic-gate 1987c478bd9Sstevel@tonic-gate /* 1997c478bd9Sstevel@tonic-gate ** An 'argument class' describes the storage allocation status 2007c478bd9Sstevel@tonic-gate ** of an object pointed to by an argument to a function. 2017c478bd9Sstevel@tonic-gate */ 2027c478bd9Sstevel@tonic-gate 2037c478bd9Sstevel@tonic-gate typedef enum 2047c478bd9Sstevel@tonic-gate { 2057c478bd9Sstevel@tonic-gate A_HEAP, /* the storage was allocated by malloc, and the 2067c478bd9Sstevel@tonic-gate * ownership of the storage is ceded by the caller 2077c478bd9Sstevel@tonic-gate * to the called function. */ 2087c478bd9Sstevel@tonic-gate A_TEMP, /* The storage is temporary, and is only guaranteed 2097c478bd9Sstevel@tonic-gate * to be valid for the duration of the function call. */ 2107c478bd9Sstevel@tonic-gate A_PERM /* The storage is 'permanent': this might mean static 2117c478bd9Sstevel@tonic-gate * storage, or rpool storage. */ 2127c478bd9Sstevel@tonic-gate } ARGCLASS_T; 2137c478bd9Sstevel@tonic-gate 2147c478bd9Sstevel@tonic-gate /* forward references for prototypes */ 2157c478bd9Sstevel@tonic-gate typedef struct envelope ENVELOPE; 2167c478bd9Sstevel@tonic-gate typedef struct mailer MAILER; 2177c478bd9Sstevel@tonic-gate typedef struct queuegrp QUEUEGRP; 2187c478bd9Sstevel@tonic-gate 2197c478bd9Sstevel@tonic-gate /* 2207c478bd9Sstevel@tonic-gate ** Address structure. 2217c478bd9Sstevel@tonic-gate ** Addresses are stored internally in this structure. 2227c478bd9Sstevel@tonic-gate */ 2237c478bd9Sstevel@tonic-gate 2247c478bd9Sstevel@tonic-gate struct address 2257c478bd9Sstevel@tonic-gate { 2267c478bd9Sstevel@tonic-gate char *q_paddr; /* the printname for the address */ 2277c478bd9Sstevel@tonic-gate char *q_user; /* user name */ 2287c478bd9Sstevel@tonic-gate char *q_ruser; /* real user name, or NULL if q_user */ 2297c478bd9Sstevel@tonic-gate char *q_host; /* host name */ 2307c478bd9Sstevel@tonic-gate struct mailer *q_mailer; /* mailer to use */ 2317c478bd9Sstevel@tonic-gate unsigned long q_flags; /* status flags, see below */ 2327c478bd9Sstevel@tonic-gate uid_t q_uid; /* user-id of receiver (if known) */ 2337c478bd9Sstevel@tonic-gate gid_t q_gid; /* group-id of receiver (if known) */ 2347c478bd9Sstevel@tonic-gate char *q_home; /* home dir (local mailer only) */ 2357c478bd9Sstevel@tonic-gate char *q_fullname; /* full name if known */ 2367c478bd9Sstevel@tonic-gate struct address *q_next; /* chain */ 2377c478bd9Sstevel@tonic-gate struct address *q_alias; /* address this results from */ 2387c478bd9Sstevel@tonic-gate char *q_owner; /* owner of q_alias */ 2397c478bd9Sstevel@tonic-gate struct address *q_tchain; /* temporary use chain */ 2407c478bd9Sstevel@tonic-gate #if PIPELINING 2417c478bd9Sstevel@tonic-gate struct address *q_pchain; /* chain for pipelining */ 2427c478bd9Sstevel@tonic-gate #endif /* PIPELINING */ 2437c478bd9Sstevel@tonic-gate char *q_finalrcpt; /* Final-Recipient: DSN header */ 2447c478bd9Sstevel@tonic-gate char *q_orcpt; /* ORCPT parameter from RCPT TO: line */ 2457c478bd9Sstevel@tonic-gate char *q_status; /* status code for DSNs */ 2467c478bd9Sstevel@tonic-gate char *q_rstatus; /* remote status message for DSNs */ 2477c478bd9Sstevel@tonic-gate time_t q_statdate; /* date of status messages */ 2487c478bd9Sstevel@tonic-gate char *q_statmta; /* MTA generating q_rstatus */ 2497c478bd9Sstevel@tonic-gate short q_state; /* address state, see below */ 2507c478bd9Sstevel@tonic-gate char *q_signature; /* MX-based sorting value */ 2517c478bd9Sstevel@tonic-gate int q_qgrp; /* index into queue groups */ 2527c478bd9Sstevel@tonic-gate int q_qdir; /* queue directory inside group */ 2537c478bd9Sstevel@tonic-gate char *q_message; /* error message */ 2547c478bd9Sstevel@tonic-gate }; 2557c478bd9Sstevel@tonic-gate 2567c478bd9Sstevel@tonic-gate typedef struct address ADDRESS; 2577c478bd9Sstevel@tonic-gate 2587c478bd9Sstevel@tonic-gate /* bit values for q_flags */ 2597c478bd9Sstevel@tonic-gate #define QGOODUID 0x00000001 /* the q_uid q_gid fields are good */ 2607c478bd9Sstevel@tonic-gate #define QPRIMARY 0x00000002 /* set from RCPT or argv */ 2617c478bd9Sstevel@tonic-gate #define QNOTREMOTE 0x00000004 /* address not for remote forwarding */ 2627c478bd9Sstevel@tonic-gate #define QSELFREF 0x00000008 /* this address references itself */ 2637c478bd9Sstevel@tonic-gate #define QBOGUSSHELL 0x00000010 /* user has no valid shell listed */ 2647c478bd9Sstevel@tonic-gate #define QUNSAFEADDR 0x00000020 /* address acquired via unsafe path */ 2657c478bd9Sstevel@tonic-gate #define QPINGONSUCCESS 0x00000040 /* give return on successful delivery */ 2667c478bd9Sstevel@tonic-gate #define QPINGONFAILURE 0x00000080 /* give return on failure */ 2677c478bd9Sstevel@tonic-gate #define QPINGONDELAY 0x00000100 /* give return on message delay */ 2687c478bd9Sstevel@tonic-gate #define QHASNOTIFY 0x00000200 /* propagate notify parameter */ 2697c478bd9Sstevel@tonic-gate #define QRELAYED 0x00000400 /* DSN: relayed to non-DSN aware sys */ 2707c478bd9Sstevel@tonic-gate #define QEXPANDED 0x00000800 /* DSN: undergone list expansion */ 2717c478bd9Sstevel@tonic-gate #define QDELIVERED 0x00001000 /* DSN: successful final delivery */ 2727c478bd9Sstevel@tonic-gate #define QDELAYED 0x00002000 /* DSN: message delayed */ 2737c478bd9Sstevel@tonic-gate #define QALIAS 0x00004000 /* expanded alias */ 2747c478bd9Sstevel@tonic-gate #define QBYTRACE 0x00008000 /* DeliverBy: trace */ 2757c478bd9Sstevel@tonic-gate #define QBYNDELAY 0x00010000 /* DeliverBy: notify, delay */ 2767c478bd9Sstevel@tonic-gate #define QBYNRELAY 0x00020000 /* DeliverBy: notify, relayed */ 2777c478bd9Sstevel@tonic-gate #define QTHISPASS 0x40000000 /* temp: address set this pass */ 2787c478bd9Sstevel@tonic-gate #define QRCPTOK 0x80000000 /* recipient() processed address */ 2797c478bd9Sstevel@tonic-gate 2807c478bd9Sstevel@tonic-gate #define Q_PINGFLAGS (QPINGONSUCCESS|QPINGONFAILURE|QPINGONDELAY) 2817c478bd9Sstevel@tonic-gate 2827c478bd9Sstevel@tonic-gate /* values for q_state */ 2837c478bd9Sstevel@tonic-gate #define QS_OK 0 /* address ok (for now)/not yet tried */ 2847c478bd9Sstevel@tonic-gate #define QS_SENT 1 /* good address, delivery complete */ 2857c478bd9Sstevel@tonic-gate #define QS_BADADDR 2 /* illegal address */ 2867c478bd9Sstevel@tonic-gate #define QS_QUEUEUP 3 /* save address in queue */ 2877c478bd9Sstevel@tonic-gate #define QS_RETRY 4 /* retry delivery for next MX */ 2887c478bd9Sstevel@tonic-gate #define QS_VERIFIED 5 /* verified, but not expanded */ 2897c478bd9Sstevel@tonic-gate 2907c478bd9Sstevel@tonic-gate /* 2917c478bd9Sstevel@tonic-gate ** Notice: all of the following values are variations of QS_DONTSEND. 2927c478bd9Sstevel@tonic-gate ** If new states are added, they must be inserted in the proper place! 2937c478bd9Sstevel@tonic-gate ** See the macro definition of QS_IS_DEAD() down below. 2947c478bd9Sstevel@tonic-gate */ 2957c478bd9Sstevel@tonic-gate 2967c478bd9Sstevel@tonic-gate #define QS_DONTSEND 6 /* don't send to this address */ 2977c478bd9Sstevel@tonic-gate #define QS_EXPANDED 7 /* expanded */ 2987c478bd9Sstevel@tonic-gate #define QS_SENDER 8 /* message sender (MeToo) */ 2997c478bd9Sstevel@tonic-gate #define QS_CLONED 9 /* addr cloned to split envelope */ 3007c478bd9Sstevel@tonic-gate #define QS_DISCARDED 10 /* rcpt discarded (EF_DISCARD) */ 3017c478bd9Sstevel@tonic-gate #define QS_REPLACED 11 /* maplocaluser()/UserDB replaced */ 3027c478bd9Sstevel@tonic-gate #define QS_REMOVED 12 /* removed (removefromlist()) */ 3037c478bd9Sstevel@tonic-gate #define QS_DUPLICATE 13 /* duplicate suppressed */ 3047c478bd9Sstevel@tonic-gate #define QS_INCLUDED 14 /* :include: delivery */ 3057c478bd9Sstevel@tonic-gate #define QS_FATALERR 15 /* fatal error, don't deliver */ 3067c478bd9Sstevel@tonic-gate 3077c478bd9Sstevel@tonic-gate /* address state testing primitives */ 3087c478bd9Sstevel@tonic-gate #define QS_IS_OK(s) ((s) == QS_OK) 3097c478bd9Sstevel@tonic-gate #define QS_IS_SENT(s) ((s) == QS_SENT) 3107c478bd9Sstevel@tonic-gate #define QS_IS_BADADDR(s) ((s) == QS_BADADDR) 3117c478bd9Sstevel@tonic-gate #define QS_IS_QUEUEUP(s) ((s) == QS_QUEUEUP) 3127c478bd9Sstevel@tonic-gate #define QS_IS_RETRY(s) ((s) == QS_RETRY) 3137c478bd9Sstevel@tonic-gate #define QS_IS_VERIFIED(s) ((s) == QS_VERIFIED) 3147c478bd9Sstevel@tonic-gate #define QS_IS_EXPANDED(s) ((s) == QS_EXPANDED) 3157c478bd9Sstevel@tonic-gate #define QS_IS_REMOVED(s) ((s) == QS_REMOVED) 3167c478bd9Sstevel@tonic-gate #define QS_IS_UNDELIVERED(s) ((s) == QS_OK || \ 3177c478bd9Sstevel@tonic-gate (s) == QS_QUEUEUP || \ 3187c478bd9Sstevel@tonic-gate (s) == QS_RETRY || \ 3197c478bd9Sstevel@tonic-gate (s) == QS_VERIFIED) 3207c478bd9Sstevel@tonic-gate #define QS_IS_UNMARKED(s) ((s) == QS_OK || \ 3217c478bd9Sstevel@tonic-gate (s) == QS_RETRY) 3227c478bd9Sstevel@tonic-gate #define QS_IS_SENDABLE(s) ((s) == QS_OK || \ 3237c478bd9Sstevel@tonic-gate (s) == QS_QUEUEUP || \ 3247c478bd9Sstevel@tonic-gate (s) == QS_RETRY) 3257c478bd9Sstevel@tonic-gate #define QS_IS_ATTEMPTED(s) ((s) == QS_QUEUEUP || \ 3267c478bd9Sstevel@tonic-gate (s) == QS_RETRY || \ 3277800901eSjbeck (s) == QS_SENT || \ 3287800901eSjbeck (s) == QS_DISCARDED) 3297c478bd9Sstevel@tonic-gate #define QS_IS_DEAD(s) ((s) >= QS_DONTSEND) 3307c478bd9Sstevel@tonic-gate 3317c478bd9Sstevel@tonic-gate 3327c478bd9Sstevel@tonic-gate #define NULLADDR ((ADDRESS *) NULL) 3337c478bd9Sstevel@tonic-gate 3347c478bd9Sstevel@tonic-gate extern ADDRESS NullAddress; /* a null (template) address [main.c] */ 3357c478bd9Sstevel@tonic-gate 3367c478bd9Sstevel@tonic-gate /* functions */ 337058561cbSjbeck extern void cataddr __P((char **, char **, char *, int, int, bool)); 3387c478bd9Sstevel@tonic-gate extern char *crackaddr __P((char *, ENVELOPE *)); 3397c478bd9Sstevel@tonic-gate extern bool emptyaddr __P((ADDRESS *)); 3407c478bd9Sstevel@tonic-gate extern ADDRESS *getctladdr __P((ADDRESS *)); 3417c478bd9Sstevel@tonic-gate extern int include __P((char *, bool, ADDRESS *, ADDRESS **, int, ENVELOPE *)); 3427c478bd9Sstevel@tonic-gate extern bool invalidaddr __P((char *, char *, bool)); 3437c478bd9Sstevel@tonic-gate extern ADDRESS *parseaddr __P((char *, ADDRESS *, int, int, char **, 3447c478bd9Sstevel@tonic-gate ENVELOPE *, bool)); 3457c478bd9Sstevel@tonic-gate extern char **prescan __P((char *, int, char[], int, char **, unsigned char *, bool)); 3467c478bd9Sstevel@tonic-gate extern void printaddr __P((SM_FILE_T *, ADDRESS *, bool)); 3477c478bd9Sstevel@tonic-gate extern ADDRESS *recipient __P((ADDRESS *, ADDRESS **, int, ENVELOPE *)); 3487c478bd9Sstevel@tonic-gate extern char *remotename __P((char *, MAILER *, int, int *, ENVELOPE *)); 3497c478bd9Sstevel@tonic-gate extern int rewrite __P((char **, int, int, ENVELOPE *, int)); 3507c478bd9Sstevel@tonic-gate extern bool sameaddr __P((ADDRESS *, ADDRESS *)); 3517c478bd9Sstevel@tonic-gate extern int sendtolist __P((char *, ADDRESS *, ADDRESS **, int, ENVELOPE *)); 3527c478bd9Sstevel@tonic-gate #if MILTER 3537c478bd9Sstevel@tonic-gate extern int removefromlist __P((char *, ADDRESS **, ENVELOPE *)); 3547c478bd9Sstevel@tonic-gate #endif /* MILTER */ 3557c478bd9Sstevel@tonic-gate extern void setsender __P((char *, ENVELOPE *, char **, int, bool)); 356058561cbSjbeck typedef void esmtp_args_F __P((ADDRESS *, char *, char *, ENVELOPE *)); 357058561cbSjbeck extern void parse_esmtp_args __P((ENVELOPE *, ADDRESS *, char *, char *, 358058561cbSjbeck char *, char *args[], esmtp_args_F)); 359058561cbSjbeck extern esmtp_args_F mail_esmtp_args; 360058561cbSjbeck extern esmtp_args_F rcpt_esmtp_args; 361058561cbSjbeck extern void reset_mail_esmtp_args __P((ENVELOPE *)); 3627c478bd9Sstevel@tonic-gate 3637c478bd9Sstevel@tonic-gate /* macro to simplify the common call to rewrite() */ 3647c478bd9Sstevel@tonic-gate #define REWRITE(pvp, rs, env) rewrite(pvp, rs, 0, env, MAXATOM) 3657c478bd9Sstevel@tonic-gate 366058561cbSjbeck /* 367058561cbSjbeck ** Token Tables for prescan 368058561cbSjbeck */ 369058561cbSjbeck 370058561cbSjbeck extern unsigned char ExtTokenTab[256]; /* external strings */ 371058561cbSjbeck extern unsigned char IntTokenTab[256]; /* internal strings */ 372058561cbSjbeck 373058561cbSjbeck 3747c478bd9Sstevel@tonic-gate /* 3757c478bd9Sstevel@tonic-gate ** Mailer definition structure. 3767c478bd9Sstevel@tonic-gate ** Every mailer known to the system is declared in this 3777c478bd9Sstevel@tonic-gate ** structure. It defines the pathname of the mailer, some 3787c478bd9Sstevel@tonic-gate ** flags associated with it, and the argument vector to 3797c478bd9Sstevel@tonic-gate ** pass to it. The flags are defined in conf.c 3807c478bd9Sstevel@tonic-gate ** 3817c478bd9Sstevel@tonic-gate ** The argument vector is expanded before actual use. All 3827c478bd9Sstevel@tonic-gate ** words except the first are passed through the macro 3837c478bd9Sstevel@tonic-gate ** processor. 3847c478bd9Sstevel@tonic-gate */ 3857c478bd9Sstevel@tonic-gate 3867c478bd9Sstevel@tonic-gate struct mailer 3877c478bd9Sstevel@tonic-gate { 3887c478bd9Sstevel@tonic-gate char *m_name; /* symbolic name of this mailer */ 3897c478bd9Sstevel@tonic-gate char *m_mailer; /* pathname of the mailer to use */ 3907c478bd9Sstevel@tonic-gate char *m_mtatype; /* type of this MTA */ 3917c478bd9Sstevel@tonic-gate char *m_addrtype; /* type for addresses */ 3927c478bd9Sstevel@tonic-gate char *m_diagtype; /* type for diagnostics */ 3937c478bd9Sstevel@tonic-gate BITMAP256 m_flags; /* status flags, see below */ 3947c478bd9Sstevel@tonic-gate short m_mno; /* mailer number internally */ 3957c478bd9Sstevel@tonic-gate short m_nice; /* niceness to run at (mostly for prog) */ 3967c478bd9Sstevel@tonic-gate char **m_argv; /* template argument vector */ 3977c478bd9Sstevel@tonic-gate short m_sh_rwset; /* rewrite set: sender header addresses */ 3987c478bd9Sstevel@tonic-gate short m_se_rwset; /* rewrite set: sender envelope addresses */ 3997c478bd9Sstevel@tonic-gate short m_rh_rwset; /* rewrite set: recipient header addresses */ 4007c478bd9Sstevel@tonic-gate short m_re_rwset; /* rewrite set: recipient envelope addresses */ 4017c478bd9Sstevel@tonic-gate char *m_eol; /* end of line string */ 4027c478bd9Sstevel@tonic-gate long m_maxsize; /* size limit on message to this mailer */ 4037c478bd9Sstevel@tonic-gate int m_linelimit; /* max # characters per line */ 4047c478bd9Sstevel@tonic-gate int m_maxdeliveries; /* max deliveries per mailer connection */ 4057c478bd9Sstevel@tonic-gate char *m_execdir; /* directory to chdir to before execv */ 4067c478bd9Sstevel@tonic-gate char *m_rootdir; /* directory to chroot to before execv */ 4077c478bd9Sstevel@tonic-gate uid_t m_uid; /* UID to run as */ 4087c478bd9Sstevel@tonic-gate gid_t m_gid; /* GID to run as */ 4097c478bd9Sstevel@tonic-gate char *m_defcharset; /* default character set */ 4107c478bd9Sstevel@tonic-gate time_t m_wait; /* timeout to wait for end */ 4117c478bd9Sstevel@tonic-gate int m_maxrcpt; /* max recipients per envelope client-side */ 4127c478bd9Sstevel@tonic-gate short m_qgrp; /* queue group for this mailer */ 4137c478bd9Sstevel@tonic-gate }; 4147c478bd9Sstevel@tonic-gate 4157c478bd9Sstevel@tonic-gate /* bits for m_flags */ 4167c478bd9Sstevel@tonic-gate #define M_ESMTP 'a' /* run Extended SMTP */ 4177c478bd9Sstevel@tonic-gate #define M_ALIASABLE 'A' /* user can be LHS of an alias */ 4187c478bd9Sstevel@tonic-gate #define M_BLANKEND 'b' /* ensure blank line at end of message */ 4197c478bd9Sstevel@tonic-gate #define M_STRIPBACKSL 'B' /* strip all leading backslashes from user */ 4207c478bd9Sstevel@tonic-gate #define M_NOCOMMENT 'c' /* don't include comment part of address */ 4217c478bd9Sstevel@tonic-gate #define M_CANONICAL 'C' /* make addresses canonical "u@dom" */ 4227c478bd9Sstevel@tonic-gate #define M_NOBRACKET 'd' /* never angle bracket envelope route-addrs */ 4237c478bd9Sstevel@tonic-gate /* 'D' CF: include Date: */ 4247c478bd9Sstevel@tonic-gate #define M_EXPENSIVE 'e' /* it costs to use this mailer.... */ 4257c478bd9Sstevel@tonic-gate #define M_ESCFROM 'E' /* escape From lines to >From */ 4267c478bd9Sstevel@tonic-gate #define M_FOPT 'f' /* mailer takes picky -f flag */ 4277c478bd9Sstevel@tonic-gate /* 'F' CF: include From: or Resent-From: */ 4287c478bd9Sstevel@tonic-gate #define M_NO_NULL_FROM 'g' /* sender of errors should be $g */ 4297c478bd9Sstevel@tonic-gate #define M_HST_UPPER 'h' /* preserve host case distinction */ 4307c478bd9Sstevel@tonic-gate #define M_PREHEAD 'H' /* MAIL11V3: preview headers */ 4317c478bd9Sstevel@tonic-gate #define M_UDBENVELOPE 'i' /* do udbsender rewriting on envelope */ 4327c478bd9Sstevel@tonic-gate #define M_INTERNAL 'I' /* SMTP to another sendmail site */ 4337c478bd9Sstevel@tonic-gate #define M_UDBRECIPIENT 'j' /* do udbsender rewriting on recipient lines */ 4347c478bd9Sstevel@tonic-gate #define M_NOLOOPCHECK 'k' /* don't check for loops in HELO command */ 4357c478bd9Sstevel@tonic-gate #define M_CHUNKING 'K' /* CHUNKING: reserved for future use */ 4367c478bd9Sstevel@tonic-gate #define M_LOCALMAILER 'l' /* delivery is to this host */ 4377c478bd9Sstevel@tonic-gate #define M_LIMITS 'L' /* must enforce SMTP line limits */ 4387c478bd9Sstevel@tonic-gate #define M_MUSER 'm' /* can handle multiple users at once */ 4397c478bd9Sstevel@tonic-gate /* 'M' CF: include Message-Id: */ 4407c478bd9Sstevel@tonic-gate #define M_NHDR 'n' /* don't insert From line */ 4417c478bd9Sstevel@tonic-gate #define M_MANYSTATUS 'N' /* MAIL11V3: DATA returns multi-status */ 4427c478bd9Sstevel@tonic-gate #define M_RUNASRCPT 'o' /* always run mailer as recipient */ 4437c478bd9Sstevel@tonic-gate #define M_FROMPATH 'p' /* use reverse-path in MAIL FROM: */ 4447c478bd9Sstevel@tonic-gate /* 'P' CF: include Return-Path: */ 4457c478bd9Sstevel@tonic-gate #define M_VRFY250 'q' /* VRFY command returns 250 instead of 252 */ 4467c478bd9Sstevel@tonic-gate #define M_ROPT 'r' /* mailer takes picky -r flag */ 4477c478bd9Sstevel@tonic-gate #define M_SECURE_PORT 'R' /* try to send on a reserved TCP port */ 4487c478bd9Sstevel@tonic-gate #define M_STRIPQ 's' /* strip quote chars from user/host */ 4497c478bd9Sstevel@tonic-gate #define M_SPECIFIC_UID 'S' /* run as specific uid/gid */ 4507c478bd9Sstevel@tonic-gate #define M_USR_UPPER 'u' /* preserve user case distinction */ 4517c478bd9Sstevel@tonic-gate #define M_UGLYUUCP 'U' /* this wants an ugly UUCP from line */ 4527c478bd9Sstevel@tonic-gate #define M_CONTENT_LEN 'v' /* add Content-Length: header (SVr4) */ 4537c478bd9Sstevel@tonic-gate /* 'V' UIUC: !-relativize all addresses */ 4547c478bd9Sstevel@tonic-gate #define M_HASPWENT 'w' /* check for /etc/passwd entry */ 4557c478bd9Sstevel@tonic-gate #define M_NOHOSTSTAT 'W' /* ignore long term host status information */ 4567c478bd9Sstevel@tonic-gate /* 'x' CF: include Full-Name: */ 4577c478bd9Sstevel@tonic-gate #define M_XDOT 'X' /* use hidden-dot algorithm */ 4587c478bd9Sstevel@tonic-gate #define M_LMTP 'z' /* run Local Mail Transport Protocol */ 4597c478bd9Sstevel@tonic-gate #define M_DIALDELAY 'Z' /* apply dial delay sleeptime */ 4607c478bd9Sstevel@tonic-gate #define M_NOMX '0' /* turn off MX lookups */ 4617c478bd9Sstevel@tonic-gate #define M_NONULLS '1' /* don't send null bytes */ 4627c478bd9Sstevel@tonic-gate #define M_FSMTP '2' /* force SMTP (no ESMTP even if offered) */ 4637c478bd9Sstevel@tonic-gate #define M_EBCDIC '3' /* extend Q-P encoding for EBCDIC */ 4647c478bd9Sstevel@tonic-gate #define M_TRYRULESET5 '5' /* use ruleset 5 after local aliasing */ 4657c478bd9Sstevel@tonic-gate #define M_7BITHDRS '6' /* strip headers to 7 bits even in 8 bit path */ 4667c478bd9Sstevel@tonic-gate #define M_7BITS '7' /* use 7-bit path */ 4677c478bd9Sstevel@tonic-gate #define M_8BITS '8' /* force "just send 8" behaviour */ 4687c478bd9Sstevel@tonic-gate #define M_MAKE8BIT '9' /* convert 7 -> 8 bit if appropriate */ 4697c478bd9Sstevel@tonic-gate #define M_CHECKINCLUDE ':' /* check for :include: files */ 4707c478bd9Sstevel@tonic-gate #define M_CHECKPROG '|' /* check for |program addresses */ 4717c478bd9Sstevel@tonic-gate #define M_CHECKFILE '/' /* check for /file addresses */ 4727c478bd9Sstevel@tonic-gate #define M_CHECKUDB '@' /* user can be user database key */ 4737c478bd9Sstevel@tonic-gate #define M_CHECKHDIR '~' /* SGI: check for valid home directory */ 4747c478bd9Sstevel@tonic-gate #define M_HOLD '%' /* Hold delivery until ETRN/-qI/-qR/-qS */ 4757c478bd9Sstevel@tonic-gate #define M_PLUS '+' /* Reserved: Used in mc for adding new flags */ 4767c478bd9Sstevel@tonic-gate #define M_MINUS '-' /* Reserved: Used in mc for removing flags */ 4777c478bd9Sstevel@tonic-gate 4787c478bd9Sstevel@tonic-gate /* functions */ 4797c478bd9Sstevel@tonic-gate extern void initerrmailers __P((void)); 4807c478bd9Sstevel@tonic-gate extern void makemailer __P((char *)); 4817c478bd9Sstevel@tonic-gate extern void makequeue __P((char *, bool)); 4827c478bd9Sstevel@tonic-gate extern void runqueueevent __P((int)); 4837c478bd9Sstevel@tonic-gate #if _FFR_QUEUE_RUN_PARANOIA 4847c478bd9Sstevel@tonic-gate extern bool checkqueuerunner __P((void)); 4857c478bd9Sstevel@tonic-gate #endif /* _FFR_QUEUE_RUN_PARANOIA */ 4867c478bd9Sstevel@tonic-gate 4877c478bd9Sstevel@tonic-gate EXTERN MAILER *FileMailer; /* ptr to *file* mailer */ 4887c478bd9Sstevel@tonic-gate EXTERN MAILER *InclMailer; /* ptr to *include* mailer */ 4897c478bd9Sstevel@tonic-gate EXTERN MAILER *LocalMailer; /* ptr to local mailer */ 4907c478bd9Sstevel@tonic-gate EXTERN MAILER *ProgMailer; /* ptr to program mailer */ 4917c478bd9Sstevel@tonic-gate EXTERN MAILER *Mailer[MAXMAILERS + 1]; 4927c478bd9Sstevel@tonic-gate 4937c478bd9Sstevel@tonic-gate /* 4947c478bd9Sstevel@tonic-gate ** Queue group definition structure. 4957c478bd9Sstevel@tonic-gate ** Every queue group known to the system is declared in this structure. 4967c478bd9Sstevel@tonic-gate ** It defines the basic pathname of the queue group, some flags 4977c478bd9Sstevel@tonic-gate ** associated with it, and the argument vector to pass to it. 4987c478bd9Sstevel@tonic-gate */ 4997c478bd9Sstevel@tonic-gate 5007c478bd9Sstevel@tonic-gate struct qpaths_s 5017c478bd9Sstevel@tonic-gate { 5027c478bd9Sstevel@tonic-gate char *qp_name; /* name of queue dir, relative path */ 5037c478bd9Sstevel@tonic-gate short qp_subdirs; /* use subdirs? */ 5047c478bd9Sstevel@tonic-gate short qp_fsysidx; /* file system index of this directory */ 5057c478bd9Sstevel@tonic-gate # if SM_CONF_SHM 5067c478bd9Sstevel@tonic-gate int qp_idx; /* index into array for queue information */ 5077c478bd9Sstevel@tonic-gate # endif /* SM_CONF_SHM */ 5087c478bd9Sstevel@tonic-gate }; 5097c478bd9Sstevel@tonic-gate 5107c478bd9Sstevel@tonic-gate typedef struct qpaths_s QPATHS; 5117c478bd9Sstevel@tonic-gate 5127c478bd9Sstevel@tonic-gate struct queuegrp 5137c478bd9Sstevel@tonic-gate { 5147c478bd9Sstevel@tonic-gate char *qg_name; /* symbolic name of this queue group */ 5157c478bd9Sstevel@tonic-gate 5167c478bd9Sstevel@tonic-gate /* 5177c478bd9Sstevel@tonic-gate ** For now this is the same across all queue groups. 5187c478bd9Sstevel@tonic-gate ** Otherwise we have to play around with chdir(). 5197c478bd9Sstevel@tonic-gate */ 5207c478bd9Sstevel@tonic-gate 5217c478bd9Sstevel@tonic-gate char *qg_qdir; /* common component of queue directory */ 5227c478bd9Sstevel@tonic-gate short qg_index; /* queue number internally, index in Queue[] */ 5237c478bd9Sstevel@tonic-gate int qg_maxqrun; /* max # of jobs in 1 queuerun */ 5247c478bd9Sstevel@tonic-gate int qg_numqueues; /* number of queues in this queue */ 5257c478bd9Sstevel@tonic-gate 5267c478bd9Sstevel@tonic-gate /* 5277c478bd9Sstevel@tonic-gate ** qg_queueintvl == 0 denotes that no individual value is used. 5287c478bd9Sstevel@tonic-gate ** Whatever accesses this must deal with "<= 0" as 5297c478bd9Sstevel@tonic-gate ** "not set, use appropriate default". 5307c478bd9Sstevel@tonic-gate */ 5317c478bd9Sstevel@tonic-gate 5327c478bd9Sstevel@tonic-gate time_t qg_queueintvl; /* interval for queue runs */ 5337c478bd9Sstevel@tonic-gate QPATHS *qg_qpaths; /* list of queue directories */ 5347c478bd9Sstevel@tonic-gate BITMAP256 qg_flags; /* status flags, see below */ 5357c478bd9Sstevel@tonic-gate short qg_nice; /* niceness for queue run */ 5367c478bd9Sstevel@tonic-gate int qg_wgrp; /* Assigned to this work group */ 5377c478bd9Sstevel@tonic-gate int qg_maxlist; /* max items in work queue for this group */ 5387c478bd9Sstevel@tonic-gate int qg_curnum; /* current number of queue for queue runs */ 5397c478bd9Sstevel@tonic-gate int qg_maxrcpt; /* max recipients per envelope, 0==no limit */ 5407c478bd9Sstevel@tonic-gate 5417c478bd9Sstevel@tonic-gate time_t qg_nextrun; /* time for next queue runs */ 5427c478bd9Sstevel@tonic-gate #if _FFR_QUEUE_GROUP_SORTORDER 5437c478bd9Sstevel@tonic-gate short qg_sortorder; /* how do we sort this queuerun */ 5447c478bd9Sstevel@tonic-gate #endif /* _FFR_QUEUE_GROUP_SORTORDER */ 5457c478bd9Sstevel@tonic-gate #if 0 5467c478bd9Sstevel@tonic-gate long qg_wkrcptfact; /* multiplier for # recipients -> priority */ 5477c478bd9Sstevel@tonic-gate long qg_qfactor; /* slope of queue function */ 5487c478bd9Sstevel@tonic-gate bool qg_doqueuerun; /* XXX flag is it time to do a queuerun */ 5497c478bd9Sstevel@tonic-gate #endif /* 0 */ 5507c478bd9Sstevel@tonic-gate }; 5517c478bd9Sstevel@tonic-gate 5527c478bd9Sstevel@tonic-gate /* bits for qg_flags (XXX: unused as of now) */ 5537c478bd9Sstevel@tonic-gate #define QD_DEFINED ((char) 1) /* queue group has been defined */ 5547c478bd9Sstevel@tonic-gate #define QD_FORK 'f' /* fork queue runs */ 5557c478bd9Sstevel@tonic-gate 5567c478bd9Sstevel@tonic-gate extern void filesys_update __P((void)); 5577c478bd9Sstevel@tonic-gate #if _FFR_ANY_FREE_FS 5587c478bd9Sstevel@tonic-gate extern bool filesys_free __P((long)); 5597c478bd9Sstevel@tonic-gate #endif /* _FFR_ANY_FREE_FS */ 5607c478bd9Sstevel@tonic-gate 5617c478bd9Sstevel@tonic-gate #if SASL 5627c478bd9Sstevel@tonic-gate /* 5637c478bd9Sstevel@tonic-gate ** SASL 5647c478bd9Sstevel@tonic-gate */ 5657c478bd9Sstevel@tonic-gate 5667c478bd9Sstevel@tonic-gate /* lines in authinfo file or index into SASL_AI_T */ 5677c478bd9Sstevel@tonic-gate # define SASL_WRONG (-1) 5687c478bd9Sstevel@tonic-gate # define SASL_USER 0 /* authorization id (user) */ 5697c478bd9Sstevel@tonic-gate # define SASL_AUTHID 1 /* authentication id */ 5707c478bd9Sstevel@tonic-gate # define SASL_PASSWORD 2 /* password fuer authid */ 5717c478bd9Sstevel@tonic-gate # define SASL_DEFREALM 3 /* realm to use */ 5727c478bd9Sstevel@tonic-gate # define SASL_MECHLIST 4 /* list of mechanisms to try */ 5737c478bd9Sstevel@tonic-gate # define SASL_ID_REALM 5 /* authid@defrealm */ 5747c478bd9Sstevel@tonic-gate 5757c478bd9Sstevel@tonic-gate /* 5767c478bd9Sstevel@tonic-gate ** Current mechanism; this is just used to convey information between 5777c478bd9Sstevel@tonic-gate ** invocation of SASL callback functions. 5787c478bd9Sstevel@tonic-gate ** It must be last in the list, because it's not allocated by us 5797c478bd9Sstevel@tonic-gate ** and hence we don't free() it. 5807c478bd9Sstevel@tonic-gate */ 5817c478bd9Sstevel@tonic-gate # define SASL_MECH 6 5827c478bd9Sstevel@tonic-gate # define SASL_ENTRIES 7 /* number of entries in array */ 5837c478bd9Sstevel@tonic-gate 5847c478bd9Sstevel@tonic-gate # define SASL_USER_BIT (1 << SASL_USER) 5857c478bd9Sstevel@tonic-gate # define SASL_AUTHID_BIT (1 << SASL_AUTHID) 5867c478bd9Sstevel@tonic-gate # define SASL_PASSWORD_BIT (1 << SASL_PASSWORD) 5877c478bd9Sstevel@tonic-gate # define SASL_DEFREALM_BIT (1 << SASL_DEFREALM) 5887c478bd9Sstevel@tonic-gate # define SASL_MECHLIST_BIT (1 << SASL_MECHLIST) 5897c478bd9Sstevel@tonic-gate 5907c478bd9Sstevel@tonic-gate /* authenticated? */ 5917c478bd9Sstevel@tonic-gate # define SASL_NOT_AUTH 0 /* not authenticated */ 5927c478bd9Sstevel@tonic-gate # define SASL_PROC_AUTH 1 /* in process of authenticating */ 5937c478bd9Sstevel@tonic-gate # define SASL_IS_AUTH 2 /* authenticated */ 5947c478bd9Sstevel@tonic-gate 5957c478bd9Sstevel@tonic-gate /* SASL options */ 5967c478bd9Sstevel@tonic-gate # define SASL_AUTH_AUTH 0x1000 /* use auth= only if authenticated */ 5977c478bd9Sstevel@tonic-gate # if SASL >= 20101 5987c478bd9Sstevel@tonic-gate # define SASL_SEC_MASK SASL_SEC_MAXIMUM /* mask for SASL_SEC_* values: sasl.h */ 5997c478bd9Sstevel@tonic-gate # else /* SASL >= 20101 */ 6007c478bd9Sstevel@tonic-gate # define SASL_SEC_MASK 0x0fff /* mask for SASL_SEC_* values: sasl.h */ 6017c478bd9Sstevel@tonic-gate # if (SASL_SEC_NOPLAINTEXT & SASL_SEC_MASK) == 0 || \ 6027c478bd9Sstevel@tonic-gate (SASL_SEC_NOACTIVE & SASL_SEC_MASK) == 0 || \ 6037c478bd9Sstevel@tonic-gate (SASL_SEC_NODICTIONARY & SASL_SEC_MASK) == 0 || \ 6047c478bd9Sstevel@tonic-gate (SASL_SEC_FORWARD_SECRECY & SASL_SEC_MASK) == 0 || \ 6057c478bd9Sstevel@tonic-gate (SASL_SEC_NOANONYMOUS & SASL_SEC_MASK) == 0 || \ 6067c478bd9Sstevel@tonic-gate (SASL_SEC_PASS_CREDENTIALS & SASL_SEC_MASK) == 0 6077c478bd9Sstevel@tonic-gate ERROR: change SASL_SEC_MASK_ notify sendmail.org! 6087c478bd9Sstevel@tonic-gate # endif /* SASL_SEC_NOPLAINTEXT & SASL_SEC_MASK) == 0 ... */ 6097c478bd9Sstevel@tonic-gate # endif /* SASL >= 20101 */ 610*e9af4bc0SJohn Beck # define MAXOUTLEN 8192 /* length of output buffer, should be 2^n */ 6117c478bd9Sstevel@tonic-gate 6127c478bd9Sstevel@tonic-gate /* functions */ 6137c478bd9Sstevel@tonic-gate extern char *intersect __P((char *, char *, SM_RPOOL_T *)); 6147c478bd9Sstevel@tonic-gate extern char *iteminlist __P((char *, char *, char *)); 6157c478bd9Sstevel@tonic-gate # if SASL >= 20000 6167c478bd9Sstevel@tonic-gate extern int proxy_policy __P((sasl_conn_t *, void *, const char *, unsigned, const char *, unsigned, const char *, unsigned, struct propctx *)); 6177c478bd9Sstevel@tonic-gate extern int safesaslfile __P((void *, const char *, sasl_verify_type_t)); 6187c478bd9Sstevel@tonic-gate # else /* SASL >= 20000 */ 6197c478bd9Sstevel@tonic-gate extern int proxy_policy __P((void *, const char *, const char *, const char **, const char **)); 6207c478bd9Sstevel@tonic-gate # if SASL > 10515 6217c478bd9Sstevel@tonic-gate extern int safesaslfile __P((void *, char *, int)); 6227c478bd9Sstevel@tonic-gate # else /* SASL > 10515 */ 6237c478bd9Sstevel@tonic-gate extern int safesaslfile __P((void *, char *)); 6247c478bd9Sstevel@tonic-gate # endif /* SASL > 10515 */ 6257c478bd9Sstevel@tonic-gate # endif /* SASL >= 20000 */ 6267c478bd9Sstevel@tonic-gate extern void stop_sasl_client __P((void)); 6277c478bd9Sstevel@tonic-gate 6287c478bd9Sstevel@tonic-gate /* structure to store authinfo */ 6297c478bd9Sstevel@tonic-gate typedef char *SASL_AI_T[SASL_ENTRIES]; 6307c478bd9Sstevel@tonic-gate 6317c478bd9Sstevel@tonic-gate EXTERN char *AuthMechanisms; /* AUTH mechanisms */ 6327c478bd9Sstevel@tonic-gate EXTERN char *AuthRealm; /* AUTH realm */ 6337c478bd9Sstevel@tonic-gate EXTERN char *SASLInfo; /* file with AUTH info */ 6347c478bd9Sstevel@tonic-gate EXTERN int SASLOpts; /* options for SASL */ 6357c478bd9Sstevel@tonic-gate EXTERN int MaxSLBits; /* max. encryption bits for SASL */ 6367c478bd9Sstevel@tonic-gate #endif /* SASL */ 6377c478bd9Sstevel@tonic-gate 6387c478bd9Sstevel@tonic-gate /* 6397c478bd9Sstevel@tonic-gate ** Structure to store macros. 6407c478bd9Sstevel@tonic-gate */ 6417c478bd9Sstevel@tonic-gate typedef struct 6427c478bd9Sstevel@tonic-gate { 6437c478bd9Sstevel@tonic-gate SM_RPOOL_T *mac_rpool; /* resource pool */ 6447c478bd9Sstevel@tonic-gate BITMAP256 mac_allocated; /* storage has been alloc()? */ 6457c478bd9Sstevel@tonic-gate char *mac_table[MAXMACROID + 1]; /* macros */ 6467c478bd9Sstevel@tonic-gate } MACROS_T; 6477c478bd9Sstevel@tonic-gate 6487c478bd9Sstevel@tonic-gate EXTERN MACROS_T GlobalMacros; 6497c478bd9Sstevel@tonic-gate 6507c478bd9Sstevel@tonic-gate /* 6517c478bd9Sstevel@tonic-gate ** Information about currently open connections to mailers, or to 6527c478bd9Sstevel@tonic-gate ** hosts that we have looked up recently. 6537c478bd9Sstevel@tonic-gate */ 6547c478bd9Sstevel@tonic-gate 6557c478bd9Sstevel@tonic-gate #define MCI struct mailer_con_info 6567c478bd9Sstevel@tonic-gate 6577c478bd9Sstevel@tonic-gate MCI 6587c478bd9Sstevel@tonic-gate { 6597c478bd9Sstevel@tonic-gate unsigned long mci_flags; /* flag bits, see below */ 6607c478bd9Sstevel@tonic-gate short mci_errno; /* error number on last connection */ 6617c478bd9Sstevel@tonic-gate short mci_herrno; /* h_errno from last DNS lookup */ 6627c478bd9Sstevel@tonic-gate short mci_exitstat; /* exit status from last connection */ 6637c478bd9Sstevel@tonic-gate short mci_state; /* SMTP state */ 6647c478bd9Sstevel@tonic-gate int mci_deliveries; /* delivery attempts for connection */ 6657c478bd9Sstevel@tonic-gate long mci_maxsize; /* max size this server will accept */ 6667c478bd9Sstevel@tonic-gate SM_FILE_T *mci_in; /* input side of connection */ 6677c478bd9Sstevel@tonic-gate SM_FILE_T *mci_out; /* output side of connection */ 6687c478bd9Sstevel@tonic-gate pid_t mci_pid; /* process id of subordinate proc */ 6697c478bd9Sstevel@tonic-gate char *mci_phase; /* SMTP phase string */ 6707c478bd9Sstevel@tonic-gate struct mailer *mci_mailer; /* ptr to the mailer for this conn */ 6717c478bd9Sstevel@tonic-gate char *mci_host; /* host name */ 6727c478bd9Sstevel@tonic-gate char *mci_status; /* DSN status to be copied to addrs */ 6737c478bd9Sstevel@tonic-gate char *mci_rstatus; /* SMTP status to be copied to addrs */ 6747c478bd9Sstevel@tonic-gate time_t mci_lastuse; /* last usage time */ 6757c478bd9Sstevel@tonic-gate SM_FILE_T *mci_statfile; /* long term status file */ 6767c478bd9Sstevel@tonic-gate char *mci_heloname; /* name to use as HELO arg */ 6777c478bd9Sstevel@tonic-gate long mci_min_by; /* minimum DELIVERBY */ 6787c478bd9Sstevel@tonic-gate bool mci_retryrcpt; /* tempfail for at least one rcpt */ 6797c478bd9Sstevel@tonic-gate char *mci_tolist; /* list of valid recipients */ 6807c478bd9Sstevel@tonic-gate SM_RPOOL_T *mci_rpool; /* resource pool */ 6817c478bd9Sstevel@tonic-gate #if PIPELINING 6827c478bd9Sstevel@tonic-gate int mci_okrcpts; /* number of valid recipients */ 6837c478bd9Sstevel@tonic-gate ADDRESS *mci_nextaddr; /* next address for pipelined status */ 6847c478bd9Sstevel@tonic-gate #endif /* PIPELINING */ 6857c478bd9Sstevel@tonic-gate #if SASL 6867c478bd9Sstevel@tonic-gate SASL_AI_T mci_sai; /* authentication info */ 6877c478bd9Sstevel@tonic-gate bool mci_sasl_auth; /* authenticated? */ 6887c478bd9Sstevel@tonic-gate int mci_sasl_string_len; 6897c478bd9Sstevel@tonic-gate char *mci_sasl_string; /* sasl reply string */ 6907c478bd9Sstevel@tonic-gate char *mci_saslcap; /* SASL list of mechanisms */ 6917c478bd9Sstevel@tonic-gate sasl_conn_t *mci_conn; /* SASL connection */ 6927c478bd9Sstevel@tonic-gate #endif /* SASL */ 6937c478bd9Sstevel@tonic-gate #if STARTTLS 6947c478bd9Sstevel@tonic-gate SSL *mci_ssl; /* SSL connection */ 6957c478bd9Sstevel@tonic-gate #endif /* STARTTLS */ 6967c478bd9Sstevel@tonic-gate MACROS_T mci_macro; /* macro definitions */ 6977c478bd9Sstevel@tonic-gate }; 6987c478bd9Sstevel@tonic-gate 6997c478bd9Sstevel@tonic-gate 7007c478bd9Sstevel@tonic-gate /* flag bits */ 7017c478bd9Sstevel@tonic-gate #define MCIF_VALID 0x00000001 /* this entry is valid */ 7027c478bd9Sstevel@tonic-gate /* 0x00000002 unused, was MCIF_TEMP */ 7037c478bd9Sstevel@tonic-gate #define MCIF_CACHED 0x00000004 /* currently in open cache */ 7047c478bd9Sstevel@tonic-gate #define MCIF_ESMTP 0x00000008 /* this host speaks ESMTP */ 7057c478bd9Sstevel@tonic-gate #define MCIF_EXPN 0x00000010 /* EXPN command supported */ 7067c478bd9Sstevel@tonic-gate #define MCIF_SIZE 0x00000020 /* SIZE option supported */ 7077c478bd9Sstevel@tonic-gate #define MCIF_8BITMIME 0x00000040 /* BODY=8BITMIME supported */ 7087c478bd9Sstevel@tonic-gate #define MCIF_7BIT 0x00000080 /* strip this message to 7 bits */ 7097c478bd9Sstevel@tonic-gate /* 0x00000100 unused, was MCIF_MULTSTAT: MAIL11V3: handles MULT status */ 7107c478bd9Sstevel@tonic-gate #define MCIF_INHEADER 0x00000200 /* currently outputing header */ 7117c478bd9Sstevel@tonic-gate #define MCIF_CVT8TO7 0x00000400 /* convert from 8 to 7 bits */ 7127c478bd9Sstevel@tonic-gate #define MCIF_DSN 0x00000800 /* DSN extension supported */ 7137c478bd9Sstevel@tonic-gate #define MCIF_8BITOK 0x00001000 /* OK to send 8 bit characters */ 7147c478bd9Sstevel@tonic-gate #define MCIF_CVT7TO8 0x00002000 /* convert from 7 to 8 bits */ 7157c478bd9Sstevel@tonic-gate #define MCIF_INMIME 0x00004000 /* currently reading MIME header */ 7167c478bd9Sstevel@tonic-gate #define MCIF_AUTH 0x00008000 /* AUTH= supported */ 7177c478bd9Sstevel@tonic-gate #define MCIF_AUTHACT 0x00010000 /* SASL (AUTH) active */ 7187c478bd9Sstevel@tonic-gate #define MCIF_ENHSTAT 0x00020000 /* ENHANCEDSTATUSCODES supported */ 7197c478bd9Sstevel@tonic-gate #define MCIF_PIPELINED 0x00040000 /* PIPELINING supported */ 7207c478bd9Sstevel@tonic-gate #define MCIF_VERB 0x00080000 /* VERB supported */ 7217c478bd9Sstevel@tonic-gate #if STARTTLS 7227c478bd9Sstevel@tonic-gate #define MCIF_TLS 0x00100000 /* STARTTLS supported */ 7237c478bd9Sstevel@tonic-gate #define MCIF_TLSACT 0x00200000 /* STARTTLS active */ 7247c478bd9Sstevel@tonic-gate #define MCIF_EXTENS (MCIF_EXPN | MCIF_SIZE | MCIF_8BITMIME | MCIF_DSN | MCIF_8BITOK | MCIF_AUTH | MCIF_ENHSTAT | MCIF_TLS) 7257c478bd9Sstevel@tonic-gate #else /* STARTTLS */ 7267c478bd9Sstevel@tonic-gate #define MCIF_EXTENS (MCIF_EXPN | MCIF_SIZE | MCIF_8BITMIME | MCIF_DSN | MCIF_8BITOK | MCIF_AUTH | MCIF_ENHSTAT) 7277c478bd9Sstevel@tonic-gate #endif /* STARTTLS */ 7287c478bd9Sstevel@tonic-gate #define MCIF_DLVR_BY 0x00400000 /* DELIVERBY */ 7297c478bd9Sstevel@tonic-gate #if _FFR_IGNORE_EXT_ON_HELO 7307c478bd9Sstevel@tonic-gate # define MCIF_HELO 0x00800000 /* we used HELO: ignore extensions */ 7317c478bd9Sstevel@tonic-gate #endif /* _FFR_IGNORE_EXT_ON_HELO */ 7327800901eSjbeck #define MCIF_INLONGLINE 0x01000000 /* in the middle of a long line */ 7337c478bd9Sstevel@tonic-gate #define MCIF_ONLY_EHLO 0x10000000 /* use only EHLO in smtpinit */ 7347c478bd9Sstevel@tonic-gate 7357c478bd9Sstevel@tonic-gate /* states */ 7367c478bd9Sstevel@tonic-gate #define MCIS_CLOSED 0 /* no traffic on this connection */ 7377c478bd9Sstevel@tonic-gate #define MCIS_OPENING 1 /* sending initial protocol */ 7387c478bd9Sstevel@tonic-gate #define MCIS_OPEN 2 /* open, initial protocol sent */ 7397c478bd9Sstevel@tonic-gate #define MCIS_MAIL 3 /* MAIL command sent */ 7407c478bd9Sstevel@tonic-gate #define MCIS_RCPT 4 /* RCPT commands being sent */ 7417c478bd9Sstevel@tonic-gate #define MCIS_DATA 5 /* DATA command sent */ 7427c478bd9Sstevel@tonic-gate #define MCIS_QUITING 6 /* running quit protocol */ 7437c478bd9Sstevel@tonic-gate #define MCIS_SSD 7 /* service shutting down */ 7447c478bd9Sstevel@tonic-gate #define MCIS_ERROR 8 /* I/O error on connection */ 7457c478bd9Sstevel@tonic-gate 7467c478bd9Sstevel@tonic-gate /* functions */ 7477c478bd9Sstevel@tonic-gate extern void mci_cache __P((MCI *)); 7487c478bd9Sstevel@tonic-gate extern void mci_close __P((MCI *, char *where)); 7497c478bd9Sstevel@tonic-gate extern void mci_dump __P((SM_FILE_T *, MCI *, bool)); 7507c478bd9Sstevel@tonic-gate extern void mci_dump_all __P((SM_FILE_T *, bool)); 7517c478bd9Sstevel@tonic-gate extern void mci_flush __P((bool, MCI *)); 7527c478bd9Sstevel@tonic-gate extern MCI *mci_get __P((char *, MAILER *)); 7537c478bd9Sstevel@tonic-gate extern int mci_lock_host __P((MCI *)); 7547c478bd9Sstevel@tonic-gate extern bool mci_match __P((char *, MAILER *)); 7557c478bd9Sstevel@tonic-gate extern int mci_print_persistent __P((char *, char *)); 7567c478bd9Sstevel@tonic-gate extern int mci_purge_persistent __P((char *, char *)); 7577c478bd9Sstevel@tonic-gate extern MCI **mci_scan __P((MCI *)); 7587c478bd9Sstevel@tonic-gate extern void mci_setstat __P((MCI *, int, char *, char *)); 7597c478bd9Sstevel@tonic-gate extern void mci_store_persistent __P((MCI *)); 760058561cbSjbeck extern int mci_traverse_persistent __P((int (*)(char *, char *), char *)); 7617c478bd9Sstevel@tonic-gate extern void mci_unlock_host __P((MCI *)); 7627c478bd9Sstevel@tonic-gate 7637c478bd9Sstevel@tonic-gate EXTERN int MaxMciCache; /* maximum entries in MCI cache */ 7647c478bd9Sstevel@tonic-gate EXTERN time_t MciCacheTimeout; /* maximum idle time on connections */ 7657c478bd9Sstevel@tonic-gate EXTERN time_t MciInfoTimeout; /* how long 'til we retry down hosts */ 7667c478bd9Sstevel@tonic-gate 7677c478bd9Sstevel@tonic-gate /* 7687c478bd9Sstevel@tonic-gate ** Header structure. 7697c478bd9Sstevel@tonic-gate ** This structure is used internally to store header items. 7707c478bd9Sstevel@tonic-gate */ 7717c478bd9Sstevel@tonic-gate 7727c478bd9Sstevel@tonic-gate struct header 7737c478bd9Sstevel@tonic-gate { 7747c478bd9Sstevel@tonic-gate char *h_field; /* the name of the field */ 7757c478bd9Sstevel@tonic-gate char *h_value; /* the value of that field */ 7767c478bd9Sstevel@tonic-gate struct header *h_link; /* the next header */ 7777c478bd9Sstevel@tonic-gate unsigned char h_macro; /* include header if macro defined */ 7787c478bd9Sstevel@tonic-gate unsigned long h_flags; /* status bits, see below */ 7797c478bd9Sstevel@tonic-gate BITMAP256 h_mflags; /* m_flags bits needed */ 7807c478bd9Sstevel@tonic-gate }; 7817c478bd9Sstevel@tonic-gate 7827c478bd9Sstevel@tonic-gate typedef struct header HDR; 7837c478bd9Sstevel@tonic-gate 7847c478bd9Sstevel@tonic-gate /* 7857c478bd9Sstevel@tonic-gate ** Header information structure. 7867c478bd9Sstevel@tonic-gate ** Defined in conf.c, this struct declares the header fields 7877c478bd9Sstevel@tonic-gate ** that have some magic meaning. 7887c478bd9Sstevel@tonic-gate */ 7897c478bd9Sstevel@tonic-gate 7907c478bd9Sstevel@tonic-gate struct hdrinfo 7917c478bd9Sstevel@tonic-gate { 7927c478bd9Sstevel@tonic-gate char *hi_field; /* the name of the field */ 7937c478bd9Sstevel@tonic-gate unsigned long hi_flags; /* status bits, see below */ 7947c478bd9Sstevel@tonic-gate char *hi_ruleset; /* validity check ruleset */ 7957c478bd9Sstevel@tonic-gate }; 7967c478bd9Sstevel@tonic-gate 7977c478bd9Sstevel@tonic-gate extern struct hdrinfo HdrInfo[]; 7987c478bd9Sstevel@tonic-gate 7997c478bd9Sstevel@tonic-gate /* bits for h_flags and hi_flags */ 8007c478bd9Sstevel@tonic-gate #define H_EOH 0x00000001 /* field terminates header */ 8017c478bd9Sstevel@tonic-gate #define H_RCPT 0x00000002 /* contains recipient addresses */ 8027c478bd9Sstevel@tonic-gate #define H_DEFAULT 0x00000004 /* if another value is found, drop this */ 8037c478bd9Sstevel@tonic-gate #define H_RESENT 0x00000008 /* this address is a "Resent-..." address */ 8047c478bd9Sstevel@tonic-gate #define H_CHECK 0x00000010 /* check h_mflags against m_flags */ 8057c478bd9Sstevel@tonic-gate #define H_ACHECK 0x00000020 /* ditto, but always (not just default) */ 8067c478bd9Sstevel@tonic-gate #define H_FORCE 0x00000040 /* force this field, even if default */ 8077c478bd9Sstevel@tonic-gate #define H_TRACE 0x00000080 /* this field contains trace information */ 8087c478bd9Sstevel@tonic-gate #define H_FROM 0x00000100 /* this is a from-type field */ 8097c478bd9Sstevel@tonic-gate #define H_VALID 0x00000200 /* this field has a validated value */ 8107c478bd9Sstevel@tonic-gate #define H_RECEIPTTO 0x00000400 /* field has return receipt info */ 8117c478bd9Sstevel@tonic-gate #define H_ERRORSTO 0x00000800 /* field has error address info */ 8127c478bd9Sstevel@tonic-gate #define H_CTE 0x00001000 /* field is a content-transfer-encoding */ 8137c478bd9Sstevel@tonic-gate #define H_CTYPE 0x00002000 /* this is a content-type field */ 8147c478bd9Sstevel@tonic-gate #define H_BCC 0x00004000 /* Bcc: header: strip value or delete */ 8157c478bd9Sstevel@tonic-gate #define H_ENCODABLE 0x00008000 /* field can be RFC 1522 encoded */ 8167c478bd9Sstevel@tonic-gate #define H_STRIPCOMM 0x00010000 /* header check: strip comments */ 8177c478bd9Sstevel@tonic-gate #define H_BINDLATE 0x00020000 /* only expand macros at deliver */ 8187c478bd9Sstevel@tonic-gate #define H_USER 0x00040000 /* header came from the user/SMTP */ 8197c478bd9Sstevel@tonic-gate 8207c478bd9Sstevel@tonic-gate /* bits for chompheader() */ 8217c478bd9Sstevel@tonic-gate #define CHHDR_DEF 0x0001 /* default header */ 8227c478bd9Sstevel@tonic-gate #define CHHDR_CHECK 0x0002 /* call ruleset for header */ 8237c478bd9Sstevel@tonic-gate #define CHHDR_USER 0x0004 /* header from user */ 8247c478bd9Sstevel@tonic-gate #define CHHDR_QUEUE 0x0008 /* header from queue file */ 8257c478bd9Sstevel@tonic-gate 8267c478bd9Sstevel@tonic-gate /* functions */ 827058561cbSjbeck extern void addheader __P((char *, char *, int, ENVELOPE *, bool)); 8287c478bd9Sstevel@tonic-gate extern unsigned long chompheader __P((char *, int, HDR **, ENVELOPE *)); 8297800901eSjbeck extern bool commaize __P((HDR *, char *, bool, MCI *, ENVELOPE *, int)); 8307c478bd9Sstevel@tonic-gate extern HDR *copyheader __P((HDR *, SM_RPOOL_T *)); 8317c478bd9Sstevel@tonic-gate extern void eatheader __P((ENVELOPE *, bool, bool)); 8327c478bd9Sstevel@tonic-gate extern char *hvalue __P((char *, HDR *)); 833058561cbSjbeck extern void insheader __P((int, char *, char *, int, ENVELOPE *, bool)); 8347c478bd9Sstevel@tonic-gate extern bool isheader __P((char *)); 835445f2479Sjbeck extern bool putfromline __P((MCI *, ENVELOPE *)); 8367c478bd9Sstevel@tonic-gate extern void setupheaders __P((void)); 8377c478bd9Sstevel@tonic-gate 8387c478bd9Sstevel@tonic-gate /* 8397c478bd9Sstevel@tonic-gate ** Performance monitoring 8407c478bd9Sstevel@tonic-gate */ 8417c478bd9Sstevel@tonic-gate 8427c478bd9Sstevel@tonic-gate #define TIMERS struct sm_timers 8437c478bd9Sstevel@tonic-gate 8447c478bd9Sstevel@tonic-gate TIMERS 8457c478bd9Sstevel@tonic-gate { 8467c478bd9Sstevel@tonic-gate TIMER ti_overall; /* the whole process */ 8477c478bd9Sstevel@tonic-gate }; 8487c478bd9Sstevel@tonic-gate 8497c478bd9Sstevel@tonic-gate 8507c478bd9Sstevel@tonic-gate #define PUSHTIMER(l, t) { if (tTd(98, l)) pushtimer(&t); } 8517c478bd9Sstevel@tonic-gate #define POPTIMER(l, t) { if (tTd(98, l)) poptimer(&t); } 8527c478bd9Sstevel@tonic-gate 8537c478bd9Sstevel@tonic-gate /* 8547c478bd9Sstevel@tonic-gate ** Envelope structure. 8557c478bd9Sstevel@tonic-gate ** This structure defines the message itself. There is usually 8567c478bd9Sstevel@tonic-gate ** only one of these -- for the message that we originally read 8577c478bd9Sstevel@tonic-gate ** and which is our primary interest -- but other envelopes can 8587c478bd9Sstevel@tonic-gate ** be generated during processing. For example, error messages 8597c478bd9Sstevel@tonic-gate ** will have their own envelope. 8607c478bd9Sstevel@tonic-gate */ 8617c478bd9Sstevel@tonic-gate 8627c478bd9Sstevel@tonic-gate struct envelope 8637c478bd9Sstevel@tonic-gate { 8647c478bd9Sstevel@tonic-gate HDR *e_header; /* head of header list */ 8657c478bd9Sstevel@tonic-gate long e_msgpriority; /* adjusted priority of this message */ 8667c478bd9Sstevel@tonic-gate time_t e_ctime; /* time message appeared in the queue */ 8677c478bd9Sstevel@tonic-gate char *e_to; /* (list of) target person(s) */ 8687c478bd9Sstevel@tonic-gate ADDRESS e_from; /* the person it is from */ 8697c478bd9Sstevel@tonic-gate char *e_sender; /* e_from.q_paddr w comments stripped */ 8707c478bd9Sstevel@tonic-gate char **e_fromdomain; /* the domain part of the sender */ 8717c478bd9Sstevel@tonic-gate ADDRESS *e_sendqueue; /* list of message recipients */ 8727c478bd9Sstevel@tonic-gate ADDRESS *e_errorqueue; /* the queue for error responses */ 8737c478bd9Sstevel@tonic-gate 8747c478bd9Sstevel@tonic-gate /* 8757c478bd9Sstevel@tonic-gate ** Overflow detection is based on < 0, so don't change this 8767c478bd9Sstevel@tonic-gate ** to unsigned. We don't use unsigned and == ULONG_MAX because 8777c478bd9Sstevel@tonic-gate ** some libc's don't have strtoul(), see mail_esmtp_args(). 8787c478bd9Sstevel@tonic-gate */ 8797c478bd9Sstevel@tonic-gate 8807c478bd9Sstevel@tonic-gate long e_msgsize; /* size of the message in bytes */ 8817c478bd9Sstevel@tonic-gate char *e_msgid; /* message id (for logging) */ 8827c478bd9Sstevel@tonic-gate unsigned long e_flags; /* flags, see below */ 8837c478bd9Sstevel@tonic-gate int e_nrcpts; /* number of recipients */ 8847c478bd9Sstevel@tonic-gate short e_class; /* msg class (priority, junk, etc.) */ 8857c478bd9Sstevel@tonic-gate short e_hopcount; /* number of times processed */ 8867c478bd9Sstevel@tonic-gate short e_nsent; /* number of sends since checkpoint */ 8877c478bd9Sstevel@tonic-gate short e_sendmode; /* message send mode */ 8887c478bd9Sstevel@tonic-gate short e_errormode; /* error return mode */ 8897c478bd9Sstevel@tonic-gate short e_timeoutclass; /* message timeout class */ 890445f2479Sjbeck bool (*e_puthdr)__P((MCI *, HDR *, ENVELOPE *, int)); 8917c478bd9Sstevel@tonic-gate /* function to put header of message */ 892445f2479Sjbeck bool (*e_putbody)__P((MCI *, ENVELOPE *, char *)); 8937c478bd9Sstevel@tonic-gate /* function to put body of message */ 8947c478bd9Sstevel@tonic-gate ENVELOPE *e_parent; /* the message this one encloses */ 8957c478bd9Sstevel@tonic-gate ENVELOPE *e_sibling; /* the next envelope of interest */ 8967c478bd9Sstevel@tonic-gate char *e_bodytype; /* type of message body */ 8977c478bd9Sstevel@tonic-gate SM_FILE_T *e_dfp; /* data file */ 8987c478bd9Sstevel@tonic-gate char *e_id; /* code for this entry in queue */ 8997800901eSjbeck #if _FFR_SESSID 9007800901eSjbeck char *e_sessid; /* session ID for this envelope */ 9017800901eSjbeck #endif /* _FFR_SESSID */ 9027c478bd9Sstevel@tonic-gate int e_qgrp; /* queue group (index into queues) */ 9037c478bd9Sstevel@tonic-gate int e_qdir; /* index into queue directories */ 9047c478bd9Sstevel@tonic-gate int e_dfqgrp; /* data file queue group index */ 9057c478bd9Sstevel@tonic-gate int e_dfqdir; /* data file queue directory index */ 9067c478bd9Sstevel@tonic-gate int e_xfqgrp; /* queue group (index into queues) */ 9077c478bd9Sstevel@tonic-gate int e_xfqdir; /* index into queue directories (xf) */ 9087c478bd9Sstevel@tonic-gate SM_FILE_T *e_xfp; /* transcript file */ 9097c478bd9Sstevel@tonic-gate SM_FILE_T *e_lockfp; /* the lock file for this message */ 910058561cbSjbeck char *e_message; /* error message; readonly; NULL, 911058561cbSjbeck * or allocated from e_rpool */ 9127c478bd9Sstevel@tonic-gate char *e_statmsg; /* stat msg (changes per delivery). 9137c478bd9Sstevel@tonic-gate * readonly. NULL or allocated from 9147c478bd9Sstevel@tonic-gate * e_rpool. */ 9157c478bd9Sstevel@tonic-gate char *e_quarmsg; /* why envelope is quarantined */ 9167c478bd9Sstevel@tonic-gate char e_qfletter; /* queue file letter on disk */ 9177c478bd9Sstevel@tonic-gate char *e_msgboundary; /* MIME-style message part boundary */ 9187c478bd9Sstevel@tonic-gate char *e_origrcpt; /* original recipient (one only) */ 9197c478bd9Sstevel@tonic-gate char *e_envid; /* envelope id from MAIL FROM: line */ 9207c478bd9Sstevel@tonic-gate char *e_status; /* DSN status for this message */ 9217c478bd9Sstevel@tonic-gate time_t e_dtime; /* time of last delivery attempt */ 9227c478bd9Sstevel@tonic-gate int e_ntries; /* number of delivery attempts */ 9237c478bd9Sstevel@tonic-gate dev_t e_dfdev; /* data file device (crash recovery) */ 9247c478bd9Sstevel@tonic-gate ino_t e_dfino; /* data file inode (crash recovery) */ 9257c478bd9Sstevel@tonic-gate MACROS_T e_macro; /* macro definitions */ 9267c478bd9Sstevel@tonic-gate MCI *e_mci; /* connection info */ 9277c478bd9Sstevel@tonic-gate char *e_auth_param; /* readonly; NULL or static storage or 9287c478bd9Sstevel@tonic-gate * allocated from e_rpool */ 9297c478bd9Sstevel@tonic-gate TIMERS e_timers; /* per job timers */ 9307c478bd9Sstevel@tonic-gate long e_deliver_by; /* deliver by */ 9317c478bd9Sstevel@tonic-gate int e_dlvr_flag; /* deliver by flag */ 9327c478bd9Sstevel@tonic-gate SM_RPOOL_T *e_rpool; /* resource pool for this envelope */ 933058561cbSjbeck unsigned int e_features; /* server features */ 934*e9af4bc0SJohn Beck #if _FFR_MILTER_ENHSC 935*e9af4bc0SJohn Beck #define ENHSC_LEN 11 936*e9af4bc0SJohn Beck char e_enhsc[ENHSC_LEN]; /* enhanced status code */ 937*e9af4bc0SJohn Beck #endif /* _FFR_MILTER_ENHSC */ 9387c478bd9Sstevel@tonic-gate }; 9397c478bd9Sstevel@tonic-gate 9407c478bd9Sstevel@tonic-gate /* values for e_flags */ 9417c478bd9Sstevel@tonic-gate #define EF_OLDSTYLE 0x00000001L /* use spaces (not commas) in hdrs */ 9427c478bd9Sstevel@tonic-gate #define EF_INQUEUE 0x00000002L /* this message is fully queued */ 9437c478bd9Sstevel@tonic-gate #define EF_NO_BODY_RETN 0x00000004L /* omit message body on error */ 9447c478bd9Sstevel@tonic-gate #define EF_CLRQUEUE 0x00000008L /* disk copy is no longer needed */ 9457c478bd9Sstevel@tonic-gate #define EF_SENDRECEIPT 0x00000010L /* send a return receipt */ 9467c478bd9Sstevel@tonic-gate #define EF_FATALERRS 0x00000020L /* fatal errors occurred */ 9477c478bd9Sstevel@tonic-gate #define EF_DELETE_BCC 0x00000040L /* delete Bcc: headers entirely */ 9487c478bd9Sstevel@tonic-gate #define EF_RESPONSE 0x00000080L /* this is an error or return receipt */ 9497c478bd9Sstevel@tonic-gate #define EF_RESENT 0x00000100L /* this message is being forwarded */ 9507c478bd9Sstevel@tonic-gate #define EF_VRFYONLY 0x00000200L /* verify only (don't expand aliases) */ 9517c478bd9Sstevel@tonic-gate #define EF_WARNING 0x00000400L /* warning message has been sent */ 9527c478bd9Sstevel@tonic-gate #define EF_QUEUERUN 0x00000800L /* this envelope is from queue */ 9537c478bd9Sstevel@tonic-gate #define EF_GLOBALERRS 0x00001000L /* treat errors as global */ 9547c478bd9Sstevel@tonic-gate #define EF_PM_NOTIFY 0x00002000L /* send return mail to postmaster */ 9557c478bd9Sstevel@tonic-gate #define EF_METOO 0x00004000L /* send to me too */ 9567c478bd9Sstevel@tonic-gate #define EF_LOGSENDER 0x00008000L /* need to log the sender */ 9577c478bd9Sstevel@tonic-gate #define EF_NORECEIPT 0x00010000L /* suppress all return-receipts */ 9587c478bd9Sstevel@tonic-gate #define EF_HAS8BIT 0x00020000L /* at least one 8-bit char in body */ 9597c478bd9Sstevel@tonic-gate #define EF_NL_NOT_EOL 0x00040000L /* don't accept raw NL as EOLine */ 9607c478bd9Sstevel@tonic-gate #define EF_CRLF_NOT_EOL 0x00080000L /* don't accept CR-LF as EOLine */ 9617c478bd9Sstevel@tonic-gate #define EF_RET_PARAM 0x00100000L /* RCPT command had RET argument */ 9627c478bd9Sstevel@tonic-gate #define EF_HAS_DF 0x00200000L /* set when data file is instantiated */ 9637c478bd9Sstevel@tonic-gate #define EF_IS_MIME 0x00400000L /* really is a MIME message */ 9647c478bd9Sstevel@tonic-gate #define EF_DONT_MIME 0x00800000L /* never MIME this message */ 9657c478bd9Sstevel@tonic-gate #define EF_DISCARD 0x01000000L /* discard the message */ 9667c478bd9Sstevel@tonic-gate #define EF_TOOBIG 0x02000000L /* message is too big */ 9677c478bd9Sstevel@tonic-gate #define EF_SPLIT 0x04000000L /* envelope has been split */ 9687c478bd9Sstevel@tonic-gate #define EF_UNSAFE 0x08000000L /* unsafe: read from untrusted source */ 9693ee0e492Sjbeck #define EF_TOODEEP 0x10000000L /* message is nested too deep */ 9707c478bd9Sstevel@tonic-gate 9717c478bd9Sstevel@tonic-gate #define DLVR_NOTIFY 0x01 9727c478bd9Sstevel@tonic-gate #define DLVR_RETURN 0x02 9737c478bd9Sstevel@tonic-gate #define DLVR_TRACE 0x10 9747c478bd9Sstevel@tonic-gate #define IS_DLVR_NOTIFY(e) (((e)->e_dlvr_flag & DLVR_NOTIFY) != 0) 9757c478bd9Sstevel@tonic-gate #define IS_DLVR_RETURN(e) (((e)->e_dlvr_flag & DLVR_RETURN) != 0) 9767c478bd9Sstevel@tonic-gate #define IS_DLVR_TRACE(e) (((e)->e_dlvr_flag & DLVR_TRACE) != 0) 9777c478bd9Sstevel@tonic-gate #define IS_DLVR_BY(e) ((e)->e_dlvr_flag != 0) 9787c478bd9Sstevel@tonic-gate 9797c478bd9Sstevel@tonic-gate #define BODYTYPE_NONE (0) 9807c478bd9Sstevel@tonic-gate #define BODYTYPE_7BIT (1) 9817c478bd9Sstevel@tonic-gate #define BODYTYPE_8BITMIME (2) 9827c478bd9Sstevel@tonic-gate #define BODYTYPE_ILLEGAL (-1) 9837c478bd9Sstevel@tonic-gate #define BODYTYPE_VALID(b) ((b) == BODYTYPE_7BIT || (b) == BODYTYPE_8BITMIME) 9847c478bd9Sstevel@tonic-gate 9857c478bd9Sstevel@tonic-gate extern ENVELOPE BlankEnvelope; 9867c478bd9Sstevel@tonic-gate 9877c478bd9Sstevel@tonic-gate /* functions */ 9887c478bd9Sstevel@tonic-gate extern void clearenvelope __P((ENVELOPE *, bool, SM_RPOOL_T *)); 989*e9af4bc0SJohn Beck extern int dropenvelope __P((ENVELOPE *, bool, bool)); 9907c478bd9Sstevel@tonic-gate extern ENVELOPE *newenvelope __P((ENVELOPE *, ENVELOPE *, SM_RPOOL_T *)); 9917c478bd9Sstevel@tonic-gate extern void clrsessenvelope __P((ENVELOPE *)); 9927c478bd9Sstevel@tonic-gate extern void printenvflags __P((ENVELOPE *)); 993445f2479Sjbeck extern bool putbody __P((MCI *, ENVELOPE *, char *)); 994445f2479Sjbeck extern bool putheader __P((MCI *, HDR *, ENVELOPE *, int)); 9957c478bd9Sstevel@tonic-gate 9967c478bd9Sstevel@tonic-gate /* 9977c478bd9Sstevel@tonic-gate ** Message priority classes. 9987c478bd9Sstevel@tonic-gate ** 9997c478bd9Sstevel@tonic-gate ** The message class is read directly from the Priority: header 10007c478bd9Sstevel@tonic-gate ** field in the message. 10017c478bd9Sstevel@tonic-gate ** 10027c478bd9Sstevel@tonic-gate ** CurEnv->e_msgpriority is the number of bytes in the message plus 10037c478bd9Sstevel@tonic-gate ** the creation time (so that jobs ``tend'' to be ordered correctly), 10047c478bd9Sstevel@tonic-gate ** adjusted by the message class, the number of recipients, and the 10057c478bd9Sstevel@tonic-gate ** amount of time the message has been sitting around. This number 10067c478bd9Sstevel@tonic-gate ** is used to order the queue. Higher values mean LOWER priority. 10077c478bd9Sstevel@tonic-gate ** 10087c478bd9Sstevel@tonic-gate ** Each priority class point is worth WkClassFact priority points; 10097c478bd9Sstevel@tonic-gate ** each recipient is worth WkRecipFact priority points. Each time 10107c478bd9Sstevel@tonic-gate ** we reprocess a message the priority is adjusted by WkTimeFact. 10117c478bd9Sstevel@tonic-gate ** WkTimeFact should normally decrease the priority so that jobs 10127c478bd9Sstevel@tonic-gate ** that have historically failed will be run later; thanks go to 10137c478bd9Sstevel@tonic-gate ** Jay Lepreau at Utah for pointing out the error in my thinking. 10147c478bd9Sstevel@tonic-gate ** 10157c478bd9Sstevel@tonic-gate ** The "class" is this number, unadjusted by the age or size of 10167c478bd9Sstevel@tonic-gate ** this message. Classes with negative representations will have 10177c478bd9Sstevel@tonic-gate ** error messages thrown away if they are not local. 10187c478bd9Sstevel@tonic-gate */ 10197c478bd9Sstevel@tonic-gate 10207c478bd9Sstevel@tonic-gate struct priority 10217c478bd9Sstevel@tonic-gate { 10227c478bd9Sstevel@tonic-gate char *pri_name; /* external name of priority */ 10237c478bd9Sstevel@tonic-gate int pri_val; /* internal value for same */ 10247c478bd9Sstevel@tonic-gate }; 10257c478bd9Sstevel@tonic-gate 10267c478bd9Sstevel@tonic-gate EXTERN int NumPriorities; /* pointer into Priorities */ 10277c478bd9Sstevel@tonic-gate EXTERN struct priority Priorities[MAXPRIORITIES]; 10287c478bd9Sstevel@tonic-gate 10297c478bd9Sstevel@tonic-gate /* 10307c478bd9Sstevel@tonic-gate ** Rewrite rules. 10317c478bd9Sstevel@tonic-gate */ 10327c478bd9Sstevel@tonic-gate 10337c478bd9Sstevel@tonic-gate struct rewrite 10347c478bd9Sstevel@tonic-gate { 10357c478bd9Sstevel@tonic-gate char **r_lhs; /* pattern match */ 10367c478bd9Sstevel@tonic-gate char **r_rhs; /* substitution value */ 10377c478bd9Sstevel@tonic-gate struct rewrite *r_next;/* next in chain */ 10387c478bd9Sstevel@tonic-gate int r_line; /* rule line in sendmail.cf */ 10397c478bd9Sstevel@tonic-gate }; 10407c478bd9Sstevel@tonic-gate 10417c478bd9Sstevel@tonic-gate /* 10427c478bd9Sstevel@tonic-gate ** Special characters in rewriting rules. 10437c478bd9Sstevel@tonic-gate ** These are used internally only. 10447c478bd9Sstevel@tonic-gate ** The COND* rules are actually used in macros rather than in 10457c478bd9Sstevel@tonic-gate ** rewriting rules, but are given here because they 10467c478bd9Sstevel@tonic-gate ** cannot conflict. 10477c478bd9Sstevel@tonic-gate */ 10487c478bd9Sstevel@tonic-gate 1049058561cbSjbeck /* "out of band" indicator */ 1050058561cbSjbeck /* sm/sendmail.h #define METAQUOTE ((unsigned char)0377) quotes the next octet */ 1051058561cbSjbeck 10527c478bd9Sstevel@tonic-gate /* left hand side items */ 10537c478bd9Sstevel@tonic-gate #define MATCHZANY ((unsigned char)0220) /* match zero or more tokens */ 10547c478bd9Sstevel@tonic-gate #define MATCHANY ((unsigned char)0221) /* match one or more tokens */ 10557c478bd9Sstevel@tonic-gate #define MATCHONE ((unsigned char)0222) /* match exactly one token */ 10567c478bd9Sstevel@tonic-gate #define MATCHCLASS ((unsigned char)0223) /* match one token in a class */ 1057058561cbSjbeck #define MATCHNCLASS ((unsigned char)0224) /* match tokens not in class */ 10587c478bd9Sstevel@tonic-gate 10597c478bd9Sstevel@tonic-gate /* right hand side items */ 1060058561cbSjbeck #define MATCHREPL ((unsigned char)0225) /* RHS replacement for above */ 10617c478bd9Sstevel@tonic-gate #define CANONNET ((unsigned char)0226) /* canonical net, next token */ 10627c478bd9Sstevel@tonic-gate #define CANONHOST ((unsigned char)0227) /* canonical host, next token */ 10637c478bd9Sstevel@tonic-gate #define CANONUSER ((unsigned char)0230) /* canonical user, next N tokens */ 10647c478bd9Sstevel@tonic-gate #define CALLSUBR ((unsigned char)0231) /* call another rewriting set */ 10657c478bd9Sstevel@tonic-gate 1066058561cbSjbeck /* conditionals in macros (anywhere) */ 10677c478bd9Sstevel@tonic-gate #define CONDIF ((unsigned char)0232) /* conditional if-then */ 10687c478bd9Sstevel@tonic-gate #define CONDELSE ((unsigned char)0233) /* conditional else */ 10697c478bd9Sstevel@tonic-gate #define CONDFI ((unsigned char)0234) /* conditional fi */ 10707c478bd9Sstevel@tonic-gate 1071058561cbSjbeck /* bracket characters for RHS host name lookup */ 10727c478bd9Sstevel@tonic-gate #define HOSTBEGIN ((unsigned char)0235) /* hostname lookup begin */ 1073058561cbSjbeck #define HOSTEND ((unsigned char)0236) /* hostname lookup end */ 10747c478bd9Sstevel@tonic-gate 1075058561cbSjbeck /* bracket characters for RHS generalized lookup */ 10767c478bd9Sstevel@tonic-gate #define LOOKUPBEGIN ((unsigned char)0205) /* generalized lookup begin */ 10777c478bd9Sstevel@tonic-gate #define LOOKUPEND ((unsigned char)0206) /* generalized lookup end */ 10787c478bd9Sstevel@tonic-gate 1079058561cbSjbeck /* macro substitution characters (anywhere) */ 10807c478bd9Sstevel@tonic-gate #define MACROEXPAND ((unsigned char)0201) /* macro expansion */ 10817c478bd9Sstevel@tonic-gate #define MACRODEXPAND ((unsigned char)0202) /* deferred macro expansion */ 10827c478bd9Sstevel@tonic-gate 10837c478bd9Sstevel@tonic-gate /* to make the code clearer */ 10847c478bd9Sstevel@tonic-gate #define MATCHZERO CANONHOST 10857c478bd9Sstevel@tonic-gate 10867c478bd9Sstevel@tonic-gate #define MAXMATCH 9 /* max params per rewrite */ 10877c478bd9Sstevel@tonic-gate #define MAX_MAP_ARGS 10 /* max arguments for map */ 10887c478bd9Sstevel@tonic-gate 10897c478bd9Sstevel@tonic-gate /* external <==> internal mapping table */ 10907c478bd9Sstevel@tonic-gate struct metamac 10917c478bd9Sstevel@tonic-gate { 10927c478bd9Sstevel@tonic-gate char metaname; /* external code (after $) */ 10937c478bd9Sstevel@tonic-gate unsigned char metaval; /* internal code (as above) */ 10947c478bd9Sstevel@tonic-gate }; 10957c478bd9Sstevel@tonic-gate 10967c478bd9Sstevel@tonic-gate /* values for macros with external names only */ 10977c478bd9Sstevel@tonic-gate #define MID_OPMODE 0202 /* operation mode */ 10987c478bd9Sstevel@tonic-gate 10997c478bd9Sstevel@tonic-gate /* functions */ 11007c478bd9Sstevel@tonic-gate #if SM_HEAP_CHECK 11017c478bd9Sstevel@tonic-gate extern void 11027c478bd9Sstevel@tonic-gate macdefine_tagged __P(( 11037c478bd9Sstevel@tonic-gate MACROS_T *_mac, 11047c478bd9Sstevel@tonic-gate ARGCLASS_T _vclass, 11057c478bd9Sstevel@tonic-gate int _id, 11067c478bd9Sstevel@tonic-gate char *_value, 11077c478bd9Sstevel@tonic-gate char *_file, 11087c478bd9Sstevel@tonic-gate int _line, 11097c478bd9Sstevel@tonic-gate int _group)); 11107c478bd9Sstevel@tonic-gate # define macdefine(mac,c,id,v) \ 11117c478bd9Sstevel@tonic-gate macdefine_tagged(mac,c,id,v,__FILE__,__LINE__,sm_heap_group()) 11127c478bd9Sstevel@tonic-gate #else /* SM_HEAP_CHECK */ 11137c478bd9Sstevel@tonic-gate extern void 11147c478bd9Sstevel@tonic-gate macdefine __P(( 11157c478bd9Sstevel@tonic-gate MACROS_T *_mac, 11167c478bd9Sstevel@tonic-gate ARGCLASS_T _vclass, 11177c478bd9Sstevel@tonic-gate int _id, 11187c478bd9Sstevel@tonic-gate char *_value)); 11197c478bd9Sstevel@tonic-gate # define macdefine_tagged(mac,c,id,v,file,line,grp) macdefine(mac,c,id,v) 11207c478bd9Sstevel@tonic-gate #endif /* SM_HEAP_CHECK */ 11217c478bd9Sstevel@tonic-gate extern void macset __P((MACROS_T *, int, char *)); 11227c478bd9Sstevel@tonic-gate #define macget(mac, i) (mac)->mac_table[i] 11237c478bd9Sstevel@tonic-gate extern void expand __P((char *, char *, size_t, ENVELOPE *)); 11247c478bd9Sstevel@tonic-gate extern int macid_parse __P((char *, char **)); 11257c478bd9Sstevel@tonic-gate #define macid(name) macid_parse(name, NULL) 11267c478bd9Sstevel@tonic-gate extern char *macname __P((int)); 11277c478bd9Sstevel@tonic-gate extern char *macvalue __P((int, ENVELOPE *)); 1128058561cbSjbeck extern int rscheck __P((char *, char *, char *, ENVELOPE *, int, int, char *, char *, ADDRESS *)); 11297c478bd9Sstevel@tonic-gate extern int rscap __P((char *, char *, char *, ENVELOPE *, char ***, char *, int)); 11307c478bd9Sstevel@tonic-gate extern void setclass __P((int, char *)); 11317c478bd9Sstevel@tonic-gate extern int strtorwset __P((char *, char **, int)); 1132058561cbSjbeck extern char *translate_dollars __P((char *, char *, int *)); 11337c478bd9Sstevel@tonic-gate extern bool wordinclass __P((char *, int)); 11347c478bd9Sstevel@tonic-gate 11357c478bd9Sstevel@tonic-gate /* 11367c478bd9Sstevel@tonic-gate ** Name canonification short circuit. 11377c478bd9Sstevel@tonic-gate ** 11387c478bd9Sstevel@tonic-gate ** If the name server for a host is down, the process of trying to 11397c478bd9Sstevel@tonic-gate ** canonify the name can hang. This is similar to (but alas, not 11407c478bd9Sstevel@tonic-gate ** identical to) looking up the name for delivery. This stab type 11417c478bd9Sstevel@tonic-gate ** caches the result of the name server lookup so we don't hang 11427c478bd9Sstevel@tonic-gate ** multiple times. 11437c478bd9Sstevel@tonic-gate */ 11447c478bd9Sstevel@tonic-gate 11457c478bd9Sstevel@tonic-gate #define NAMECANON struct _namecanon 11467c478bd9Sstevel@tonic-gate 11477c478bd9Sstevel@tonic-gate NAMECANON 11487c478bd9Sstevel@tonic-gate { 11497c478bd9Sstevel@tonic-gate short nc_errno; /* cached errno */ 11507c478bd9Sstevel@tonic-gate short nc_herrno; /* cached h_errno */ 11517c478bd9Sstevel@tonic-gate short nc_stat; /* cached exit status code */ 11527c478bd9Sstevel@tonic-gate short nc_flags; /* flag bits */ 11537c478bd9Sstevel@tonic-gate char *nc_cname; /* the canonical name */ 11547c478bd9Sstevel@tonic-gate time_t nc_exp; /* entry expires at */ 11557c478bd9Sstevel@tonic-gate }; 11567c478bd9Sstevel@tonic-gate 11577c478bd9Sstevel@tonic-gate /* values for nc_flags */ 11587c478bd9Sstevel@tonic-gate #define NCF_VALID 0x0001 /* entry valid */ 11597c478bd9Sstevel@tonic-gate 11607c478bd9Sstevel@tonic-gate /* hostsignature structure */ 11617c478bd9Sstevel@tonic-gate 11627c478bd9Sstevel@tonic-gate struct hostsig_t 11637c478bd9Sstevel@tonic-gate { 11647c478bd9Sstevel@tonic-gate char *hs_sig; /* hostsignature */ 11657c478bd9Sstevel@tonic-gate time_t hs_exp; /* entry expires at */ 11667c478bd9Sstevel@tonic-gate }; 11677c478bd9Sstevel@tonic-gate 11687c478bd9Sstevel@tonic-gate typedef struct hostsig_t HOSTSIG_T; 11697c478bd9Sstevel@tonic-gate 11707c478bd9Sstevel@tonic-gate /* functions */ 11717c478bd9Sstevel@tonic-gate extern bool getcanonname __P((char *, int, bool, int *)); 11727c478bd9Sstevel@tonic-gate extern int getmxrr __P((char *, char **, unsigned short *, bool, int *, bool, int *)); 11737c478bd9Sstevel@tonic-gate extern char *hostsignature __P((MAILER *, char *)); 11747c478bd9Sstevel@tonic-gate extern int getfallbackmxrr __P((char *)); 11757c478bd9Sstevel@tonic-gate 11767c478bd9Sstevel@tonic-gate /* 11777c478bd9Sstevel@tonic-gate ** Mapping functions 11787c478bd9Sstevel@tonic-gate ** 11797c478bd9Sstevel@tonic-gate ** These allow arbitrary mappings in the config file. The idea 11807c478bd9Sstevel@tonic-gate ** (albeit not the implementation) comes from IDA sendmail. 11817c478bd9Sstevel@tonic-gate */ 11827c478bd9Sstevel@tonic-gate 11837c478bd9Sstevel@tonic-gate #define