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\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 Perl Compatible 16# Regular Expression form. In this case, each input is compared 17# against a list of patterns. When a match is found, the 18# corresponding 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 as 24# 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 PCRE table is: 35# .IP "\fB/\fIpattern\fB/\fIflags result\fR" 36# When \fIpattern\fR matches the input string, use 37# the corresponding \fIresult\fR value. 38# .IP "\fB!/\fIpattern\fB/\fIflags result\fR" 39# When \fIpattern\fR does \fBnot\fR match the input string, use 40# 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 matches 45# \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 \fBnot\fR 55# 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 perl-like regular expression. The expression 69# delimiter can be any non-alphanumerical character, except 70# whitespace or characters 71# that have special meaning (traditionally the forward slash is used). 72# The regular expression can contain whitespace. 73# 74# By default, matching is case-insensitive, and newlines are not 75# treated as special characters. The behavior is controlled by flags, 76# which are toggled by appending one or more of the following 77# characters after the pattern: 78# .IP "\fBi\fR (default: on)" 79# Toggles the case sensitivity flag. By default, matching is case 80# insensitive. 81# .IP "\fBm\fR (default: off)" 82# Toggles the PCRE_MULTILINE flag. When this flag is on, the \fB^\fR 83# and \fB$\fR metacharacters match immediately after and immediately 84# before a newline character, respectively, in addition to 85# matching at the start and end of the subject string. 86# .IP "\fBs\fR (default: on)" 87# Toggles the PCRE_DOTALL flag. When this flag is on, the \fB.\fR 88# metacharacter matches the newline character. With 89# Postfix versions prior to 2.0, the flag is off by 90# default, which is inconvenient for multi-line message header 91# matching. 92# .IP "\fBx\fR (default: off)" 93# Toggles the pcre extended flag. When this flag is on, whitespace 94# characters in the pattern (other than in a character class) 95# are ignored. To include a whitespace character as part of 96# the pattern, escape it with backslash. 97# .sp 98# Note: do not use \fB#\fIcomment\fR after patterns. 99# .IP "\fBA\fR (default: off)" 100# Toggles the PCRE_ANCHORED flag. When this flag is on, 101# the pattern is forced to be "anchored", that is, it is 102# constrained to match only at the start of the string which 103# is being searched (the "subject string"). This effect can 104# also be achieved by appropriate constructs in the pattern 105# itself. 106# .IP "\fBE\fR (default: off)" 107# Toggles the PCRE_DOLLAR_ENDONLY flag. When this flag is on, 108# a \fB$\fR metacharacter in the pattern matches only at the 109# end of the subject string. Without this flag, a dollar also 110# matches immediately before the final character if it is a 111# newline character (but not before any other newline 112# characters). This flag is ignored if PCRE_MULTILINE 113# flag is set. 114# .IP "\fBU\fR (default: off)" 115# Toggles the ungreedy matching flag. When this flag is on, 116# the pattern matching engine inverts the "greediness" of 117# the quantifiers so that they are not greedy by default, 118# but become greedy if followed by "?". This flag can also 119# set by a (?U) modifier within the pattern. 120# .IP "\fBX\fR (default: off)" 121# Toggles the PCRE_EXTRA flag. 122# When this flag is on, any backslash in a pattern that is 123# followed by a letter that has no special meaning causes an 124# error, thus reserving these combinations for future expansion. 125# SEARCH ORDER 126# .ad 127# .fi 128# Patterns are applied in the order as specified in the table, until a 129# pattern is found that matches the input string. 130# 131# Each pattern is applied to the entire input string. 132# Depending on the application, that string is an entire client 133# hostname, an entire client IP address, or an entire mail address. 134# Thus, no parent domain or parent network search is done, and 135# \fIuser@domain\fR mail addresses are not broken up into their 136# \fIuser\fR and \fIdomain\fR constituent parts, nor is \fIuser+foo\fR 137# broken up into \fIuser\fR and \fIfoo\fR. 138# TEXT SUBSTITUTION 139# .ad 140# .fi 141# Substitution of substrings from the matched expression into the result 142# string is possible using the conventional perl syntax ($1, $2, etc.); 143# specify $$ to produce a $ character as output. 144# The macros in the result string may need to be written as ${n} 145# or $(n) if they aren't followed by whitespace. 146# 147# Note: since negated patterns (those preceded by \fB!\fR) return a 148# result when the expression does not match, substitutions are not 149# available for negated patterns. 150# EXAMPLE SMTPD ACCESS MAP 151# # Protect your outgoing majordomo exploders 152# /^(?!owner-)(.*)-outgoing@(.*)/ 550 Use ${1}@${2} instead 153# 154# # Bounce friend@whatever, except when whatever is our domain (you would 155# # be better just bouncing all friend@ mail - this is just an example). 156# /^(friend@(?!my\\.domain$).*)$/ 550 Stick this in your pipe $1 157# 158# # A multi-line entry. The text is sent as one line. 159# # 160# /^noddy@my\\.domain$/ 161# \ 550 This user is a funny one. You really don't want to send mail to 162# \ them as it only makes their head spin. 163# EXAMPLE HEADER FILTER MAP 164# /^Subject: make money fast/ REJECT 165# /^To: friend@public\\.com/ REJECT 166# EXAMPLE BODY FILTER MAP 167# # First skip over base 64 encoded text to save CPU cycles. 168# # Requires PCRE version 3. 169# ~^[[:alnum:]+/]{60,}$~ OK 170# 171# # Put your own body patterns here. 172# SEE ALSO 173# postmap(1), Postfix lookup table manager 174# postconf(5), configuration parameters 175# regexp_table(5), format of POSIX regular expression tables 176# README FILES 177# .ad 178# .fi 179# Use "\fBpostconf readme_directory\fR" or 180# "\fBpostconf html_directory\fR" to locate this information. 181# .na 182# .nf 183# DATABASE_README, Postfix lookup table overview 184# AUTHOR(S) 185# The PCRE table lookup code was originally written by: 186# Andrew McNamara 187# andrewm@connect.com.au 188# connect.com.au Pty. Ltd. 189# Level 3, 213 Miller St 190# North Sydney, NSW, Australia 191# 192# Adopted and adapted by: 193# Wietse Venema 194# IBM T.J. Watson Research 195# P.O. Box 704 196# Yorktown Heights, NY 10598, USA 197#-- 198