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# INLINE SPECIFICATION 159# .ad 160# .fi 161# The contents of a table may be specified in the table name. 162# The basic syntax is: 163# 164# .nf 165# main.cf: 166# \fIparameter\fR \fB= .. pcre:{ { \fIrule-1\fB }, { \fIrule-2\fB } .. } ..\fR 167# 168# master.cf: 169# \fB.. -o { \fIparameter\fR \fB= .. pcre:{ { \fIrule-1\fB }, { \fIrule-2\fB } .. } .. } ..\fR 170# .fi 171# 172# Postfix ignores whitespace after '{' and before '}', and 173# writes each \fIrule\fR as one text line to an in-memory 174# file: 175# 176# .nf 177# in-memory file: 178# rule-1 179# rule-2 180# .. 181# .fi 182# 183# Postfix parses the result as if it is a file in /etc/postfix. 184# 185# Note: if a rule contains \fB$\fR, specify \fB$$\fR to keep 186# Postfix from trying to do \fI$name\fR expansion as it 187# evaluates a parameter value. 188# EXAMPLE SMTPD ACCESS MAP 189# # Protect your outgoing majordomo exploders 190# /^(?!owner-)(.*)-outgoing@(.*)/ 550 Use ${1}@${2} instead 191# 192# # Bounce friend@whatever, except when whatever is our domain (you would 193# # be better just bouncing all friend@ mail - this is just an example). 194# /^(friend@(?!my\\.domain$).*)$/ 550 Stick this in your pipe $1 195# 196# # A multi-line entry. The text is sent as one line. 197# # 198# /^noddy@my\\.domain$/ 199# \ 550 This user is a funny one. You really don't want to send mail to 200# \ them as it only makes their head spin. 201# EXAMPLE HEADER FILTER MAP 202# /^Subject: make money fast/ REJECT 203# /^To: friend@public\\.com/ REJECT 204# EXAMPLE BODY FILTER MAP 205# # First skip over base 64 encoded text to save CPU cycles. 206# # Requires PCRE version 3. 207# ~^[[:alnum:]+/]{60,}$~ OK 208# 209# # Put your own body patterns here. 210# SEE ALSO 211# postmap(1), Postfix lookup table manager 212# postconf(5), configuration parameters 213# regexp_table(5), format of POSIX regular expression tables 214# README FILES 215# .ad 216# .fi 217# Use "\fBpostconf readme_directory\fR" or 218# "\fBpostconf html_directory\fR" to locate this information. 219# .na 220# .nf 221# DATABASE_README, Postfix lookup table overview 222# AUTHOR(S) 223# The PCRE table lookup code was originally written by: 224# Andrew McNamara 225# andrewm@connect.com.au 226# connect.com.au Pty. Ltd. 227# Level 3, 213 Miller St 228# North Sydney, NSW, Australia 229# 230# Adopted and adapted by: 231# Wietse Venema 232# IBM T.J. Watson Research 233# P.O. Box 704 234# Yorktown Heights, NY 10598, USA 235# 236# Wietse Venema 237# Google, Inc. 238# 111 8th Avenue 239# New York, NY 10011, USA 240#-- 241