~ubuntu-branches/ubuntu/hoary/postfix/hoary-security

« back to all changes in this revision

Viewing changes to man/man5/regexp_table.5

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-10-06 11:50:33 UTC
  • Revision ID: james.westby@ubuntu.com-20041006115033-ooo6yfg6kmoteu04
Tags: upstream-2.1.3
ImportĀ upstreamĀ versionĀ 2.1.3

Show diffs side-by-side

added added

removed removed

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