xref: /netbsd-src/external/ibm-public/postfix/dist/proto/regexp_table (revision b1c86f5f087524e68db12794ee9c3e3da1ab17a0)
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\fR <\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.
25# COMPATIBILITY
26# .ad
27# .fi
28#	With Postfix version 2.2 and earlier specify "\fBpostmap
29#	-fq\fR" to query a table that contains case sensitive
30#	patterns. Patterns are case insensitive by default.
31# TABLE FORMAT
32# .ad
33# .fi
34#	The general form of a Postfix regular expression table is:
35# .IP "\fB/\fIpattern\fB/\fIflags result\fR"
36#	When \fIpattern\fR matches the input string,
37#	use the corresponding \fIresult\fR value.
38# .IP "\fB!/\fIpattern\fB/\fIflags result\fR"
39#	When \fIpattern\fR does \fBnot\fR match the input string,
40#	use the corresponding \fIresult\fR value.
41# .IP "\fBif /\fIpattern\fB/\fIflags\fR"
42# .IP "\fBendif\fR"
43#       Match the input string against the patterns between \fBif\fR
44#	and \fBendif\fR, if and only if that same input string also
45#	matches \fIpattern\fR. The \fBif\fR..\fBendif\fR can nest.
46# .sp
47#       Note: do not prepend whitespace to patterns inside
48#	\fBif\fR..\fBendif\fR.
49# .sp
50#	This feature is available in Postfix 2.1 and later.
51# .IP "\fBif !/\fIpattern\fB/\fIflags\fR"
52# .IP "\fBendif\fR"
53#       Match the input string against the patterns between \fBif\fR
54#	and \fBendif\fR, if and only if that same input string does
55#	\fBnot\fR match \fIpattern\fR. The \fBif\fR..\fBendif\fR can nest.
56# .sp
57#       Note: do not prepend whitespace to patterns inside
58#	\fBif\fR..\fBendif\fR.
59# .sp
60#	This feature is available in Postfix 2.1 and later.
61# .IP "blank lines and comments"
62#	Empty lines and whitespace-only lines are ignored, as
63#	are lines whose first non-whitespace character is a `#'.
64# .IP "multi-line text"
65#	A logical line starts with non-whitespace text. A line that
66#	starts with whitespace continues a logical line.
67# .PP
68#	Each pattern is a POSIX regular expression enclosed by a pair of
69#	delimiters. The regular expression syntax is documented in
70#	\fBre_format\fR(7) with 4.4BSD, in \fBregex\fR(5) with Solaris, and in
71#	\fBregex\fR(7) with Linux. Other systems may use other document names.
72#
73#	The expression delimiter can be any non-alphanumerical
74#	character, except whitespace
75#	or characters that have special meaning (traditionally the forward
76#	slash is used). The regular expression can contain whitespace.
77#
78#	By default, matching is case-insensitive, and newlines are not
79#	treated as special characters. The behavior is controlled by flags,
80#	which are toggled by appending one or more of the following
81#	characters after the pattern:
82# .IP "\fBi\fR (default: on)"
83#	Toggles the case sensitivity flag. By default, matching is case
84#	insensitive.
85# .IP "\fBm\fR (default: off)"
86#	Toggle the multi-line mode flag. When this flag is on, the \fB^\fR
87#	and \fB$\fR metacharacters match immediately after and immediately
88#	before a newline character, respectively, in addition to
89#	matching at the start and end of the input string.
90# .IP "\fBx\fR (default: on)"
91#	Toggles the extended expression syntax flag. By default, support
92#	for extended expression syntax is enabled.
93# TABLE SEARCH ORDER
94# .ad
95# .fi
96#	Patterns are applied in the order as specified in the table, until a
97#	pattern is found that matches the input string.
98#
99#	Each pattern is applied to the entire input string.
100#	Depending on the application, that string is an entire client
101#	hostname, an entire client IP address, or an entire mail address.
102#	Thus, no parent domain or parent network search is done, and
103#	\fIuser@domain\fR mail addresses are not broken up into their
104#	\fIuser\fR and \fIdomain\fR constituent parts, nor is \fIuser+foo\fR
105#	broken up into \fIuser\fR and \fIfoo\fR.
106# TEXT SUBSTITUTION
107# .ad
108# .fi
109#	Substitution of substrings from the matched expression into the result
110#	string is possible using $1, $2, etc.;
111#	specify $$ to produce a $ character as output.
112#	The macros in the result string
113#	may need to be written as ${n} or $(n) if they aren't followed
114#	by whitespace.
115#
116#	Note: since negated patterns (those preceded by \fB!\fR) return a
117#	result when the expression does not match, substitutions are not
118#	available for negated patterns.
119# EXAMPLE SMTPD ACCESS MAP
120#	# Disallow sender-specified routing. This is a must if you relay mail
121#	# for other domains.
122#	/[%!@].*[%!@]/	     550 Sender-specified routing rejected
123#
124#	# Postmaster is OK, that way they can talk to us about how to fix
125#	# their problem.
126#	/^postmaster@/	     OK
127#
128#	# Protect your outgoing majordomo exploders
129#	if !/^owner-/
130#	/^(.*)-outgoing@(.*)$/	 550 Use ${1}@${2} instead
131#	endif
132# EXAMPLE HEADER FILTER MAP
133#	# These were once common in junk mail.
134#	/^Subject: make money fast/     REJECT
135#	/^To: friend@public\\.com/	 REJECT
136# EXAMPLE BODY FILTER MAP
137#	# First skip over base 64 encoded text to save CPU cycles.
138#	~^[[:alnum:]+/]{60,}$~		OK
139#
140#	# Put your own body patterns here.
141# SEE ALSO
142#	postmap(1), Postfix lookup table manager
143#	pcre_table(5), format of PCRE tables
144#	cidr_table(5), format of CIDR tables
145# README FILES
146# .ad
147# .fi
148#	Use "\fBpostconf readme_directory\fR" or
149#	"\fBpostconf html_directory\fR" to locate this information.
150# .na
151# .nf
152#	DATABASE_README, Postfix lookup table overview
153# AUTHOR(S)
154#	The regexp table lookup code was originally written by:
155#	LaMont Jones
156#	lamont@hp.com
157#
158#	That code was based on the PCRE dictionary contributed by:
159#	Andrew McNamara
160#	andrewm@connect.com.au
161#	connect.com.au Pty. Ltd.
162#	Level 3, 213 Miller St
163#	North Sydney, NSW, Australia
164#
165#	Adopted and adapted by:
166#	Wietse Venema
167#	IBM T.J. Watson Research
168#	P.O. Box 704
169#	Yorktown Heights, NY 10598, USA
170#--
171