xref: /netbsd-src/external/ibm-public/postfix/dist/proto/regexp_table (revision 059c16a85b0b39d60ad6d18f53c09510815afa2b)
1#++
2# NAME
3#	regexp_table 5
4# SUMMARY
5#	format of Postfix regular expression tables
6# SYNOPSIS
7#	\fBpostmap -q "\fIstring\fB" regexp:/etc/postfix/\fIfilename\fR
8#
9#	\fBpostmap -q - regexp:/etc/postfix/\fIfilename\fB <\fIinputfile\fR
10# DESCRIPTION
11#	The Postfix mail system uses optional tables for address
12#	rewriting, mail routing, or access control. These tables
13#	are usually in \fBdbm\fR or \fBdb\fR format.
14#
15#	Alternatively, lookup tables can be specified in POSIX regular
16#	expression form. In this case, each input is compared against a
17#	list of patterns. When a match is found, the corresponding
18#	result is returned and the search is terminated.
19#
20#	To find out what types of lookup tables your Postfix system
21#	supports use the "\fBpostconf -m\fR" command.
22#
23#	To test lookup tables, use the "\fBpostmap -q\fR" command
24#	as described in the SYNOPSIS above. Use "\fBpostmap -hmq
25#	-\fR <\fIfile\fR" for header_checks(5) patterns, and
26#	"\fBpostmap -bmq -\fR <\fIfile\fR" for body_checks(5)
27#	(Postfix 2.6 and later).
28# COMPATIBILITY
29# .ad
30# .fi
31#	With Postfix version 2.2 and earlier specify "\fBpostmap
32#	-fq\fR" to query a table that contains case sensitive
33#	patterns. Patterns are case insensitive by default.
34# TABLE FORMAT
35# .ad
36# .fi
37#	The general form of a Postfix regular expression table is:
38# .IP "\fB/\fIpattern\fB/\fIflags result\fR"
39#	When \fIpattern\fR matches the input string,
40#	use the corresponding \fIresult\fR value.
41# .IP "\fB!/\fIpattern\fB/\fIflags result\fR"
42#	When \fIpattern\fR does \fBnot\fR match the input string,
43#	use the corresponding \fIresult\fR value.
44# .IP "\fBif /\fIpattern\fB/\fIflags\fR"
45# .IP "\fBendif\fR"
46#	If the input string matches /\fIpattern\fR/, then match that
47#	input string against the patterns between \fBif\fR and
48#	\fBendif\fR.  The \fBif\fR..\fBendif\fR can nest.
49# .sp
50#	Note: do not prepend whitespace to patterns inside
51#	\fBif\fR..\fBendif\fR.
52# .sp
53#	This feature is available in Postfix 2.1 and later.
54# .IP "\fBif !/\fIpattern\fB/\fIflags\fR"
55# .IP "\fBendif\fR"
56#	If the input string does not match /\fIpattern\fR/, then
57#	match that input string against the patterns between \fBif\fR
58#	and \fBendif\fR. The \fBif\fR..\fBendif\fR can nest.
59# .sp
60#	Note: do not prepend whitespace to patterns inside
61#	\fBif\fR..\fBendif\fR.
62# .sp
63#	This feature is available in Postfix 2.1 and later.
64# .IP "blank lines and comments"
65#	Empty lines and whitespace-only lines are ignored, as
66#	are lines whose first non-whitespace character is a `#'.
67# .IP "multi-line text"
68#	A logical line starts with non-whitespace text. A line that
69#	starts with whitespace continues a logical line.
70# .PP
71#	Each pattern is a POSIX regular expression enclosed by a pair of
72#	delimiters. The regular expression syntax is documented in
73#	\fBre_format\fR(7) with 4.4BSD, in \fBregex\fR(5) with Solaris, and in
74#	\fBregex\fR(7) with Linux. Other systems may use other document names.
75#
76#	The expression delimiter can be any non-alphanumerical
77#	character, except whitespace
78#	or characters that have special meaning (traditionally the forward
79#	slash is used). The regular expression can contain whitespace.
80#
81#	By default, matching is case-insensitive, and newlines are not
82#	treated as special characters. The behavior is controlled by flags,
83#	which are toggled by appending one or more of the following
84#	characters after the pattern:
85# .IP "\fBi\fR (default: on)"
86#	Toggles the case sensitivity flag. By default, matching is case
87#	insensitive.
88# .IP "\fBm\fR (default: off)"
89#	Toggle the multi-line mode flag. When this flag is on, the \fB^\fR
90#	and \fB$\fR metacharacters match immediately after and immediately
91#	before a newline character, respectively, in addition to
92#	matching at the start and end of the input string.
93# .IP "\fBx\fR (default: on)"
94#	Toggles the extended expression syntax flag. By default, support
95#	for extended expression syntax is enabled.
96# TABLE SEARCH ORDER
97# .ad
98# .fi
99#	Patterns are applied in the order as specified in the table, until a
100#	pattern is found that matches the input string.
101#
102#	Each pattern is applied to the entire input string.
103#	Depending on the application, that string is an entire client
104#	hostname, an entire client IP address, or an entire mail address.
105#	Thus, no parent domain or parent network search is done, and
106#	\fIuser@domain\fR mail addresses are not broken up into their
107#	\fIuser\fR and \fIdomain\fR constituent parts, nor is \fIuser+foo\fR
108#	broken up into \fIuser\fR and \fIfoo\fR.
109# TEXT SUBSTITUTION
110# .ad
111# .fi
112#	Substitution of substrings (text that matches patterns
113#	inside "()") from the matched expression into the result
114#	string is requested with $1, $2, etc.; specify $$ to produce
115#	a $ character as output.
116#	The macros in the result string may need to be written as
117#	${n} or $(n) if they aren't followed by whitespace.
118#
119#	Note: since negated patterns (those preceded by \fB!\fR) return a
120#	result when the expression does not match, substitutions are not
121#	available for negated patterns.
122# INLINE SPECIFICATION
123# .ad
124# .fi
125#	The contents of a table may be specified in the table name
126#	(Postfix 3.7 and later).
127#	The basic syntax is:
128#
129# .nf
130#	main.cf:
131#	    \fIparameter\fR \fB= .. regexp:{ { \fIrule-1\fB }, { \fIrule-2\fB } .. } ..\fR
132#
133#	master.cf:
134#	    \fB.. -o { \fIparameter\fR \fB= .. regexp:{ { \fIrule-1\fB }, { \fIrule-2\fB } .. } .. } ..\fR
135# .fi
136#
137#	Postfix ignores whitespace after '{' and before '}', and
138#	writes each \fIrule\fR as one text line to an in-memory
139#	file:
140#
141# .nf
142#	in-memory file:
143#	    rule-1
144#	    rule-2
145#	    ..
146# .fi
147#
148#	Postfix parses the result as if it is a file in /etc/postfix.
149#
150#	Note: if a rule contains \fB$\fR, specify \fB$$\fR to keep
151#	Postfix from trying to do \fI$name\fR expansion as it
152#	evaluates a parameter value.
153# EXAMPLE SMTPD ACCESS MAP
154#	# Disallow sender-specified routing. This is a must if you relay mail
155#	# for other domains.
156#	/[%!@].*[%!@]/	     550 Sender-specified routing rejected
157#
158#	# Postmaster is OK, that way they can talk to us about how to fix
159#	# their problem.
160#	/^postmaster@/	     OK
161#
162#	# Protect your outgoing majordomo exploders
163#	if !/^owner-/
164#	/^(.*)-outgoing@(.*)$/	 550 Use ${1}@${2} instead
165#	endif
166# EXAMPLE HEADER FILTER MAP
167#	# These were once common in junk mail.
168#	/^Subject: make money fast/     REJECT
169#	/^To: friend@public\\.com/	 REJECT
170# EXAMPLE BODY FILTER MAP
171#	# First skip over base 64 encoded text to save CPU cycles.
172#	~^[[:alnum:]+/]{60,}$~		OK
173#
174#	# Put your own body patterns here.
175# SEE ALSO
176#	postmap(1), Postfix lookup table manager
177#	pcre_table(5), format of PCRE tables
178#	cidr_table(5), format of CIDR tables
179# README FILES
180# .ad
181# .fi
182#	Use "\fBpostconf readme_directory\fR" or
183#	"\fBpostconf html_directory\fR" to locate this information.
184# .na
185# .nf
186#	DATABASE_README, Postfix lookup table overview
187# AUTHOR(S)
188#	The regexp table lookup code was originally written by:
189#	LaMont Jones
190#	lamont@hp.com
191#
192#	That code was based on the PCRE dictionary contributed by:
193#	Andrew McNamara
194#	andrewm@connect.com.au
195#	connect.com.au Pty. Ltd.
196#	Level 3, 213 Miller St
197#	North Sydney, NSW, Australia
198#
199#	Adopted and adapted by:
200#	Wietse Venema
201#	IBM T.J. Watson Research
202#	P.O. Box 704
203#	Yorktown Heights, NY 10598, USA
204#
205#	Wietse Venema
206#	Google, Inc.
207#	111 8th Avenue
208#	New York, NY 10011, USA
209#--
210