Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2015
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 65.19 KB | None | 0 0
  1. #
  2. # Copyright (c) 1998-2005 Richard Nelson. All Rights Reserved.
  3. #
  4. # This file is used to configure Sendmail for use with Debian systems.
  5. #
  6. #
  7. # Copyright (c) 1998-2004, 2009 Sendmail, Inc. and its suppliers.
  8. # All rights reserved.
  9. # Copyright (c) 1983, 1995 Eric P. Allman. All rights reserved.
  10. # Copyright (c) 1988, 1993
  11. # The Regents of the University of California. All rights reserved.
  12. #
  13. # By using this file, you agree to the terms and conditions set
  14. # forth in the LICENSE file which can be found at the top level of
  15. # the sendmail distribution.
  16. #
  17. #
  18.  
  19. ######################################################################
  20. ######################################################################
  21. #####
  22. ##### SENDMAIL CONFIGURATION FILE
  23. #####
  24. ##### in /etc/mail
  25. ##### using /usr/share/sendmail/cf/ as configuration include directory
  26. #####
  27. ######################################################################
  28. #####
  29. ##### DO NOT EDIT THIS FILE! Only edit the source .mc file.
  30. #####
  31. ######################################################################
  32. ######################################################################
  33.  
  34. ##### $Id: cfhead.m4,v 8.120 2009/01/23 22:39:21 ca Exp $ #####
  35. ##### $Id: cf.m4,v 8.32 1999/02/07 07:26:14 gshapiro Exp $ #####
  36. ##### $Id: sendmail.mc, v 8.14.4-4.1ubuntu1 2014-02-11 13:02:08 cowboy Exp $ #####
  37. ##### $Id: autoconf.m4, v 8.14.4-4.1ubuntu1 2014-02-11 13:02:08 cowboy Exp $ #####
  38. ##### $Id: debian.m4, v 8.14.4-4.1ubuntu1 2014-02-11 13:02:08 cowboy Exp $ #####
  39. #
  40. #-------------------------------------------------------------------------
  41. #
  42. # Undocumented features are available in Debian Sendmail 8.14.4-4.1ubuntu1.
  43. # * none
  44. #
  45. # _FFR_ features are available in Debian Sendmail 8.14.4-4.1ubuntu1.
  46. # * milter
  47. # * -D_FFR_QUEUE_SCHED_DBG -D_FFR_SKIP_DOMAINS -D_FFR_GROUPREADABLEAUTHINFOFILE -D_FFR_DAEMON_NETUNIX -D_FFR_NO_PIPE -D_FFR_SHM_STATUS -D_FFR_RHS -D_FFR_MAIL_MACRO -D_FFR_QUEUEDELAY=1 -D_FFR_BADRCPT_SHUTDOWN -D_FFR_RESET_MACRO_GLOBALS -D_FFR_TLS_1 -D_FFR_DEAL_WITH_ERROR_SSL
  48. #-------------------------------------------------------------------------
  49. #
  50. # These _FFR_ features are for sendmail.mc processing
  51. #
  52.  
  53. #-------------------------------------------------------------------------
  54. ##### $Id: debian-mta.m4, v 8.14.4-4.1ubuntu1 2014-02-11 13:02:08 cowboy Exp $ #####
  55.  
  56.  
  57. ##### $Id: no_default_msa.m4,v 8.2 2001/02/14 05:03:22 gshapiro Exp $ #####
  58.  
  59. ##### $Id: use_cw_file.m4,v 8.11 2001/08/26 20:58:57 gshapiro Exp $ #####
  60.  
  61.  
  62. ##### $Id: access_db.m4,v 8.27 2006/07/06 21:10:10 ca Exp $ #####
  63.  
  64. ##### $Id: greet_pause.m4,v 1.4 2004/07/06 20:49:51 ca Exp $ #####
  65.  
  66. ##### $Id: delay_checks.m4,v 8.8 2000/12/05 18:50:45 ca Exp $ #####
  67.  
  68. ##### $Id: conncontrol.m4,v 1.4 2004/02/19 21:31:47 ca Exp $ #####
  69.  
  70.  
  71. ##### $Id: ratecontrol.m4,v 1.5 2004/02/19 21:31:47 ca Exp $ #####
  72.  
  73. ##### $Id: starttls.m4,v 8.14.4-4.1ubuntu1 2014-02-11 13:02:08 cowboy Exp $ #####
  74.  
  75.  
  76. ##### $Id: proto.m4,v 8.741 2009/12/11 00:04:53 ca Exp $ #####
  77.  
  78. # level 10 config file format
  79. V10/Berkeley
  80.  
  81. # override file safeties - setting this option compromises system security,
  82. # addressing the actual file configuration problem is preferred
  83. # need to set this before any file actions are encountered in the cf file
  84. O DontBlameSendmail= ,AssumeSafeChown,ForwardFileInGroupWritableDirPath,GroupWritableForwardFileSafe,GroupWritableIncludeFileSafe,IncludeFileInGroupWritableDirPath,DontWarnForwardFileInUnsafeDirPath,TrustStickyBit,NonRootSafeAddr,GroupWritableIncludeFile,GroupReadableaDefaultAuthInfoFile,GroupReadableKeyFile
  85.  
  86. # default LDAP map specification
  87. # need to set this now before any LDAP maps are defined
  88. #O LDAPDefaultSpec=-h localhost
  89.  
  90. ##################
  91. # local info #
  92. ##################
  93.  
  94. # my LDAP cluster
  95. # need to set this before any LDAP lookups are done (including classes)
  96. #D{sendmailMTACluster}$m
  97.  
  98. Cwlocalhost
  99. # file containing names of hosts for which we receive email
  100. Fw/etc/mail/local-host-names %[^\#]
  101.  
  102. # my official domain name
  103. # ... define this only if sendmail cannot automatically determine your domain
  104. #Dj$w.Foo.COM
  105.  
  106. # host/domain names ending with a token in class P are canonical
  107. CP.
  108.  
  109. # "Smart" relay host (may be null)
  110. DS
  111.  
  112.  
  113. # operators that cannot be in local usernames (i.e., network indicators)
  114. CO @ % !
  115.  
  116. # a class with just dot (for identifying canonical names)
  117. C..
  118.  
  119. # a class with just a left bracket (for identifying domain literals)
  120. C[[
  121.  
  122. # access_db acceptance class
  123. C{Accept}OK RELAY
  124.  
  125.  
  126. # Resolve map (to check if a host exists in check_mail)
  127. Kresolve host -a<OKR> -T<TEMP>
  128. C{ResOk}OKR
  129.  
  130.  
  131. # Hosts for which relaying is permitted ($=R)
  132. FR-o /etc/mail/relay-domains %[^\#]
  133.  
  134. # arithmetic map
  135. Karith arith
  136. # macro storage map
  137. Kmacro macro
  138. # possible values for TLS_connection in access map
  139. C{Tls}VERIFY ENCR
  140.  
  141. # who I send unqualified names to if FEATURE(stickyhost) is used
  142. # (null means deliver locally)
  143.  
  144. # who gets all local email traffic
  145. # ($R has precedence for unqualified names if FEATURE(stickyhost) is used)
  146.  
  147. # dequoting map
  148. Kdequote dequote
  149.  
  150. # class E: names that should be exposed as from this host, even if we masquerade
  151. # class L: names that should be delivered locally, even if we have a relay
  152. # class M: domains that should be converted to $M
  153. # class N: domains that should not be converted to $M
  154. #CL root
  155.  
  156.  
  157.  
  158. # my name for error messages
  159. DnMAILER-DAEMON
  160.  
  161.  
  162. # Access list database (for spam stomping)
  163. Kaccess hash -T<TMPF> /etc/mail/access
  164.  
  165. # Configuration version number
  166. DZ8.14.4/Debian-4.1ubuntu1
  167.  
  168.  
  169. ###############
  170. # Options #
  171. ###############
  172.  
  173. # strip message body to 7 bits on input?
  174. O SevenBitInput=False
  175.  
  176. # 8-bit data handling
  177. #O EightBitMode=pass8
  178.  
  179. # wait for alias file rebuild (default units: minutes)
  180. O AliasWait=10
  181.  
  182. # location of alias file
  183. O AliasFile=/etc/mail/aliases
  184.  
  185. # minimum number of free blocks on filesystem
  186. O MinFreeBlocks=100
  187.  
  188. # maximum message size
  189. #O MaxMessageSize=0
  190.  
  191. # substitution for space (blank) characters
  192. O BlankSub=.
  193.  
  194. # avoid connecting to "expensive" mailers on initial submission?
  195. O HoldExpensive=False
  196.  
  197. # checkpoint queue runs after every N successful deliveries
  198. #O CheckpointInterval=10
  199.  
  200. # default delivery mode
  201. O DeliveryMode=background
  202.  
  203. # error message header/file
  204. #O ErrorHeader=/etc/mail/error-header
  205.  
  206. # error mode
  207. #O ErrorMode=print
  208.  
  209. # save Unix-style "From_" lines at top of header?
  210. #O SaveFromLine=False
  211.  
  212. # queue file mode (qf files)
  213. O QueueFileMode=0640
  214.  
  215. # temporary file mode
  216. O TempFileMode=0640
  217.  
  218. # match recipients against GECOS field?
  219. #O MatchGECOS=False
  220.  
  221. # maximum hop count
  222. O MaxHopCount=100
  223.  
  224. # location of help file
  225. O HelpFile=/etc/mail/helpfile
  226.  
  227. # ignore dots as terminators in incoming messages?
  228. #O IgnoreDots=False
  229.  
  230. # name resolver options
  231. O ResolverOptions=+WorkAroundBrokenAAAA
  232.  
  233. # deliver MIME-encapsulated error messages?
  234. O SendMimeErrors=True
  235.  
  236. # Forward file search path
  237. O ForwardPath=$z/.forward.$w:$z/.forward
  238.  
  239. # open connection cache size
  240. O ConnectionCacheSize=2
  241.  
  242. # open connection cache timeout
  243. O ConnectionCacheTimeout=5m
  244.  
  245. # persistent host status directory
  246. #O HostStatusDirectory=.hoststat
  247.  
  248. # single thread deliveries (requires HostStatusDirectory)?
  249. #O SingleThreadDelivery=False
  250.  
  251. # use Errors-To: header?
  252. O UseErrorsTo=False
  253.  
  254. # log level
  255. O LogLevel=9
  256.  
  257. # send to me too, even in an alias expansion?
  258. O MeToo=True
  259.  
  260. # verify RHS in newaliases?
  261. O CheckAliases=False
  262.  
  263. # default messages to old style headers if no special punctuation?
  264. O OldStyleHeaders=True
  265.  
  266. # SMTP daemon options
  267.  
  268. O DaemonPortOptions=Family=inet, Name=MTA-v4, Port=smtp, Addr=127.0.0.1
  269. O DaemonPortOptions=Family=inet, Name=MSP-v4, Port=submission, M=Ea, Addr=127.0.0.1
  270.  
  271. # SMTP client options
  272. #O ClientPortOptions=Family=inet, Address=0.0.0.0
  273.  
  274. # Modifiers to define {daemon_flags} for direct submissions
  275. #O DirectSubmissionModifiers
  276.  
  277. # Use as mail submission program? See sendmail/SECURITY
  278. #O UseMSP
  279.  
  280. # privacy flags
  281. O PrivacyOptions=needmailhelo,needexpnhelo,needvrfyhelo,restrictqrun,restrictexpand,nobodyreturn,authwarnings
  282.  
  283. # who (if anyone) should get extra copies of error messages
  284. #O PostmasterCopy=Postmaster
  285.  
  286. # slope of queue-only function
  287. #O QueueFactor=600000
  288.  
  289. # limit on number of concurrent queue runners
  290. #O MaxQueueChildren
  291.  
  292. # maximum number of queue-runners per queue-grouping with multiple queues
  293. O MaxRunnersPerQueue=5
  294.  
  295. # priority of queue runners (nice(3))
  296. #O NiceQueueRun
  297.  
  298. # shall we sort the queue by hostname first?
  299. #O QueueSortOrder=priority
  300.  
  301. # minimum time in queue before retry
  302. #O MinQueueAge=30m
  303.  
  304. # how many jobs can you process in the queue?
  305. #O MaxQueueRunSize=0
  306.  
  307. # perform initial split of envelope without checking MX records
  308. #O FastSplit=1
  309.  
  310. # queue directory
  311. O QueueDirectory=/var/spool/mqueue
  312.  
  313. # key for shared memory; 0 to turn off, -1 to auto-select
  314. #O SharedMemoryKey=0
  315.  
  316. # file to store auto-selected key for shared memory (SharedMemoryKey = -1)
  317. #O SharedMemoryKeyFile
  318.  
  319. # timeouts (many of these)
  320. #O Timeout.initial=5m
  321. #O Timeout.connect=5m
  322. #O Timeout.aconnect=0s
  323. O Timeout.iconnect=2m
  324. #O Timeout.helo=5m
  325. O Timeout.mail=2m
  326. #O Timeout.rcpt=1h
  327. O Timeout.datainit=2m
  328. #O Timeout.datablock=1h
  329. #O Timeout.datafinal=1h
  330. O Timeout.rset=1m
  331. O Timeout.quit=2m
  332. #O Timeout.misc=2m
  333. O Timeout.command=5m
  334. O Timeout.ident=5s
  335. #O Timeout.fileopen=60s
  336. #O Timeout.control=2m
  337. O Timeout.queuereturn=5d
  338. #O Timeout.queuereturn.normal=5d
  339. #O Timeout.queuereturn.urgent=2d
  340. #O Timeout.queuereturn.non-urgent=7d
  341. #O Timeout.queuereturn.dsn=5d
  342. O Timeout.queuewarn=4h
  343. #O Timeout.queuewarn.normal=4h
  344. #O Timeout.queuewarn.urgent=1h
  345. #O Timeout.queuewarn.non-urgent=12h
  346. #O Timeout.queuewarn.dsn=4h
  347. #O Timeout.hoststatus=30m
  348. #O Timeout.resolver.retrans=5s
  349. #O Timeout.resolver.retrans.first=5s
  350. #O Timeout.resolver.retrans.normal=5s
  351. #O Timeout.resolver.retry=4
  352. #O Timeout.resolver.retry.first=4
  353. #O Timeout.resolver.retry.normal=4
  354. #O Timeout.lhlo=2m
  355. #O Timeout.auth=10m
  356. O Timeout.starttls=2m
  357.  
  358. # time for DeliverBy; extension disabled if less than 0
  359. #O DeliverByMin=0
  360.  
  361. # should we not prune routes in route-addr syntax addresses?
  362. #O DontPruneRoutes=False
  363.  
  364. # queue up everything before forking?
  365. O SuperSafe=True
  366.  
  367. # status file
  368. O StatusFile=/var/lib/sendmail/sendmail.st
  369.  
  370. # time zone handling:
  371. # if undefined, use system default
  372. # if defined but null, use TZ envariable passed in
  373. # if defined and non-null, use that info
  374. #O TimeZoneSpec=
  375.  
  376. # default UID (can be username or userid:groupid)
  377. O DefaultUser=mail:mail
  378.  
  379. # list of locations of user database file (null means no lookup)
  380. #O UserDatabaseSpec=/etc/mail/userdb
  381.  
  382. # fallback MX host
  383. #O FallbackMXhost=fall.back.host.net
  384.  
  385. # fallback smart host
  386. #O FallbackSmartHost=fall.back.host.net
  387.  
  388. # if we are the best MX host for a site, try it directly instead of config err
  389. #O TryNullMXList=False
  390.  
  391. # load average at which we just queue messages
  392. #O QueueLA=8
  393.  
  394. # load average at which we refuse connections
  395. #O RefuseLA=12
  396.  
  397. # log interval when refusing connections for this long
  398. #O RejectLogInterval=3h
  399.  
  400. # load average at which we delay connections; 0 means no limit
  401. #O DelayLA=0
  402.  
  403. # maximum number of children we allow at one time
  404. O MaxDaemonChildren=0
  405.  
  406. # maximum number of new connections per second
  407. O ConnectionRateThrottle=15
  408.  
  409. # Width of the window
  410. O ConnectionRateWindowSize=10m
  411.  
  412. # work recipient factor
  413. #O RecipientFactor=30000
  414.  
  415. # deliver each queued job in a separate process?
  416. #O ForkEachJob=False
  417.  
  418. # work class factor
  419. #O ClassFactor=1800
  420.  
  421. # work time factor
  422. #O RetryFactor=90000
  423.  
  424. # default character set
  425. #O DefaultCharSet=unknown-8bit
  426.  
  427. # service switch file (name hardwired on Solaris, Ultrix, OSF/1, others)
  428. #O ServiceSwitchFile=/etc/mail/service.switch
  429.  
  430. # hosts file (normally /etc/hosts)
  431. #O HostsFile=/etc/hosts
  432.  
  433. # dialup line delay on connection failure
  434. #O DialDelay=0s
  435.  
  436. # action to take if there are no recipients in the message
  437. #O NoRecipientAction=none
  438.  
  439. # chrooted environment for writing to files
  440. O SafeFileEnvironment=/
  441.  
  442. # are colons OK in addresses?
  443. #O ColonOkInAddr=True
  444.  
  445. # shall I avoid expanding CNAMEs (violates protocols)?
  446. #O DontExpandCnames=False
  447.  
  448. # SMTP initial login message (old $e macro)
  449. O SmtpGreetingMessage=$j Sendmail $v/$Z; $b; (No UCE/UBE) $?{client_addr}logging access from: ${client_name}(${client_resolve})-$_$.
  450.  
  451. # UNIX initial From header format (old $l macro)
  452. O UnixFromLine=From $g $d
  453.  
  454. # From: lines that have embedded newlines are unwrapped onto one line
  455. #O SingleLineFromHeader=False
  456.  
  457. # Allow HELO SMTP command that does not include a host name
  458. #O AllowBogusHELO=False
  459.  
  460. # Characters to be quoted in a full name phrase (@,;:\()[] are automatic)
  461. O MustQuoteChars=.'
  462.  
  463. # delimiter (operator) characters (old $o macro)
  464. O OperatorChars=.:%@!^/[]+
  465.  
  466. # shall I avoid calling initgroups(3) because of high NIS costs?
  467. #O DontInitGroups=False
  468.  
  469. # are group-writable :include: and .forward files (un)trustworthy?
  470. # True (the default) means they are not trustworthy.
  471. #O UnsafeGroupWrites=True
  472.  
  473.  
  474. # where do errors that occur when sending errors get sent?
  475. #O DoubleBounceAddress=postmaster
  476.  
  477. # issue temporary errors (4xy) instead of permanent errors (5xy)?
  478. #O SoftBounce=False
  479.  
  480. # where to save bounces if all else fails
  481. O DeadLetterDrop=/var/lib/sendmail/dead.letter
  482.  
  483. # what user id do we assume for the majority of the processing?
  484. #O RunAsUser=sendmail
  485.  
  486. # maximum number of recipients per SMTP envelope
  487. #O MaxRecipientsPerMessage=0
  488.  
  489. # limit the rate recipients per SMTP envelope are accepted
  490. # once the threshold number of recipients have been rejected
  491. O BadRcptThrottle=3
  492.  
  493.  
  494. # shall we get local names from our installed interfaces?
  495. #O DontProbeInterfaces=False
  496.  
  497. # Return-Receipt-To: header implies DSN request
  498. O RrtImpliesDsn=False
  499.  
  500. # override connection address (for testing)
  501. #O ConnectOnlyTo=0.0.0.0
  502.  
  503. # Trusted user for file ownership and starting the daemon
  504. O TrustedUser=smmta
  505.  
  506. # Control socket for daemon management
  507. O ControlSocketName=/var/run/sendmail/mta/smcontrol
  508.  
  509. # Maximum MIME header length to protect MUAs
  510. #O MaxMimeHeaderLength=0/0
  511.  
  512. # Maximum length of the sum of all headers
  513. #O MaxHeadersLength=32768
  514.  
  515. # Maximum depth of alias recursion
  516. #O MaxAliasRecursion=10
  517.  
  518. # location of pid file
  519. O PidFile=/var/run/sendmail/mta/sendmail.pid
  520.  
  521. # Prefix string for the process title shown on 'ps' listings
  522. O ProcessTitlePrefix=MTA
  523.  
  524. # Data file (df) memory-buffer file maximum size
  525. #O DataFileBufferSize=4096
  526.  
  527. # Transcript file (xf) memory-buffer file maximum size
  528. #O XscriptFileBufferSize=4096
  529.  
  530. # lookup type to find information about local mailboxes
  531. #O MailboxDatabase=pw
  532.  
  533. # override compile time flag REQUIRES_DIR_FSYNC
  534. #O RequiresDirfsync=true
  535.  
  536. # list of authentication mechanisms
  537. #O AuthMechanisms=EXTERNAL GSSAPI KERBEROS_V4 DIGEST-MD5 CRAM-MD5
  538.  
  539. # Authentication realm
  540. #O AuthRealm
  541.  
  542. # default authentication information for outgoing connections
  543. #O DefaultAuthInfo=/etc/mail/default-auth-info
  544.  
  545. # SMTP AUTH flags
  546. #O AuthOptions
  547.  
  548. # SMTP AUTH maximum encryption strength
  549. #O AuthMaxBits
  550.  
  551. # SMTP STARTTLS server options
  552. O TLSSrvOptions=V
  553.  
  554.  
  555. # Input mail filters
  556. O InputMailFilters=opendkim
  557.  
  558. # Milter options
  559. #O Milter.LogLevel
  560. O Milter.macros.connect=j, _, {daemon_name}, {if_name}, {if_addr}
  561. O Milter.macros.helo={tls_version}, {cipher}, {cipher_bits}, {cert_subject}, {cert_issuer}
  562. O Milter.macros.envfrom=i, {auth_type}, {auth_authen}, {auth_ssf}, {auth_author}, {mail_mailer}, {mail_host}, {mail_addr}
  563. O Milter.macros.envrcpt={rcpt_mailer}, {rcpt_host}, {rcpt_addr}
  564. O Milter.macros.eom={msg_id}
  565. #O Milter.macros.eoh
  566. #O Milter.macros.data
  567.  
  568. # CA directory
  569. O CACertPath=/etc/ssl/certs
  570. # CA file
  571. O CACertFile=/etc/mail/tls/sendmail-server.crt
  572. # Server Cert
  573. O ServerCertFile=/etc/mail/tls/sendmail-server.crt
  574. # Server private key
  575. O ServerKeyFile=/etc/mail/tls/sendmail-common.key
  576. # Client Cert
  577. O ClientCertFile=/etc/mail/tls/sendmail-client.crt
  578. # Client private key
  579. O ClientKeyFile=/etc/mail/tls/sendmail-common.key
  580. # File containing certificate revocation lists
  581. #O CRLFile
  582. # DHParameters (only required if DSA/DH is used)
  583. O DHParameters=/etc/mail/tls/sendmail-common.prm
  584. # Random data source (required for systems without /dev/urandom under OpenSSL)
  585. #O RandFile
  586.  
  587. # Maximum number of "useless" commands before slowing down
  588. #O MaxNOOPCommands=20
  589.  
  590. # Name to use for EHLO (defaults to $j)
  591. #O HeloName
  592.  
  593. ############################
  594. # QUEUE GROUP DEFINITIONS #
  595. ############################
  596.  
  597.  
  598. ###########################
  599. # Message precedences #
  600. ###########################
  601.  
  602. Pfirst-class=0
  603. Pspecial-delivery=100
  604. Plist=-30
  605. Pbulk=-60
  606. Pjunk=-100
  607.  
  608. #####################
  609. # Trusted users #
  610. #####################
  611.  
  612. # this is equivalent to setting class "t"
  613. #Ft/etc/mail/trusted-users %[^\#]
  614. Troot
  615. Tdaemon
  616. Tuucp
  617.  
  618. #########################
  619. # Format of headers #
  620. #########################
  621.  
  622. H?P?Return-Path: <$g>
  623. HReceived: $?sfrom $s $.$?_($?s$|from $.$_)
  624. $.$?{auth_type}(authenticated$?{auth_ssf} bits=${auth_ssf}$.)
  625. $.by $j ($v/$Z)$?r with $r$. id $i$?{tls_version}
  626. (version=${tls_version} cipher=${cipher} bits=${cipher_bits} verify=${verify})$.$?u
  627. for $u; $|;
  628. $.$b
  629. H?D?Resent-Date: $a
  630. H?D?Date: $a
  631. H?F?Resent-From: $?x$x <$g>$|$g$.
  632. H?F?From: $?x$x <$g>$|$g$.
  633. H?x?Full-Name: $x
  634. # HPosted-Date: $a
  635. # H?l?Received-Date: $b
  636. H?M?Resent-Message-Id: <$t.$i@$j>
  637. H?M?Message-Id: <$t.$i@$j>
  638.  
  639. #
  640. ######################################################################
  641. ######################################################################
  642. #####
  643. ##### REWRITING RULES
  644. #####
  645. ######################################################################
  646. ######################################################################
  647.  
  648. ############################################
  649. ### Ruleset 3 -- Name Canonicalization ###
  650. ############################################
  651. Scanonify=3
  652.  
  653. # handle null input (translate to <@> special case)
  654. R$@ $@ <@>
  655.  
  656. # strip group: syntax (not inside angle brackets!) and trailing semicolon
  657. R$* $: $1 <@> mark addresses
  658. R$* < $* > $* <@> $: $1 < $2 > $3 unmark <addr>
  659. R@ $* <@> $: @ $1 unmark @host:...
  660. R$* [ IPv6 : $+ ] <@> $: $1 [ IPv6 : $2 ] unmark IPv6 addr
  661. R$* :: $* <@> $: $1 :: $2 unmark node::addr
  662. R:include: $* <@> $: :include: $1 unmark :include:...
  663. R$* : $* [ $* ] $: $1 : $2 [ $3 ] <@> remark if leading colon
  664. R$* : $* <@> $: $2 strip colon if marked
  665. R$* <@> $: $1 unmark
  666. R$* ; $1 strip trailing semi
  667. R$* < $+ :; > $* $@ $2 :; <@> catch <list:;>
  668. R$* < $* ; > $1 < $2 > bogus bracketed semi
  669.  
  670. # null input now results from list:; syntax
  671. R$@ $@ :; <@>
  672.  
  673. # strip angle brackets -- note RFC733 heuristic to get innermost item
  674. R$* $: < $1 > housekeeping <>
  675. R$+ < $* > < $2 > strip excess on left
  676. R< $* > $+ < $1 > strip excess on right
  677. R<> $@ < @ > MAIL FROM:<> case
  678. R< $+ > $: $1 remove housekeeping <>
  679.  
  680. # strip route address <@a,@b,@c:user@d> -> <user@d>
  681. R@ $+ , $+ $2
  682. R@ [ $* ] : $+ $2
  683. R@ $+ : $+ $2
  684.  
  685. # find focus for list syntax
  686. R $+ : $* ; @ $+ $@ $>Canonify2 $1 : $2 ; < @ $3 > list syntax
  687. R $+ : $* ; $@ $1 : $2; list syntax
  688.  
  689. # find focus for @ syntax addresses
  690. R$+ @ $+ $: $1 < @ $2 > focus on domain
  691. R$+ < $+ @ $+ > $1 $2 < @ $3 > move gaze right
  692. R$+ < @ $+ > $@ $>Canonify2 $1 < @ $2 > already canonical
  693.  
  694.  
  695. # convert old-style addresses to a domain-based address
  696. R$- ! $+ $@ $>Canonify2 $2 < @ $1 .UUCP > resolve uucp names
  697. R$+ . $- ! $+ $@ $>Canonify2 $3 < @ $1 . $2 > domain uucps
  698. R$+ ! $+ $@ $>Canonify2 $2 < @ $1 .UUCP > uucp subdomains
  699.  
  700. # if we have % signs, take the rightmost one
  701. R$* % $* $1 @ $2 First make them all @s.
  702. R$* @ $* @ $* $1 % $2 @ $3 Undo all but the last.
  703. R$* @ $* $@ $>Canonify2 $1 < @ $2 > Insert < > and finish
  704.  
  705. # else we must be a local name
  706. R$* $@ $>Canonify2 $1
  707.  
  708.  
  709. ################################################
  710. ### Ruleset 96 -- bottom half of ruleset 3 ###
  711. ################################################
  712.  
  713. SCanonify2=96
  714.  
  715. # handle special cases for local names
  716. R$* < @ localhost > $* $: $1 < @ $j . > $2 no domain at all
  717. R$* < @ localhost . $m > $* $: $1 < @ $j . > $2 local domain
  718. R$* < @ localhost . UUCP > $* $: $1 < @ $j . > $2 .UUCP domain
  719.  
  720. # check for IPv4/IPv6 domain literal
  721. R$* < @ [ $+ ] > $* $: $1 < @@ [ $2 ] > $3 mark [addr]
  722. R$* < @@ $=w > $* $: $1 < @ $j . > $3 self-literal
  723. R$* < @@ $+ > $* $@ $1 < @ $2 > $3 canon IP addr
  724.  
  725.  
  726.  
  727.  
  728.  
  729. # if really UUCP, handle it immediately
  730.  
  731. # try UUCP traffic as a local address
  732. R$* < @ $+ . UUCP > $* $: $1 < @ $[ $2 $] . UUCP . > $3
  733. R$* < @ $+ . . UUCP . > $* $@ $1 < @ $2 . > $3
  734.  
  735. # hostnames ending in class P are always canonical
  736. R$* < @ $* $=P > $* $: $1 < @ $2 $3 . > $4
  737. R$* < @ $* $~P > $* $: $&{daemon_flags} $| $1 < @ $2 $3 > $4
  738. R$* CC $* $| $* < @ $+.$+ > $* $: $3 < @ $4.$5 . > $6
  739. R$* CC $* $| $* $: $3
  740. # pass to name server to make hostname canonical
  741. R$* $| $* < @ $* > $* $: $2 < @ $[ $3 $] > $4
  742. R$* $| $* $: $2
  743.  
  744. # local host aliases and pseudo-domains are always canonical
  745. R$* < @ $=w > $* $: $1 < @ $2 . > $3
  746. R$* < @ $=M > $* $: $1 < @ $2 . > $3
  747. R$* < @ $* . . > $* $1 < @ $2 . > $3
  748.  
  749.  
  750. ##################################################
  751. ### Ruleset 4 -- Final Output Post-rewriting ###
  752. ##################################################
  753. Sfinal=4
  754.  
  755. R$+ :; <@> $@ $1 : handle <list:;>
  756. R$* <@> $@ handle <> and list:;
  757.  
  758. # strip trailing dot off possibly canonical name
  759. R$* < @ $+ . > $* $1 < @ $2 > $3
  760.  
  761. # eliminate internal code
  762. R$* < @ *LOCAL* > $* $1 < @ $j > $2
  763.  
  764. # externalize local domain info
  765. R$* < $+ > $* $1 $2 $3 defocus
  766. R@ $+ : @ $+ : $+ @ $1 , @ $2 : $3 <route-addr> canonical
  767. R@ $* $@ @ $1 ... and exit
  768.  
  769. # UUCP must always be presented in old form
  770. R$+ @ $- . UUCP $2!$1 [email protected] => h!u
  771.  
  772. # delete duplicate local names
  773. R$+ % $=w @ $=w $1 @ $2 u%host@host => u@host
  774.  
  775.  
  776.  
  777. ##############################################################
  778. ### Ruleset 97 -- recanonicalize and call ruleset zero ###
  779. ### (used for recursive calls) ###
  780. ##############################################################
  781.  
  782. SRecurse=97
  783. R$* $: $>canonify $1
  784. R$* $@ $>parse $1
  785.  
  786.  
  787. ######################################
  788. ### Ruleset 0 -- Parse Address ###
  789. ######################################
  790.  
  791. Sparse=0
  792.  
  793. R$* $: $>Parse0 $1 initial parsing
  794. R<@> $#local $: <@> special case error msgs
  795. R$* $: $>ParseLocal $1 handle local hacks
  796. R$* $: $>Parse1 $1 final parsing
  797.  
  798. #
  799. # Parse0 -- do initial syntax checking and eliminate local addresses.
  800. # This should either return with the (possibly modified) input
  801. # or return with a #error mailer. It should not return with a
  802. # #mailer other than the #error mailer.
  803. #
  804.  
  805. SParse0
  806. R<@> $@ <@> special case error msgs
  807. R$* : $* ; <@> $#error $@ 5.1.3 $: "553 List:; syntax illegal for recipient addresses"
  808. R@ <@ $* > < @ $1 > catch "@@host" bogosity
  809. R<@ $+> $#error $@ 5.1.3 $: "553 User address required"
  810. R$+ <@> $#error $@ 5.1.3 $: "553 Hostname required"
  811. R$* $: <> $1
  812. R<> $* < @ [ $* ] : $+ > $* $1 < @ [ $2 ] : $3 > $4
  813. R<> $* < @ [ $* ] , $+ > $* $1 < @ [ $2 ] , $3 > $4
  814. R<> $* < @ [ $* ] $+ > $* $#error $@ 5.1.2 $: "553 Invalid address"
  815. R<> $* < @ [ $+ ] > $* $1 < @ [ $2 ] > $3
  816. R<> $* <$* : $* > $* $#error $@ 5.1.3 $: "553 Colon illegal in host name part"
  817. R<> $* $1
  818. R$* < @ . $* > $* $#error $@ 5.1.2 $: "553 Invalid host name"
  819. R$* < @ $* .. $* > $* $#error $@ 5.1.2 $: "553 Invalid host name"
  820. R$* < @ $* @ > $* $#error $@ 5.1.2 $: "553 Invalid route address"
  821. R$* @ $* < @ $* > $* $#error $@ 5.1.3 $: "553 Invalid route address"
  822. R$* , $~O $* $#error $@ 5.1.3 $: "553 Invalid route address"
  823.  
  824.  
  825. # now delete the local info -- note $=O to find characters that cause forwarding
  826. R$* < @ > $* $@ $>Parse0 $>canonify $1 user@ => user
  827. R< @ $=w . > : $* $@ $>Parse0 $>canonify $2 @here:... -> ...
  828. R$- < @ $=w . > $: $(dequote $1 $) < @ $2 . > dequote "foo"@here
  829. R< @ $+ > $#error $@ 5.1.3 $: "553 User address required"
  830. R$* $=O $* < @ $=w . > $@ $>Parse0 $>canonify $1 $2 $3 ...@here -> ...
  831. R$- $: $(dequote $1 $) < @ *LOCAL* > dequote "foo"
  832. R< @ *LOCAL* > $#error $@ 5.1.3 $: "553 User address required"
  833. R$* $=O $* < @ *LOCAL* >
  834. $@ $>Parse0 $>canonify $1 $2 $3 ...@*LOCAL* -> ...
  835. R$* < @ *LOCAL* > $: $1
  836.  
  837. #
  838. # Parse1 -- the bottom half of ruleset 0.
  839. #
  840.  
  841. SParse1
  842.  
  843. # handle numeric address spec
  844. R$* < @ [ $+ ] > $* $: $>ParseLocal $1 < @ [ $2 ] > $3 numeric internet spec
  845. R$* < @ [ $+ ] > $* $: $1 < @ [ $2 ] : $S > $3 Add smart host to path
  846. R$* < @ [ $+ ] : > $* $#esmtp $@ [$2] $: $1 < @ [$2] > $3 no smarthost: send
  847. R$* < @ [ $+ ] : $- : $*> $* $#$3 $@ $4 $: $1 < @ [$2] > $5 smarthost with mailer
  848. R$* < @ [ $+ ] : $+ > $* $#esmtp $@ $3 $: $1 < @ [$2] > $4 smarthost without mailer
  849.  
  850.  
  851. # short circuit local delivery so forwarded email works
  852.  
  853.  
  854. R$=L < @ $=w . > $#local $: @ $1 special local names
  855. R$+ < @ $=w . > $#local $: $1 regular local name
  856.  
  857.  
  858. # resolve remotely connected UUCP links (if any)
  859.  
  860. # resolve fake top level domains by forwarding to other hosts
  861.  
  862.  
  863.  
  864. # pass names that still have a host to a smarthost (if defined)
  865. R$* < @ $* > $* $: $>MailerToTriple < $S > $1 < @ $2 > $3 glue on smarthost name
  866.  
  867. # deal with other remote names
  868. R$* < @$* > $* $#esmtp $@ $2 $: $1 < @ $2 > $3 [email protected]
  869.  
  870. # handle locally delivered names
  871. R$=L $#local $: @ $1 special local names
  872. R$+ $#local $: $1 regular local names
  873.  
  874. ###########################################################################
  875. ### Ruleset 5 -- special rewriting after aliases have been expanded ###
  876. ###########################################################################
  877.  
  878. SLocal_localaddr
  879. Slocaladdr=5
  880. R$+ $: $1 $| $>"Local_localaddr" $1
  881. R$+ $| $#ok $@ $1 no change
  882. R$+ $| $#$* $#$2
  883. R$+ $| $* $: $1
  884.  
  885.  
  886.  
  887.  
  888. # deal with plussed users so aliases work nicely
  889. R$+ + * $#local $@ $&h $: $1
  890. R$+ + $* $#local $@ + $2 $: $1 + *
  891.  
  892. # prepend an empty "forward host" on the front
  893. R$+ $: <> $1
  894.  
  895.  
  896.  
  897. R< > $+ $: < $H > $1 try hub
  898. R< > $+ $: < $R > $1 try relay
  899. R< > $+ $: < > < $1 <> $&h > nope, restore +detail
  900.  
  901. R< > < $+ <> + $* > $: < > < $1 + $2 > check whether +detail
  902. R< > < $+ <> $* > $: < > < $1 > else discard
  903. R< > < $+ + $* > $* < > < $1 > + $2 $3 find the user part
  904. R< > < $+ > + $* $#local $@ $2 $: @ $1 strip the extra +
  905. R< > < $+ > $@ $1 no +detail
  906. R$+ $: $1 <> $&h add +detail back in
  907.  
  908. R$+ <> + $* $: $1 + $2 check whether +detail
  909. R$+ <> $* $: $1 else discard
  910. R< local : $* > $* $: $>MailerToTriple < local : $1 > $2 no host extension
  911. R< error : $* > $* $: $>MailerToTriple < error : $1 > $2 no host extension
  912.  
  913. R< $~[ : $+ > $+ $: $>MailerToTriple < $1 : $2 > $3 < @ $2 >
  914.  
  915. R< $+ > $+ $@ $>MailerToTriple < $1 > $2 < @ $1 >
  916.  
  917.  
  918. ###################################################################
  919. ### Ruleset 95 -- canonify mailer:[user@]host syntax to triple ###
  920. ###################################################################
  921.  
  922. SMailerToTriple=95
  923. R< > $* $@ $1 strip off null relay
  924. R< error : $-.$-.$- : $+ > $* $#error $@ $1.$2.$3 $: $4
  925. R< error : $- : $+ > $* $#error $@ $(dequote $1 $) $: $2
  926. R< error : $+ > $* $#error $: $1
  927. R< local : $* > $* $>CanonLocal < $1 > $2
  928. R< $~[ : $+ @ $+ > $*<$*>$* $# $1 $@ $3 $: $2<@$3> use literal user
  929. R< $~[ : $+ > $* $# $1 $@ $2 $: $3 try qualified mailer
  930. R< $=w > $* $@ $2 delete local host
  931. R< $+ > $* $#relay $@ $1 $: $2 use unqualified mailer
  932.  
  933. ###################################################################
  934. ### Ruleset CanonLocal -- canonify local: syntax ###
  935. ###################################################################
  936.  
  937. SCanonLocal
  938. # strip local host from routed addresses
  939. R< $* > < @ $+ > : $+ $@ $>Recurse $3
  940. R< $* > $+ $=O $+ < @ $+ > $@ $>Recurse $2 $3 $4
  941.  
  942. # strip trailing dot from any host name that may appear
  943. R< $* > $* < @ $* . > $: < $1 > $2 < @ $3 >
  944.  
  945. # handle local: syntax -- use old user, either with or without host
  946. R< > $* < @ $* > $* $#local $@ $1@$2 $: $1
  947. R< > $+ $#local $@ $1 $: $1
  948.  
  949. # handle local:user@host syntax -- ignore host part
  950. R< $+ @ $+ > $* < @ $* > $: < $1 > $3 < @ $4 >
  951.  
  952. # handle local:user syntax
  953. R< $+ > $* <@ $* > $* $#local $@ $2@$3 $: $1
  954. R< $+ > $* $#local $@ $2 $: $1
  955.  
  956. ###################################################################
  957. ### Ruleset 93 -- convert header names to masqueraded form ###
  958. ###################################################################
  959.  
  960. SMasqHdr=93
  961.  
  962.  
  963. # do not masquerade anything in class N
  964. R$* < @ $* $=N . > $@ $1 < @ $2 $3 . >
  965.  
  966. R$* < @ *LOCAL* > $@ $1 < @ $j . >
  967.  
  968. ###################################################################
  969. ### Ruleset 94 -- convert envelope names to masqueraded form ###
  970. ###################################################################
  971.  
  972. SMasqEnv=94
  973. R$* < @ *LOCAL* > $* $: $1 < @ $j . > $2
  974.  
  975. ###################################################################
  976. ### Ruleset 98 -- local part of ruleset zero (can be null) ###
  977. ###################################################################
  978.  
  979. SParseLocal=98
  980.  
  981.  
  982.  
  983. ######################################################################
  984. ### D: LookUpDomain -- search for domain in access database
  985. ###
  986. ### Parameters:
  987. ### <$1> -- key (domain name)
  988. ### <$2> -- default (what to return if not found in db)
  989. ### <$3> -- mark (must be <(!|+) single-token>)
  990. ### ! does lookup only with tag
  991. ### + does lookup with and without tag
  992. ### <$4> -- passthru (additional data passed unchanged through)
  993. ######################################################################
  994.  
  995. SD
  996. R<$*> <$+> <$- $-> <$*> $: < $(access $4:$1 $: ? $) > <$1> <$2> <$3 $4> <$5>
  997. R<?> <$+> <$+> <+ $-> <$*> $: < $(access $1 $: ? $) > <$1> <$2> <+ $3> <$4>
  998. R<SKIP> <$+> <$+> <$- $-> <$*> $@ <$2> <$5>
  999. R<?> <[$+.$-]> <$+> <$- $-> <$*> $@ $>D <[$1]> <$3> <$4 $5> <$6>
  1000. R<?> <[$+::$-]> <$+> <$- $-> <$*> $: $>D <[$1]> <$3> <$4 $5> <$6>
  1001. R<?> <[$+:$-]> <$+> <$- $-> <$*> $: $>D <[$1]> <$3> <$4 $5> <$6>
  1002. R<?> <$+.$+> <$+> <$- $-> <$*> $@ $>D <$2> <$3> <$4 $5> <$6>
  1003. R<?> <$+> <$+> <$- $-> <$*> $@ <$2> <$5>
  1004. R<$* <TMPF>> <$+> <$+> <$- $-> <$*> $@ <<TMPF>> <$6>
  1005. R<$*> <$+> <$+> <$- $-> <$*> $@ <$1> <$6>
  1006.  
  1007. ######################################################################
  1008. ### A: LookUpAddress -- search for host address in access database
  1009. ###
  1010. ### Parameters:
  1011. ### <$1> -- key (dot quadded host address)
  1012. ### <$2> -- default (what to return if not found in db)
  1013. ### <$3> -- mark (must be <(!|+) single-token>)
  1014. ### ! does lookup only with tag
  1015. ### + does lookup with and without tag
  1016. ### <$4> -- passthru (additional data passed through)
  1017. ######################################################################
  1018.  
  1019. SA
  1020. R<$+> <$+> <$- $-> <$*> $: < $(access $4:$1 $: ? $) > <$1> <$2> <$3 $4> <$5>
  1021. R<?> <$+> <$+> <+ $-> <$*> $: < $(access $1 $: ? $) > <$1> <$2> <+ $3> <$4>
  1022. R<SKIP> <$+> <$+> <$- $-> <$*> $@ <$2> <$5>
  1023. R<?> <$+::$-> <$+> <$- $-> <$*> $@ $>A <$1> <$3> <$4 $5> <$6>
  1024. R<?> <$+:$-> <$+> <$- $-> <$*> $@ $>A <$1> <$3> <$4 $5> <$6>
  1025. R<?> <$+.$-> <$+> <$- $-> <$*> $@ $>A <$1> <$3> <$4 $5> <$6>
  1026. R<?> <$+> <$+> <$- $-> <$*> $@ <$2> <$5>
  1027. R<$* <TMPF>> <$+> <$+> <$- $-> <$*> $@ <<TMPF>> <$6>
  1028. R<$*> <$+> <$+> <$- $-> <$*> $@ <$1> <$6>
  1029.  
  1030. ######################################################################
  1031. ### CanonAddr -- Convert an address into a standard form for
  1032. ### relay checking. Route address syntax is
  1033. ### crudely converted into a %-hack address.
  1034. ###
  1035. ### Parameters:
  1036. ### $1 -- full recipient address
  1037. ###
  1038. ### Returns:
  1039. ### parsed address, not in source route form
  1040. ######################################################################
  1041.  
  1042. SCanonAddr
  1043. R$* $: $>Parse0 $>canonify $1 make domain canonical
  1044.  
  1045.  
  1046. ######################################################################
  1047. ### ParseRecipient -- Strip off hosts in $=R as well as possibly
  1048. ### $* $=m or the access database.
  1049. ### Check user portion for host separators.
  1050. ###
  1051. ### Parameters:
  1052. ### $1 -- full recipient address
  1053. ###
  1054. ### Returns:
  1055. ### parsed, non-local-relaying address
  1056. ######################################################################
  1057.  
  1058. SParseRecipient
  1059. R$* $: <?> $>CanonAddr $1
  1060. R<?> $* < @ $* . > <?> $1 < @ $2 > strip trailing dots
  1061. R<?> $- < @ $* > $: <?> $(dequote $1 $) < @ $2 > dequote local part
  1062.  
  1063. # if no $=O character, no host in the user portion, we are done
  1064. R<?> $* $=O $* < @ $* > $: <NO> $1 $2 $3 < @ $4>
  1065. R<?> $* $@ $1
  1066.  
  1067.  
  1068. R<NO> $* < @ $* $=R > $: <RELAY> $1 < @ $2 $3 >
  1069. R<NO> $* < @ $+ > $: $>D <$2> <NO> <+ To> <$1 < @ $2 >>
  1070. R<$+> <$+> $: <$1> $2
  1071.  
  1072.  
  1073.  
  1074. R<RELAY> $* < @ $* > $@ $>ParseRecipient $1
  1075. R<$+> $* $@ $2
  1076.  
  1077.  
  1078. ######################################################################
  1079. ### check_relay -- check hostname/address on SMTP startup
  1080. ######################################################################
  1081.  
  1082. Scheck_relay
  1083. R$* $: $>"RateControl" dummy
  1084. R$* $: $>"ConnControl" dummy
  1085.  
  1086. SLocal_check_relay
  1087. Scheckrelay
  1088. R$* $: $1 $| $>"Local_check_relay" $1
  1089. R$* $| $* $| $#$* $#$3
  1090. R$* $| $* $| $* $@ $>"Basic_check_relay" $1 $| $2
  1091.  
  1092. SBasic_check_relay
  1093. # check for deferred delivery mode
  1094. R$* $: < $&{deliveryMode} > $1
  1095. R< d > $* $@ deferred
  1096. R< $* > $* $: $2
  1097.  
  1098. R$+ $| $+ $: $>D < $1 > <?> <+ Connect> < $2 >
  1099. R $| $+ $: $>A < $1 > <?> <+ Connect> <> empty client_name
  1100. R<?> <$+> $: $>A < $1 > <?> <+ Connect> <> no: another lookup
  1101. R<?> <$*> $: OK found nothing
  1102. R<$={Accept}> <$*> $@ $1 return value of lookup
  1103. R<REJECT> <$*> $#error $@ 5.7.1 $: "550 Access denied"
  1104. R<DISCARD> <$*> $#discard $: discard
  1105. R<QUARANTINE:$+> <$*> $#error $@ quarantine $: $1
  1106. R<ERROR:$-.$-.$-:$+> <$*> $#error $@ $1.$2.$3 $: $4
  1107. R<ERROR:$+> <$*> $#error $: $1
  1108. R<$* <TMPF>> <$*> $#error $@ 4.3.0 $: "451 Temporary system failure. Please try again later."
  1109. R<$+> <$*> $#error $: $1
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115. ######################################################################
  1116. ### check_mail -- check SMTP `MAIL FROM:' command argument
  1117. ######################################################################
  1118.  
  1119. SLocal_check_mail
  1120. Scheckmail
  1121. R$* $: $1 $| $>"Local_check_mail" $1
  1122. R$* $| $#$* $#$2
  1123. R$* $| $* $@ $>"Basic_check_mail" $1
  1124.  
  1125. SBasic_check_mail
  1126. # check for deferred delivery mode
  1127. R$* $: < $&{deliveryMode} > $1
  1128. R< d > $* $@ deferred
  1129. R< $* > $* $: $2
  1130.  
  1131. # authenticated?
  1132. R$* $: $1 $| $>"tls_client" $&{verify} $| MAIL
  1133. R$* $| $#$+ $#$2
  1134. R$* $| $* $: $1
  1135.  
  1136. R<> $@ <OK> we MUST accept <> (RFC 1123)
  1137. R$+ $: <?> $1
  1138. R<?><$+> $: <@> <$1>
  1139. R<?>$+ $: <@> <$1>
  1140. R$* $: $&{daemon_flags} $| $1
  1141. R$* f $* $| <@> < $* @ $- > $: < ? $&{client_name} > < $3 @ $4 >
  1142. R$* u $* $| <@> < $* > $: <?> < $3 >
  1143. R$* $| $* $: $2
  1144. # handle case of @localhost on address
  1145. R<@> < $* @ localhost > $: < ? $&{client_name} > < $1 @ localhost >
  1146. R<@> < $* @ [127.0.0.1] >
  1147. $: < ? $&{client_name} > < $1 @ [127.0.0.1] >
  1148. R<@> < $* @ localhost.$m >
  1149. $: < ? $&{client_name} > < $1 @ localhost.$m >
  1150. R<@> < $* @ localhost.UUCP >
  1151. $: < ? $&{client_name} > < $1 @ localhost.UUCP >
  1152. R<@> $* $: $1 no localhost as domain
  1153. R<? $=w> $* $: $2 local client: ok
  1154. R<? $+> <$+> $#error $@ 5.5.4 $: "553 Real domain name required for sender address"
  1155. R<?> $* $: $1
  1156. R$* $: <?> $>CanonAddr $1 canonify sender address and mark it
  1157. R<?> $* < @ $+ . > <?> $1 < @ $2 > strip trailing dots
  1158. # handle non-DNS hostnames (*.bitnet, *.decnet, *.uucp, etc)
  1159. R<?> $* < @ $* $=P > $: <OKR> $1 < @ $2 $3 >
  1160. R<?> $* < @ $j > $: <OKR> $1 < @ $j >
  1161. R<?> $* < @ $+ > $: <? $(resolve $2 $: $2 <PERM> $) > $1 < @ $2 >
  1162. R<? $* <$->> $* < @ $+ >
  1163. $: <$2> $3 < @ $4 >
  1164.  
  1165. # check sender address: user@address, user@, address
  1166. R<$+> $+ < @ $* > $: @<$1> <$2 < @ $3 >> $| <F:$2@$3> <U:$2@> <D:$3>
  1167. R<$+> $+ $: @<$1> <$2> $| <U:$2@>
  1168. R@ <$+> <$*> $| <$+> $: <@> <$1> <$2> $| $>SearchList <+ From> $| <$3> <>
  1169. R<@> <$+> <$*> $| <$*> $: <$3> <$1> <$2> reverse result
  1170. # retransform for further use
  1171. R<?> <$+> <$*> $: <$1> $2 no match
  1172. R<$+> <$+> <$*> $: <$1> $3 relevant result, keep it
  1173.  
  1174. # handle case of no @domain on address
  1175. R<?> $* $: $&{daemon_flags} $| <?> $1
  1176. R$* u $* $| <?> $* $: <OKR> $3
  1177. R$* $| $* $: $2
  1178. R<?> $* $: < ? $&{client_addr} > $1
  1179. R<?> $* $@ <OKR> ...local unqualed ok
  1180. R<? $+> $* $#error $@ 5.5.4 $: "553 Domain name required for sender address " $&f
  1181. ...remote is not
  1182. # check results
  1183. R<?> $* $: @ $1 mark address: nothing known about it
  1184. R<$={ResOk}> $* $: @ $2 domain ok
  1185. R<TEMP> $* $#error $@ 4.1.8 $: "451 Domain of sender address " $&f " does not resolve"
  1186. R<PERM> $* $#error $@ 5.1.8 $: "553 Domain of sender address " $&f " does not exist"
  1187. R<$={Accept}> $* $# $1 accept from access map
  1188. R<DISCARD> $* $#discard $: discard
  1189. R<QUARANTINE:$+> $* $#error $@ quarantine $: $1
  1190. R<REJECT> $* $#error $@ 5.7.1 $: "550 Access denied"
  1191. R<ERROR:$-.$-.$-:$+> $* $#error $@ $1.$2.$3 $: $4
  1192. R<ERROR:$+> $* $#error $: $1
  1193. R<<TMPF>> $* $#error $@ 4.3.0 $: "451 Temporary system failure. Please try again later."
  1194. R<$+> $* $#error $: $1 error from access db
  1195.  
  1196.  
  1197.  
  1198. ######################################################################
  1199. ### check_rcpt -- check SMTP `RCPT TO:' command argument
  1200. ######################################################################
  1201.  
  1202. SLocal_check_rcpt
  1203. Scheckrcpt
  1204. R$* $: $1 $| $>"Local_check_rcpt" $1
  1205. R$* $| $#$* $#$2
  1206. R$* $| $* $@ $>"Basic_check_rcpt" $1
  1207.  
  1208. SBasic_check_rcpt
  1209. # empty address?
  1210. R<> $#error $@ nouser $: "553 User address required"
  1211. R$@ $#error $@ nouser $: "553 User address required"
  1212. # check for deferred delivery mode
  1213. R$* $: < $&{deliveryMode} > $1
  1214. R< d > $* $@ deferred
  1215. R< $* > $* $: $2
  1216.  
  1217.  
  1218. ######################################################################
  1219. R$* $: $1 $| @ $>"Rcpt_ok" $1
  1220. R$* $| @ $#TEMP $+ $: $1 $| T $2
  1221. R$* $| @ $#$* $#$2
  1222. R$* $| @ RELAY $@ RELAY
  1223. R$* $| @ $* $: O $| $>"Relay_ok" $1
  1224. R$* $| T $+ $: T $2 $| $>"Relay_ok" $1
  1225. R$* $| $#TEMP $+ $#error $2
  1226. R$* $| $#$* $#$2
  1227. R$* $| RELAY $@ RELAY
  1228. R T $+ $| $* $#error $1
  1229. # anything else is bogus
  1230. R$* $#error $@ 5.7.1 $: "550 Relaying denied"
  1231.  
  1232.  
  1233. ######################################################################
  1234. ### Rcpt_ok: is the recipient ok?
  1235. ######################################################################
  1236. SRcpt_ok
  1237. R$* $: $>ParseRecipient $1 strip relayable hosts
  1238.  
  1239.  
  1240.  
  1241.  
  1242. # authenticated via TLS?
  1243. R$* $: $1 $| $>RelayTLS client authenticated?
  1244. R$* $| $# $+ $# $2 error/ok?
  1245. R$* $| $* $: $1 no
  1246.  
  1247. R$* $: $1 $| $>"Local_Relay_Auth" $&{auth_type}
  1248. R$* $| $# $* $# $2
  1249. R$* $| NO $: $1
  1250. R$* $| $* $: $1 $| $&{auth_type}
  1251. R$* $| $: $1
  1252. R$* $| $={TrustAuthMech} $# RELAY
  1253. R$* $| $* $: $1
  1254. # anything terminating locally is ok
  1255. R$+ < @ $=w > $@ RELAY
  1256. R$+ < @ $* $=R > $@ RELAY
  1257. R$+ < @ $+ > $: $>D <$2> <?> <+ To> <$1 < @ $2 >>
  1258. R<RELAY> $* $@ RELAY
  1259. R<$* <TMPF>> $* $#TEMP $@ 4.3.0 $: "451 Temporary system failure. Please try again later."
  1260. R<$*> <$*> $: $2
  1261.  
  1262.  
  1263.  
  1264. # check for local user (i.e. unqualified address)
  1265. R$* $: <?> $1
  1266. R<?> $* < @ $+ > $: <REMOTE> $1 < @ $2 >
  1267. # local user is ok
  1268. R<?> $+ $@ RELAY
  1269. R<$+> $* $: $2
  1270.  
  1271. ######################################################################
  1272. ### Relay_ok: is the relay/sender ok?
  1273. ######################################################################
  1274. SRelay_ok
  1275. # anything originating locally is ok
  1276. # check IP address
  1277. R$* $: $&{client_addr}
  1278. R$@ $@ RELAY originated locally
  1279. R0 $@ RELAY originated locally
  1280. R127.0.0.1 $@ RELAY originated locally
  1281. RIPv6:::1 $@ RELAY originated locally
  1282. R$=R $* $@ RELAY relayable IP address
  1283. R$* $: $>A <$1> <?> <+ Connect> <$1>
  1284. R<RELAY> $* $@ RELAY relayable IP address
  1285.  
  1286. R<<TMPF>> $* $#TEMP $@ 4.3.0 $: "451 Temporary system failure. Please try again later."
  1287. R<$*> <$*> $: $2
  1288. R$* $: [ $1 ] put brackets around it...
  1289. R$=w $@ RELAY ... and see if it is local
  1290.  
  1291.  
  1292. # check client name: first: did it resolve?
  1293. R$* $: < $&{client_resolve} >
  1294. R<TEMP> $#TEMP $@ 4.4.0 $: "450 Relaying temporarily denied. Cannot resolve PTR record for " $&{client_addr}
  1295. R<FORGED> $#error $@ 5.7.1 $: "550 Relaying denied. IP name possibly forged " $&{client_name}
  1296. R<FAIL> $#error $@ 5.7.1 $: "550 Relaying denied. IP name lookup failed " $&{client_name}
  1297. R$* $: <@> $&{client_name}
  1298. # pass to name server to make hostname canonical
  1299. R<@> $* $=P $:<?> $1 $2
  1300. R<@> $+ $:<?> $[ $1 $]
  1301. R$* . $1 strip trailing dots
  1302. R<?> $=w $@ RELAY
  1303. R<?> $* $=R $@ RELAY
  1304. R<?> $* $: $>D <$1> <?> <+ Connect> <$1>
  1305. R<RELAY> $* $@ RELAY
  1306. R<$* <TMPF>> $* $#TEMP $@ 4.3.0 $: "451 Temporary system failure. Please try again later."
  1307. R<$*> <$*> $: $2
  1308.  
  1309. # turn a canonical address in the form user<@domain>
  1310. # qualify unqual. addresses with $j
  1311. SFullAddr
  1312. R$* <@ $+ . > $1 <@ $2 >
  1313. R$* <@ $* > $@ $1 <@ $2 >
  1314. R$+ $@ $1 <@ $j >
  1315.  
  1316. SDelay_TLS_Clt
  1317. # authenticated?
  1318. R$* $: $1 $| $>"tls_client" $&{verify} $| MAIL
  1319. R$* $| $#$+ $#$2
  1320. R$* $| $* $# $1
  1321. R$* $# $1
  1322.  
  1323. SDelay_TLS_Clt2
  1324. # authenticated?
  1325. R$* $: $1 $| $>"tls_client" $&{verify} $| MAIL
  1326. R$* $| $#$+ $#$2
  1327. R$* $| $* $@ $1
  1328. R$* $@ $1
  1329.  
  1330. # call all necessary rulesets
  1331. Scheck_rcpt
  1332. # R$@ $#error $@ 5.1.3 $: "553 Recipient address required"
  1333.  
  1334. R$+ $: $1 $| $>checkrcpt $1
  1335. R$+ $| $#error $* $#error $2
  1336. R$+ $| $#discard $* $#discard $2
  1337. R$+ $| $#$* $@ $>"Delay_TLS_Clt" $2
  1338. R$+ $| $* $: <?> $>FullAddr $>CanonAddr $1
  1339. R<?> $+ < @ $=w > $: <> $1 < @ $2 > $| <F: $1@$2 > <D: $2 > <U: $1@>
  1340. R<?> $+ < @ $* > $: <> $1 < @ $2 > $| <F: $1@$2 > <D: $2 >
  1341. # lookup the addresses only with Spam tag
  1342. R<> $* $| <$+> $: <@> $1 $| $>SearchList <! Spam> $| <$2> <>
  1343. R<@> $* $| $* $: $2 $1 reverse result
  1344. # is the recipient a spam friend?
  1345. R<FRIEND> $+ $@ $>"Delay_TLS_Clt2" SPAMFRIEND
  1346. R<$*> $+ $: $2
  1347.  
  1348. R$* $: $1 $| $>checkmail $&{mail_from}
  1349. R$* $| $#$* $#$2
  1350. R$* $| $* $: $1 $| $>checkrelay $&{client_name} $| $&{client_addr}
  1351. R$* $| $#$* $#$2
  1352. R$* $| $* $: $1
  1353.  
  1354.  
  1355.  
  1356. ######################################################################
  1357. ### F: LookUpFull -- search for an entry in access database
  1358. ###
  1359. ### lookup of full key (which should be an address) and
  1360. ### variations if +detail exists: +* and without +detail
  1361. ###
  1362. ### Parameters:
  1363. ### <$1> -- key
  1364. ### <$2> -- default (what to return if not found in db)
  1365. ### <$3> -- mark (must be <(!|+) single-token>)
  1366. ### ! does lookup only with tag
  1367. ### + does lookup with and without tag
  1368. ### <$4> -- passthru (additional data passed unchanged through)
  1369. ######################################################################
  1370.  
  1371. SF
  1372. R<$+> <$*> <$- $-> <$*> $: <$(access $4:$1 $: ? $)> <$1> <$2> <$3 $4> <$5>
  1373. R<?> <$+> <$*> <+ $-> <$*> $: <$(access $1 $: ? $)> <$1> <$2> <+ $3> <$4>
  1374. R<?> <$+ + $* @ $+> <$*> <$- $-> <$*>
  1375. $: <$(access $6:$1+*@$3 $: ? $)> <$1+$2@$3> <$4> <$5 $6> <$7>
  1376. R<?> <$+ + $* @ $+> <$*> <+ $-> <$*>
  1377. $: <$(access $1+*@$3 $: ? $)> <$1+$2@$3> <$4> <+ $5> <$6>
  1378. R<?> <$+ + $* @ $+> <$*> <$- $-> <$*>
  1379. $: <$(access $6:$1@$3 $: ? $)> <$1+$2@$3> <$4> <$5 $6> <$7>
  1380. R<?> <$+ + $* @ $+> <$*> <+ $-> <$*>
  1381. $: <$(access $1@$3 $: ? $)> <$1+$2@$3> <$4> <+ $5> <$6>
  1382. R<?> <$+> <$*> <$- $-> <$*> $@ <$2> <$5>
  1383. R<$+ <TMPF>> <$*> <$- $-> <$*> $@ <<TMPF>> <$5>
  1384. R<$+> <$*> <$- $-> <$*> $@ <$1> <$5>
  1385.  
  1386. ######################################################################
  1387. ### E: LookUpExact -- search for an entry in access database
  1388. ###
  1389. ### Parameters:
  1390. ### <$1> -- key
  1391. ### <$2> -- default (what to return if not found in db)
  1392. ### <$3> -- mark (must be <(!|+) single-token>)
  1393. ### ! does lookup only with tag
  1394. ### + does lookup with and without tag
  1395. ### <$4> -- passthru (additional data passed unchanged through)
  1396. ######################################################################
  1397.  
  1398. SE
  1399. R<$*> <$*> <$- $-> <$*> $: <$(access $4:$1 $: ? $)> <$1> <$2> <$3 $4> <$5>
  1400. R<?> <$+> <$*> <+ $-> <$*> $: <$(access $1 $: ? $)> <$1> <$2> <+ $3> <$4>
  1401. R<?> <$+> <$*> <$- $-> <$*> $@ <$2> <$5>
  1402. R<$+ <TMPF>> <$*> <$- $-> <$*> $@ <<TMPF>> <$5>
  1403. R<$+> <$*> <$- $-> <$*> $@ <$1> <$5>
  1404.  
  1405. ######################################################################
  1406. ### U: LookUpUser -- search for an entry in access database
  1407. ###
  1408. ### lookup of key (which should be a local part) and
  1409. ### variations if +detail exists: +* and without +detail
  1410. ###
  1411. ### Parameters:
  1412. ### <$1> -- key (user@)
  1413. ### <$2> -- default (what to return if not found in db)
  1414. ### <$3> -- mark (must be <(!|+) single-token>)
  1415. ### ! does lookup only with tag
  1416. ### + does lookup with and without tag
  1417. ### <$4> -- passthru (additional data passed unchanged through)
  1418. ######################################################################
  1419.  
  1420. SU
  1421. R<$+> <$*> <$- $-> <$*> $: <$(access $4:$1 $: ? $)> <$1> <$2> <$3 $4> <$5>
  1422. R<?> <$+> <$*> <+ $-> <$*> $: <$(access $1 $: ? $)> <$1> <$2> <+ $3> <$4>
  1423. R<?> <$+ + $* @> <$*> <$- $-> <$*>
  1424. $: <$(access $5:$1+*@ $: ? $)> <$1+$2@> <$3> <$4 $5> <$6>
  1425. R<?> <$+ + $* @> <$*> <+ $-> <$*>
  1426. $: <$(access $1+*@ $: ? $)> <$1+$2@> <$3> <+ $4> <$5>
  1427. R<?> <$+ + $* @> <$*> <$- $-> <$*>
  1428. $: <$(access $5:$1@ $: ? $)> <$1+$2@> <$3> <$4 $5> <$6>
  1429. R<?> <$+ + $* @> <$*> <+ $-> <$*>
  1430. $: <$(access $1@ $: ? $)> <$1+$2@> <$3> <+ $4> <$5>
  1431. R<?> <$+> <$*> <$- $-> <$*> $@ <$2> <$5>
  1432. R<$+ <TMPF>> <$*> <$- $-> <$*> $@ <<TMPF>> <$5>
  1433. R<$+> <$*> <$- $-> <$*> $@ <$1> <$5>
  1434.  
  1435. ######################################################################
  1436. ### SearchList: search a list of items in the access map
  1437. ### Parameters:
  1438. ### <exact tag> $| <mark:address> <mark:address> ... <>
  1439. ### where "exact" is either "+" or "!":
  1440. ### <+ TAG> lookup with and w/o tag
  1441. ### <! TAG> lookup with tag
  1442. ### possible values for "mark" are:
  1443. ### D: recursive host lookup (LookUpDomain)
  1444. ### E: exact lookup, no modifications
  1445. ### F: full lookup, try user+ext@domain and user@domain
  1446. ### U: user lookup, try user+ext and user (input must have trailing @)
  1447. ### return: <RHS of lookup> or <?> (not found)
  1448. ######################################################################
  1449.  
  1450. # class with valid marks for SearchList
  1451. C{Src}E F D U A
  1452. SSearchList
  1453. # just call the ruleset with the name of the tag... nice trick...
  1454. R<$+> $| <$={Src}:$*> <$*> $: <$1> $| <$4> $| $>$2 <$3> <?> <$1> <>
  1455. R<$+> $| <> $| <?> <> $@ <?>
  1456. R<$+> $| <$+> $| <?> <> $@ $>SearchList <$1> $| <$2>
  1457. R<$+> $| <$*> $| <$+> <> $@ <$3>
  1458. R<$+> $| <$+> $@ <$2>
  1459.  
  1460.  
  1461. ######################################################################
  1462. ### trust_auth: is user trusted to authenticate as someone else?
  1463. ###
  1464. ### Parameters:
  1465. ### $1: AUTH= parameter from MAIL command
  1466. ######################################################################
  1467.  
  1468. SLocal_trust_auth
  1469. Strust_auth
  1470. R$* $: $&{auth_type} $| $1
  1471. # required by RFC 2554 section 4.
  1472. R$@ $| $* $#error $@ 5.7.1 $: "550 not authenticated"
  1473. R$* $| $&{auth_authen} $@ identical
  1474. R$* $| <$&{auth_authen}> $@ identical
  1475. R$* $| $* $: $1 $| $>"Local_trust_auth" $2
  1476. R$* $| $#$* $#$2
  1477. R$* $#error $@ 5.7.1 $: "550 " $&{auth_authen} " not allowed to act as " $&{auth_author}
  1478.  
  1479. ######################################################################
  1480. ### Relay_Auth: allow relaying based on authentication?
  1481. ###
  1482. ### Parameters:
  1483. ### $1: ${auth_type}
  1484. ######################################################################
  1485. SLocal_Relay_Auth
  1486.  
  1487. ######################################################################
  1488. ### srv_features: which features to offer to a client?
  1489. ### (done in server)
  1490. ######################################################################
  1491. Ssrv_features
  1492. R$* $: $>D <$&{client_name}> <?> <! "Srv_Features"> <>
  1493. R<?>$* $: $>A <$&{client_addr}> <?> <! "Srv_Features"> <>
  1494. R<?>$* $: <$(access "Srv_Features": $: ? $)>
  1495. R<?>$* $@ OK
  1496. R<$* <TMPF>>$* $#temp
  1497. R<$+>$* $# $1
  1498.  
  1499. ######################################################################
  1500. ### try_tls: try to use STARTTLS?
  1501. ### (done in client)
  1502. ######################################################################
  1503. Stry_tls
  1504. R$* $: $>D <$&{server_name}> <?> <! "Try_TLS"> <>
  1505. R<?>$* $: $>A <$&{server_addr}> <?> <! "Try_TLS"> <>
  1506. R<?>$* $: <$(access "Try_TLS": $: ? $)>
  1507. R<?>$* $@ OK
  1508. R<$* <TMPF>>$* $#error $@ 4.3.0 $: "451 Temporary system failure. Please try again later."
  1509. R<NO>$* $#error $@ 5.7.1 $: "550 do not try TLS with " $&{server_name} " ["$&{server_addr}"]"
  1510.  
  1511. ######################################################################
  1512. ### tls_rcpt: is connection with server "good" enough?
  1513. ### (done in client, per recipient)
  1514. ###
  1515. ### Parameters:
  1516. ### $1: recipient
  1517. ######################################################################
  1518. Stls_rcpt
  1519. R$* $: $(macro {TLS_Name} $@ $&{server_name} $) $1
  1520. R$+ $: <?> $>CanonAddr $1
  1521. R<?> $+ < @ $+ . > <?> $1 <@ $2 >
  1522. R<?> $+ < @ $+ > $: $1 <@ $2 > $| <F:$1@$2> <U:$1@> <D:$2> <E:>
  1523. R<?> $+ $: $1 $| <U:$1@> <E:>
  1524. R$* $| $+ $: $1 $| $>SearchList <! "TLS_Rcpt"> $| $2 <>
  1525. R$* $| <?> $@ OK
  1526. R$* $| <$* <TMPF>> $#error $@ 4.3.0 $: "451 Temporary system failure. Please try again later."
  1527. R$* $| <$+> $@ $>"TLS_connection" $&{verify} $| <$2>
  1528.  
  1529. ######################################################################
  1530. ### tls_client: is connection with client "good" enough?
  1531. ### (done in server)
  1532. ###
  1533. ### Parameters:
  1534. ### ${verify} $| (MAIL|STARTTLS)
  1535. ######################################################################
  1536. Stls_client
  1537. R$* $: $(macro {TLS_Name} $@ $&{client_name} $) $1
  1538. R$* $| $* $: $1 $| $>D <$&{client_name}> <?> <! "TLS_Clt"> <>
  1539. R$* $| <?>$* $: $1 $| $>A <$&{client_addr}> <?> <! "TLS_Clt"> <>
  1540. R$* $| <?>$* $: $1 $| <$(access "TLS_Clt": $: ? $)>
  1541. R$* $| <$* <TMPF>> $#error $@ 4.3.0 $: "451 Temporary system failure. Please try again later."
  1542. R$* $@ $>"TLS_connection" $1
  1543.  
  1544. ######################################################################
  1545. ### tls_server: is connection with server "good" enough?
  1546. ### (done in client)
  1547. ###
  1548. ### Parameter:
  1549. ### ${verify}
  1550. ######################################################################
  1551. Stls_server
  1552. R$* $: $(macro {TLS_Name} $@ $&{server_name} $) $1
  1553. R$* $: $1 $| $>D <$&{server_name}> <?> <! "TLS_Srv"> <>
  1554. R$* $| <?>$* $: $1 $| $>A <$&{server_addr}> <?> <! "TLS_Srv"> <>
  1555. R$* $| <?>$* $: $1 $| <$(access "TLS_Srv": $: ? $)>
  1556. R$* $| <$* <TMPF>> $#error $@ 4.3.0 $: "451 Temporary system failure. Please try again later."
  1557. R$* $@ $>"TLS_connection" $1
  1558.  
  1559. ######################################################################
  1560. ### TLS_connection: is TLS connection "good" enough?
  1561. ###
  1562. ### Parameters:
  1563. ### ${verify} $| <Requirement> [<>]
  1564. ### Requirement: RHS from access map, may be ? for none.
  1565. ######################################################################
  1566. STLS_connection
  1567. R$* $| <$*>$* $: $1 $| <$2>
  1568. # create the appropriate error codes
  1569. R$* $| <PERM + $={Tls} $*> $: $1 $| <503:5.7.0> <$2 $3>
  1570. R$* $| <TEMP + $={Tls} $*> $: $1 $| <403:4.7.0> <$2 $3>
  1571. R$* $| <$={Tls} $*> $: $1 $| <403:4.7.0> <$2 $3>
  1572. # deal with TLS handshake failures: abort
  1573. RSOFTWARE $| <$-:$+> $* $#error $@ $2 $: $1 " TLS handshake failed."
  1574. RSOFTWARE $| $* $#error $@ 4.7.0 $: "403 TLS handshake failed."
  1575. # deal with TLS protocol errors: abort
  1576. RPROTOCOL $| <$-:$+> $* $#error $@ $2 $: $1 " STARTTLS failed."
  1577. RPROTOCOL $| $* $#error $@ 4.7.0 $: "403 STARTTLS failed."
  1578. R$* $| <$*> <VERIFY> $: <$2> <VERIFY> <> $1
  1579. R$* $| <$*> <VERIFY + $+> $: <$2> <VERIFY> <$3> $1
  1580. R$* $| <$*> <$={Tls}:$->$* $: <$2> <$3:$4> <> $1
  1581. R$* $| <$*> <$={Tls}:$- + $+>$* $: <$2> <$3:$4> <$5> $1
  1582. R$* $| $* $@ OK
  1583. # authentication required: give appropriate error
  1584. # other side did authenticate (via STARTTLS)
  1585. R<$*><VERIFY> <> OK $@ OK
  1586. R<$*><VERIFY> <$+> OK $: <$1> <REQ:0> <$2>
  1587. R<$*><VERIFY:$-> <$*> OK $: <$1> <REQ:$2> <$3>
  1588. R<$*><ENCR:$-> <$*> $* $: <$1> <REQ:$2> <$3>
  1589. R<$-:$+><VERIFY $*> <$*> $#error $@ $2 $: $1 " authentication required"
  1590. R<$-:$+><VERIFY $*> <$*> FAIL $#error $@ $2 $: $1 " authentication failed"
  1591. R<$-:$+><VERIFY $*> <$*> NO $#error $@ $2 $: $1 " not authenticated"
  1592. R<$-:$+><VERIFY $*> <$*> NOT $#error $@ $2 $: $1 " no authentication requested"
  1593. R<$-:$+><VERIFY $*> <$*> NONE $#error $@ $2 $: $1 " other side does not support STARTTLS"
  1594. R<$-:$+><VERIFY $*> <$*> $+ $#error $@ $2 $: $1 " authentication failure " $4
  1595. R<$*><REQ:$-> <$*> $: <$1> <REQ:$2> <$3> $>max $&{cipher_bits} : $&{auth_ssf}
  1596. R<$*><REQ:$-> <$*> $- $: <$1> <$2:$4> <$3> $(arith l $@ $4 $@ $2 $)
  1597. R<$-:$+><$-:$-> <$*> TRUE $#error $@ $2 $: $1 " encryption too weak " $4 " less than " $3
  1598. R<$-:$+><$-:$-> <$*> $* $: <$1:$2 ++ $5>
  1599. R<$-:$+ ++ > $@ OK
  1600. R<$-:$+ ++ $+ > $: <$1:$2> <$3>
  1601. R<$-:$+> < $+ ++ $+ > <$1:$2> <$3> <$4>
  1602. R<$-:$+> $+ $@ $>"TLS_req" $3 $| <$1:$2>
  1603.  
  1604. ######################################################################
  1605. ### TLS_req: check additional TLS requirements
  1606. ###
  1607. ### Parameters: [<list> <of> <req>] $| <$-:$+>
  1608. ### $-: SMTP reply code
  1609. ### $+: Enhanced Status Code
  1610. ######################################################################
  1611. STLS_req
  1612. R $| $+ $@ OK
  1613. R<CN> $* $| <$+> $: <CN:$&{TLS_Name}> $1 $| <$2>
  1614. R<CN:$&{cn_subject}> $* $| <$+> $@ $>"TLS_req" $1 $| <$2>
  1615. R<CN:$+> $* $| <$-:$+> $#error $@ $4 $: $3 " CN " $&{cn_subject} " does not match " $1
  1616. R<CS:$&{cert_subject}> $* $| <$+> $@ $>"TLS_req" $1 $| <$2>
  1617. R<CS:$+> $* $| <$-:$+> $#error $@ $4 $: $3 " Cert Subject " $&{cert_subject} " does not match " $1
  1618. R<CI:$&{cert_issuer}> $* $| <$+> $@ $>"TLS_req" $1 $| <$2>
  1619. R<CI:$+> $* $| <$-:$+> $#error $@ $4 $: $3 " Cert Issuer " $&{cert_issuer} " does not match " $1
  1620. ROK $@ OK
  1621.  
  1622. ######################################################################
  1623. ### max: return the maximum of two values separated by :
  1624. ###
  1625. ### Parameters: [$-]:[$-]
  1626. ######################################################################
  1627. Smax
  1628. R: $: 0
  1629. R:$- $: $1
  1630. R$-: $: $1
  1631. R$-:$- $: $(arith l $@ $1 $@ $2 $) : $1 : $2
  1632. RTRUE:$-:$- $: $2
  1633. R$-:$-:$- $: $2
  1634.  
  1635.  
  1636. ######################################################################
  1637. ### RelayTLS: allow relaying based on TLS authentication
  1638. ###
  1639. ### Parameters:
  1640. ### none
  1641. ######################################################################
  1642. SRelayTLS
  1643. # authenticated?
  1644. R$* $: <?> $&{verify}
  1645. R<?> OK $: OK authenticated: continue
  1646. R<?> $* $@ NO not authenticated
  1647. R$* $: $&{cert_issuer}
  1648. R$+ $: $(access CERTISSUER:$1 $)
  1649. RRELAY $# RELAY
  1650. RSUBJECT $: <@> $&{cert_subject}
  1651. R<@> $+ $: <@> $(access CERTSUBJECT:$1 $)
  1652. R<@> RELAY $# RELAY
  1653. R$* $: NO
  1654.  
  1655. ######################################################################
  1656. ### authinfo: lookup authinfo in the access map
  1657. ###
  1658. ### Parameters:
  1659. ### $1: {server_name}
  1660. ### $2: {server_addr}
  1661. ######################################################################
  1662. Sauthinfo
  1663. R$* $: $1 $| $>D <$&{server_name}> <?> <! AuthInfo> <>
  1664. R$* $| <?>$* $: $1 $| $>A <$&{server_addr}> <?> <! AuthInfo> <>
  1665. R$* $| <?>$* $: $1 $| <$(access AuthInfo: $: ? $)> <>
  1666. R$* $| <?>$* $@ no no authinfo available
  1667. R$* $| <$*> <> $# $2
  1668.  
  1669. ######################################################################
  1670. ### RateControl:
  1671. ### Parameters: ignored
  1672. ### return: $#error or OK
  1673. ######################################################################
  1674. SRateControl
  1675. R$* $: <A:$&{client_addr}> <E:>
  1676. R$+ $: $>SearchList <! ClientRate> $| $1 <>
  1677. R<?> $@ OK
  1678. R<$* <TMPF>> $#error $@ 4.3.0 $: "451 Temporary system failure. Please try again later."
  1679. R<0> $@ OK no limit
  1680. R<$+> $: <$1> $| $(arith l $@ $1 $@ $&{client_rate} $)
  1681. R<$+> $| TRUE $#error $@ 4.3.2 $: 421 Connection rate limit exceeded.
  1682.  
  1683.  
  1684. ######################################################################
  1685. ### ConnControl:
  1686. ### Parameters: ignored
  1687. ### return: $#error or OK
  1688. ######################################################################
  1689. SConnControl
  1690. R$* $: <A:$&{client_addr}> <E:>
  1691. R$+ $: $>SearchList <! ClientConn> $| $1 <>
  1692. R<?> $@ OK
  1693. R<$* <TMPF>> $#error $@ 4.3.0 $: "451 Temporary system failure. Please try again later."
  1694. R<0> $@ OK no limit
  1695. R<$+> $: <$1> $| $(arith l $@ $1 $@ $&{client_connections} $)
  1696. R<$+> $| TRUE $#error $@ 4.3.2 $: 421 Too many open connections.
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702. ######################################################################
  1703. ### greet_pause: lookup pause time before 220 greeting
  1704. ###
  1705. ### Parameters:
  1706. ### $1: {client_name}
  1707. ### $2: {client_addr}
  1708. ######################################################################
  1709. SLocal_greet_pause
  1710. Sgreet_pause
  1711. R$* $: <$1><?> $| $>"Local_greet_pause" $1
  1712. R<$*><?> $| $#$* $#$2
  1713. R<$*><?> $| $* $: $1
  1714. R$+ $| $+ $: $>D < $1 > <?> <! GreetPause> < $2 >
  1715. R $| $+ $: $>A < $1 > <?> <! GreetPause> <> empty client_name
  1716. R<?> <$+> $: $>A < $1 > <?> <! GreetPause> <> no: another lookup
  1717. R<?> <$*> $# 1000
  1718. R<$* <TMPF>> <$*> $@
  1719. R<$+> <$*> $# $1
  1720. #
  1721. ######################################################################
  1722. ######################################################################
  1723. #####
  1724. ##### MAIL FILTER DEFINITIONS
  1725. #####
  1726. ######################################################################
  1727. ######################################################################
  1728.  
  1729. Xopendkim, S=inet:8891@localhost
  1730. #
  1731. ######################################################################
  1732. ######################################################################
  1733. #####
  1734. ##### MAILER DEFINITIONS
  1735. #####
  1736. ######################################################################
  1737. ######################################################################
  1738.  
  1739.  
  1740.  
  1741. ##################################################
  1742. ### Local and Program Mailer specification ###
  1743. ##################################################
  1744.  
  1745. ##### $Id: local.m4,v 8.59 2004/11/23 00:37:25 ca Exp $ #####
  1746.  
  1747. #
  1748. # Envelope sender rewriting
  1749. #
  1750. SEnvFromL
  1751. R<@> $n errors to mailer-daemon
  1752. R@ <@ $*> $n temporarily bypass Sun bogosity
  1753. R$+ $: $>AddDomain $1 add local domain if needed
  1754. R$* $: $>MasqEnv $1 do masquerading
  1755.  
  1756. #
  1757. # Envelope recipient rewriting
  1758. #
  1759. SEnvToL
  1760. R$+ < @ $* > $: $1 strip host part
  1761. R$+ + $* $: < $&{addr_type} > $1 + $2 mark with addr type
  1762. R<e s> $+ + $* $: $1 remove +detail for sender
  1763. R< $* > $+ $: $2 else remove mark
  1764.  
  1765. #
  1766. # Header sender rewriting
  1767. #
  1768. SHdrFromL
  1769. R<@> $n errors to mailer-daemon
  1770. R@ <@ $*> $n temporarily bypass Sun bogosity
  1771. R$+ $: $>AddDomain $1 add local domain if needed
  1772. R$* $: $>MasqHdr $1 do masquerading
  1773.  
  1774. #
  1775. # Header recipient rewriting
  1776. #
  1777. SHdrToL
  1778. R$+ $: $>AddDomain $1 add local domain if needed
  1779. R$* < @ *LOCAL* > $* $: $1 < @ $j . > $2
  1780.  
  1781. #
  1782. # Common code to add local domain name (only if always-add-domain)
  1783. #
  1784. SAddDomain
  1785.  
  1786. Mlocal, P=/usr/sbin/sensible-mda, F=lsDFMAw5:/|@qPn9S, S=EnvFromL/HdrFromL, R=EnvToL/HdrToL,
  1787. T=DNS/RFC822/X-Unix,
  1788. A=sensible-mda $g $u $h ${client_addr}
  1789. Mprog, P=/bin/sh, F=lsDFMoqeu9, S=EnvFromL/HdrFromL, R=EnvToL/HdrToL, D=$z:/,
  1790. T=X-Unix/X-Unix/X-Unix,
  1791. A=sh -c $u
  1792.  
  1793. #####################################
  1794. ### SMTP Mailer specification ###
  1795. #####################################
  1796.  
  1797. ##### $Id: smtp.m4,v 8.65 2006/07/12 21:08:10 ca Exp $ #####
  1798.  
  1799. #
  1800. # common sender and masquerading recipient rewriting
  1801. #
  1802. SMasqSMTP
  1803. R$* < @ $* > $* $@ $1 < @ $2 > $3 already fully qualified
  1804. R$+ $@ $1 < @ *LOCAL* > add local qualification
  1805.  
  1806. #
  1807. # convert pseudo-domain addresses to real domain addresses
  1808. #
  1809. SPseudoToReal
  1810.  
  1811. # pass <route-addr>s through
  1812. R< @ $+ > $* $@ < @ $1 > $2 resolve <route-addr>
  1813.  
  1814. # output fake domains as user%fake@relay
  1815.  
  1816. # do UUCP heuristics; note that these are shared with UUCP mailers
  1817. R$+ < @ $+ .UUCP. > $: < $2 ! > $1 convert to UUCP form
  1818. R$+ < @ $* > $* $@ $1 < @ $2 > $3 not UUCP form
  1819.  
  1820. # leave these in .UUCP form to avoid further tampering
  1821. R< $&h ! > $- ! $+ $@ $2 < @ $1 .UUCP. >
  1822. R< $&h ! > $-.$+ ! $+ $@ $3 < @ $1.$2 >
  1823. R< $&h ! > $+ $@ $1 < @ $&h .UUCP. >
  1824. R< $+ ! > $+ $: $1 ! $2 < @ $Y > use UUCP_RELAY
  1825. R$+ < @ $~[ $* : $+ > $@ $1 < @ $4 > strip mailer: part
  1826. R$+ < @ > $: $1 < @ *LOCAL* > if no UUCP_RELAY
  1827.  
  1828.  
  1829. #
  1830. # envelope sender rewriting
  1831. #
  1832. SEnvFromSMTP
  1833. R$+ $: $>PseudoToReal $1 sender/recipient common
  1834. R$* :; <@> $@ list:; special case
  1835. R$* $: $>MasqSMTP $1 qualify unqual'ed names
  1836. R$+ $: $>MasqEnv $1 do masquerading
  1837.  
  1838.  
  1839. #
  1840. # envelope recipient rewriting --
  1841. # also header recipient if not masquerading recipients
  1842. #
  1843. SEnvToSMTP
  1844. R$+ $: $>PseudoToReal $1 sender/recipient common
  1845. R$+ $: $>MasqSMTP $1 qualify unqual'ed names
  1846. R$* < @ *LOCAL* > $* $: $1 < @ $j . > $2
  1847.  
  1848. #
  1849. # header sender and masquerading header recipient rewriting
  1850. #
  1851. SHdrFromSMTP
  1852. R$+ $: $>PseudoToReal $1 sender/recipient common
  1853. R:; <@> $@ list:; special case
  1854.  
  1855. # do special header rewriting
  1856. R$* <@> $* $@ $1 <@> $2 pass null host through
  1857. R< @ $* > $* $@ < @ $1 > $2 pass route-addr through
  1858. R$* $: $>MasqSMTP $1 qualify unqual'ed names
  1859. R$+ $: $>MasqHdr $1 do masquerading
  1860.  
  1861.  
  1862. #
  1863. # relay mailer header masquerading recipient rewriting
  1864. #
  1865. SMasqRelay
  1866. R$+ $: $>MasqSMTP $1
  1867. R$+ $: $>MasqHdr $1
  1868.  
  1869. Msmtp, P=[IPC], F=mDFMuX, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP, E=\r\n, L=990,
  1870. T=DNS/RFC822/SMTP,
  1871. A=TCP $h
  1872. Mesmtp, P=[IPC], F=mDFMuXa, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP, E=\r\n, L=990,
  1873. T=DNS/RFC822/SMTP,
  1874. A=TCP $h
  1875. Msmtp8, P=[IPC], F=mDFMuX8, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP, E=\r\n, L=990,
  1876. T=DNS/RFC822/SMTP,
  1877. A=TCP $h
  1878. Mdsmtp, P=[IPC], F=mDFMuXa%, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP, E=\r\n, L=990,
  1879. T=DNS/RFC822/SMTP,
  1880. A=TCP $h
  1881. Mrelay, P=[IPC], F=mDFMuXa8, S=EnvFromSMTP/HdrFromSMTP, R=MasqSMTP, E=\r\n, L=2040,
  1882. T=DNS/RFC822/SMTP,
  1883. A=TCP $h
  1884.  
  1885.  
  1886.  
  1887. ### /etc/mail/sendmail.mc ###
  1888. # divert(-1)dnl
  1889. # #-----------------------------------------------------------------------------
  1890. # # $Sendmail: debproto.mc,v 8.14.4 2014-02-11 13:02:08 cowboy Exp $
  1891. # #
  1892. # # Copyright (c) 1998-2010 Richard Nelson. All Rights Reserved.
  1893. # #
  1894. # # cf/debian/sendmail.mc. Generated from sendmail.mc.in by configure.
  1895. # #
  1896. # # sendmail.mc prototype config file for building Sendmail 8.14.4
  1897. # #
  1898. # # Note: the .in file supports 8.7.6 - 9.0.0, but the generated
  1899. # # file is customized to the version noted above.
  1900. # #
  1901. # # This file is used to configure Sendmail for use with Debian systems.
  1902. # #
  1903. # # If you modify this file, you will have to regenerate /etc/mail/sendmail.cf
  1904. # # by running this file through the m4 preprocessor via one of the following:
  1905. # # * make (or make -C /etc/mail)
  1906. # # * sendmailconfig
  1907. # # * m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
  1908. # # The first two options are preferred as they will also update other files
  1909. # # that depend upon the contents of this file.
  1910. # #
  1911. # # The best documentation for this .mc file is:
  1912. # # /usr/share/doc/sendmail-doc/cf.README.gz
  1913. # #
  1914. # #-----------------------------------------------------------------------------
  1915. # divert(0)dnl
  1916. # #
  1917. # # Copyright (c) 1998-2005 Richard Nelson. All Rights Reserved.
  1918. # #
  1919. # # This file is used to configure Sendmail for use with Debian systems.
  1920. # #
  1921. # define(`_USE_ETC_MAIL_')dnl
  1922. # include(`/usr/share/sendmail/cf/m4/cf.m4')dnl
  1923. # VERSIONID(`$Id: sendmail.mc, v 8.14.4-4.1ubuntu1 2014-02-11 13:02:08 cowboy Exp $')
  1924. # OSTYPE(`debian')dnl
  1925. # DOMAIN(`debian-mta')dnl
  1926. # dnl # Items controlled by /etc/mail/sendmail.conf - DO NOT TOUCH HERE
  1927. # undefine(`confHOST_STATUS_DIRECTORY')dnl #DAEMON_HOSTSTATS=
  1928. # dnl # Items controlled by /etc/mail/sendmail.conf - DO NOT TOUCH HERE
  1929. # dnl #
  1930. # dnl # General defines
  1931. # dnl #
  1932. # dnl # SAFE_FILE_ENV: [undefined] If set, sendmail will do a chroot()
  1933. # dnl # into this directory before writing files.
  1934. # dnl # If *all* your user accounts are under /home then use that
  1935. # dnl # instead - it will prevent any writes outside of /home !
  1936. # dnl # define(`confSAFE_FILE_ENV', `')dnl
  1937. # dnl #
  1938. # dnl # Daemon options - restrict to servicing LOCALHOST ONLY !!!
  1939. # dnl # Remove `, Addr=' clauses to receive from any interface
  1940. # dnl # If you want to support IPv6, switch the commented/uncommentd lines
  1941. # dnl #
  1942. # FEATURE(`no_default_msa')dnl
  1943. # dnl DAEMON_OPTIONS(`Family=inet6, Name=MTA-v6, Port=smtp, Addr=::1')dnl
  1944. # DAEMON_OPTIONS(`Family=inet, Name=MTA-v4, Port=smtp, Addr=127.0.0.1')dnl
  1945. # dnl DAEMON_OPTIONS(`Family=inet6, Name=MSP-v6, Port=submission, M=Ea, Addr=::1')dnl
  1946. # DAEMON_OPTIONS(`Family=inet, Name=MSP-v4, Port=submission, M=Ea, Addr=127.0.0.1')dnl
  1947. # dnl #
  1948. # dnl # Be somewhat anal in what we allow
  1949. # define(`confPRIVACY_FLAGS',dnl
  1950. # `needmailhelo,needexpnhelo,needvrfyhelo,restrictqrun,restrictexpand,nobodyreturn,authwarnings')dnl
  1951. # dnl #
  1952. # dnl # Define connection throttling and window length
  1953. # define(`confCONNECTION_RATE_THROTTLE', `15')dnl
  1954. # define(`confCONNECTION_RATE_WINDOW_SIZE',`10m')dnl
  1955. # dnl #
  1956. # dnl # Features
  1957. # dnl #
  1958. # dnl # use /etc/mail/local-host-names
  1959. # FEATURE(`use_cw_file')dnl
  1960. # dnl #
  1961. # dnl # The access db is the basis for most of sendmail's checking
  1962. # FEATURE(`access_db', , `skip')dnl
  1963. # dnl #
  1964. # dnl # The greet_pause feature stops some automail bots - but check the
  1965. # dnl # provided access db for details on excluding localhosts...
  1966. # FEATURE(`greet_pause', `1000')dnl 1 seconds
  1967. # dnl #
  1968. # dnl # Delay_checks allows sender<->recipient checking
  1969. # FEATURE(`delay_checks', `friend', `n')dnl
  1970. # dnl #
  1971. # dnl # If we get too many bad recipients, slow things down...
  1972. # define(`confBAD_RCPT_THROTTLE',`3')dnl
  1973. # dnl #
  1974. # dnl # Stop connections that overflow our concurrent and time connection rates
  1975. # FEATURE(`conncontrol', `nodelay', `terminate')dnl
  1976. # FEATURE(`ratecontrol', `nodelay', `terminate')dnl
  1977. # dnl #
  1978. # dnl # If you're on a dialup link, you should enable this - so sendmail
  1979. # dnl # will not bring up the link (it will queue mail for later)
  1980. # dnl define(`confCON_EXPENSIVE',`True')dnl
  1981. # dnl #
  1982. # dnl # Dialup/LAN connection overrides
  1983. # dnl #
  1984. # dnl include(`/etc/mail/m4/dialup.m4')dnl
  1985. # dnl include(`/etc/mail/m4/provider.m4')dnl
  1986. # dnl #
  1987. # dnl # Default Mailer setup
  1988. # MAILER_DEFINITIONS
  1989. # MAILER(`local')dnl
  1990. # MAILER(`smtp')dnl
  1991. # INPUT_MAIL_FILTER(`opendkim', `S=inet:8891@localhost')dnl
  1992. # include(`/etc/mail/tls/starttls.m4')dnl
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement