Subversion Repositories configs

Rev

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