proto.m4 revision 66494
138032Speterdivert(-1) 238032Speter# 364562Sgshapiro# Copyright (c) 1998-2000 Sendmail, Inc. and its suppliers. 464562Sgshapiro# All rights reserved. 538032Speter# Copyright (c) 1983, 1995 Eric P. Allman. All rights reserved. 638032Speter# Copyright (c) 1988, 1993 738032Speter# The Regents of the University of California. All rights reserved. 838032Speter# 938032Speter# By using this file, you agree to the terms and conditions set 1038032Speter# forth in the LICENSE file which can be found at the top level of 1138032Speter# the sendmail distribution. 1238032Speter# 1338032Speter# 1438032Speterdivert(0) 1538032Speter 1666494SgshapiroVERSIONID(`$Id: proto.m4,v 8.446.2.5.2.29 2000/09/15 04:45:14 gshapiro Exp $') 1738032Speter 1838032SpeterMAILER(local)dnl 1938032Speter 2064562Sgshapiro# level CF_LEVEL config file format 2164562SgshapiroV`'CF_LEVEL/ifdef(`VENDOR_NAME', `VENDOR_NAME', `Berkeley') 2238032Speterdivert(-1) 2338032Speter 2438032Speter# do some sanity checking 2538032Speterifdef(`__OSTYPE__',, 2664562Sgshapiro `errprint(`*** ERROR: No system type defined (use OSTYPE macro) 2764562Sgshapiro')') 2838032Speter 2938032Speter# pick our default mailers 3038032Speterifdef(`confSMTP_MAILER',, `define(`confSMTP_MAILER', `esmtp')') 3138032Speterifdef(`confLOCAL_MAILER',, `define(`confLOCAL_MAILER', `local')') 3238032Speterifdef(`confRELAY_MAILER',, 3338032Speter `define(`confRELAY_MAILER', 3438032Speter `ifdef(`_MAILER_smtp_', `relay', 3538032Speter `ifdef(`_MAILER_uucp', `uucp-new', `unknown')')')') 3638032Speterifdef(`confUUCP_MAILER',, `define(`confUUCP_MAILER', `uucp-old')') 3738032Speterdefine(`_SMTP_', `confSMTP_MAILER')dnl for readability only 3838032Speterdefine(`_LOCAL_', `confLOCAL_MAILER')dnl for readability only 3938032Speterdefine(`_RELAY_', `confRELAY_MAILER')dnl for readability only 4038032Speterdefine(`_UUCP_', `confUUCP_MAILER')dnl for readability only 4138032Speter 4238032Speter# back compatibility with old config files 4338032Speterifdef(`confDEF_GROUP_ID', 4464562Sgshapiro`errprint(`*** confDEF_GROUP_ID is obsolete. 4564562Sgshapiro Use confDEF_USER_ID with a colon in the value instead. 4664562Sgshapiro')') 4738032Speterifdef(`confREAD_TIMEOUT', 4864562Sgshapiro`errprint(`*** confREAD_TIMEOUT is obsolete. 4964562Sgshapiro Use individual confTO_<timeout> parameters instead. 5064562Sgshapiro')') 5138032Speterifdef(`confMESSAGE_TIMEOUT', 5238032Speter `define(`_ARG_', index(confMESSAGE_TIMEOUT, /)) 5338032Speter ifelse(_ARG_, -1, 5438032Speter `define(`confTO_QUEUERETURN', confMESSAGE_TIMEOUT)', 5538032Speter `define(`confTO_QUEUERETURN', 5638032Speter substr(confMESSAGE_TIMEOUT, 0, _ARG_)) 5738032Speter define(`confTO_QUEUEWARN', 5838032Speter substr(confMESSAGE_TIMEOUT, eval(_ARG_+1)))')') 5938032Speterifdef(`confMIN_FREE_BLOCKS', `ifelse(index(confMIN_FREE_BLOCKS, /), -1,, 6064562Sgshapiro`errprint(`*** compound confMIN_FREE_BLOCKS is obsolete. 6164562Sgshapiro Use confMAX_MESSAGE_SIZE for the second part of the value. 6264562Sgshapiro')')') 6338032Speter 6464562Sgshapiro 6564562Sgshapiro# Sanity check on ldap_routing feature 6664562Sgshapiro# If the user doesn't specify a new map, they better have given as a 6764562Sgshapiro# default LDAP specification which has the LDAP base (and most likely the host) 6864562Sgshapiroifdef(`confLDAP_DEFAULT_SPEC',, `ifdef(`_LDAP_ROUTING_WARN_', `errprint(` 6964562SgshapiroWARNING: Using default FEATURE(ldap_routing) map definition(s) 7064562Sgshapirowithout setting confLDAP_DEFAULT_SPEC option. 7164562Sgshapiro')')')dnl 7264562Sgshapiro 7338032Speter# clean option definitions below.... 7464562Sgshapirodefine(`_OPTION', `ifdef(`$2', `O $1`'ifelse(defn(`$2'), `',, `=$2')', `#O $1`'ifelse(`$3', `',,`=$3')')')dnl 7538032Speter 7664562Sgshapirodnl required to "rename" the check_* rulesets... 7764562Sgshapirodefine(`_U_',ifdef(`_DELAY_CHECKS_',`',`_')) 7864562Sgshapirodnl default relaying denied message 7964562Sgshapiroifdef(`confRELAY_MSG', `', `define(`confRELAY_MSG', `"550 Relaying denied"')') 8038032Speterdivert(0)dnl 8138032Speter 8264562Sgshapiro# override file safeties - setting this option compromises system security, 8364562Sgshapiro# addressing the actual file configuration problem is preferred 8464562Sgshapiro# need to set this before any file actions are encountered in the cf file 8564562Sgshapiro_OPTION(DontBlameSendmail, `confDONT_BLAME_SENDMAIL', `safe') 8638032Speter 8764562Sgshapiro# default LDAP map specification 8864562Sgshapiro# need to set this now before any LDAP maps are defined 8964562Sgshapiro_OPTION(LDAPDefaultSpec, `confLDAP_DEFAULT_SPEC', `-h localhost') 9064562Sgshapiro 9138032Speter################## 9238032Speter# local info # 9338032Speter################## 9438032Speter 9538032SpeterCwlocalhost 9638032Speterifdef(`USE_CW_FILE', 9738032Speter`# file containing names of hosts for which we receive email 9838032SpeterFw`'confCW_FILE', 9938032Speter `dnl') 10038032Speter 10138032Speter# my official domain name 10238032Speter# ... `define' this only if sendmail cannot automatically determine your domain 10338032Speterifdef(`confDOMAIN_NAME', `Dj`'confDOMAIN_NAME', `#Dj$w.Foo.COM') 10438032Speter 10538032SpeterCP. 10638032Speter 10738032Speterifdef(`UUCP_RELAY', 10838032Speter`# UUCP relay host 10938032SpeterDY`'UUCP_RELAY 11038032SpeterCPUUCP 11138032Speter 11238032Speter')dnl 11338032Speterifdef(`BITNET_RELAY', 11438032Speter`# BITNET relay host 11538032SpeterDB`'BITNET_RELAY 11638032SpeterCPBITNET 11738032Speter 11838032Speter')dnl 11938032Speterifdef(`DECNET_RELAY', 12038032Speter`define(`_USE_DECNET_SYNTAX_', 1)dnl 12138032Speter# DECnet relay host 12238032SpeterDC`'DECNET_RELAY 12338032SpeterCPDECNET 12438032Speter 12538032Speter')dnl 12638032Speterifdef(`FAX_RELAY', 12738032Speter`# FAX relay host 12838032SpeterDF`'FAX_RELAY 12938032SpeterCPFAX 13038032Speter 13138032Speter')dnl 13238032Speter# "Smart" relay host (may be null) 13338032SpeterDS`'ifdef(`SMART_HOST', SMART_HOST) 13438032Speter 13538032Speterifdef(`LUSER_RELAY', `dnl 13638032Speter# place to which unknown users should be forwarded 13738032SpeterKuser user -m -a<> 13838032SpeterDL`'LUSER_RELAY', 13938032Speter`dnl') 14038032Speter 14138032Speter# operators that cannot be in local usernames (i.e., network indicators) 14238032SpeterCO @ % ifdef(`_NO_UUCP_', `', `!') 14338032Speter 14438032Speter# a class with just dot (for identifying canonical names) 14538032SpeterC.. 14638032Speter 14738032Speter# a class with just a left bracket (for identifying domain literals) 14838032SpeterC[[ 14938032Speter 15064562Sgshapiroifdef(`_ACCESS_TABLE_', `dnl 15164562Sgshapiro# access_db acceptance class 15264562SgshapiroC{Accept}OK RELAY 15364562Sgshapiroifdef(`_DELAY_CHECKS_',`dnl 15464562Sgshapiroifdef(`_BLACKLIST_RCPT_',`dnl 15564562Sgshapiro# possible access_db RHS for spam friends/haters 15664562SgshapiroC{SpamTag}SPAMFRIEND SPAMHATER')')', 15738032Speter`dnl') 15838032Speter 15938032Speterifdef(`_ACCEPT_UNRESOLVABLE_DOMAINS_',`dnl',`dnl 16038032Speter# Resolve map (to check if a host exists in check_mail) 16138032SpeterKresolve host -a<OK> -T<TEMP>') 16238032Speter 16366494Sgshapiroifdef(`_FFR_5_', `# macro storage map 16466494SgshapiroKmacro macro') 16566494Sgshapiro 16638032Speterifdef(`confCR_FILE', `dnl 16766494Sgshapiro# Hosts for which relaying is permitted ($=R) 16838032SpeterFR`'confCR_FILE', 16938032Speter`dnl') 17038032Speter 17164562Sgshapirodefine(`TLS_SRV_TAG', `TLS_Srv')dnl 17264562Sgshapirodefine(`TLS_CLT_TAG', `TLS_Clt')dnl 17364562Sgshapirodefine(`TLS_TRY_TAG', `Try_TLS')dnl 17464562Sgshapirodefine(`TLS_OFF_TAG', `Offer_TLS')dnl 17564562Sgshapirodnl this may be useful in other contexts too 17664562Sgshapiroifdef(`_ARITH_MAP_', `', `# arithmetic map 17764562Sgshapirodefine(`_ARITH_MAP_', `1')dnl 17864562SgshapiroKarith arith') 17964562Sgshapiroifdef(`_ACCESS_TABLE_', `dnl 18064562Sgshapiro# possible values for tls_connect in access map 18164562SgshapiroC{tls}VERIFY ENCR', `dnl') 18264562Sgshapiroifdef(`_CERT_REGEX_ISSUER_', `dnl 18364562Sgshapiro# extract relevant part from cert issuer 18464562SgshapiroKCERTIssuer regex _CERT_REGEX_ISSUER_', `dnl') 18564562Sgshapiroifdef(`_CERT_REGEX_SUBJECT_', `dnl 18664562Sgshapiro# extract relevant part from cert subject 18764562SgshapiroKCERTSubject regex _CERT_REGEX_SUBJECT_', `dnl') 18864562Sgshapiro 18938032Speter# who I send unqualified names to (null means deliver locally) 19038032SpeterDR`'ifdef(`LOCAL_RELAY', LOCAL_RELAY) 19138032Speter 19238032Speter# who gets all local email traffic ($R has precedence for unqualified names) 19338032SpeterDH`'ifdef(`MAIL_HUB', MAIL_HUB) 19438032Speter 19538032Speter# dequoting map 19638032SpeterKdequote dequote 19738032Speter 19838032Speterdivert(0)dnl # end of nullclient diversion 19938032Speter# class E: names that should be exposed as from this host, even if we masquerade 20064562Sgshapiro# class L: names that should be delivered locally, even if we have a relay 20138032Speter# class M: domains that should be converted to $M 20264562Sgshapiro# class N: domains that should not be converted to $M 20338032Speter#CL root 20438032Speterundivert(5)dnl 20564562Sgshapiroifdef(`_VIRTHOSTS_', `CR$={VirtHost}', `dnl') 20638032Speter 20738032Speter# who I masquerade as (null for no masquerading) (see also $=M) 20838032SpeterDM`'ifdef(`MASQUERADE_NAME', MASQUERADE_NAME) 20938032Speter 21038032Speter# my name for error messages 21138032Speterifdef(`confMAILER_NAME', `Dn`'confMAILER_NAME', `#DnMAILER-DAEMON') 21238032Speter 21364562Sgshapiroundivert(6)dnl LOCAL_CONFIG 21438032Speterinclude(_CF_DIR_`m4/version.m4') 21538032Speter 21638032Speter############### 21738032Speter# Options # 21838032Speter############### 21938032Speter 22038032Speter# strip message body to 7 bits on input? 22164562Sgshapiro_OPTION(SevenBitInput, `confSEVEN_BIT_INPUT', `False') 22238032Speter 22338032Speter# 8-bit data handling 22464562Sgshapiro_OPTION(EightBitMode, `confEIGHT_BIT_HANDLING', `adaptive') 22538032Speter 22638032Speter# wait for alias file rebuild (default units: minutes) 22764562Sgshapiro_OPTION(AliasWait, `confALIAS_WAIT', `5m') 22838032Speter 22938032Speter# location of alias file 23064562Sgshapiro_OPTION(AliasFile, `ALIAS_FILE', `MAIL_SETTINGS_DIR`'aliases') 23164562Sgshapiro 23238032Speter# minimum number of free blocks on filesystem 23364562Sgshapiro_OPTION(MinFreeBlocks, `confMIN_FREE_BLOCKS', `100') 23438032Speter 23538032Speter# maximum message size 23664562Sgshapiro_OPTION(MaxMessageSize, `confMAX_MESSAGE_SIZE', `1000000') 23738032Speter 23838032Speter# substitution for space (blank) characters 23964562Sgshapiro_OPTION(BlankSub, `confBLANK_SUB', `_') 24038032Speter 24138032Speter# avoid connecting to "expensive" mailers on initial submission? 24264562Sgshapiro_OPTION(HoldExpensive, `confCON_EXPENSIVE', `False') 24338032Speter 24438032Speter# checkpoint queue runs after every N successful deliveries 24564562Sgshapiro_OPTION(CheckpointInterval, `confCHECKPOINT_INTERVAL', `10') 24638032Speter 24738032Speter# default delivery mode 24864562Sgshapiro_OPTION(DeliveryMode, `confDELIVERY_MODE', `background') 24938032Speter 25038032Speter# automatically rebuild the alias database? 25164562Sgshapiro# NOTE: There is a potential for a denial of service attack if this is set. 25264562Sgshapiro# This option is deprecated and will be removed from a future version. 25364562Sgshapiro_OPTION(AutoRebuildAliases, `confAUTO_REBUILD', `False') 25438032Speter 25538032Speter# error message header/file 25664562Sgshapiro_OPTION(ErrorHeader, `confERROR_MESSAGE', `MAIL_SETTINGS_DIR`'error-header') 25738032Speter 25838032Speter# error mode 25964562Sgshapiro_OPTION(ErrorMode, `confERROR_MODE', `print') 26038032Speter 26138032Speter# save Unix-style "From_" lines at top of header? 26264562Sgshapiro_OPTION(SaveFromLine, `confSAVE_FROM_LINES', `False') 26338032Speter 26438032Speter# temporary file mode 26564562Sgshapiro_OPTION(TempFileMode, `confTEMP_FILE_MODE', `0600') 26638032Speter 26738032Speter# match recipients against GECOS field? 26864562Sgshapiro_OPTION(MatchGECOS, `confMATCH_GECOS', `False') 26938032Speter 27038032Speter# maximum hop count 27164562Sgshapiro_OPTION(MaxHopCount, `confMAX_HOP', `17') 27238032Speter 27338032Speter# location of help file 27464562SgshapiroO HelpFile=ifdef(`HELP_FILE', HELP_FILE, `MAIL_SETTINGS_DIR`'helpfile') 27538032Speter 27638032Speter# ignore dots as terminators in incoming messages? 27764562Sgshapiro_OPTION(IgnoreDots, `confIGNORE_DOTS', `False') 27838032Speter 27938032Speter# name resolver options 28064562Sgshapiro_OPTION(ResolverOptions, `confBIND_OPTS', `+AAONLY') 28138032Speter 28238032Speter# deliver MIME-encapsulated error messages? 28364562Sgshapiro_OPTION(SendMimeErrors, `confMIME_FORMAT_ERRORS', `True') 28438032Speter 28538032Speter# Forward file search path 28664562Sgshapiro_OPTION(ForwardPath, `confFORWARD_PATH', `/var/forward/$u:$z/.forward.$w:$z/.forward') 28738032Speter 28838032Speter# open connection cache size 28964562Sgshapiro_OPTION(ConnectionCacheSize, `confMCI_CACHE_SIZE', `2') 29038032Speter 29138032Speter# open connection cache timeout 29264562Sgshapiro_OPTION(ConnectionCacheTimeout, `confMCI_CACHE_TIMEOUT', `5m') 29338032Speter 29438032Speter# persistent host status directory 29564562Sgshapiro_OPTION(HostStatusDirectory, `confHOST_STATUS_DIRECTORY', `.hoststat') 29638032Speter 29738032Speter# single thread deliveries (requires HostStatusDirectory)? 29864562Sgshapiro_OPTION(SingleThreadDelivery, `confSINGLE_THREAD_DELIVERY', `False') 29938032Speter 30038032Speter# use Errors-To: header? 30164562Sgshapiro_OPTION(UseErrorsTo, `confUSE_ERRORS_TO', `False') 30238032Speter 30338032Speter# log level 30464562Sgshapiro_OPTION(LogLevel, `confLOG_LEVEL', `10') 30538032Speter 30638032Speter# send to me too, even in an alias expansion? 30764562Sgshapiro_OPTION(MeToo, `confME_TOO', `True') 30838032Speter 30938032Speter# verify RHS in newaliases? 31064562Sgshapiro_OPTION(CheckAliases, `confCHECK_ALIASES', `False') 31138032Speter 31238032Speter# default messages to old style headers if no special punctuation? 31364562Sgshapiro_OPTION(OldStyleHeaders, `confOLD_STYLE_HEADERS', `False') 31438032Speter 31538032Speter# SMTP daemon options 31664562Sgshapiroifelse(defn(`confDAEMON_OPTIONS'), `', `dnl', 31764562Sgshapiro`errprint(WARNING: `confDAEMON_OPTIONS' is no longer valid. See cf/README for more information. 31864562Sgshapiro)'dnl 31964562Sgshapiro`DAEMON_OPTIONS(`confDAEMON_OPTIONS')') 32066494Sgshapiroifelse(defn(`_DPO_'), `', 32166494Sgshapiro`ifdef(`_NETINET6_', `O DaemonPortOptions=Name=MTA-IPv4, Family=inet 32266494SgshapiroO DaemonPortOptions=Name=MTA-IPv6, Family=inet6',`O DaemonPortOptions=Name=MTA')', `_DPO_') 32364562Sgshapiroifdef(`_NO_MSA_', `dnl', `O DaemonPortOptions=Port=587, Name=MSA, M=E') 32438032Speter 32564562Sgshapiro# SMTP client options 32664562Sgshapiro_OPTION(ClientPortOptions, `confCLIENT_OPTIONS', `Address=0.0.0.0') 32764562Sgshapiro 32838032Speter# privacy flags 32964562Sgshapiro_OPTION(PrivacyOptions, `confPRIVACY_FLAGS', `authwarnings') 33038032Speter 33138032Speter# who (if anyone) should get extra copies of error messages 33264562Sgshapiro_OPTION(PostmasterCopy, `confCOPY_ERRORS_TO', `Postmaster') 33338032Speter 33438032Speter# slope of queue-only function 33564562Sgshapiro_OPTION(QueueFactor, `confQUEUE_FACTOR', `600000') 33638032Speter 33738032Speter# queue directory 33864562SgshapiroO QueueDirectory=ifdef(`QUEUE_DIR', QUEUE_DIR, `/var/spool/mqueue') 33938032Speter 34038032Speter# timeouts (many of these) 34164562Sgshapiro_OPTION(Timeout.initial, `confTO_INITIAL', `5m') 34264562Sgshapiro_OPTION(Timeout.connect, `confTO_CONNECT', `5m') 34364562Sgshapiro_OPTION(Timeout.iconnect, `confTO_ICONNECT', `5m') 34464562Sgshapiro_OPTION(Timeout.helo, `confTO_HELO', `5m') 34564562Sgshapiro_OPTION(Timeout.mail, `confTO_MAIL', `10m') 34664562Sgshapiro_OPTION(Timeout.rcpt, `confTO_RCPT', `1h') 34764562Sgshapiro_OPTION(Timeout.datainit, `confTO_DATAINIT', `5m') 34864562Sgshapiro_OPTION(Timeout.datablock, `confTO_DATABLOCK', `1h') 34964562Sgshapiro_OPTION(Timeout.datafinal, `confTO_DATAFINAL', `1h') 35064562Sgshapiro_OPTION(Timeout.rset, `confTO_RSET', `5m') 35164562Sgshapiro_OPTION(Timeout.quit, `confTO_QUIT', `2m') 35264562Sgshapiro_OPTION(Timeout.misc, `confTO_MISC', `2m') 35364562Sgshapiro_OPTION(Timeout.command, `confTO_COMMAND', `1h') 35464562Sgshapiro_OPTION(Timeout.ident, `confTO_IDENT', `5s') 35564562Sgshapiro_OPTION(Timeout.fileopen, `confTO_FILEOPEN', `60s') 35664562Sgshapiro_OPTION(Timeout.control, `confTO_CONTROL', `2m') 35764562Sgshapiro_OPTION(Timeout.queuereturn, `confTO_QUEUERETURN', `5d') 35864562Sgshapiro_OPTION(Timeout.queuereturn.normal, `confTO_QUEUERETURN_NORMAL', `5d') 35964562Sgshapiro_OPTION(Timeout.queuereturn.urgent, `confTO_QUEUERETURN_URGENT', `2d') 36064562Sgshapiro_OPTION(Timeout.queuereturn.non-urgent, `confTO_QUEUERETURN_NONURGENT', `7d') 36164562Sgshapiro_OPTION(Timeout.queuewarn, `confTO_QUEUEWARN', `4h') 36264562Sgshapiro_OPTION(Timeout.queuewarn.normal, `confTO_QUEUEWARN_NORMAL', `4h') 36364562Sgshapiro_OPTION(Timeout.queuewarn.urgent, `confTO_QUEUEWARN_URGENT', `1h') 36464562Sgshapiro_OPTION(Timeout.queuewarn.non-urgent, `confTO_QUEUEWARN_NONURGENT', `12h') 36564562Sgshapiro_OPTION(Timeout.hoststatus, `confTO_HOSTSTATUS', `30m') 36664562Sgshapiro_OPTION(Timeout.resolver.retrans, `confTO_RESOLVER_RETRANS', `5s') 36764562Sgshapiro_OPTION(Timeout.resolver.retrans.first, `confTO_RESOLVER_RETRANS_FIRST', `5s') 36864562Sgshapiro_OPTION(Timeout.resolver.retrans.normal, `confTO_RESOLVER_RETRANS_NORMAL', `5s') 36964562Sgshapiro_OPTION(Timeout.resolver.retry, `confTO_RESOLVER_RETRY', `4') 37064562Sgshapiro_OPTION(Timeout.resolver.retry.first, `confTO_RESOLVER_RETRY_FIRST', `4') 37164562Sgshapiro_OPTION(Timeout.resolver.retry.normal, `confTO_RESOLVER_RETRY_NORMAL', `4') 37238032Speter 37338032Speter# should we not prune routes in route-addr syntax addresses? 37464562Sgshapiro_OPTION(DontPruneRoutes, `confDONT_PRUNE_ROUTES', `False') 37538032Speter 37638032Speter# queue up everything before forking? 37764562Sgshapiro_OPTION(SuperSafe, `confSAFE_QUEUE', `True') 37838032Speter 37938032Speter# status file 38064562SgshapiroO StatusFile=ifdef(`STATUS_FILE', `STATUS_FILE', `MAIL_SETTINGS_DIR`'statistics') 38138032Speter 38238032Speter# time zone handling: 38338032Speter# if undefined, use system default 38438032Speter# if defined but null, use TZ envariable passed in 38538032Speter# if defined and non-null, use that info 38638032Speterifelse(confTIME_ZONE, `USE_SYSTEM', `#O TimeZoneSpec=', 38738032Speter confTIME_ZONE, `USE_TZ', `O TimeZoneSpec=', 38838032Speter `O TimeZoneSpec=confTIME_ZONE') 38938032Speter 39038032Speter# default UID (can be username or userid:groupid) 39164562Sgshapiro_OPTION(DefaultUser, `confDEF_USER_ID', `mailnull') 39238032Speter 39338032Speter# list of locations of user database file (null means no lookup) 39464562Sgshapiro_OPTION(UserDatabaseSpec, `confUSERDB_SPEC', `MAIL_SETTINGS_DIR`'userdb') 39538032Speter 39638032Speter# fallback MX host 39764562Sgshapiro_OPTION(FallbackMXhost, `confFALLBACK_MX', `fall.back.host.net') 39838032Speter 39938032Speter# if we are the best MX host for a site, try it directly instead of config err 40064562Sgshapiro_OPTION(TryNullMXList, `confTRY_NULL_MX_LIST', `False') 40138032Speter 40238032Speter# load average at which we just queue messages 40364562Sgshapiro_OPTION(QueueLA, `confQUEUE_LA', `8') 40438032Speter 40538032Speter# load average at which we refuse connections 40664562Sgshapiro_OPTION(RefuseLA, `confREFUSE_LA', `12') 40738032Speter 40838032Speter# maximum number of children we allow at one time 40964562Sgshapiro_OPTION(MaxDaemonChildren, `confMAX_DAEMON_CHILDREN', `12') 41038032Speter 41138032Speter# maximum number of new connections per second 41264562Sgshapiro_OPTION(ConnectionRateThrottle, `confCONNECTION_RATE_THROTTLE', `3') 41338032Speter 41438032Speter# work recipient factor 41564562Sgshapiro_OPTION(RecipientFactor, `confWORK_RECIPIENT_FACTOR', `30000') 41638032Speter 41738032Speter# deliver each queued job in a separate process? 41864562Sgshapiro_OPTION(ForkEachJob, `confSEPARATE_PROC', `False') 41938032Speter 42038032Speter# work class factor 42164562Sgshapiro_OPTION(ClassFactor, `confWORK_CLASS_FACTOR', `1800') 42238032Speter 42338032Speter# work time factor 42464562Sgshapiro_OPTION(RetryFactor, `confWORK_TIME_FACTOR', `90000') 42538032Speter 42638032Speter# shall we sort the queue by hostname first? 42764562Sgshapiro_OPTION(QueueSortOrder, `confQUEUE_SORT_ORDER', `priority') 42838032Speter 42938032Speter# minimum time in queue before retry 43064562Sgshapiro_OPTION(MinQueueAge, `confMIN_QUEUE_AGE', `30m') 43138032Speter 43238032Speter# default character set 43364562Sgshapiro_OPTION(DefaultCharSet, `confDEF_CHAR_SET', `iso-8859-1') 43438032Speter 43538032Speter# service switch file (ignored on Solaris, Ultrix, OSF/1, others) 43664562Sgshapiro_OPTION(ServiceSwitchFile, `confSERVICE_SWITCH_FILE', `MAIL_SETTINGS_DIR`'service.switch') 43738032Speter 43838032Speter# hosts file (normally /etc/hosts) 43964562Sgshapiro_OPTION(HostsFile, `confHOSTS_FILE', `/etc/hosts') 44038032Speter 44138032Speter# dialup line delay on connection failure 44264562Sgshapiro_OPTION(DialDelay, `confDIAL_DELAY', `10s') 44338032Speter 44438032Speter# action to take if there are no recipients in the message 44564562Sgshapiro_OPTION(NoRecipientAction, `confNO_RCPT_ACTION', `add-to-undisclosed') 44638032Speter 44738032Speter# chrooted environment for writing to files 44864562Sgshapiro_OPTION(SafeFileEnvironment, `confSAFE_FILE_ENV', `/arch') 44938032Speter 45038032Speter# are colons OK in addresses? 45164562Sgshapiro_OPTION(ColonOkInAddr, `confCOLON_OK_IN_ADDR', `True') 45238032Speter 45338032Speter# how many jobs can you process in the queue? 45464562Sgshapiro_OPTION(MaxQueueRunSize, `confMAX_QUEUE_RUN_SIZE', `10000') 45538032Speter 45638032Speter# shall I avoid expanding CNAMEs (violates protocols)? 45764562Sgshapiro_OPTION(DontExpandCnames, `confDONT_EXPAND_CNAMES', `False') 45838032Speter 45938032Speter# SMTP initial login message (old $e macro) 46064562Sgshapiro_OPTION(SmtpGreetingMessage, `confSMTP_LOGIN_MSG', `$j Sendmail $v ready at $b') 46138032Speter 46238032Speter# UNIX initial From header format (old $l macro) 46364562Sgshapiro_OPTION(UnixFromLine, `confFROM_LINE', `From $g $d') 46438032Speter 46538032Speter# From: lines that have embedded newlines are unwrapped onto one line 46664562Sgshapiro_OPTION(SingleLineFromHeader, `confSINGLE_LINE_FROM_HEADER', `False') 46738032Speter 46838032Speter# Allow HELO SMTP command that does not `include' a host name 46964562Sgshapiro_OPTION(AllowBogusHELO, `confALLOW_BOGUS_HELO', `False') 47038032Speter 47138032Speter# Characters to be quoted in a full name phrase (@,;:\()[] are automatic) 47264562Sgshapiro_OPTION(MustQuoteChars, `confMUST_QUOTE_CHARS', `.') 47338032Speter 47438032Speter# delimiter (operator) characters (old $o macro) 47564562Sgshapiro_OPTION(OperatorChars, `confOPERATORS', `.:@[]') 47638032Speter 47738032Speter# shall I avoid calling initgroups(3) because of high NIS costs? 47864562Sgshapiro_OPTION(DontInitGroups, `confDONT_INIT_GROUPS', `False') 47938032Speter 48038032Speter# are group-writable `:include:' and .forward files (un)trustworthy? 48164562Sgshapiro_OPTION(UnsafeGroupWrites, `confUNSAFE_GROUP_WRITES', `True') 48238032Speter 48338032Speter# where do errors that occur when sending errors get sent? 48464562Sgshapiro_OPTION(DoubleBounceAddress, `confDOUBLE_BOUNCE_ADDRESS', `postmaster') 48538032Speter 48664562Sgshapiro# where to save bounces if all else fails 48764562Sgshapiro_OPTION(DeadLetterDrop, `confDEAD_LETTER_DROP', `/var/tmp/dead.letter') 48864562Sgshapiro 48938032Speter# what user id do we assume for the majority of the processing? 49064562Sgshapiro_OPTION(RunAsUser, `confRUN_AS_USER', `sendmail') 49138032Speter 49238032Speter# maximum number of recipients per SMTP envelope 49364562Sgshapiro_OPTION(MaxRecipientsPerMessage, `confMAX_RCPTS_PER_MESSAGE', `100') 49438032Speter 49538032Speter# shall we get local names from our installed interfaces? 49664562Sgshapiro_OPTION(DontProbeInterfaces, `confDONT_PROBE_INTERFACES', `False') 49738032Speter 49864562Sgshapiro# Return-Receipt-To: header implies DSN request 49964562Sgshapiro_OPTION(RrtImpliesDsn, `confRRT_IMPLIES_DSN', `False') 50064562Sgshapiro 50164562Sgshapiro# override connection address (for testing) 50264562Sgshapiro_OPTION(ConnectOnlyTo, `confCONNECT_ONLY_TO', `0.0.0.0') 50364562Sgshapiro 50464562Sgshapiro# Trusted user for file ownership and starting the daemon 50564562Sgshapiro_OPTION(TrustedUser, `confTRUSTED_USER', `root') 50664562Sgshapiro 50764562Sgshapiro# Control socket for daemon management 50864562Sgshapiro_OPTION(ControlSocketName, `confCONTROL_SOCKET_NAME', `/var/spool/mqueue/.control') 50964562Sgshapiro 51064562Sgshapiro# Maximum MIME header length to protect MUAs 51164562Sgshapiro_OPTION(MaxMimeHeaderLength, `confMAX_MIME_HEADER_LENGTH', `0/0') 51264562Sgshapiro 51364562Sgshapiro# Maximum length of the sum of all headers 51464562Sgshapiro_OPTION(MaxHeadersLength, `confMAX_HEADERS_LENGTH', `32768') 51564562Sgshapiro 51664562Sgshapiro# Maximum depth of alias recursion 51764562Sgshapiro_OPTION(MaxAliasRecursion, `confMAX_ALIAS_RECURSION', `10') 51864562Sgshapiro 51964562Sgshapiro# location of pid file 52064562Sgshapiro_OPTION(PidFile, `confPID_FILE', `/var/run/sendmail.pid') 52164562Sgshapiro 52264562Sgshapiro# Prefix string for the process title shown on 'ps' listings 52364562Sgshapiro_OPTION(ProcessTitlePrefix, `confPROCESS_TITLE_PREFIX', `prefix') 52464562Sgshapiro 52564562Sgshapiro# Data file (df) memory-buffer file maximum size 52664562Sgshapiro_OPTION(DataFileBufferSize, `confDF_BUFFER_SIZE', `4096') 52764562Sgshapiro 52864562Sgshapiro# Transcript file (xf) memory-buffer file maximum size 52964562Sgshapiro_OPTION(XscriptFileBufferSize, `confXF_BUFFER_SIZE', `4096') 53064562Sgshapiro 53164562Sgshapiro# list of authentication mechanisms 53264562Sgshapiro_OPTION(AuthMechanisms, `confAUTH_MECHANISMS', `GSSAPI KERBEROS_V4 DIGEST-MD5 CRAM-MD5') 53364562Sgshapiro 53464562Sgshapiro# default authentication information for outgoing connections 53564562Sgshapiro_OPTION(DefaultAuthInfo, `confDEF_AUTH_INFO', `MAIL_SETTINGS_DIR`'default-auth-info') 53664562Sgshapiro 53764562Sgshapiro# SMTP AUTH flags 53864562Sgshapiro_OPTION(AuthOptions, `confAUTH_OPTIONS', `') 53964562Sgshapiro 54064562Sgshapiroifdef(`_FFR_MILTER', ` 54164562Sgshapiro# Input mail filters 54264562Sgshapiro_OPTION(InputMailFilters, `confINPUT_MAIL_FILTERS', `') 54364562Sgshapiro 54464562Sgshapiro# Milter options 54564562Sgshapiro_OPTION(Milter.macros.connect, `confMILTER_MACROS_CONNECT', `') 54664562Sgshapiro_OPTION(Milter.macros.helo, `confMILTER_MACROS_HELO', `') 54764562Sgshapiro_OPTION(Milter.macros.envfrom, `confMILTER_MACROS_ENVFROM', `') 54864562Sgshapiro_OPTION(Milter.macros.envrcpt, `confMILTER_MACROS_ENVRCPT', `')') 54964562Sgshapiro 55064562Sgshapiro# CA directory 55164562Sgshapiro_OPTION(CACERTPath, `confCACERT_PATH', `') 55264562Sgshapiro# CA file 55364562Sgshapiro_OPTION(CACERTFile, `confCACERT', `') 55464562Sgshapiro# Server Cert 55564562Sgshapiro_OPTION(ServerCertFile, `confSERVER_CERT', `') 55664562Sgshapiro# Server private key 55764562Sgshapiro_OPTION(ServerKeyFile, `confSERVER_KEY', `') 55864562Sgshapiro# Client Cert 55964562Sgshapiro_OPTION(ClientCertFile, `confCLIENT_CERT', `') 56064562Sgshapiro# Client private key 56164562Sgshapiro_OPTION(ClientKeyFile, `confCLIENT_KEY', `') 56264562Sgshapiro# DHParameters (only required if DSA/DH is used) 56364562Sgshapiro_OPTION(DHParameters, `confDH_PARAMETERS', `') 56464562Sgshapiro# Random data source (required for systems without /dev/urandom under OpenSSL) 56564562Sgshapiro_OPTION(RandFile, `confRAND_FILE', `') 56664562Sgshapiro 56764562Sgshapiroifdef(`confQUEUE_FILE_MODE', 56864562Sgshapiro`# queue file mode (qf files) 56964562SgshapiroO QueueFileMode=confQUEUE_FILE_MODE 57042575Speter') 57142575Speter 57238032Speter########################### 57338032Speter# Message precedences # 57438032Speter########################### 57538032Speter 57638032SpeterPfirst-class=0 57738032SpeterPspecial-delivery=100 57838032SpeterPlist=-30 57938032SpeterPbulk=-60 58038032SpeterPjunk=-100 58138032Speter 58238032Speter##################### 58338032Speter# Trusted users # 58438032Speter##################### 58538032Speter 58638032Speter# this is equivalent to setting class "t" 58764562Sgshapiroifdef(`_USE_CT_FILE_', `', `#')Ft`'ifdef(`confCT_FILE', confCT_FILE, `MAIL_SETTINGS_DIR`'trusted-users') 58838032SpeterTroot 58938032SpeterTdaemon 59038032Speterifdef(`_NO_UUCP_', `dnl', `Tuucp') 59138032Speterifdef(`confTRUSTED_USERS', `T`'confTRUSTED_USERS', `dnl') 59238032Speter 59338032Speter######################### 59438032Speter# Format of headers # 59538032Speter######################### 59638032Speter 59738032Speterifdef(`confFROM_HEADER',, `define(`confFROM_HEADER', `$?x$x <$g>$|$g$.')')dnl 59838032SpeterH?P?Return-Path: <$g> 59938032SpeterHReceived: confRECEIVED_HEADER 60038032SpeterH?D?Resent-Date: $a 60138032SpeterH?D?Date: $a 60238032SpeterH?F?Resent-From: confFROM_HEADER 60338032SpeterH?F?From: confFROM_HEADER 60438032SpeterH?x?Full-Name: $x 60538032Speter# HPosted-Date: $a 60638032Speter# H?l?Received-Date: $b 60738032SpeterH?M?Resent-Message-Id: <$t.$i@$j> 60838032SpeterH?M?Message-Id: <$t.$i@$j> 60964562Sgshapiro 61038032Speter# 61138032Speter###################################################################### 61238032Speter###################################################################### 61338032Speter##### 61438032Speter##### REWRITING RULES 61538032Speter##### 61638032Speter###################################################################### 61738032Speter###################################################################### 61838032Speter 61938032Speter############################################ 62038032Speter### Ruleset 3 -- Name Canonicalization ### 62138032Speter############################################ 62264562SgshapiroScanonify=3 62338032Speter 62438032Speter# handle null input (translate to <@> special case) 62538032SpeterR$@ $@ <@> 62638032Speter 62738032Speter# strip group: syntax (not inside angle brackets!) and trailing semicolon 62838032SpeterR$* $: $1 <@> mark addresses 62938032SpeterR$* < $* > $* <@> $: $1 < $2 > $3 unmark <addr> 63038032SpeterR@ $* <@> $: @ $1 unmark @host:... 63138032SpeterR$* :: $* <@> $: $1 :: $2 unmark node::addr 63238032SpeterR:`include': $* <@> $: :`include': $1 unmark :`include':... 63364562SgshapiroR$* [ IPv6 $- ] <@> $: $1 [ IPv6 $2 ] unmark IPv6 addr 63438032SpeterR$* : $* [ $* ] $: $1 : $2 [ $3 ] <@> remark if leading colon 63538032SpeterR$* : $* <@> $: $2 strip colon if marked 63638032SpeterR$* <@> $: $1 unmark 63738032SpeterR$* ; $1 strip trailing semi 63838032SpeterR$* < $* ; > $1 < $2 > bogus bracketed semi 63938032Speter 64038032Speter# null input now results from list:; syntax 64138032SpeterR$@ $@ :; <@> 64238032Speter 64338032Speter# strip angle brackets -- note RFC733 heuristic to get innermost item 64438032SpeterR$* $: < $1 > housekeeping <> 64538032SpeterR$+ < $* > < $2 > strip excess on left 64638032SpeterR< $* > $+ < $1 > strip excess on right 64738032SpeterR<> $@ < @ > MAIL FROM:<> case 64838032SpeterR< $+ > $: $1 remove housekeeping <> 64938032Speter 65064562Sgshapiroifdef(`_USE_DEPRECATED_ROUTE_ADDR_',`dnl 65138032Speter# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later 65238032SpeterR@ $+ , $+ @ $1 : $2 change all "," to ":" 65338032Speter 65438032Speter# localize and dispose of route-based addresses 65564562SgshapiroR@ $+ : $+ $@ $>Canonify2 < @$1 > : $2 handle <route-addr> 65664562Sgshapirodnl',`dnl 65764562Sgshapiro# strip route address <@a,@b,@c:user@d> -> <user@d> 65864562SgshapiroR@ $+ , $+ $2 65964562SgshapiroR@ $+ : $+ $2 66064562Sgshapirodnl') 66138032Speter 66238032Speter# find focus for list syntax 66364562SgshapiroR $+ : $* ; @ $+ $@ $>Canonify2 $1 : $2 ; < @ $3 > list syntax 66438032SpeterR $+ : $* ; $@ $1 : $2; list syntax 66538032Speter 66638032Speter# find focus for @ syntax addresses 66738032SpeterR$+ @ $+ $: $1 < @ $2 > focus on domain 66838032SpeterR$+ < $+ @ $+ > $1 $2 < @ $3 > move gaze right 66964562SgshapiroR$+ < @ $+ > $@ $>Canonify2 $1 < @ $2 > already canonical 67038032Speter 67138032Speter# do some sanity checking 67238032SpeterR$* < @ $* : $* > $* $1 < @ $2 $3 > $4 nix colons in addrs 67338032Speter 67438032Speterifdef(`_NO_UUCP_', `dnl', 67538032Speter`# convert old-style addresses to a domain-based address 67664562SgshapiroR$- ! $+ $@ $>Canonify2 $2 < @ $1 .UUCP > resolve uucp names 67764562SgshapiroR$+ . $- ! $+ $@ $>Canonify2 $3 < @ $1 . $2 > domain uucps 67864562SgshapiroR$+ ! $+ $@ $>Canonify2 $2 < @ $1 .UUCP > uucp subdomains 67938032Speter') 68038032Speterifdef(`_USE_DECNET_SYNTAX_', 68138032Speter`# convert node::user addresses into a domain-based address 68264562SgshapiroR$- :: $+ $@ $>Canonify2 $2 < @ $1 .DECNET > resolve DECnet names 68364562SgshapiroR$- . $- :: $+ $@ $>Canonify2 $3 < @ $1.$2 .DECNET > numeric DECnet addr 68438032Speter', 68538032Speter `dnl') 68638032Speter# if we have % signs, take the rightmost one 68738032SpeterR$* % $* $1 @ $2 First make them all @s. 68838032SpeterR$* @ $* @ $* $1 % $2 @ $3 Undo all but the last. 68964562SgshapiroR$* @ $* $@ $>Canonify2 $1 < @ $2 > Insert < > and finish 69038032Speter 69138032Speter# else we must be a local name 69264562SgshapiroR$* $@ $>Canonify2 $1 69338032Speter 69438032Speter 69538032Speter################################################ 69638032Speter### Ruleset 96 -- bottom half of ruleset 3 ### 69738032Speter################################################ 69838032Speter 69964562SgshapiroSCanonify2=96 70038032Speter 70138032Speter# handle special cases for local names 70238032SpeterR$* < @ localhost > $* $: $1 < @ $j . > $2 no domain at all 70338032SpeterR$* < @ localhost . $m > $* $: $1 < @ $j . > $2 local domain 70438032Speterifdef(`_NO_UUCP_', `dnl', 70538032Speter`R$* < @ localhost . UUCP > $* $: $1 < @ $j . > $2 .UUCP domain') 70664562Sgshapiro 70764562Sgshapiro# check for IPv6 domain literal (save quoted form) 70864562SgshapiroR$* < @ [ IPv6 $- ] > $* $: $2 $| $1 < @@ [ $(dequote $2 $) ] > $3 mark IPv6 addr 70964562SgshapiroR$- $| $* < @@ $=w > $* $: $2 < @ $j . > $4 self-literal 71064562SgshapiroR$- $| $* < @@ [ $+ ] > $* $@ $2 < @ [ IPv6 $1 ] > $4 canon IP addr 71164562Sgshapiro 71264562Sgshapiro# check for IPv4 domain literal 71338032SpeterR$* < @ [ $+ ] > $* $: $1 < @@ [ $2 ] > $3 mark [a.b.c.d] 71438032SpeterR$* < @@ $=w > $* $: $1 < @ $j . > $3 self-literal 71538032SpeterR$* < @@ $+ > $* $@ $1 < @ $2 > $3 canon IP addr 71638032Speter 71764562Sgshapiroifdef(`_DOMAIN_TABLE_', `dnl 71838032Speter# look up domains in the domain table 71938032SpeterR$* < @ $+ > $* $: $1 < @ $(domaintable $2 $) > $3', `dnl') 72038032Speter 72164562Sgshapiroundivert(2)dnl LOCAL_RULE_3 72238032Speter 72364562Sgshapiroifdef(`_BITDOMAIN_TABLE_', `dnl 72438032Speter# handle BITNET mapping 72538032SpeterR$* < @ $+ .BITNET > $* $: $1 < @ $(bitdomain $2 $: $2.BITNET $) > $3', `dnl') 72638032Speter 72764562Sgshapiroifdef(`_UUDOMAIN_TABLE_', `dnl 72838032Speter# handle UUCP mapping 72938032SpeterR$* < @ $+ .UUCP > $* $: $1 < @ $(uudomain $2 $: $2.UUCP $) > $3', `dnl') 73038032Speter 73138032Speterifdef(`_NO_UUCP_', `dnl', 73238032Speter`ifdef(`UUCP_RELAY', 73338032Speter`# pass UUCP addresses straight through 73438032SpeterR$* < @ $+ . UUCP > $* $@ $1 < @ $2 . UUCP . > $3', 73538032Speter`# if really UUCP, handle it immediately 73638032Speterifdef(`_CLASS_U_', 73738032Speter`R$* < @ $=U . UUCP > $* $@ $1 < @ $2 . UUCP . > $3', `dnl') 73838032Speterifdef(`_CLASS_V_', 73938032Speter`R$* < @ $=V . UUCP > $* $@ $1 < @ $2 . UUCP . > $3', `dnl') 74038032Speterifdef(`_CLASS_W_', 74138032Speter`R$* < @ $=W . UUCP > $* $@ $1 < @ $2 . UUCP . > $3', `dnl') 74238032Speterifdef(`_CLASS_X_', 74338032Speter`R$* < @ $=X . UUCP > $* $@ $1 < @ $2 . UUCP . > $3', `dnl') 74438032Speterifdef(`_CLASS_Y_', 74538032Speter`R$* < @ $=Y . UUCP > $* $@ $1 < @ $2 . UUCP . > $3', `dnl') 74638032Speter 74738032Speterifdef(`_NO_CANONIFY_', `dnl', `dnl 74838032Speter# try UUCP traffic as a local address 74938032SpeterR$* < @ $+ . UUCP > $* $: $1 < @ $[ $2 $] . UUCP . > $3 75038032SpeterR$* < @ $+ . . UUCP . > $* $@ $1 < @ $2 . > $3') 75138032Speter')') 75264562Sgshapiro# hostnames ending in class P are always canonical 75364562SgshapiroR$* < @ $* $=P > $* $: $1 < @ $2 $3 . > $4 75464562Sgshapirodnl apply the next rule only for hostnames not in class P 75564562Sgshapirodnl this even works for phrases in class P since . is in class P 75664562Sgshapirodnl which daemon flags are set? 75764562SgshapiroR$* < @ $* $~P > $* $: $&{daemon_flags} $| $1 < @ $2 $3 > $4 75864562Sgshapirodnl the other rules in this section only apply if the hostname 75964562Sgshapirodnl does not end in class P hence no further checks are done here 76064562Sgshapirodnl if this ever changes make sure the lookups are "protected" again! 76164562Sgshapiroifdef(`_NO_CANONIFY_', `dnl 76264562Sgshapirodnl do not canonify unless: 76364562Sgshapirodnl domain ends in class {Canonify} (this does not work if the intersection 76464562Sgshapirodnl with class P is non-empty) 76564562Sgshapirodnl or {daemon_flags} has c set 76664562Sgshapiro# pass to name server to make hostname canonical if in class {Canonify} 76764562SgshapiroR$* $| $* < @ $* $={Canonify} > $* $: $2 < @ $[ $3 $4 $] > $5 76864562Sgshapiro# pass to name server to make hostname canonical if requested 76964562SgshapiroR$* c $* $| $* < @ $* > $* $: $3 < @ $[ $4 $] > $5 77064562Sgshapirodnl trailing dot? -> do not apply _CANONIFY_HOSTS_ 77164562SgshapiroR$* $| $* < @ $+ . > $* $: $2 < @ $3 . > $4 77264562Sgshapiro# add a trailing dot to qualified hostnames so other rules will work 77364562SgshapiroR$* $| $* < @ $+.$+ > $* $: $2 < @ $3.$4 . > $5 77464562Sgshapiroifdef(`_CANONIFY_HOSTS_', `dnl 77564562Sgshapirodnl this should only apply to unqualified hostnames 77664562Sgshapirodnl but if a valid character inside an unqualified hostname is an OperatorChar 77764562Sgshapirodnl then $- does not work. 77864562Sgshapiro# lookup unqualified hostnames 77964562SgshapiroR$* $| $* < @ $* > $* $: $2 < @ $[ $3 $] > $4', `dnl')', `dnl 78064562Sgshapirodnl _NO_CANONIFY_ is not set: canonify unless: 78164562Sgshapirodnl {daemon_flags} contains CC (do not canonify) 78264562SgshapiroR$* CC $* $| $* $: $3 78338032Speter# pass to name server to make hostname canonical 78464562SgshapiroR$* $| $* < @ $* > $* $: $2 < @ $[ $3 $] > $4') 78564562Sgshapirodnl remove {daemon_flags} for other cases 78664562SgshapiroR$* $| $* $: $2 78738032Speter 78838032Speter# local host aliases and pseudo-domains are always canonical 78938032SpeterR$* < @ $=w > $* $: $1 < @ $2 . > $3 79038032Speterifdef(`_MASQUERADE_ENTIRE_DOMAIN_', 79138032Speter`R$* < @ $* $=M > $* $: $1 < @ $2 $3 . > $4', 79238032Speter`R$* < @ $=M > $* $: $1 < @ $2 . > $3') 79364562Sgshapiroifdef(`_VIRTUSER_TABLE_', `dnl 79464562Sgshapirodnl virtual hosts are also canonical 79564562Sgshapiroifdef(`_VIRTUSER_ENTIRE_DOMAIN_', 79664562Sgshapiro`R$* < @ $* $={VirtHost} > $* $: $1 < @ $2 $3 . > $4', 79764562Sgshapiro`R$* < @ $={VirtHost} > $* $: $1 < @ $2 . > $3')', 79864562Sgshapiro`dnl') 79964562Sgshapirodnl remove superfluous dots (maybe repeatedly) which may have been added 80064562Sgshapirodnl by one of the rules before 80138032SpeterR$* < @ $* . . > $* $1 < @ $2 . > $3 80238032Speter 80338032Speter 80438032Speter################################################## 80538032Speter### Ruleset 4 -- Final Output Post-rewriting ### 80638032Speter################################################## 80764562SgshapiroSfinal=4 80838032Speter 80938032SpeterR$* <@> $@ handle <> and list:; 81038032Speter 81138032Speter# strip trailing dot off possibly canonical name 81238032SpeterR$* < @ $+ . > $* $1 < @ $2 > $3 81338032Speter 81464562Sgshapiro# eliminate internal code 81538032SpeterR$* < @ *LOCAL* > $* $1 < @ $j > $2 81638032Speter 81738032Speter# externalize local domain info 81838032SpeterR$* < $+ > $* $1 $2 $3 defocus 81938032SpeterR@ $+ : @ $+ : $+ @ $1 , @ $2 : $3 <route-addr> canonical 82038032SpeterR@ $* $@ @ $1 ... and exit 82138032Speter 82238032Speterifdef(`_NO_UUCP_', `dnl', 82338032Speter`# UUCP must always be presented in old form 82438032SpeterR$+ @ $- . UUCP $2!$1 u@h.UUCP => h!u') 82538032Speter 82638032Speterifdef(`_USE_DECNET_SYNTAX_', 82738032Speter`# put DECnet back in :: form 82838032SpeterR$+ @ $+ . DECNET $2 :: $1 u@h.DECNET => h::u', 82938032Speter `dnl') 83038032Speter# delete duplicate local names 83138032SpeterR$+ % $=w @ $=w $1 @ $2 u%host@host => u@host 83238032Speter 83338032Speter 83438032Speter 83538032Speter############################################################## 83638032Speter### Ruleset 97 -- recanonicalize and call ruleset zero ### 83738032Speter### (used for recursive calls) ### 83838032Speter############################################################## 83938032Speter 84064562SgshapiroSRecurse=97 84164562SgshapiroR$* $: $>canonify $1 84264562SgshapiroR$* $@ $>parse $1 84338032Speter 84438032Speter 84538032Speter###################################### 84638032Speter### Ruleset 0 -- Parse Address ### 84738032Speter###################################### 84838032Speter 84964562SgshapiroSparse=0 85038032Speter 85138032SpeterR$* $: $>Parse0 $1 initial parsing 85238032SpeterR<@> $#_LOCAL_ $: <@> special case error msgs 85364562SgshapiroR$* $: $>ParseLocal $1 handle local hacks 85438032SpeterR$* $: $>Parse1 $1 final parsing 85538032Speter 85638032Speter# 85738032Speter# Parse0 -- do initial syntax checking and eliminate local addresses. 85838032Speter# This should either return with the (possibly modified) input 85938032Speter# or return with a #error mailer. It should not return with a 86038032Speter# #mailer other than the #error mailer. 86138032Speter# 86238032Speter 86338032SpeterSParse0 86438032SpeterR<@> $@ <@> special case error msgs 86566494SgshapiroR$* : $* ; <@> $#error $@ 5.1.3 $: "501 List:; syntax illegal for recipient addresses" 86664562SgshapiroR@ <@ $* > < @ $1 > catch "@@host" bogosity 86766494SgshapiroR<@ $+> $#error $@ 5.1.3 $: "501 User address required" 86838032SpeterR$* $: <> $1 86938032SpeterR<> $* < @ [ $+ ] > $* $1 < @ [ $2 ] > $3 87066494SgshapiroR<> $* <$* : $* > $* $#error $@ 5.1.3 $: "501 Colon illegal in host name part" 87138032SpeterR<> $* $1 87266494SgshapiroR$* < @ . $* > $* $#error $@ 5.1.2 $: "501 Invalid host name" 87366494SgshapiroR$* < @ $* .. $* > $* $#error $@ 5.1.2 $: "501 Invalid host name" 87464562Sgshapirodnl comma only allowed before @; this check is not complete 87566494SgshapiroR$* , $~O $* $#error $@ 5.1.2 $: "501 Invalid route address" 87638032Speter 87738032Speter# now delete the local info -- note $=O to find characters that cause forwarding 87864562SgshapiroR$* < @ > $* $@ $>Parse0 $>canonify $1 user@ => user 87964562SgshapiroR< @ $=w . > : $* $@ $>Parse0 $>canonify $2 @here:... -> ... 88038032SpeterR$- < @ $=w . > $: $(dequote $1 $) < @ $2 . > dequote "foo"@here 88166494SgshapiroR< @ $+ > $#error $@ 5.1.3 $: "501 User address required" 88264562SgshapiroR$* $=O $* < @ $=w . > $@ $>Parse0 $>canonify $1 $2 $3 ...@here -> ... 88338032SpeterR$- $: $(dequote $1 $) < @ *LOCAL* > dequote "foo" 88466494SgshapiroR< @ *LOCAL* > $#error $@ 5.1.3 $: "501 User address required" 88538032SpeterR$* $=O $* < @ *LOCAL* > 88664562Sgshapiro $@ $>Parse0 $>canonify $1 $2 $3 ...@*LOCAL* -> ... 88738032SpeterR$* < @ *LOCAL* > $: $1 88838032Speter 88938032Speter# 89038032Speter# Parse1 -- the bottom half of ruleset 0. 89138032Speter# 89238032Speter 89338032SpeterSParse1 89464562Sgshapiroifdef(`_LDAP_ROUTING_', `dnl 89564562Sgshapiro# handle LDAP routing for hosts in $={LDAPRoute} 89664562SgshapiroR$+ < @ $={LDAPRoute} . > $: $>LDAPExpand <$1 < @ $2 . >> <$1 @ $2>', 89764562Sgshapiro`dnl') 89864562Sgshapiro 89938032Speterifdef(`_MAILER_smtp_', 90038032Speter`# handle numeric address spec 90164562Sgshapirodnl there is no check whether this is really an IP number 90264562SgshapiroR$* < @ [ $+ ] > $* $: $>ParseLocal $1 < @ [ $2 ] > $3 numeric internet spec 90364562SgshapiroR$* < @ [ $+ ] > $* $1 < @ [ $2 ] : $S > $3 Add smart host to path 90464562SgshapiroR$* < @ [ IPv6 $- ] : > $* 90564562Sgshapiro $#_SMTP_ $@ [ $(dequote $2 $) ] $: $1 < @ [IPv6 $2 ] > $3 no smarthost: send 90664562SgshapiroR$* < @ [ $+ ] : > $* $#_SMTP_ $@ [$2] $: $1 < @ [$2] > $3 no smarthost: send 90764562SgshapiroR$* < @ [ $+ ] : $- : $*> $* $#$3 $@ $4 $: $1 < @ [$2] > $5 smarthost with mailer 90864562SgshapiroR$* < @ [ $+ ] : $+ > $* $#_SMTP_ $@ $3 $: $1 < @ [$2] > $4 smarthost without mailer', 90938032Speter `dnl') 91038032Speter 91164562Sgshapiroifdef(`_VIRTUSER_TABLE_', `dnl 91238032Speter# handle virtual users 91364562SgshapiroR$+ $: <!> $1 Mark for lookup 91464562Sgshapiroifdef(`_VIRTUSER_ENTIRE_DOMAIN_', 91564562Sgshapiro`R<!> $+ < @ $* $={VirtHost} . > $: < $(virtuser $1 @ $2 $3 $@ $1 $: @ $) > $1 < @ $2 $3 . >', 91664562Sgshapiro`R<!> $+ < @ $={VirtHost} . > $: < $(virtuser $1 @ $2 $@ $1 $: @ $) > $1 < @ $2 . >') 91764562SgshapiroR<!> $+ < @ $=w . > $: < $(virtuser $1 @ $2 $@ $1 $: @ $) > $1 < @ $2 . > 91838032SpeterR<@> $+ + $* < @ $* . > 91964562Sgshapiro $: < $(virtuser $1 + * @ $3 $@ $1 $@ $2 $: @ $) > $1 + $2 < @ $3 . > 92038032SpeterR<@> $+ + $* < @ $* . > 92138032Speter $: < $(virtuser $1 @ $3 $@ $1 $: @ $) > $1 + $2 < @ $3 . > 92264562Sgshapirodnl try default entry: @domain 92364562Sgshapirodnl +*@domain 92464562SgshapiroR<@> $+ + $+ < @ $+ . > $: < $(virtuser + * @ $3 $@ $1 $@ $2 $: @ $) > $1 + $2 < @ $3 . > 92564562Sgshapirodnl @domain if +detail exists 92664562SgshapiroR<@> $+ + $* < @ $+ . > $: < $(virtuser @ $3 $@ $1 $@ $2 $: @ $) > $1 + $2 < @ $3 . > 92764562Sgshapirodnl without +detail (or no match) 92838032SpeterR<@> $+ < @ $+ . > $: < $(virtuser @ $2 $@ $1 $: @ $) > $1 < @ $2 . > 92938032SpeterR<@> $+ $: $1 93064562SgshapiroR<!> $+ $: $1 93164562SgshapiroR< error : $-.$-.$- : $+ > $* $#error $@ $1.$2.$3 $: $4 93238032SpeterR< error : $- $+ > $* $#error $@ $(dequote $1 $) $: $2 93364562SgshapiroR< $+ > $+ < @ $+ > $: $>Recurse $1', 93438032Speter`dnl') 93538032Speter 93638032Speter# short circuit local delivery so forwarded email works 93738032Speterifdef(`_MAILER_usenet_', `dnl 93864562SgshapiroR$+ . USENET < @ $=w . > $#usenet $@ usenet $: $1 handle usenet specially', `dnl') 93966494Sgshapiro 94066494Sgshapiro 94138032Speterifdef(`_STICKY_LOCAL_DOMAIN_', 94238032Speter`R$+ < @ $=w . > $: < $H > $1 < @ $2 . > first try hub 94364562SgshapiroR< $+ > $+ < $+ > $>MailerToTriple < $1 > $2 < $3 > yep .... 94464562Sgshapirodnl $H empty (but @$=w.) 94538032SpeterR< > $+ + $* < $+ > $#_LOCAL_ $: $1 + $2 plussed name? 94638032SpeterR< > $+ < $+ > $#_LOCAL_ $: @ $1 nope, local address', 94764562Sgshapiro`R$=L < @ $=w . > $#_LOCAL_ $: @ $1 special local names 94838032SpeterR$+ < @ $=w . > $#_LOCAL_ $: $1 regular local name') 94938032Speter 95064562Sgshapiroifdef(`_MAILER_TABLE_', `dnl 95138032Speter# not local -- try mailer table lookup 95238032SpeterR$* <@ $+ > $* $: < $2 > $1 < @ $2 > $3 extract host name 95338032SpeterR< $+ . > $* $: < $1 > $2 strip trailing dot 95438032SpeterR< $+ > $* $: < $(mailertable $1 $) > $2 lookup 95564562Sgshapirodnl it is $~[ instead of $- to avoid matches on IPv6 addresses 95664562SgshapiroR< $~[ : $* > $* $>MailerToTriple < $1 : $2 > $3 check -- resolved? 95764562SgshapiroR< $+ > $* $: $>Mailertable <$1> $2 try domain', 95838032Speter`dnl') 95964562Sgshapiroundivert(4)dnl UUCP rules from `MAILER(uucp)' 96038032Speter 96138032Speterifdef(`_NO_UUCP_', `dnl', 96238032Speter`# resolve remotely connected UUCP links (if any) 96338032Speterifdef(`_CLASS_V_', 96464562Sgshapiro`R$* < @ $=V . UUCP . > $* $: $>MailerToTriple < $V > $1 <@$2.UUCP.> $3', 96538032Speter `dnl') 96638032Speterifdef(`_CLASS_W_', 96764562Sgshapiro`R$* < @ $=W . UUCP . > $* $: $>MailerToTriple < $W > $1 <@$2.UUCP.> $3', 96838032Speter `dnl') 96938032Speterifdef(`_CLASS_X_', 97064562Sgshapiro`R$* < @ $=X . UUCP . > $* $: $>MailerToTriple < $X > $1 <@$2.UUCP.> $3', 97138032Speter `dnl')') 97238032Speter 97338032Speter# resolve fake top level domains by forwarding to other hosts 97438032Speterifdef(`BITNET_RELAY', 97564562Sgshapiro`R$*<@$+.BITNET.>$* $: $>MailerToTriple < $B > $1 <@$2.BITNET.> $3 user@host.BITNET', 97638032Speter `dnl') 97738032Speterifdef(`DECNET_RELAY', 97864562Sgshapiro`R$*<@$+.DECNET.>$* $: $>MailerToTriple < $C > $1 <@$2.DECNET.> $3 user@host.DECNET', 97938032Speter `dnl') 98038032Speterifdef(`_MAILER_pop_', 98138032Speter`R$+ < @ POP. > $#pop $: $1 user@POP', 98238032Speter `dnl') 98338032Speterifdef(`_MAILER_fax_', 98438032Speter`R$+ < @ $+ .FAX. > $#fax $@ $2 $: $1 user@host.FAX', 98538032Speter`ifdef(`FAX_RELAY', 98664562Sgshapiro`R$*<@$+.FAX.>$* $: $>MailerToTriple < $F > $1 <@$2.FAX.> $3 user@host.FAX', 98738032Speter `dnl')') 98838032Speter 98938032Speterifdef(`UUCP_RELAY', 99038032Speter`# forward non-local UUCP traffic to our UUCP relay 99164562SgshapiroR$*<@$*.UUCP.>$* $: $>MailerToTriple < $Y > $1 <@$2.UUCP.> $3 uucp mail', 99238032Speter`ifdef(`_MAILER_uucp_', 99338032Speter`# forward other UUCP traffic straight to UUCP 99438032SpeterR$* < @ $+ .UUCP. > $* $#_UUCP_ $@ $2 $: $1 < @ $2 .UUCP. > $3 user@host.UUCP', 99538032Speter `dnl')') 99638032Speterifdef(`_MAILER_usenet_', ` 99738032Speter# addresses sent to net.group.USENET will get forwarded to a newsgroup 99864562SgshapiroR$+ . USENET $#usenet $@ usenet $: $1', 99938032Speter `dnl') 100038032Speter 100138032Speterifdef(`_LOCAL_RULES_', 100238032Speter`# figure out what should stay in our local mail system 100338032Speterundivert(1)', `dnl') 100438032Speter 100538032Speter# pass names that still have a host to a smarthost (if defined) 100664562SgshapiroR$* < @ $* > $* $: $>MailerToTriple < $S > $1 < @ $2 > $3 glue on smarthost name 100738032Speter 100838032Speter# deal with other remote names 100938032Speterifdef(`_MAILER_smtp_', 101064562Sgshapiro`R$* < @$* > $* $#_SMTP_ $@ $2 $: $1 < @ $2 > $3 user@host.domain', 101166494Sgshapiro`R$* < @$* > $* $#error $@ 5.1.2 $: "501 Unrecognized host name " $2') 101238032Speter 101338032Speter# handle locally delivered names 101464562SgshapiroR$=L $#_LOCAL_ $: @ $1 special local names 101538032SpeterR$+ $#_LOCAL_ $: $1 regular local names 101638032Speter 101738032Speter########################################################################### 101838032Speter### Ruleset 5 -- special rewriting after aliases have been expanded ### 101938032Speter########################################################################### 102038032Speter 102164562SgshapiroSLocal_localaddr 102264562SgshapiroSlocaladdr=5 102364562SgshapiroR$+ $: $1 $| $>"Local_localaddr" $1 102464562SgshapiroR$+ $| $#$* $#$2 102564562SgshapiroR$+ $| $* $: $1 102638032Speter 102766494Sgshapiroifdef(`_FFR_5_', ` 102866494Sgshapiro# Preserve host in a macro 102966494SgshapiroR$+ $: $(macro {LocalAddrHost} $) $1 103066494SgshapiroR$+ @ $+ $: $(macro {LocalAddrHost} $@ @ $2 $) $1') 103166494Sgshapiro 103266494Sgshapiroifdef(`_PRESERVE_LOCAL_PLUS_DETAIL_', `', ` 103338032Speter# deal with plussed users so aliases work nicely 103466494SgshapiroR$+ + * $#_LOCAL_ $@ $&h $: $1`'ifdef(`_FFR_5_', ` $&{LocalAddrHost}') 103566494SgshapiroR$+ + $* $#_LOCAL_ $@ + $2 $: $1 + *`'ifdef(`_FFR_5_', ` $&{LocalAddrHost}') 103666494Sgshapiro') 103738032Speter# prepend an empty "forward host" on the front 103838032SpeterR$+ $: <> $1 103938032Speter 104038032Speterifdef(`LUSER_RELAY', `dnl 104138032Speter# send unrecognized local users to a relay host 104266494Sgshapiroifdef(`_PRESERVE_LOCAL_PLUS_DETAIL_', ` 104366494SgshapiroR< > $+ + $* $: < ? $L > <+ $2> $(user $1 $) look up user+ 104466494SgshapiroR< > $+ $: < ? $L > < > $(user $1 $) look up user 104566494SgshapiroR< ? $* > < $* > $+ <> $: < > $3 $2 found; strip $L 104666494SgshapiroR< ? $* > < $* > $+ $: < $1 > $3 $2 not found', ` 104764562SgshapiroR< > $+ $: < $L > $(user $1 $) look up user 104866494SgshapiroR< $* > $+ <> $: < > $2 found; strip $L')', 104938032Speter`dnl') 105038032Speter 105138032Speter# see if we have a relay or a hub 105238032SpeterR< > $+ $: < $H > $1 try hub 105338032SpeterR< > $+ $: < $R > $1 try relay 105466494Sgshapiroifdef(`_PRESERVE_LOCAL_PLUS_DETAIL_', ` 105566494SgshapiroR< > $+ $@ $1', ` 105664562SgshapiroR< > $+ $: < > < $1 <> $&h > nope, restore +detail 105764562SgshapiroR< > < $+ <> + $* > $: < > < $1 + $2 > check whether +detail 105864562SgshapiroR< > < $+ <> $* > $: < > < $1 > else discard 105938032SpeterR< > < $+ + $* > $* < > < $1 > + $2 $3 find the user part 106066494SgshapiroR< > < $+ > + $* $#_LOCAL_ $@ $2 $: @ $1`'ifdef(`_FFR_5_', ` $&{LocalAddrHost}') strip the extra + 106138032SpeterR< > < $+ > $@ $1 no +detail 106243730SpeterR$+ $: $1 <> $&h add +detail back in 106343730SpeterR$+ <> + $* $: $1 + $2 check whether +detail 106466494SgshapiroR$+ <> $* $: $1 else discard') 106564562SgshapiroR< local : $* > $* $: $>MailerToTriple < local : $1 > $2 no host extension 106664562SgshapiroR< error : $* > $* $: $>MailerToTriple < error : $1 > $2 no host extension 106764562SgshapiroR< $- : $+ > $+ $: $>MailerToTriple < $1 : $2 > $3 < @ $2 > 106864562SgshapiroR< $+ > $+ $@ $>MailerToTriple < $1 > $2 < @ $1 > 106938032Speter 107064562Sgshapiroifdef(`_MAILER_TABLE_', `dnl 107138032Speter################################################################### 107238032Speter### Ruleset 90 -- try domain part of mailertable entry ### 107364562Sgshapirodnl input: LeftPartOfDomain <RightPartOfDomain> FullAddress 107438032Speter################################################################### 107538032Speter 107664562SgshapiroSMailertable=90 107764562Sgshapirodnl shift and check 107864562Sgshapirodnl %2 is not documented in cf/README 107938032SpeterR$* <$- . $+ > $* $: $1$2 < $(mailertable .$3 $@ $1$2 $@ $2 $) > $4 108064562Sgshapirodnl it is $~[ instead of $- to avoid matches on IPv6 addresses 108164562SgshapiroR$* <$~[ : $* > $* $>MailerToTriple < $2 : $3 > $4 check -- resolved? 108264562SgshapiroR$* < . $+ > $* $@ $>Mailertable $1 . <$2> $3 no -- strip & try again 108364562Sgshapirodnl is $2 always empty? 108438032SpeterR$* < $* > $* $: < $(mailertable . $@ $1$2 $) > $3 try "." 108564562SgshapiroR< $~[ : $* > $* $>MailerToTriple < $1 : $2 > $3 "." found? 108664562Sgshapirodnl return full address 108738032SpeterR< $* > $* $@ $2 no mailertable match', 108838032Speter`dnl') 108938032Speter 109038032Speter################################################################### 109138032Speter### Ruleset 95 -- canonify mailer:[user@]host syntax to triple ### 109264562Sgshapirodnl input: in general: <[mailer:]host> lp<@domain>rest 109364562Sgshapirodnl <> address -> address 109464562Sgshapirodnl <error:d.s.n:text> -> error 109564562Sgshapirodnl <error:text> -> error 109664562Sgshapirodnl <mailer:user@host> lp<@domain>rest -> mailer host user 109764562Sgshapirodnl <mailer:host> address -> mailer host address 109864562Sgshapirodnl <localdomain> address -> address 109964562Sgshapirodnl <[IPv6 number]> address -> relay number address 110064562Sgshapirodnl <host> address -> relay host address 110138032Speter################################################################### 110238032Speter 110364562SgshapiroSMailerToTriple=95 110438032SpeterR< > $* $@ $1 strip off null relay 110564562SgshapiroR< error : $-.$-.$- : $+ > $* $#error $@ $1.$2.$3 $: $4 110638032SpeterR< error : $- $+ > $* $#error $@ $(dequote $1 $) $: $2 110738032SpeterR< local : $* > $* $>CanonLocal < $1 > $2 110838032SpeterR< $- : $+ @ $+ > $*<$*>$* $# $1 $@ $3 $: $2<@$3> use literal user 110938032SpeterR< $- : $+ > $* $# $1 $@ $2 $: $3 try qualified mailer 111038032SpeterR< $=w > $* $@ $2 delete local host 111164562SgshapiroR< [ IPv6 $+ ] > $* $#_RELAY_ $@ $(dequote $1 $) $: $2 use unqualified mailer 111238032SpeterR< $+ > $* $#_RELAY_ $@ $1 $: $2 use unqualified mailer 111338032Speter 111438032Speter################################################################### 111538032Speter### Ruleset CanonLocal -- canonify local: syntax ### 111664562Sgshapirodnl input: <user> address 111764562Sgshapirodnl <x> <@host> : rest -> Recurse rest 111864562Sgshapirodnl <x> p1 $=O p2 <@host> -> Recurse p1 $=O p2 111964562Sgshapirodnl <> user <@host> rest -> local user@host user 112064562Sgshapirodnl <> user -> local user user 112164562Sgshapirodnl <user@host> lp <@domain> rest -> <user> lp <@host> [cont] 112264562Sgshapirodnl <user> lp <@host> rest -> local lp@host user 112364562Sgshapirodnl <user> lp -> local lp user 112438032Speter################################################################### 112538032Speter 112638032SpeterSCanonLocal 112743730Speter# strip local host from routed addresses 112864562SgshapiroR< $* > < @ $+ > : $+ $@ $>Recurse $3 112964562SgshapiroR< $* > $+ $=O $+ < @ $+ > $@ $>Recurse $2 $3 $4 113043730Speter 113138032Speter# strip trailing dot from any host name that may appear 113238032SpeterR< $* > $* < @ $* . > $: < $1 > $2 < @ $3 > 113338032Speter 113438032Speter# handle local: syntax -- use old user, either with or without host 113538032SpeterR< > $* < @ $* > $* $#_LOCAL_ $@ $1@$2 $: $1 113638032SpeterR< > $+ $#_LOCAL_ $@ $1 $: $1 113738032Speter 113838032Speter# handle local:user@host syntax -- ignore host part 113938032SpeterR< $+ @ $+ > $* < @ $* > $: < $1 > $3 < @ $4 > 114038032Speter 114138032Speter# handle local:user syntax 114238032SpeterR< $+ > $* <@ $* > $* $#_LOCAL_ $@ $2@$3 $: $1 114338032SpeterR< $+ > $* $#_LOCAL_ $@ $2 $: $1 114438032Speter 114538032Speter################################################################### 114638032Speter### Ruleset 93 -- convert header names to masqueraded form ### 114738032Speter################################################################### 114838032Speter 114964562SgshapiroSMasqHdr=93 115038032Speter 115164562Sgshapiroifdef(`_GENERICS_TABLE_', `dnl 115238032Speter# handle generics database 115338032Speterifdef(`_GENERICS_ENTIRE_DOMAIN_', 115464562Sgshapirodnl if generics should be applied add a @ as mark 115538032Speter`R$+ < @ $* $=G . > $: < $1@$2$3 > $1 < @ $2$3 . > @ mark', 115638032Speter`R$+ < @ $=G . > $: < $1@$2 > $1 < @ $2 . > @ mark') 115738032SpeterR$+ < @ *LOCAL* > $: < $1@$j > $1 < @ *LOCAL* > @ mark 115864562Sgshapirodnl workspace: either user<@domain> or <user@domain> user <@domain> @ 115964562Sgshapirodnl ignore the first case for now 116064562Sgshapirodnl if it has the mark lookup full address 116164562SgshapiroR< $+ > $+ < $* > @ $: < $(generics $1 $: @ $1 $) > $2 < $3 > 116264562Sgshapirodnl workspace: ... or <match|@user@domain> user <@domain> 116364562Sgshapirodnl no match, try user+detail@domain 116464562SgshapiroR<@$+ + $* @ $+> $+ < @ $+ > 116564562Sgshapiro $: < $(generics $1+*@$3 $@ $2 $:@$1 + $2@$3 $) > $4 < @ $5 > 116664562SgshapiroR<@$+ + $* @ $+> $+ < @ $+ > 116764562Sgshapiro $: < $(generics $1@$3 $: $) > $4 < @ $5 > 116864562Sgshapirodnl no match, remove mark 116964562SgshapiroR<@$+ > $+ < @ $+ > $: < > $2 < @ $3 > 117064562Sgshapirodnl no match, try @domain for exceptions 117164562SgshapiroR< > $+ < @ $+ . > $: < $(generics @$2 $@ $1 $: $) > $1 < @ $2 . > 117264562Sgshapirodnl workspace: ... or <match> user <@domain> 117364562Sgshapirodnl no match, try local part 117438032SpeterR< > $+ < @ $+ > $: < $(generics $1 $: $) > $1 < @ $2 > 117564562SgshapiroR< > $+ + $* < @ $+ > $: < $(generics $1+* $@ $2 $: $) > $1 + $2 < @ $3 > 117664562SgshapiroR< > $+ + $* < @ $+ > $: < $(generics $1 $: $) > $1 + $2 < @ $3 > 117764562SgshapiroR< $* @ $* > $* < $* > $@ $>canonify $1 @ $2 found qualified 117864562SgshapiroR< $+ > $* < $* > $: $>canonify $1 @ *LOCAL* found unqualified 117938032SpeterR< > $* $: $1 not found', 118038032Speter`dnl') 118138032Speter 118264562Sgshapiro# do not masquerade anything in class N 118364562SgshapiroR$* < @ $* $=N . > $@ $1 < @ $2 $3 . > 118464562Sgshapiro 118538032Speter# special case the users that should be exposed 118638032SpeterR$=E < @ *LOCAL* > $@ $1 < @ $j . > leave exposed 118738032Speterifdef(`_MASQUERADE_ENTIRE_DOMAIN_', 118838032Speter`R$=E < @ $* $=M . > $@ $1 < @ $2 $3 . >', 118938032Speter`R$=E < @ $=M . > $@ $1 < @ $2 . >') 119038032Speterifdef(`_LIMITED_MASQUERADE_', `dnl', 119138032Speter`R$=E < @ $=w . > $@ $1 < @ $2 . >') 119238032Speter 119338032Speter# handle domain-specific masquerading 119438032Speterifdef(`_MASQUERADE_ENTIRE_DOMAIN_', 119538032Speter`R$* < @ $* $=M . > $* $: $1 < @ $2 $3 . @ $M > $4 convert masqueraded doms', 119638032Speter`R$* < @ $=M . > $* $: $1 < @ $2 . @ $M > $3 convert masqueraded doms') 119738032Speterifdef(`_LIMITED_MASQUERADE_', `dnl', 119838032Speter`R$* < @ $=w . > $* $: $1 < @ $2 . @ $M > $3') 119938032SpeterR$* < @ *LOCAL* > $* $: $1 < @ $j . @ $M > $2 120038032SpeterR$* < @ $+ @ > $* $: $1 < @ $2 > $3 $M is null 120138032SpeterR$* < @ $+ @ $+ > $* $: $1 < @ $3 . > $4 $M is not null 120238032Speter 120338032Speter################################################################### 120438032Speter### Ruleset 94 -- convert envelope names to masqueraded form ### 120538032Speter################################################################### 120638032Speter 120764562SgshapiroSMasqEnv=94 120838032Speterifdef(`_MASQUERADE_ENVELOPE_', 120964562Sgshapiro`R$+ $@ $>MasqHdr $1', 121038032Speter`R$* < @ *LOCAL* > $* $: $1 < @ $j . > $2') 121138032Speter 121238032Speter################################################################### 121338032Speter### Ruleset 98 -- local part of ruleset zero (can be null) ### 121438032Speter################################################################### 121538032Speter 121664562SgshapiroSParseLocal=98 121764562Sgshapiroundivert(3)dnl LOCAL_RULE_0 121838032Speter 121964562Sgshapiroifdef(`_LDAP_ROUTING_', `dnl 122064562SgshapiroSLDAPExpand 122164562Sgshapiro# do the LDAP lookups 122264562SgshapiroR<$+><$+> $: <$(ldapmra $2 $: $)> <$(ldapmh $2 $: $)> <$1> <$2> 122364562Sgshapiro 122464562Sgshapiro# if mailRoutingAddress and local or non-existant mailHost, 122564562Sgshapiro# return the new mailRoutingAddress 122664562SgshapiroR< $+ > < $=w > < $+ > < $+ > $@ $>Parse0 $>canonify $1 122764562SgshapiroR< $+ > < > < $+ > < $+ > $@ $>Parse0 $>canonify $1 122864562Sgshapiro 122964562Sgshapiro# if mailRoutingAddress and non-local mailHost, 123064562Sgshapiro# relay to mailHost with new mailRoutingAddress 123164562SgshapiroR< $+ > < $+ > < $+ > < $+ > $#_RELAY_ $@ $2 $: $>canonify $1 123264562Sgshapiro 123364562Sgshapiro# if no mailRoutingAddress and local mailHost, 123464562Sgshapiro# return original address 123564562SgshapiroR< > < $=w > <$+> <$+> $@ $2 123664562Sgshapiro 123764562Sgshapiro# if no mailRoutingAddress and non-local mailHost, 123864562Sgshapiro# relay to mailHost with original address 123964562SgshapiroR< > < $+ > <$+> <$+> $#_RELAY_ $@ $1 $: $2 124064562Sgshapiro 124164562Sgshapiro# if no mailRoutingAddress and no mailHost, 124264562Sgshapiro# try @domain 124364562SgshapiroR< > < > <$+> <$+ @ $+> $@ $>LDAPExpand <$1> <@ $3> 124464562Sgshapiro 124564562Sgshapiro# if no mailRoutingAddress and no mailHost and this was a domain attempt, 124664562Sgshapiroifelse(_LDAP_ROUTING_, `_MUST_EXIST_', `dnl 124764562Sgshapiro# user does not exist 124864562SgshapiroR< > < > <$+> <@ $+> $#error $@ nouser $: "550 User unknown"', 124964562Sgshapiro`dnl 125064562Sgshapiro# return the original address 125164562SgshapiroR< > < > <$+> <@ $+> $@ $1')', 125264562Sgshapiro`dnl') 125364562Sgshapiro 125464562Sgshapiroifelse(substr(confDELIVERY_MODE,0,1), `d', `errprint(`WARNING: Antispam rules not available in deferred delivery mode. 125564562Sgshapiro')') 125664562Sgshapiroifdef(`_ACCESS_TABLE_', `dnl 125738032Speter###################################################################### 125838032Speter### LookUpDomain -- search for domain in access database 125938032Speter### 126038032Speter### Parameters: 126138032Speter### <$1> -- key (domain name) 126238032Speter### <$2> -- default (what to return if not found in db) 126364562Sgshapirodnl must not be empty 126438032Speter### <$3> -- passthru (additional data passed unchanged through) 126564562Sgshapiro### <$4> -- mark (must be <(!|+) single-token>) 126664562Sgshapiro### ! does lookup only with tag 126764562Sgshapiro### + does lookup with and without tag 126864562Sgshapirodnl returns: <default> <passthru> 126964562Sgshapirodnl <result> <passthru> 127038032Speter###################################################################### 127138032Speter 127238032SpeterSLookUpDomain 127364562Sgshapirodnl remove IPv6 mark and dequote address 127464562Sgshapirodnl it is a bit ugly because it is checked on each "iteration" 127564562SgshapiroR<[IPv6 $-]> <$+> <$*> <$*> $: <[$(dequote $1 $)]> <$2> <$3> <$4> 127664562Sgshapirodnl workspace <key> <default> <passthru> <mark> 127764562Sgshapirodnl lookup with tag (in front, no delimiter here) 127864562SgshapiroR<$*> <$+> <$*> <$- $-> $: < $(access $5`'_TAG_DELIM_`'$1 $: ? $) > <$1> <$2> <$3> <$4 $5> 127964562Sgshapirodnl workspace <result-of-lookup|?> <key> <default> <passthru> <mark> 128064562Sgshapiroifdef(`_FFR_LOOKUPDOTDOMAIN', `dnl omit first component: lookup .rest 128164562SgshapiroR<?> <$+.$+> <$+> <$*> <$- $-> $: < $(access $5`'_TAG_DELIM_`'.$2 $: ? $) > <$1.$2> <$3> <$4> <$5 $6>', `dnl') 128264562Sgshapirodnl lookup without tag? 128364562SgshapiroR<?> <$+> <$+> <$*> <+ $*> $: < $(access $1 $: ? $) > <$1> <$2> <$3> <+ $4> 128464562Sgshapiroifdef(`_FFR_LOOKUPDOTDOMAIN', `dnl omit first component: lookup .rest 128564562SgshapiroR<?> <$+.$+> <$+> <$*> <+ $*> $: < $(access .$2 $: ? $) > <$1.$2> <$3> <$4> <+ $5>', `dnl') 128664562Sgshapirodnl lookup IP address (no check is done whether it is an IP number!) 128764562SgshapiroR<?> <[$+.$-]> <$+> <$*> <$*> $@ $>LookUpDomain <[$1]> <$3> <$4> <$5> 128864562Sgshapirodnl lookup IPv6 address 128964562SgshapiroR<?> <[$+:$-]> <$+> <$*> <$*> $: $>LookUpDomain <[$1]> <$3> <$4> <$5> 129064562Sgshapirodnl not found, but subdomain: try again 129164562SgshapiroR<?> <$+.$+> <$+> <$*> <$*> $@ $>LookUpDomain <$2> <$3> <$4> <$5> 129264562Sgshapirodnl not found, no subdomain: return default 129364562SgshapiroR<?> <$+> <$+> <$*> <$*> $@ <$2> <$3> 129464562Sgshapirodnl return result of lookup 129564562SgshapiroR<$*> <$+> <$+> <$*> <$*> $@ <$1> <$4> 129638032Speter 129738032Speter###################################################################### 129838032Speter### LookUpAddress -- search for host address in access database 129938032Speter### 130038032Speter### Parameters: 130138032Speter### <$1> -- key (dot quadded host address) 130238032Speter### <$2> -- default (what to return if not found in db) 130364562Sgshapirodnl must not be empty 130438032Speter### <$3> -- passthru (additional data passed through) 130564562Sgshapiro### <$4> -- mark (must be <(!|+) single-token>) 130664562Sgshapiro### ! does lookup only with tag 130764562Sgshapiro### + does lookup with and without tag 130864562Sgshapirodnl returns: <default> <passthru> 130964562Sgshapirodnl <result> <passthru> 131038032Speter###################################################################### 131138032Speter 131238032SpeterSLookUpAddress 131364562Sgshapirodnl lookup with tag 131464562SgshapiroR<$+> <$+> <$*> <$- $+> $: < $(access $5`'_TAG_DELIM_`'$1 $: ? $) > <$1> <$2> <$3> <$4 $5> 131564562Sgshapirodnl lookup without tag 131664562SgshapiroR<?> <$+> <$+> <$*> <+ $+> $: < $(access $1 $: ? $) > <$1> <$2> <$3> <+ $4> 131764562Sgshapirodnl no match; IPv6: remove last part 131864562SgshapiroR<?> <$+:$-> <$+> <$*> <$*> $@ $>LookUpAddress <$1> <$3> <$4> <$5> 131964562Sgshapirodnl no match; IPv4: remove last part 132064562SgshapiroR<?> <$+.$-> <$+> <$*> <$*> $@ $>LookUpAddress <$1> <$3> <$4> <$5> 132164562Sgshapirodnl no match: return default 132264562SgshapiroR<?> <$+> <$+> <$*> <$*> $@ <$2> <$3> 132364562Sgshapirodnl match: return result 132464562SgshapiroR<$*> <$+> <$+> <$*> <$*> $@ <$1> <$4>', 132538032Speter`dnl') 132638032Speter 132738032Speter###################################################################### 132842575Speter### CanonAddr -- Convert an address into a standard form for 132942575Speter### relay checking. Route address syntax is 133042575Speter### crudely converted into a %-hack address. 133142575Speter### 133242575Speter### Parameters: 133342575Speter### $1 -- full recipient address 133442575Speter### 133542575Speter### Returns: 133642575Speter### parsed address, not in source route form 133764562Sgshapirodnl user%host%host<@domain> 133864562Sgshapirodnl host!user<@domain> 133942575Speter###################################################################### 134042575Speter 134142575SpeterSCanonAddr 134264562SgshapiroR$* $: $>Parse0 $>canonify $1 make domain canonical 134364562Sgshapiroifdef(`_USE_DEPRECATED_ROUTE_ADDR_',`dnl 134442575SpeterR< @ $+ > : $* @ $* < @ $1 > : $2 % $3 change @ to % in src route 134542575SpeterR$* < @ $+ > : $* : $* $3 $1 < @ $2 > : $4 change to % hack. 134642575SpeterR$* < @ $+ > : $* $3 $1 < @ $2 > 134764562Sgshapirodnl') 134842575Speter 134942575Speter###################################################################### 135038032Speter### ParseRecipient -- Strip off hosts in $=R as well as possibly 135138032Speter### $* $=m or the access database. 135238032Speter### Check user portion for host separators. 135338032Speter### 135438032Speter### Parameters: 135538032Speter### $1 -- full recipient address 135638032Speter### 135738032Speter### Returns: 135838032Speter### parsed, non-local-relaying address 135938032Speter###################################################################### 136038032Speter 136138032SpeterSParseRecipient 136264562Sgshapirodnl mark and canonify address 136342575SpeterR$* $: <?> $>CanonAddr $1 136464562Sgshapirodnl workspace: <?> localpart<@domain[.]> 136542575SpeterR<?> $* < @ $* . > <?> $1 < @ $2 > strip trailing dots 136664562Sgshapirodnl workspace: <?> localpart<@domain> 136742575SpeterR<?> $- < @ $* > $: <?> $(dequote $1 $) < @ $2 > dequote local part 136838032Speter 136938032Speter# if no $=O character, no host in the user portion, we are done 137042575SpeterR<?> $* $=O $* < @ $* > $: <NO> $1 $2 $3 < @ $4> 137164562Sgshapirodnl no $=O in localpart: return 137242575SpeterR<?> $* $@ $1 137338032Speter 137464562Sgshapirodnl workspace: <?> localpart<@domain>, where localpart contains $=O 137564562Sgshapirodnl mark everything which has an "authorized" domain with <RELAY> 137638032Speterifdef(`_RELAY_ENTIRE_DOMAIN_', `dnl 137738032Speter# if we relay, check username portion for user%host so host can be checked also 137842575SpeterR<NO> $* < @ $* $=m > $: <RELAY> $1 < @ $2 $3 >', `dnl') 137942575Speter 138042575Speterifdef(`_RELAY_MX_SERVED_', `dnl 138164562Sgshapirodnl do "we" ($=w) act as backup MX server for the destination domain? 138242575SpeterR<NO> $* < @ $+ > $: <MX> < : $(mxserved $2 $) : > < $1 < @$2 > > 138342575SpeterR<MX> < : $* <TEMP> : > $* $#error $@ 4.7.1 $: "450 Can not check MX records for recipient host " $1 138464562Sgshapirodnl yes: mark it as <RELAY> 138542575SpeterR<MX> < $* : $=w. : $* > < $+ > $: <RELAY> $4 138664562Sgshapirodnl no: put old <NO> mark back 138742575SpeterR<MX> < : $* : > < $+ > $: <NO> $2', `dnl') 138842575Speter 138964562Sgshapirodnl workspace: <(NO|RELAY)> localpart<@domain>, where localpart contains $=O 139064562Sgshapirodnl if mark is <NO> then change it to <RELAY> if domain is "authorized" 139138032Speterifdef(`_RELAY_HOSTS_ONLY_', 139242575Speter`R<NO> $* < @ $=R > $: <RELAY> $1 < @ $2 > 139364562Sgshapiroifdef(`_ACCESS_TABLE_', `dnl 139464562SgshapiroR<NO> $* < @ $+ > $: <$(access To:$2 $: NO $)> $1 < @ $2 > 139542575SpeterR<NO> $* < @ $+ > $: <$(access $2 $: NO $)> $1 < @ $2 >',`dnl')', 139642575Speter`R<NO> $* < @ $* $=R > $: <RELAY> $1 < @ $2 $3 > 139764562Sgshapiroifdef(`_ACCESS_TABLE_', `dnl 139864562SgshapiroR<NO> $* < @ $+ > $: $>LookUpDomain <$2> <NO> <$1 < @ $2 >> <+To> 139942575SpeterR<$+> <$+> $: <$1> $2',`dnl')') 140038032Speter 140164562Sgshapiro 140242575SpeterR<RELAY> $* < @ $* > $@ $>ParseRecipient $1 140342575SpeterR<$-> $* $@ $2 140442575Speter 140564562Sgshapiro 140638032Speter###################################################################### 140738032Speter### check_relay -- check hostname/address on SMTP startup 140838032Speter###################################################################### 140938032Speter 141038032SpeterSLocal_check_relay 141164562SgshapiroScheck`'_U_`'relay 141238032SpeterR$* $: $1 $| $>"Local_check_relay" $1 141338032SpeterR$* $| $* $| $#$* $#$3 141438032SpeterR$* $| $* $| $* $@ $>"Basic_check_relay" $1 $| $2 141538032Speter 141638032SpeterSBasic_check_relay 141738032Speter# check for deferred delivery mode 141838032SpeterR$* $: < ${deliveryMode} > $1 141938032SpeterR< d > $* $@ deferred 142038032SpeterR< $* > $* $: $2 142138032Speter 142264562Sgshapiroifdef(`_ACCESS_TABLE_', `dnl 142366494Sgshapirodnl workspace: {client_name} $| {client_addr} 142464562SgshapiroR$+ $| $+ $: $>LookUpDomain < $1 > <?> < $2 > <+Connect> 142566494Sgshapirodnl workspace: <result-of-lookup> <{client_addr}> 142664562SgshapiroR<?> <$+> $: $>LookUpAddress < $1 > <?> < $1 > <+Connect> no: another lookup 142766494Sgshapirodnl workspace: <result-of-lookup> <{client_addr}> 142864562SgshapiroR<?> < $+ > $: $1 found nothing 142966494Sgshapirodnl workspace: <result-of-lookup> <{client_addr}> 143066494Sgshapirodnl or {client_addr} 143166494SgshapiroR<$={Accept}> < $* > $@ $1 return value of lookup 143264562SgshapiroR<REJECT> $* $#error ifdef(`confREJECT_MSG', `$: "confREJECT_MSG"', `$@ 5.7.1 $: "550 Access denied"') 143338032SpeterR<DISCARD> $* $#discard $: discard 143464562Sgshapirodnl error tag 143566494SgshapiroR<ERROR:$-.$-.$-:$+> <$*> $#error $@ $1.$2.$3 $: $4 143666494SgshapiroR<ERROR:$+> <$*> $#error $: $1 143764562Sgshapirodnl generic error from access map 143866494SgshapiroR<$+> <$*> $#error $: $1', `dnl') 143938032Speter 144064562Sgshapiroifdef(`_RBL_',`dnl 144164562Sgshapiro# DNS based IP address spam list 144238032SpeterR$* $: $&{client_addr} 144364562SgshapiroR::ffff:$-.$-.$-.$- $: <?> $(host $4.$3.$2.$1._RBL_. $: OK $) 144464562SgshapiroR$-.$-.$-.$- $: <?> $(host $4.$3.$2.$1._RBL_. $: OK $) 144564562SgshapiroR<?>OK $: OKSOFAR 144664562SgshapiroR<?>$+ $#error $@ 5.7.1 $: "550 Mail from " $&{client_addr} " refused by blackhole site _RBL_"', 144738032Speter`dnl') 144864562Sgshapiroundivert(8) 144938032Speter 145038032Speter###################################################################### 145138032Speter### check_mail -- check SMTP ``MAIL FROM:'' command argument 145238032Speter###################################################################### 145338032Speter 145438032SpeterSLocal_check_mail 145564562SgshapiroScheck`'_U_`'mail 145638032SpeterR$* $: $1 $| $>"Local_check_mail" $1 145738032SpeterR$* $| $#$* $#$2 145838032SpeterR$* $| $* $@ $>"Basic_check_mail" $1 145938032Speter 146038032SpeterSBasic_check_mail 146138032Speter# check for deferred delivery mode 146238032SpeterR$* $: < ${deliveryMode} > $1 146338032SpeterR< d > $* $@ deferred 146438032SpeterR< $* > $* $: $2 146538032Speter 146664562Sgshapiro# authenticated? 146764562Sgshapirodnl done first: we can require authentication for every mail transaction 146864562Sgshapirodnl workspace: address as given by MAIL FROM: (sender) 146964562SgshapiroR$* $: $1 $| $>"tls_client" $&{verify} $| MAIL 147064562SgshapiroR$* $| $#$+ $#$2 147164562Sgshapirodnl undo damage: remove result of tls_client call 147264562SgshapiroR$* $| $* $: $1 147338032Speter 147464562Sgshapirodnl workspace: address as given by MAIL FROM: 147564562SgshapiroR<> $@ <OK> we MUST accept <> (RFC 1123) 147638032Speterifdef(`_ACCEPT_UNQUALIFIED_SENDERS_',`dnl',`dnl 147764562Sgshapirodnl do some additional checks 147864562Sgshapirodnl no user@host 147964562Sgshapirodnl no user@localhost (if nonlocal sender) 148064562Sgshapirodnl this is a pretty simple canonification, it will not catch every case 148164562Sgshapirodnl just make sure the address has <> around it (which is required by 148264562Sgshapirodnl the RFC anyway, maybe we should complain if they are missing...) 148364562Sgshapirodnl dirty trick: if it is user@host, just add a dot: user@host. this will 148464562Sgshapirodnl not be modified by host lookups. 148564562SgshapiroR$+ $: <?> $1 148664562SgshapiroR<?><$+> $: <@> <$1> 148764562SgshapiroR<?>$+ $: <@> <$1> 148864562Sgshapirodnl workspace: <@> <address> 148964562Sgshapirodnl prepend daemon_flags 149064562SgshapiroR$* $: $&{daemon_flags} $| $1 149164562Sgshapirodnl workspace: ${daemon_flags} $| <@> <address> 149264562Sgshapirodnl do not allow these at all or only from local systems? 149364562SgshapiroR$* f $* $| <@> < $* @ $- > $: < ? $&{client_name} > < $3 @ $4 > 149464562Sgshapirodnl accept unqualified sender: change mark to avoid test 149564562SgshapiroR$* u $* $| <@> < $* > $: <?> < $3 > 149664562Sgshapirodnl workspace: ${daemon_flags} $| <@> <address> 149764562Sgshapirodnl or: <? ${client_name} > <address> 149864562Sgshapirodnl or: <?> <address> 149964562Sgshapirodnl remove daemon_flags 150064562SgshapiroR$* $| $* $: $2 150138032Speter# handle case of @localhost on address 150264562SgshapiroR<@> < $* @ localhost > $: < ? $&{client_name} > < $1 @ localhost > 150364562SgshapiroR<@> < $* @ [127.0.0.1] > 150464562Sgshapiro $: < ? $&{client_name} > < $1 @ [127.0.0.1] > 150564562SgshapiroR<@> < $* @ localhost.$m > 150664562Sgshapiro $: < ? $&{client_name} > < $1 @ localhost.$m > 150738032Speterifdef(`_NO_UUCP_', `dnl', 150864562Sgshapiro`R<@> < $* @ localhost.UUCP > 150964562Sgshapiro $: < ? $&{client_name} > < $1 @ localhost.UUCP >') 151064562Sgshapirodnl workspace: < ? $&{client_name} > <user@localhost|host> 151164562Sgshapirodnl or: <@> <address> 151264562Sgshapirodnl or: <?> <address> (thanks to u in ${daemon_flags}) 151364562SgshapiroR<@> $* $: $1 no localhost as domain 151464562Sgshapirodnl workspace: < ? $&{client_name} > <user@localhost|host> 151564562Sgshapirodnl or: <address> 151664562Sgshapirodnl or: <?> <address> (thanks to u in ${daemon_flags}) 151764562SgshapiroR<? $=w> $* $: $2 local client: ok 151866494SgshapiroR<? $+> <$+> $#error $@ 5.5.4 $: "501 Real domain name required for sender address" 151964562Sgshapirodnl remove <?> (happens only if ${client_name} == "" or u in ${daemon_flags}) 152064562SgshapiroR<?> $* $: $1') 152164562Sgshapirodnl workspace: address (or <address>) 152264562SgshapiroR$* $: <?> $>CanonAddr $1 canonify sender address and mark it 152364562Sgshapirodnl workspace: <?> CanonicalAddress (i.e. address in canonical form localpart<@host>) 152464562Sgshapirodnl there is nothing behind the <@host> so no trailing $* needed 152564562SgshapiroR<?> $* < @ $+ . > <?> $1 < @ $2 > strip trailing dots 152664562Sgshapiro# handle non-DNS hostnames (*.bitnet, *.decnet, *.uucp, etc) 152764562SgshapiroR<?> $* < @ $* $=P > $: <OK> $1 < @ $2 $3 > 152864562Sgshapirodnl workspace <mark> CanonicalAddress where mark is ? or OK 152964562Sgshapiroifdef(`_ACCEPT_UNRESOLVABLE_DOMAINS_', 153064562Sgshapiro`R<?> $* < @ $+ > $: <OK> $1 < @ $2 > ... unresolvable OK', 153164562Sgshapiro`R<?> $* < @ $+ > $: <? $(resolve $2 $: $2 <PERM> $) > $1 < @ $2 > 153264562SgshapiroR<? $* <$->> $* < @ $+ > 153364562Sgshapiro $: <$2> $3 < @ $4 >') 153464562Sgshapirodnl workspace <mark> CanonicalAddress where mark is ?, OK, PERM, TEMP 153564562Sgshapirodnl mark is ? iff the address is user (wo @domain) 153638032Speter 153764562Sgshapiroifdef(`_ACCESS_TABLE_', `dnl 153864562Sgshapiro# check sender address: user@address, user@, address 153964562Sgshapirodnl should we remove +ext from user? 154064562Sgshapirodnl workspace: <mark> CanonicalAddress where mark is: ?, OK, PERM, TEMP 154164562SgshapiroR<$+> $+ < @ $* > $: @<$1> <$2 < @ $3 >> $| <F:$2@$3> <U:$2@> <H:$3> 154264562SgshapiroR<$+> $+ $: @<$1> <$2> $| <U:$2@> 154364562Sgshapirodnl workspace: @<mark> <CanonicalAddress> $| <@type:address> .... 154464562Sgshapirodnl $| is used as delimiter, otherwise false matches may occur: <user<@domain>> 154564562Sgshapirodnl will only return user<@domain when "reversing" the args 154664562SgshapiroR@ <$+> <$*> $| <$+> $: <@> <$1> <$2> $| $>SearchList <+From> $| <$3> <> 154764562Sgshapirodnl workspace: <@><mark> <CanonicalAddress> $| <result> 154864562SgshapiroR<@> <$+> <$*> $| <$*> $: <$3> <$1> <$2> reverse result 154964562Sgshapirodnl workspace: <result> <mark> <CanonicalAddress> 155038032Speter# retransform for further use 155164562Sgshapirodnl required form: 155264562Sgshapirodnl <ResultOfLookup|mark> CanonicalAddress 155364562SgshapiroR<?> <$+> <$*> $: <$1> $2 no match 155464562SgshapiroR<$+> <$+> <$*> $: <$1> $3 relevant result, keep it', `dnl') 155564562Sgshapirodnl workspace <ResultOfLookup|mark> CanonicalAddress 155664562Sgshapirodnl mark is ? iff the address is user (wo @domain) 155738032Speter 155838032Speterifdef(`_ACCEPT_UNQUALIFIED_SENDERS_',`dnl',`dnl 155938032Speter# handle case of no @domain on address 156064562Sgshapirodnl prepend daemon_flags 156164562SgshapiroR<?> $* $: $&{daemon_flags} $| <?> $1 156264562Sgshapirodnl accept unqualified sender: change mark to avoid test 156364562SgshapiroR$* u $* $| <?> $* $: <OK> $3 156464562Sgshapirodnl remove daemon_flags 156564562SgshapiroR$* $| $* $: $2 156638032SpeterR<?> $* $: < ? $&{client_name} > $1 156738032SpeterR<?> $* $@ <OK> ...local unqualed ok 156866494SgshapiroR<? $+> $* $#error $@ 5.5.4 $: "501 Domain name required for sender address " $&f 156938032Speter ...remote is not') 157038032Speter# check results 157164562SgshapiroR<?> $* $: @ $1 mark address: nothing known about it 157238032SpeterR<OK> $* $@ <OK> 157364562SgshapiroR<TEMP> $* $#error $@ 4.1.8 $: "451 Domain of sender address " $&f " does not resolve" 157464562SgshapiroR<PERM> $* $#error $@ 5.1.8 $: "501 Domain of sender address " $&f " does not exist" 157564562Sgshapiroifdef(`_ACCESS_TABLE_', `dnl 157664562SgshapiroR<$={Accept}> $* $# $1 157738032SpeterR<DISCARD> $* $#discard $: discard 157864562SgshapiroR<REJECT> $* $#error ifdef(`confREJECT_MSG', `$: "confREJECT_MSG"', `$@ 5.7.1 $: "550 Access denied"') 157964562Sgshapirodnl error tag 158064562SgshapiroR<ERROR:$-.$-.$-:$+> $* $#error $@ $1.$2.$3 $: $4 158164562SgshapiroR<ERROR:$+> $* $#error $: $1 158264562Sgshapirodnl generic error from access map 158364562SgshapiroR<$+> $* $#error $: $1 error from access db', 158438032Speter`dnl') 158538032Speter 158638032Speter###################################################################### 158738032Speter### check_rcpt -- check SMTP ``RCPT TO:'' command argument 158838032Speter###################################################################### 158938032Speter 159038032SpeterSLocal_check_rcpt 159164562SgshapiroScheck`'_U_`'rcpt 159238032SpeterR$* $: $1 $| $>"Local_check_rcpt" $1 159338032SpeterR$* $| $#$* $#$2 159438032SpeterR$* $| $* $@ $>"Basic_check_rcpt" $1 159538032Speter 159638032SpeterSBasic_check_rcpt 159738032Speter# check for deferred delivery mode 159838032SpeterR$* $: < ${deliveryMode} > $1 159938032SpeterR< d > $* $@ deferred 160038032SpeterR< $* > $* $: $2 160138032Speter 160264562Sgshapiroifdef(`_REQUIRE_QUAL_RCPT_', `dnl 160364562Sgshapiro# require qualified recipient? 160464562SgshapiroR$+ $: <?> $1 160564562SgshapiroR<?><$+> $: <@> <$1> 160664562SgshapiroR<?>$+ $: <@> <$1> 160764562Sgshapirodnl prepend daemon_flags 160864562SgshapiroR$* $: $&{daemon_flags} $| $1 160964562Sgshapirodnl workspace: ${daemon_flags} $| <@> <address> 161064562Sgshapirodnl do not allow these at all or only from local systems? 161164562SgshapiroR$* r $* $| <@> < $* @ $- > $: < ? $&{client_name} > < $3 @ $4 > 161264562SgshapiroR<?> < $* > $: <$1> 161364562SgshapiroR<? $=w> < $* > $: <$1> 161464562SgshapiroR<? $+> <$+> $#error $@ 5.5.4 $: "553 Domain name required" 161564562Sgshapirodnl remove daemon_flags for other cases 161664562SgshapiroR$* $| <@> $* $: $2', `dnl') 161764562Sgshapiro 161838032Speterifdef(`_LOOSE_RELAY_CHECK_',`dnl 161942575SpeterR$* $: $>CanonAddr $1 162038032SpeterR$* < @ $* . > $1 < @ $2 > strip trailing dots', 162138032Speter`R$* $: $>ParseRecipient $1 strip relayable hosts') 162238032Speter 162342575Speterifdef(`_BESTMX_IS_LOCAL_',`dnl 162442575Speterifelse(_BESTMX_IS_LOCAL_, `', `dnl 162542575Speter# unlimited bestmx 162642575SpeterR$* < @ $* > $* $: $1 < @ $2 @@ $(bestmx $2 $) > $3', 162742575Speter`dnl 162842575Speter# limit bestmx to $=B 162943730SpeterR$* < @ $* $=B > $* $: $1 < @ $2 $3 @@ $(bestmx $2 $3 $) > $4') 163064562SgshapiroR$* $=O $* < @ $* @@ $=w . > $* $@ $>"Basic_check_rcpt" $1 $2 $3 163142575SpeterR$* < @ $* @@ $=w . > $* $: $1 < @ $3 > $4 163242575SpeterR$* < @ $* @@ $* > $* $: $1 < @ $2 > $4') 163342575Speter 163438032Speterifdef(`_BLACKLIST_RCPT_',`dnl 163564562Sgshapiroifdef(`_ACCESS_TABLE_', `dnl 163638032Speter# blacklist local users or any host from receiving mail 163738032SpeterR$* $: <?> $1 163864562Sgshapirodnl user is now tagged with @ to be consistent with check_mail 163964562Sgshapirodnl and to distinguish users from hosts (com would be host, com@ would be user) 164064562SgshapiroR<?> $+ < @ $=w > $: <> <$1 < @ $2 >> $| <F:$1@$2> <U:$1@> <H:$2> 164164562SgshapiroR<?> $+ < @ $* > $: <> <$1 < @ $2 >> $| <F:$1@$2> <H:$2> 164264562SgshapiroR<?> $+ $: <> <$1> $| <U:$1@> 164364562Sgshapirodnl $| is used as delimiter, otherwise false matches may occur: <user<@domain>> 164464562Sgshapirodnl will only return user<@domain when "reversing" the args 164564562SgshapiroR<> <$*> $| <$+> $: <@> <$1> $| $>SearchList <+To> $| <$2> <> 164664562SgshapiroR<@> <$*> $| <$*> $: <$2> <$1> reverse result 164764562SgshapiroR<?> <$*> $: @ $1 mark address as no match 164864562SgshapiroR<$={Accept}> <$*> $: @ $2 mark address as no match 164964562Sgshapiroifdef(`_DELAY_CHECKS_',`dnl 165064562Sgshapirodnl we have to filter these because otherwise they would be interpreted 165164562Sgshapirodnl as generic error message... 165264562Sgshapirodnl error messages should be "tagged" by prefixing them with error: ! 165364562Sgshapirodnl that would make a lot of things easier. 165464562Sgshapirodnl maybe we should stop checks already here (if SPAM_xyx)? 165564562SgshapiroR<$={SpamTag}> <$*> $: @ $2 mark address as no match') 165638032SpeterR<REJECT> $* $#error $@ 5.2.1 $: "550 Mailbox disabled for this recipient" 165764562SgshapiroR<DISCARD> $* $#discard $: discard 165864562Sgshapirodnl error tag 165964562SgshapiroR<ERROR:$-.$-.$-:$+> $* $#error $@ $1.$2.$3 $: $4 166064562SgshapiroR<ERROR:$+> $* $#error $: $1 166164562Sgshapirodnl generic error from access map 166264562SgshapiroR<$+> $* $#error $: $1 error from access db 166364562SgshapiroR@ $* $1 remove mark', `dnl')', `dnl') 166438032Speter 166564562Sgshapiroifdef(`_PROMISCUOUS_RELAY_', `divert(-1)') 166664562Sgshapiro# authenticated? 166764562Sgshapirodnl do this unconditionally? this requires to manage CAs carefully 166864562Sgshapirodnl just because someone has a CERT signed by a "trusted" CA 166964562Sgshapirodnl does not mean we want to allow relaying for her, 167064562Sgshapirodnl either use a subroutine or provide something more sophisticated 167164562Sgshapirodnl this could for example check the DN (maybe an access map lookup) 167264562SgshapiroR$* $: $1 $| $>RelayAuth $1 $| $&{verify} client authenticated? 167364562SgshapiroR$* $| $# $+ $# $2 error/ok? 167464562SgshapiroR$* $| $* $: $1 no 167564562Sgshapiro 167664562Sgshapiro# authenticated by a trusted mechanism? 167764562SgshapiroR$* $: $1 $| $&{auth_type} 167864562Sgshapirodnl empty ${auth_type}? 167964562SgshapiroR$* $| $: $1 168064562Sgshapirodnl mechanism ${auth_type} accepted? 168164562Sgshapirodnl use $# to override further tests (delay_checks): see check_rcpt below 168264562SgshapiroR$* $| $={TrustAuthMech} $# RELAYAUTH 168364562Sgshapirodnl undo addition of ${auth_type} 168464562SgshapiroR$* $| $* $: $1 168564562Sgshapirodnl workspace: localpart<@domain> 168664562Sgshapiroifelse(defn(`_NO_UUCP_'), `r', 168764562Sgshapiro`R$* ! $* < @ $* > $: <REMOTE> $2 < @ BANG_PATH >', `dnl') 168838032Speter# anything terminating locally is ok 168938032Speterifdef(`_RELAY_ENTIRE_DOMAIN_', `dnl 169064562SgshapiroR$+ < @ $* $=m > $@ RELAYTO', `dnl') 169164562SgshapiroR$+ < @ $=w > $@ RELAYTO 169238032Speterifdef(`_RELAY_HOSTS_ONLY_', 169364562Sgshapiro`R$+ < @ $=R > $@ RELAYTO 169464562Sgshapiroifdef(`_ACCESS_TABLE_', `dnl 169564562SgshapiroR$+ < @ $+ > $: <$(access To:$2 $: ? $)> <$1 < @ $2 >> 169664562Sgshapirodnl workspace: <Result-of-lookup | ?> <localpart<@domain>> 169764562SgshapiroR<?> <$+ < @ $+ >> $: <$(access $2 $: ? $)> <$1 < @ $2 >>',`dnl')', 169864562Sgshapiro`R$+ < @ $* $=R > $@ RELAYTO 169964562Sgshapiroifdef(`_ACCESS_TABLE_', `dnl 170064562SgshapiroR$+ < @ $+ > $: $>LookUpDomain <$2> <?> <$1 < @ $2 >> <+To>',`dnl')') 170164562Sgshapiroifdef(`_ACCESS_TABLE_', `dnl 170264562Sgshapirodnl workspace: <Result-of-lookup | ?> <localpart<@domain>> 170364562SgshapiroR<RELAY> $* $@ RELAYTO 170438032SpeterR<$*> <$*> $: $2',`dnl') 170538032Speter 170664562Sgshapiro 170738032Speterifdef(`_RELAY_MX_SERVED_', `dnl 170838032Speter# allow relaying for hosts which we MX serve 170964562SgshapiroR$+ < @ $+ > $: < : $(mxserved $2 $) : > $1 < @ $2 > 171064562Sgshapirodnl this must not necessarily happen if the client is checked first... 171138032SpeterR< : $* <TEMP> : > $* $#error $@ 4.7.1 $: "450 Can not check MX records for recipient host " $1 171264562SgshapiroR<$* : $=w . : $*> $* $@ RELAYTO 171342575SpeterR< : $* : > $* $: $2', 171438032Speter`dnl') 171538032Speter 171638032Speter# check for local user (i.e. unqualified address) 171738032SpeterR$* $: <?> $1 171842575SpeterR<?> $* < @ $+ > $: <REMOTE> $1 < @ $2 > 171938032Speter# local user is ok 172064562Sgshapirodnl is it really? the standard requires user@domain, not just user 172164562Sgshapirodnl but we should accept it anyway (maybe making it an option: 172264562Sgshapirodnl RequireFQDN ?) 172364562Sgshapirodnl postmaster must be accepted without domain (DRUMS) 172464562Sgshapiroifdef(`_REQUIRE_QUAL_RCPT_', `dnl 172564562SgshapiroR<?> postmaster $@ TOPOSTMASTER 172664562Sgshapiro# require qualified recipient? 172764562Sgshapirodnl prepend daemon_flags 172864562SgshapiroR<?> $+ $: $&{daemon_flags} $| <?> $1 172964562Sgshapirodnl workspace: ${daemon_flags} $| <?> localpart 173064562Sgshapirodnl do not allow these at all or only from local systems? 173164562Sgshapirodnl r flag? add client_name 173264562SgshapiroR$* r $* $| <?> $+ $: < ? $&{client_name} > <?> $3 173364562Sgshapirodnl no r flag: relay to local user (only local part) 173464562Sgshapiro# no qualified recipient required 173564562SgshapiroR$* $| <?> $+ $@ RELAYTOLOCAL 173664562Sgshapirodnl client_name is empty 173764562SgshapiroR<?> <?> $+ $@ RELAYTOLOCAL 173864562Sgshapirodnl client_name is local 173964562SgshapiroR<? $=w> <?> $+ $@ RELAYTOLOCAL 174064562Sgshapirodnl client_name is not local 174164562SgshapiroR<? $+> $+ $#error $@ 5.5.4 $: "553 Domain name required"', `dnl 174264562Sgshapirodnl no qualified recipient required 174364562SgshapiroR<?> $+ $@ RELAYTOLOCAL') 174464562Sgshapirodnl it is a remote user: remove mark and then check client 174538032SpeterR<$+> $* $: $2 174664562Sgshapirodnl currently the recipient address is not used below 174738032Speter 174838032Speter# anything originating locally is ok 174964562Sgshapiro# check IP address 175064562SgshapiroR$* $: $&{client_addr} 175164562SgshapiroR$@ $@ RELAYFROM originated locally 175264562SgshapiroR0 $@ RELAYFROM originated locally 175364562SgshapiroR$=R $* $@ RELAYFROM relayable IP address 175464562Sgshapiroifdef(`_ACCESS_TABLE_', `dnl 175564562SgshapiroR$* $: $>LookUpAddress <$1> <?> <$1> <+Connect> 175664562SgshapiroR<RELAY> $* $@ RELAYFROM relayable IP address 175764562SgshapiroR<$*> <$*> $: $2', `dnl') 175864562SgshapiroR$* $: [ $1 ] put brackets around it... 175964562SgshapiroR$=w $@ RELAYFROM ... and see if it is local 176064562Sgshapiro 176164562Sgshapiroifdef(`_RELAY_DB_FROM_', `define(`_RELAY_MAIL_FROM_', `1')')dnl 176264562Sgshapiroifdef(`_RELAY_LOCAL_FROM_', `define(`_RELAY_MAIL_FROM_', `1')')dnl 176364562Sgshapiroifdef(`_RELAY_MAIL_FROM_', `dnl 176464562Sgshapirodnl input: {client_addr} or something "broken" 176564562Sgshapirodnl just throw the input away; we do not need it. 176664562Sgshapiro# check whether FROM is allowed to use system as relay 176764562SgshapiroR$* $: <?> $>CanonAddr $&f 176864562Sgshapiroifdef(`_RELAY_LOCAL_FROM_', `dnl 176964562Sgshapiro# check whether local FROM is ok 177064562SgshapiroR<?> $+ < @ $=w . > $@ RELAYFROMMAIL FROM local', `dnl') 177164562Sgshapiroifdef(`_RELAY_DB_FROM_', `dnl 177264562SgshapiroR<?> $+ < @ $+ . > <?> $1 < @ $2 > remove trailing dot 177364562SgshapiroR<?> $+ < @ $+ > $: $1 < @ $2 > $| $>SearchList <! From> $| <F:$1@$2> ifdef(`_RELAY_DB_FROM_DOMAIN_', `<H:$2>') <> 177464562SgshapiroR$* <RELAY> $@ RELAYFROMMAIL RELAY FROM sender ok', `dnl 177564562Sgshapiroifdef(`_RELAY_DB_FROM_DOMAIN_', `errprint(`*** ERROR: _RELAY_DB_FROM_DOMAIN_ requires _RELAY_DB_FROM_ 177664562Sgshapiro')', 177764562Sgshapiro`dnl') 177864562Sgshapirodnl')', `dnl') 177964562Sgshapiro 178064562Sgshapiro# check client name: first: did it resolve? 178164562Sgshapirodnl input: ignored 178264562SgshapiroR$* $: < $&{client_resolve} > 178364562SgshapiroR<TEMP> $#error $@ 4.7.1 $: "450 Relaying temporarily denied. Cannot resolve PTR record for " $&{client_addr} 178464562SgshapiroR<FORGED> $#error $@ 5.7.1 $: "550 Relaying denied. IP name possibly forged " $&{client_name} 178564562SgshapiroR<FAIL> $#error $@ 5.7.1 $: "550 Relaying denied. IP name lookup failed " $&{client_name} 178664562Sgshapirodnl ${client_resolve} should be OK, so go ahead 178738032SpeterR$* $: <?> $&{client_name} 178838032Speter# pass to name server to make hostname canonical 178964562SgshapiroR<?> $* $~P $:<?> $[ $1 $2 $] 179064562SgshapiroR$* . $1 strip trailing dots 179164562Sgshapirodnl should not be necessary since it has been done for client_addr already 179264562SgshapiroR<?> $@ RELAYFROM 179338032Speterifdef(`_RELAY_ENTIRE_DOMAIN_', `dnl 179464562SgshapiroR<?> $* $=m $@ RELAYFROM', `dnl') 179564562SgshapiroR<?> $=w $@ RELAYFROM 179638032Speterifdef(`_RELAY_HOSTS_ONLY_', 179764562Sgshapiro`R<?> $=R $@ RELAYFROM 179864562Sgshapiroifdef(`_ACCESS_TABLE_', `dnl 179964562SgshapiroR<?> $* $: <$(access Connect:$1 $: ? $)> <$1> 180064562SgshapiroR<?> <$*> $: <$(access $1 $: ? $)> <$1>',`dnl')', 180164562Sgshapiro`R<?> $* $=R $@ RELAYFROM 180264562Sgshapiroifdef(`_ACCESS_TABLE_', `dnl 180364562SgshapiroR<?> $* $: $>LookUpDomain <$1> <?> <$1> <+Connect>',`dnl')') 180464562Sgshapiroifdef(`_ACCESS_TABLE_', `dnl 180564562SgshapiroR<RELAY> $* $@ RELAYFROM 180638032SpeterR<$*> <$*> $: $2',`dnl') 180738032Speter 180864562Sgshapiro# anything else is bogus 180964562SgshapiroR$* $#error $@ 5.7.1 $: confRELAY_MSG 181064562Sgshapirodivert(0) 181164562Sgshapiroifdef(`_DELAY_CHECKS_',`dnl 181264562Sgshapiro# turn a canonical address in the form user<@domain> 181364562Sgshapiro# qualify unqual. addresses with $j 181464562Sgshapirodnl it might have been only user (without <@domain>) 181564562SgshapiroSFullAddr 181664562SgshapiroR$* <@ $+ . > $1 <@ $2 > 181764562SgshapiroR$* <@ $* > $@ $1 <@ $2 > 181864562SgshapiroR$+ $@ $1 <@ $j > 181938032Speter 182064562Sgshapiro# call all necessary rulesets 182164562SgshapiroScheck_rcpt 182264562Sgshapirodnl this test should be in the Basic_check_rcpt ruleset 182364562Sgshapirodnl which is the correct DSN code? 182464562Sgshapiro# R$@ $#error $@ 5.1.3 $: "553 Recipient address required" 182564562SgshapiroR$+ $: $1 $| $>checkrcpt $1 182664562Sgshapirodnl now we can simply stop checks by returning "$# xyz" instead of just "ok" 182764562SgshapiroR$+ $| $#$* $#$2 182864562SgshapiroR$+ $| $* $: <?> $>FullAddr $>CanonAddr $1 182964562Sgshapiroifdef(`_SPAM_FH_', 183064562Sgshapiro`dnl lookup user@ and user@address 183164562Sgshapiroifdef(`_ACCESS_TABLE_', `', 183264562Sgshapiro`errprint(`*** ERROR: FEATURE(`delay_checks', `argument') requires FEATURE(`access_db') 183364562Sgshapiro')')dnl 183464562Sgshapirodnl one of the next two rules is supposed to match 183564562Sgshapirodnl this code has been copied from BLACKLIST... etc 183664562Sgshapirodnl and simplified by omitting some < >. 183764562SgshapiroR<?> $+ < @ $=w > $: <> $1 < @ $2 > $| <F: $1@$2 > <U: $1@> 183864562SgshapiroR<?> $+ < @ $* > $: <> $1 < @ $2 > $| <F: $1@$2 > 183964562Sgshapirodnl R<?> $@ something_is_very_wrong_here 184064562Sgshapiro# lookup the addresses only with To tag 184164562SgshapiroR<> $* $| <$+> $: <@> $1 $| $>SearchList <!To> $| <$2> <> 184264562SgshapiroR<@> $* $| $* $: $2 $1 reverse result 184364562Sgshapirodnl', `dnl') 184464562Sgshapiroifdef(`_SPAM_FRIEND_', 184564562Sgshapiro`# is the recipient a spam friend? 184664562Sgshapiroifdef(`_SPAM_HATER_', 184764562Sgshapiro `errprint(`*** ERROR: define either SpamHater or SpamFriend 184864562Sgshapiro')', `dnl') 184964562SgshapiroR<SPAMFRIEND> $+ $@ SPAMFRIEND 185064562SgshapiroR<$*> $+ $: $2', 185164562Sgshapiro`dnl') 185264562Sgshapiroifdef(`_SPAM_HATER_', 185364562Sgshapiro`# is the recipient no spam hater? 185464562SgshapiroR<SPAMHATER> $+ $: $1 spam hater: continue checks 185564562SgshapiroR<$*> $+ $@ NOSPAMHATER everyone else: stop 185664562Sgshapirodnl',`dnl') 185764562Sgshapirodnl run further checks: check_mail 185864562Sgshapirodnl should we "clean up" $&f? 185964562SgshapiroR$* $: $1 $| $>checkmail <$&f> 186064562SgshapiroR$* $| $#$* $#$2 186164562Sgshapirodnl run further checks: check_relay 186264562SgshapiroR$* $: $1 $| $>checkrelay $&{client_name} $| $&{client_addr} 186364562SgshapiroR$* $| $#$* $#$2 186438032SpeterR$* $| $* $: $1 186538032Speter', `dnl') 186664562Sgshapiroifdef(`_ACCESS_TABLE_', `dnl 186764562Sgshapiro###################################################################### 186864562Sgshapiro### SearchList: search a list of items in the access map 186964562Sgshapiro### Parameters: 187064562Sgshapiro### <exact tag> $| <mark:address> <mark:address> ... <> 187164562Sgshapirodnl maybe we should have a @ (again) in front of the mark to 187264562Sgshapirodnl avoid errorneous matches (with error messages?) 187364562Sgshapirodnl if we can make sure that tag is always a single token 187464562Sgshapirodnl then we can omit the delimiter $|, otherwise we need it 187564562Sgshapirodnl to avoid errorneous matchs (first rule: H: if there 187664562Sgshapirodnl is that mark somewhere in the list, it will be taken). 187764562Sgshapirodnl moreover, we can do some tricks to enforce lookup with 187864562Sgshapirodnl the tag only, e.g.: 187964562Sgshapiro### where "exact" is either "+" or "!": 188064562Sgshapiro### <+ TAG> lookup with and w/o tag 188164562Sgshapiro### <! TAG> lookup with tag 188264562Sgshapirodnl Warning: + and ! should be in OperatorChars (otherwise there must be 188364562Sgshapirodnl a blank between them and the tag. 188464562Sgshapiro### possible values for "mark" are: 188564562Sgshapiro### H: recursive host lookup (LookUpDomain) 188664562Sgshapirodnl A: recursive address lookup (LookUpAddress) [not yet required] 188764562Sgshapiro### E: exact lookup, no modifications 188864562Sgshapiro### F: full lookup, try user+ext@domain and user@domain 188964562Sgshapiro### U: user lookup, try user+ext and user (input must have trailing @) 189064562Sgshapiro### return: <RHS of lookup> or <?> (not found) 189164562Sgshapiro###################################################################### 189238032Speter 189364562Sgshapiro# class with valid marks for SearchList 189464562Sgshapirodnl if A is activated: add it 189564562SgshapiroC{src}E F H U 189664562SgshapiroSSearchList 189764562Sgshapiro# mark H: lookup domain 189864562SgshapiroR<$+> $| <H:$+> <$*> $: <$1> $| <@> $>LookUpDomain <$2> <?> <$3> <$1> 189964562SgshapiroR<$+> $| <@> <$+> <$*> $: <$1> $| <$2> <$3> 190064562Sgshapirodnl A: NOT YET REQUIRED 190164562Sgshapirodnl R<$+> $| <A:$+> <$*> $: <$1> $| <@> $>LookUpAddress <$2> <?> <$3> <$1> 190264562Sgshapirodnl R<$+> $| <@> <$+> <$*> $: <$1> $| <$2> <$3> 190364562Sgshapirodnl lookup of the item with tag 190464562Sgshapirodnl this applies to F: U: E: 190564562SgshapiroR<$- $-> $| <$={src}:$+> <$*> $: <$1 $2> $| <$(access $2`'_TAG_DELIM_`'$4 $: $3:$4 $)> <$5> 190664562Sgshapirodnl no match, try without tag 190764562SgshapiroR<+ $-> $| <$={src}:$+> <$*> $: <+ $1> $| <$(access $3 $: $2:$3 $)> <$4> 190864562Sgshapirodnl do we really have to distinguish these cases? 190964562Sgshapirodnl probably yes, there might be a + in the domain part (is that allowed?) 191064562Sgshapirodnl user+detail lookups: should it be: 191164562Sgshapirodnl user+detail, user+*, user; just like aliases? 191264562SgshapiroR<$- $-> $| <F:$* + $*@$+> <$*> $: <$1 $2> $| <$(access $2`'_TAG_DELIM_`'$3@$5 $: F:$3 + $4@$5$)> <$6> 191364562SgshapiroR<+ $-> $| <F:$* + $*@$+> <$*> $: <+ $1> $| <$(access $2@$4 $: F:$2 + $3@$4$)> <$5> 191464562Sgshapirodnl user lookups are always with trailing @ 191564562Sgshapirodnl do not remove the @ from the lookup: 191664562Sgshapirodnl it is part of the +detail@ which is omitted for the lookup 191764562SgshapiroR<$- $-> $| <U:$* + $*> <$*> $: <$1 $2> $| <$(access $2`'_TAG_DELIM_`'$3@ $: U:$3 + $4$)> <$5> 191864562Sgshapirodnl no match, try without tag 191964562SgshapiroR<+ $-> $| <U:$* + $*> <$*> $: <+ $1> $| <$(access $2@ $: U:$2 + $3$)> <$4> 192064562Sgshapirodnl no match, try rest of list 192164562SgshapiroR<$+> $| <$={src}:$+> <$+> $@ $>SearchList <$1> $| <$4> 192264562Sgshapirodnl no match, list empty: return failure 192364562SgshapiroR<$+> $| <$={src}:$+> <> $@ <?> 192464562Sgshapirodnl got result, return it 192564562SgshapiroR<$+> $| <$+> <$*> $@ <$2> 192664562Sgshapirodnl return result from recursive invocation 192764562SgshapiroR<$+> $| <$+> $@ <$2>', `dnl') 192838032Speter 192964562Sgshapiro# is user trusted to authenticate as someone else? 193064562Sgshapirodnl AUTH= parameter from MAIL command 193164562SgshapiroStrust_auth 193264562SgshapiroR$* $: $&{auth_type} $| $1 193364562Sgshapiro# required by RFC 2554 section 4. 193464562SgshapiroR$@ $| $* $#error $@ 5.7.1 $: "550 not authenticated" 193564562Sgshapirodnl seems to be useful... 193664562SgshapiroR$* $| $&{auth_authen} $@ identical 193764562SgshapiroR$* $| <$&{auth_authen}> $@ identical 193864562Sgshapirodnl call user supplied code 193964562SgshapiroR$* $| $* $: $1 $| $>"Local_trust_auth" $1 194064562SgshapiroR$* $| $#$* $#$2 194164562Sgshapirodnl default: error 194264562SgshapiroR$* $#error $@ 5.7.1 $: "550 " $&{auth_authen} " not allowed to act as " $&{auth_author} 194364562Sgshapiro 194464562Sgshapirodnl empty ruleset definition so it can be called 194564562SgshapiroSLocal_trust_auth 194664562Sgshapiro 194764562Sgshapiroifdef(`_FFR_TLS_O_T', `dnl 194864562SgshapiroSoffer_tls 194964562SgshapiroR$* $: $>LookUpDomain <$&{client_name}> <?> <> <! TLS_OFF_TAG> 195064562SgshapiroR<?>$* $: $>LookUpAddress <$&{client_addr}> <?> <> <! TLS_OFF_TAG> 195164562SgshapiroR<?>$* $: <$(access TLS_OFF_TAG: $: ? $)> 195264562SgshapiroR<?>$* $@ OK 195364562SgshapiroR<NO> <> $#error $@ 5.7.1 $: "550 do not offer TLS for " $&{client_name} " ["$&{client_addr}"]" 195464562Sgshapiro 195564562SgshapiroStry_tls 195664562SgshapiroR$* $: $>LookUpDomain <$&{server_name}> <?> <> <! TLS_TRY_TAG> 195764562SgshapiroR<?>$* $: $>LookUpAddress <$&{server_addr}> <?> <> <! TLS_TRY_TAG> 195864562SgshapiroR<?>$* $: <$(access TLS_TRY_TAG: $: ? $)> 195964562SgshapiroR<?>$* $@ OK 196064562SgshapiroR<NO> <> $#error $@ 5.7.1 $: "550 do not try TLS with " $&{server_name} " ["$&{server_addr}"]" 196164562Sgshapiro')dnl 196264562Sgshapiro 196364562Sgshapiro# is connection with client "good" enough? (done in server) 196464562Sgshapiro# input: ${verify} $| (MAIL|STARTTLS) 196564562Sgshapirodnl MAIL: called from check_mail 196664562Sgshapirodnl STARTTLS: called from smtp() after STARTTLS has been accepted 196764562SgshapiroStls_client 196864562Sgshapiroifdef(`_ACCESS_TABLE_', `dnl 196964562Sgshapirodnl ignore second arg for now 197064562Sgshapirodnl maybe use it to distinguish permanent/temporary error? 197164562Sgshapirodnl if MAIL: permanent (STARTTLS has not been offered) 197264562Sgshapirodnl if STARTTLS: temporary (offered but maybe failed) 197364562SgshapiroR$* $| $* $: $1 $| $>LookUpDomain <$&{client_name}> <?> <> <! TLS_CLT_TAG> 197464562SgshapiroR$* $| <?>$* $: $1 $| $>LookUpAddress <$&{client_addr}> <?> <> <! TLS_CLT_TAG> 197564562Sgshapirodnl do a default lookup: just TLS_CLT_TAG 197664562SgshapiroR$* $| <?>$* $: $1 $| <$(access TLS_CLT_TAG`'_TAG_DELIM_ $: ? $)> 197764562SgshapiroR$* $@ $>"tls_connection" $1', `dnl 197864562SgshapiroR$* $| $* $@ $>"tls_connection" $1') 197964562Sgshapiro 198064562Sgshapiro# is connection with server "good" enough? (done in client) 198164562Sgshapirodnl i.e. has the server been authenticated and is encryption active? 198264562Sgshapirodnl called from deliver() after STARTTLS command 198364562Sgshapiro# input: ${verify} 198464562SgshapiroStls_server 198564562Sgshapiroifdef(`_ACCESS_TABLE_', `dnl 198664562SgshapiroR$* $: $1 $| $>LookUpDomain <$&{server_name}> <?> <> <! TLS_SRV_TAG> 198764562SgshapiroR$* $| <?>$* $: $1 $| $>LookUpAddress <$&{server_addr}> <?> <> <! TLS_SRV_TAG> 198864562Sgshapirodnl do a default lookup: just TLS_SRV_TAG 198964562SgshapiroR$* $| <?>$* $: $1 $| <$(access TLS_SRV_TAG`'_TAG_DELIM_ $: ? $)> 199064562SgshapiroR$* $@ $>"tls_connection" $1', `dnl 199164562SgshapiroR$* $@ $>"tls_connection" $1') 199264562Sgshapiro 199364562SgshapiroStls_connection 199464562Sgshapiroifdef(`_ACCESS_TABLE_', `dnl 199564562Sgshapirodnl common ruleset for tls_{client|server} 199664562Sgshapirodnl input: $&{verify} $| <ResultOfLookup> [<>] 199764562Sgshapirodnl remove optional <> 199864562SgshapiroR$* $| <$*>$* $: $1 $| <$2> 199964562Sgshapirodnl permanent or temporary error? 200064562SgshapiroR$* $| <PERM + $={tls} $*> $: $1 $| <503:5.7.0> <$2 $3> 200164562SgshapiroR$* $| <TEMP + $={tls} $*> $: $1 $| <403:4.7.0> <$2 $3> 200264562Sgshapirodnl default case depends on TLS_PERM_ERR 200364562SgshapiroR$* $| <$={tls} $*> $: $1 $| <ifdef(`TLS_PERM_ERR', `503:5.7.0', `403:4.7.0')> <$2 $3> 200464562Sgshapirodnl deal with TLS handshake failures: abort 200564562SgshapiroRSOFTWARE $| <$-:$+> $* $#error $@ $2 $: $1 " TLS handshake failed." 200664562Sgshapirodnl no <reply:dns> i.e. not requirements in the access map 200764562Sgshapirodnl use default error 200864562SgshapiroRSOFTWARE $| $* $#error $@ ifdef(`TLS_PERM_ERR', `5.7.0', `4.7.0') $: "ifdef(`TLS_PERM_ERR', `503', `403') TLS handshake failed." 200964562SgshapiroR$* $| <$*> <VERIFY> $: <$2> <VERIFY> $1 201064562SgshapiroR$* $| <$*> <$={tls}:$->$* $: <$2> <$3:$4> $1 201164562Sgshapirodnl some other value in access map: accept 201264562Sgshapirodnl this also allows to override the default case (if used) 201364562SgshapiroR$* $| $* $@ OK 201464562Sgshapiro# authentication required: give appropriate error 201564562Sgshapiro# other side did authenticate (via STARTTLS) 201664562Sgshapirodnl workspace: <SMTP:ESC> <{VERIFY,ENCR}[:BITS]> ${verify} 201764562Sgshapirodnl only verification required and it succeeded 201864562SgshapiroR<$*><VERIFY> OK $@ OK 201964562Sgshapirodnl verification required + some level of encryption 202064562SgshapiroR<$*><VERIFY:$-> OK $: <$1> <REQ:$2> 202164562Sgshapirodnl just some level of encryption required 202264562SgshapiroR<$*><ENCR:$-> $* $: <$1> <REQ:$2> 202364562Sgshapirodnl verification required but ${verify} is not set 202464562SgshapiroR<$-:$+><VERIFY $*> $#error $@ $2 $: $1 " authentication required" 202564562SgshapiroR<$-:$+><VERIFY $*> FAIL $#error $@ $2 $: $1 " authentication failed" 202664562SgshapiroR<$-:$+><VERIFY $*> NO $#error $@ $2 $: $1 " not authenticated" 202764562SgshapiroR<$-:$+><VERIFY $*> NONE $#error $@ $2 $: $1 " other side does not support STARTTLS" 202864562Sgshapirodnl some other value for ${verify} 202964562SgshapiroR<$-:$+><VERIFY $*> $+ $#error $@ $2 $: $1 " authentication failure " $4 203064562Sgshapirodnl some level of encryption required: get the maximum level 203164562SgshapiroR<$*><REQ:$-> $: <$1> <REQ:$2> $>max $&{cipher_bits} : $&{auth_ssf} 203264562Sgshapirodnl compare required bits with actual bits 203364562SgshapiroR<$*><REQ:$-> $- $: <$1> <$2:$3> $(arith l $@ $3 $@ $2 $) 203464562SgshapiroR<$-:$+><$-:$-> TRUE $#error $@ $2 $: $1 " encryption too weak " $4 " less than " $3 203564562Sgshapiro 203664562SgshapiroSmax 203764562Sgshapirodnl compute the max of two values separated by : 203864562SgshapiroR: $: 0 203964562SgshapiroR:$- $: $1 204064562SgshapiroR$-: $: $1 204164562SgshapiroR$-:$- $: $(arith l $@ $1 $@ $2 $) : $1 : $2 204264562SgshapiroRTRUE:$-:$- $: $2 204364562SgshapiroR$-:$-:$- $: $2', 204464562Sgshapiro`dnl use default error 204564562Sgshapirodnl deal with TLS handshake failures: abort 204664562SgshapiroRSOFTWARE $#error $@ ifdef(`TLS_PERM_ERR', `5.7.0', `4.7.0') $: "ifdef(`TLS_PERM_ERR', `503', `403') TLS handshake."') 204764562Sgshapiro 204864562SgshapiroSRelayAuth 204964562Sgshapiro# authenticated? 205064562Sgshapirodnl we do not allow relaying for anyone who can present a cert 205164562Sgshapirodnl signed by a "trusted" CA. For example, even if we put verisigns 205264562Sgshapirodnl CA in CERTPath so we can authenticate users, we do not allow 205364562Sgshapirodnl them to abuse our server (they might be easier to get hold of, 205464562Sgshapirodnl but anyway). 205564562Sgshapirodnl so here is the trick: if the verification succeeded 205664562Sgshapirodnl we look up the cert issuer in the access map 205764562Sgshapirodnl (maybe after extracting a part with a regular expression) 205864562Sgshapirodnl if this returns RELAY we relay without further questions 205964562Sgshapirodnl if it returns SUBJECT we perform a similar check on the 206064562Sgshapirodnl cert subject. 206164562SgshapiroR$* $| OK $: $1 206264562SgshapiroR$* $| $* $@ NO not authenticated 206364562Sgshapiroifdef(`_ACCESS_TABLE_', `dnl 206464562Sgshapiroifdef(`_CERT_REGEX_ISSUER_', `dnl 206564562SgshapiroR$* $: $1 $| $(CERTIssuer $&{cert_issuer} $)', 206664562Sgshapiro`R$* $: $1 $| $&{cert_issuer}') 206764562SgshapiroR$* $| $+ $: $1 $| $(access CERTISSUER:$2 $) 206864562Sgshapirodnl use $# to stop further checks (delay_check) 206964562SgshapiroR$* $| RELAY $# RELAYCERTISSUER 207064562Sgshapiroifdef(`_CERT_REGEX_SUBJECT_', `dnl 207164562SgshapiroR$* $| SUBJECT $: $1 $| <@> $(CERTSubject $&{cert_subject} $)', 207264562Sgshapiro`R$* $| SUBJECT $: $1 $| <@> $&{cert_subject}') 207366494SgshapiroR$* $| <@> $+ $: $1 $| <@> $(access CERTSUBJECT:$2 $) 207464562SgshapiroR$* $| <@> RELAY $# RELAYCERTSUBJECT 207564562SgshapiroR$* $| $* $: $1', `dnl') 207664562Sgshapiro 207764562Sgshapiroundivert(9)dnl LOCAL_RULESETS 207864562Sgshapiroifdef(`_FFR_MILTER', ` 207938032Speter# 208038032Speter###################################################################### 208138032Speter###################################################################### 208238032Speter##### 208364562Sgshapiro`##### MAIL FILTER DEFINITIONS' 208464562Sgshapiro##### 208564562Sgshapiro###################################################################### 208664562Sgshapiro###################################################################### 208764562Sgshapiro_MAIL_FILTERS_') 208864562Sgshapiro# 208964562Sgshapiro###################################################################### 209064562Sgshapiro###################################################################### 209164562Sgshapiro##### 209238032Speter`##### MAILER DEFINITIONS' 209338032Speter##### 209438032Speter###################################################################### 209538032Speter###################################################################### 209664562Sgshapiroundivert(7)dnl MAILER_DEFINITIONS 209766494Sgshapiro 2098