Subversion Repositories configs

Rev

Rev 3 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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