1#++ 2# NAME 3# pcre_table 5 4# SUMMARY 5# format of Postfix PCRE tables 6# SYNOPSIS 7# \fBpostmap -q "\fIstring\fB" pcre:/etc/postfix/\fIfilename\fR 8# 9# \fBpostmap -q - pcre:/etc/postfix/\fIfilename\fB <\fIinputfile\fR 10# 11# \fBpostmap -hmq - pcre:/etc/postfix/\fIfilename\fB <\fIinputfile\fR 12# 13# \fBpostmap -bmq - pcre:/etc/postfix/\fIfilename\fB <\fIinputfile\fR 14# DESCRIPTION 15# The Postfix mail system uses optional tables for address 16# rewriting, mail routing, or access control. These tables 17# are usually in \fBdbm\fR or \fBdb\fR format. 18# 19# Alternatively, lookup tables can be specified in Perl Compatible 20# Regular Expression form. In this case, each input is compared 21# against a list of patterns. When a match is found, the 22# corresponding result is returned and the search is terminated. 23# 24# To find out what types of lookup tables your Postfix system 25# supports use the "\fBpostconf -m\fR" command. 26# 27# To test lookup tables, use the "\fBpostmap -q\fR" command 28# as described in the SYNOPSIS above. Use "\fBpostmap -hmq 29# -\fR <\fIfile\fR" for header_checks(5) patterns, and 30# "\fBpostmap -bmq -\fR <\fIfile\fR" for body_checks(5) 31# (Postfix 2.6 and later). 32# COMPATIBILITY 33# .ad 34# .fi 35# With Postfix version 2.2 and earlier specify "\fBpostmap 36# -fq\fR" to query a table that contains case sensitive 37# patterns. Patterns are case insensitive by default. 38# TABLE FORMAT 39# .ad 40# .fi 41# The general form of a PCRE table is: 42# .IP "\fB/\fIpattern\fB/\fIflags result\fR" 43# When \fIpattern\fR matches the input string, use 44# the corresponding \fIresult\fR value. 45# .IP "\fB!/\fIpattern\fB/\fIflags result\fR" 46# When \fIpattern\fR does \fBnot\fR match the input string, use 47# the corresponding \fIresult\fR value. 48# .IP "\fBif /\fIpattern\fB/\fIflags\fR" 49# .IP "\fBendif\fR" 50# If the input string matches /\fIpattern\fR/, then match that 51# input string against the patterns between \fBif\fR and 52# \fBendif\fR. The \fBif\fR..\fBendif\fR can nest. 53# .sp 54# Note: do not prepend whitespace to patterns inside 55# \fBif\fR..\fBendif\fR. 56# .sp 57# This feature is available in Postfix 2.1 and later. 58# .IP "\fBif !/\fIpattern\fB/\fIflags\fR" 59# .IP "\fBendif\fR" 60# If the input string does not match /\fIpattern\fR/, then 61# match that input string against the patterns between \fBif\fR 62# and \fBendif\fR. The \fBif\fR..\fBendif\fR can nest. 63# .sp 64# Note: do not prepend whitespace to patterns inside 65# \fBif\fR..\fBendif\fR. 66# .sp 67# This feature is available in Postfix 2.1 and later. 68# .IP "blank lines and comments" 69# Empty lines and whitespace-only lines are ignored, as 70# are lines whose first non-whitespace character is a `#'. 71# .IP "multi-line text" 72# A logical line starts with non-whitespace text. A line that 73# starts with whitespace continues a logical line. 74# .PP 75# Each pattern is a perl-like regular expression. The expression 76# delimiter can be any non-alphanumerical character, except 77# whitespace or characters 78# that have special meaning (traditionally the forward slash is used). 79# 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# Toggles the PCRE_MULTILINE 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 subject string. 93# .IP "\fBs\fR (default: on)" 94# Toggles the PCRE_DOTALL flag. When this flag is on, the \fB.\fR 95# metacharacter matches the newline character. With 96# Postfix versions prior to 2.0, the flag is off by 97# default, which is inconvenient for multi-line message header 98# matching. 99# .IP "\fBx\fR (default: off)" 100# Toggles the pcre extended flag. When this flag is on, whitespace 101# characters in the pattern (other than in a character class) 102# are ignored. To include a whitespace character as part of 103# the pattern, escape it with backslash. 104# .sp 105# Note: do not use \fB#\fIcomment\fR after patterns. 106# .IP "\fBA\fR (default: off)" 107# Toggles the PCRE_ANCHORED flag. When this flag is on, 108# the pattern is forced to be "anchored", that is, it is 109# constrained to match only at the start of the string which 110# is being searched (the "subject string"). This effect can 111# also be achieved by appropriate constructs in the pattern 112# itself. 113# .IP "\fBE\fR (default: off)" 114# Toggles the PCRE_DOLLAR_ENDONLY flag. When this flag is on, 115# a \fB$\fR metacharacter in the pattern matches only at the 116# end of the subject string. Without this flag, a dollar also 117# matches immediately before the final character if it is a 118# newline character (but not before any other newline 119# characters). This flag is ignored if PCRE_MULTILINE 120# flag is set. 121# .IP "\fBU\fR (default: off)" 122# Toggles the ungreedy matching flag. When this flag is on, 123# the pattern matching engine inverts the "greediness" of 124# the quantifiers so that they are not greedy by default, 125# but become greedy if followed by "?". This flag can also 126# set by a (?U) modifier within the pattern. 127# .IP "\fBX\fR (default: off)" 128# Toggles the PCRE_EXTRA flag. 129# When this flag is on, any backslash in a pattern that is 130# followed by a letter that has no special meaning causes an 131# error, thus reserving these combinations for future expansion. 132# SEARCH ORDER 133# .ad 134# .fi 135# Patterns are applied in the order as specified in the table, until a 136# pattern is found that matches the input string. 137# 138# Each pattern is applied to the entire input string. 139# Depending on the application, that string is an entire client 140# hostname, an entire client IP address, or an entire mail address. 141# Thus, no parent domain or parent network search is done, and 142# \fIuser@domain\fR mail addresses are not broken up into their 143# \fIuser\fR and \fIdomain\fR constituent parts, nor is \fIuser+foo\fR 144# broken up into \fIuser\fR and \fIfoo\fR. 145# TEXT SUBSTITUTION 146# .ad 147# .fi 148# Substitution of substrings (text that matches patterns 149# inside "()") from the matched expression into the result 150# string is requested with $1, $2, etc.; specify $$ to produce 151# a $ character as output. 152# The macros in the result string may need to be written as 153# ${n} or $(n) if they aren't followed by whitespace. 154# 155# Note: since negated patterns (those preceded by \fB!\fR) return a 156# result when the expression does not match, substitutions are not 157# available for negated patterns. 158# EXAMPLE SMTPD ACCESS MAP 159# # Protect your outgoing majordomo exploders 160# /^(?!owner-)(.*)-outgoing@(.*)/ 550 Use ${1}@${2} instead 161# 162# # Bounce friend@whatever, except when whatever is our domain (you would 163# # be better just bouncing all friend@ mail - this is just an example). 164# /^(friend@(?!my\\.domain$).*)$/ 550 Stick this in your pipe $1 165# 166# # A multi-line entry. The text is sent as one line. 167# # 168# /^noddy@my\\.domain$/ 169# \ 550 This user is a funny one. You really don't want to send mail to 170# \ them as it only makes their head spin. 171# EXAMPLE HEADER FILTER MAP 172# /^Subject: make money fast/ REJECT 173# /^To: friend@public\\.com/ REJECT 174# EXAMPLE BODY FILTER MAP 175# # First skip over base 64 encoded text to save CPU cycles. 176# # Requires PCRE version 3. 177# ~^[[:alnum:]+/]{60,}$~ OK 178# 179# # Put your own body patterns here. 180# SEE ALSO 181# postmap(1), Postfix lookup table manager 182# postconf(5), configuration parameters 183# regexp_table(5), format of POSIX regular expression tables 184# README FILES 185# .ad 186# .fi 187# Use "\fBpostconf readme_directory\fR" or 188# "\fBpostconf html_directory\fR" to locate this information. 189# .na 190# .nf 191# DATABASE_README, Postfix lookup table overview 192# AUTHOR(S) 193# The PCRE table lookup code was originally written by: 194# Andrew McNamara 195# andrewm@connect.com.au 196# connect.com.au Pty. Ltd. 197# Level 3, 213 Miller St 198# North Sydney, NSW, Australia 199# 200# Adopted and adapted by: 201# Wietse Venema 202# IBM T.J. Watson Research 203# P.O. Box 704 204# Yorktown Heights, NY 10598, USA 205# 206# Wietse Venema 207# Google, Inc. 208# 111 8th Avenue 209# New York, NY 10011, USA 210#-- 211