This involved a rewrite of the pcre map code similar to
the regexp map code. File: util/dict_pcre.c.
+20020917
+
+ Feature: on Linux, support for PCRE lookup tables is now
+ compiled in if the PCRE library code is found under
+ /usr/include and /usr/lib. File: makedefs.
+
Open problems:
Low: smtpd should log queue ID with reject/warn/hold/discard
date. Snapshots change only the release date, unless they include
the same bugfixes as a patch release.
-Incompatible changes with Postfix snapshot 1.1.11-20020916
+Incompatible changes with Postfix snapshot 1.1.11-20020917
==========================================================
The relayhost setting now behaves as documented, i.e. you can no
longer specify multiple destinations.
-Major changes with Postfix snapshot 1.1.11-20020916
+In regexp lookup tables, the form /pattern1/!/pattern2/ is going
+away. Use the cleaner and more flexible "if !/pattern2/..endif"
+form. The old form still exists but is no longer documented.
+
+Major changes with Postfix snapshot 1.1.11-20020917
===================================================
-Speedups of regexp table lookups by optimizing the compilation and
-execution settings for the actual number of $number substitutions
-in the right-hand side. Based on a suggestion by Liviu Daia.
+Speedups of regexp table lookups by optimizing for the $number
+substitutions that are actually present in the right-hand side.
+Based on a suggestion by Liviu Daia.
-Speedups of regexp and pcre tables, using IF..ENDIF support based
-on an idea by Bert Driehuis. To protect a block of patterns, use:
+Speedups of regexp and pcre tables, using IF..ENDIF support. Based
+on an idea by Bert Driehuis. To protect a block of patterns, use:
- if /pattern/
- /pattern2/ replacement text1
- /pattern2/ replacement text2
+ if /pattern1/
+ /pattern2/ result2
+ /pattern3/ result3
endif
IF..ENDIF can nest. Don't specify blanks at the beginning of lines
-inside IF..ENDIF. Lines beginning with whitespace are appended to
-the previous line.
+inside IF..ENDIF, because lines beginning with whitespace are
+appended to the previous line. More details about the syntax are
+given in the pcre_table(5) and regexp_table(5) manual pages.
Incompatible changes with Postfix snapshot 1.1.11-20020906
==========================================================
# SYNOPSIS
# postmap /etc/postfix/access
#
+# postmap -q "string" /etc/postfix/access
+#
+# postmap -q - /etc/postfix/access <inputfile
+#
# DESCRIPTION
# The optional access table directs the Postfix SMTP server
# to selectively reject or accept mail. Access can be
-#
# CANONICAL(5) CANONICAL(5)
#
# NAME
# SYNOPSIS
# postmap /etc/postfix/canonical
#
+# postmap -q "string" /etc/postfix/canonical
+#
+# postmap -q - /etc/postfix/canonical <inputfile
+#
# DESCRIPTION
# The optional canonical table specifies an address mapping
# for local and non-local addresses. The mapping is used by
# P.O. Box 704
# Yorktown Heights, NY 10598, USA
#
-# 1
-#
+# CANONICAL(5)
# The header_checks parameter specifies an optional table with patterns
# that each logical message header is matched against, including
-# headers that span multiple physical lines. Patterns are matched
-# in the specified order, and the search stops upon the first match.
-# When a pattern matches, what happens next depends on the associated
-# action that is specified in the right-hand side of the table:
-#
-# REJECT [optional text...]
-# Reject the entire message. The optional text is sent to the
-# originator and is logged to the maillog file.
-# IGNORE Silently discard the header line.
-# WARN [optional text...]
-# Log the message header and the optional text. This is useful
-# for testing. When the pattern is OK, change the WARN into a
-# REJECT or into a DISCARD.
-# HOLD [optional text...]
-# Place the message on the hold queue. Mail on hold can be
-# inspected with the postcat command, and can be destroyed or
-# taken off hold (i.e. delivered) with the postsuper command.
-# The matched header is logged with the optional text.
-# DISCARD [optional text...]
-# Claim successful delivery and silently discard the message.
-# The matched header is logged with the optional text.
-# FILTER transport:nexthop
-# after the message is queued, send the entire message through
-# a content filter. This requires different cleanup servers
-# before and after the filter, with header/body checks turned
-# off in the second cleanup server.
+# headers that span multiple physical lines.
#
# By default, these patterns also apply to MIME headers and to the
# headers of attached messages. With older Postfix versions, MIME and
# attached message headers were treated as body text.
#
-# See also the body_checks example in the sample-filter.cf file.
+# For details, see the sample-filter.cf file.
#
#header_checks = regexp:/etc/postfix/header_checks
# SYNOPSIS
# pcre:/etc/postfix/filename
#
+# postmap -q "string" pcre:/etc/postfix/filename
+#
+# postmap -q - pcre:/etc/postfix/filename <inputfile
+#
# DESCRIPTION
# The Postfix mail system uses optional tables for address
# rewriting or mail routing. These tables are usually in dbm
# To find out what types of lookup tables your Postfix sys-
# tem supports use the postconf -m command.
#
+# To test lookup tables, use the postmap command as
+# described in the SYNOPSIS above.
+#
# The general form of a PCRE table is:
#
-# pattern result
-# When pattern matches a search string, use the cor-
-# responding result.
+# /pattern/flags result
+# When pattern matches a search string, use the cor-
+# responding result value.
#
# blank lines and comments
-# Empty lines and whitespace-only lines are ignored,
-# as are lines whose first non-whitespace character
+# Empty lines and whitespace-only lines are ignored,
+# as are lines whose first non-whitespace character
# is a `#'.
#
# multi-line text
-# A logical line starts with non-whitespace text. A
-# line that starts with whitespace continues a logi-
+# A logical line starts with non-whitespace text. A
+# line that starts with whitespace continues a logi-
# cal line.
#
+# if /pattern/flags
+#
+# endif Examine the lines between if..endif only if pattern
+# matches. The if..endif can nest. Do not prepend
+# whitespace to patterns inside if..endif.
+#
# Each pattern is a perl-like regular expression. The
-# expression delimiter can be any character, except whites-
-# pace or characters that have special meaning (tradition-
-# ally the forward slash is used). The regular expression
+# expression delimiter can be any character, except whites-
+# pace or characters that have special meaning (tradition-
+# ally the forward slash is used). The regular expression
# can contain whitespace.
#
# By default, matching is case-insensitive, and newlines are
-# not treated as special characters. The behavior is con-
-# trolled by flags, which are toggled by appending one or
+# not treated as special characters. The behavior is con-
+# trolled by flags, which are toggled by appending one or
# more of the following characters after the pattern:
#
# i (default: on)
-# Toggles the case sensitivity flag. By default,
+# Toggles the case sensitivity flag. By default,
# matching is case insensitive.
#
# m (default: off)
-# Toggles the PCRE_MULTILINE flag. When this flag is
-# on, the ^ and $ metacharacters match immediately
-# after and immediately before a newline character,
-# respectively, in addition to matching at the start
+# Toggles the PCRE_MULTILINE flag. When this flag is
+# on, the ^ and $ metacharacters match immediately
+# after and immediately before a newline character,
+# respectively, in addition to matching at the start
# and end of the subject string.
#
# s (default: on)
# Toggles the PCRE_DOTALL flag. When this flag is on,
# the . metacharacter matches the newline character.
-# With Postfix versions prior to 20020528, The flag
+# With Postfix versions prior to 20020528, The flag
# is off by default, which is inconvenient for multi-
# line message header matching.
#
# x (default: off)
-# Toggles the pcre extended flag. When this flag is
-# on, whitespace in the pattern (other than in a
+# Toggles the pcre extended flag. When this flag is
+# on, whitespace in the pattern (other than in a
# character class) and characters between a # outside
-# a character class and the next newline character
-# are ignored. An escaping backslash can be used to
-# include a whitespace or # character as part of the
+# a character class and the next newline character
+# are ignored. An escaping backslash can be used to
+# include a whitespace or # character as part of the
# pattern.
#
# A (default: off)
-# Toggles the PCRE_ANCHORED flag. When this flag is
-# on, the pattern is forced to be "anchored", that
+# Toggles the PCRE_ANCHORED flag. When this flag is
+# on, the pattern is forced to be "anchored", that
# is, it is constrained to match only at the start of
-# the string which is being searched (the "subject
-# string"). This effect can also be achieved by
+# the string which is being searched (the "subject
+# string"). This effect can also be achieved by
# appropriate constructs in the pattern itself.
#
# E (default: off)
-# Toggles the PCRE_DOLLAR_ENDONLY flag. When this
-# flag is on, a $ metacharacter in the pattern
-# matches only at the end of the subject string.
-# Without this flag, a dollar also matches immedi-
+# Toggles the PCRE_DOLLAR_ENDONLY flag. When this
+# flag is on, a $ metacharacter in the pattern
+# matches only at the end of the subject string.
+# Without this flag, a dollar also matches immedi-
# ately before the final character if it is a newline
# character (but not before any other newline charac-
-# ters). This flag is ignored if PCRE_MULTILINE flag
+# ters). This flag is ignored if PCRE_MULTILINE flag
# is set.
#
# U (default: off)
# Toggles the ungreedy matching flag. When this flag
-# is on, the pattern matching engine inverts the
-# "greediness" of the quantifiers so that they are
-# not greedy by default, but become greedy if fol-
-# lowed by "?". This flag can also set by a (?U)
+# is on, the pattern matching engine inverts the
+# "greediness" of the quantifiers so that they are
+# not greedy by default, but become greedy if fol-
+# lowed by "?". This flag can also set by a (?U)
# modifier within the pattern.
#
# X (default: off)
# Toggles the PCRE_EXTRA flag. When this flag is on,
-# any backslash in a pattern that is followed by a
+# any backslash in a pattern that is followed by a
# letter that has no special meaning causes an error,
# thus reserving these combinations for future expan-
# sion.
#
-# Each pattern is applied to the entire lookup key string.
-# Depending on the application, that string is an entire
+# Each pattern is applied to the entire lookup key string.
+# Depending on the application, that string is an entire
# client hostname, an entire client IP address, or an entire
-# mail address. Thus, no parent domain or parent network
-# search is done, and user@domain mail addresses are not
-# broken up into their user and domain constituent parts,
+# mail address. Thus, no parent domain or parent network
+# search is done, and user@domain mail addresses are not
+# broken up into their user and domain constituent parts,
# nor is user+foo broken up into user and foo.
#
-# Patterns are applied in the order as specified in the
-# table, until a pattern is found that matches the search
+# Patterns are applied in the order as specified in the
+# table, until a pattern is found that matches the search
# string.
#
-# Substitution of substrings from the matched expression
-# into the result string is possible using the conventional
-# perl syntax ($1, $2, etc.). The macros in the result
-# string may need to be written as ${n} or $(n) if they
+# Substitution of substrings from the matched expression
+# into the result string is possible using the conventional
+# perl syntax ($1, $2, etc.). The macros in the result
+# string may need to be written as ${n} or $(n) if they
# aren't followed by whitespace.
#
# EXAMPLE SMTPD ACCESS MAP
# SYNOPSIS
# regexp:/etc/postfix/filename
#
+# postmap -q "string" regexp:/etc/postfix/filename
+#
+# postmap -q - regexp:/etc/postfix/filename <inputfile
+#
# DESCRIPTION
# The Postfix mail system uses optional tables for address
# rewriting or mail routing. These tables are usually in dbm
# To find out what types of lookup tables your Postfix sys-
# tem supports use the postconf -m command.
#
+# To test lookup tables, use the postmap command as
+# described in the SYNOPSIS above.
+#
# The general form of a Postfix regular expression table is:
#
-# pattern result
-# When pattern matches a search string, use the cor-
-# responding result.
+# /pattern/flags result
+#
+# !/pattern/flags result
+# When pattern matches (does not match) a search
+# string, use the corresponding result value.
#
# blank lines and comments
-# Empty lines and whitespace-only lines are ignored,
-# as are lines whose first non-whitespace character
+# Empty lines and whitespace-only lines are ignored,
+# as are lines whose first non-whitespace character
# is a `#'.
#
# multi-line text
-# A logical line starts with non-whitespace text. A
-# line that starts with whitespace continues a logi-
+# A logical line starts with non-whitespace text. A
+# line that starts with whitespace continues a logi-
# cal line.
#
-# pattern1!pattern2 result
-# Matches pattern1 but not pattern2.
+# if /pattern/flags
+#
+# if !/pattern/flags
+#
+# endif Examine the lines between if..endif only if pattern
+# matches (does not match). The if..endif can nest.
+# Do not prepend whitespace to patterns inside
+# if..endif.
#
# Each pattern is a regular expression enclosed by a pair of
# delimiters. The regular expression syntax is described in
# that each logical message header is matched against, including
# headers that span multiple physical lines. Patterns are matched
# in the specified order, and the search stops upon the first match.
+#
+# For examples of pattern syntax see the sample-regexp-header.cf and
+# sample-pcre-header.cf files.
+#
# When a pattern matches, what happens next depends on the associated
# action that is specified in the right-hand side of the table:
#
# REJECT [optional text...]
-# Reject the entire message. The optional text is sent to the
+# Reject the entire message. The optional text is sent to the
# originator and is logged to the maillog file.
# IGNORE Silently discard the header line.
# WARN [optional text...]
# related headers in message headers, and to the headers that follow
# multipart boundary strings. Headers may span multiple physical lines.
# Patterns are matched in the specified order, and the search stops
-# upon the first match. When a pattern matches, what happens next
-# depends on the associated action that is specified in the right-hand
-# side of the table:
+# upon the first match.
+#
+# For examples of pattern syntax see the sample-regexp-header.cf and
+# sample-pcre-header files.
+#
+# When a pattern matches, what happens next depends on the associated
+# action that is specified in the right-hand side of the table:
#
# REJECT [optional text...]
-# Reject the entire message. The optional text is sent to the
+# Reject the entire message. The optional text is sent to the
# originator and is logged to the maillog file.
# IGNORE Silently discard the body line
-# WARN [optional text...]
+# WARN [optional text...]
# Log the body line and the optional text. This is useful
-# for testing. When the pattern is OK, change the WARN into a
+# for testing. When the pattern is OK, change the WARN into a
# REJECT or into a DISCARD.
# HOLD [optional text...]
# Place the message on the hold queue. Mail on hold can be
# that each attached message header is matched against (except for
# MIME related headers). Headers may span multiple physical lines.
# Patterns are matched in the specified order, and the search stops
-# upon the first match. When a pattern matches, what happens next
-# depends on the associated action that is specified in the right-hand
-# side of the table:
+# upon the first match.
+#
+# For examples of pattern syntax see the sample-regexp-header.cf and
+# sample-pcre-header.cf files.
+#
+# When a pattern matches, what happens next depends on the associated
+# action that is specified in the right-hand side of the table:
#
# REJECT the entire message is rejected.
# REJECT text.... The text is sent to the originator.
# The body_checks parameter specifies an optional table with patterns
# that each physical line in the message body is matched against
# (including MIME headers inside the message body - Postfix does not
-# recognize multi-line MIME headers in the message body).
+# recognize multi-line MIME headers in the message body).
# Lines are matched one at a time. Long lines are matched in chunks
# of at most $line_length_limit characters. Patterns are matched in
# the specified order, and the search stops upon the first match.
+#
+# For examples of pattern syntax see the sample-regexp-body.cf and
+# sample-pcre-body.cf files.
+#
# When a pattern matches, what happens next depends on the associated
# action that is specified in the right-hand side of the table:
#
# matching ungreedy (see PCRE documentation and source for more
# info).
#
+# A block of table entries may be "enclosed" by a line with
+# `if /pattern/flags' and a line with `endif'. This causes
+# the block of table entries to be examined only when the
+# pattern produces a successful match. The `if..endif' may
+# be nested. There currently is no `else' operator.
+#
# The second field is the "replacement" string - the text
# returned by the match. When used for smtpd checks, this would
# be a helpful message to misguided users (or an offensive
# Sample pcre (PERL-compatible regular expression) map file for
# mail body filtering. See pcre_table(5) for syntax description.
#
-# Mail body lines are filtered one line at a time. In particular,
-# multi-line MIME headers in the message body are filtered one text
-# line at a time.
+# Mail body lines are filtered one line at a time. MIME headers are
+# filtered as message headers, i.e. not as part of the mail body.
#
# The first field is a perl-like regular expression. The expression
# delimiter can be any character except whitespace, or characters
# matching ungreedy (see PCRE documentation and source for more
# info).
#
+# A block of table entries may be "enclosed" by a line with
+# `if /pattern/flags' and a line with `endif'. This causes
+# the block of table entries to be examined only when the
+# pattern produces a successful match. The `if..endif' may
+# be nested. There currently is no `else' operator.
+#
# The second field is the "replacement" string - the text
# returned by the match.
#
# matching ungreedy (see PCRE documentation and source for more
# info).
#
+# A block of table entries may be "enclosed" by a line with
+# `if /pattern/flags' and a line with `endif'. This causes
+# the block of table entries to be examined only when the
+# pattern produces a successful match. The `if..endif' may
+# be nested. There currently is no `else' operator.
+#
# The second field is the "replacement" string - the text
# returned by the match.
#
#
# The general format of a table entry is PATTERN RESULT.
#
-# The pattern format is /regexp/flags or /regexp/flags!/regexp/flags
-# where regexp is a regular expression as found in regexp(5), and flags are
+# The pattern format is `/regexp/flags' or `!/regexp/flags' where regexp
+# is a regular expression as found in re_format(7), and flags are
# i: toggle ignore case (REG_ICASE - default is to ignore case)
# x: toggle extended expression (REG_EXTENDED - default is extended)
# m: toggle multiline mode (REG_NEWLINE - default is non-multiline mode)
#
-# In order for a line to match, the first regexp must match, and the
-# second (if present) must not match. The first matching line wins,
-# terminating processing of the ruleset.
+# In order for a line to match, the regexp must match. If the regexp
+# is prefixed with !, it must not match. The first line with a successful
+# (non)match wins, terminating processing of the ruleset.
#
-# The result syntax is described in the access(5) manual page.
+# A block of table entries may be "enclosed" by a line with `if
+# /pattern/flags' or `if !/pattern/flags' and a line with `endif'.
+# This causes the block of table entries to be examined only when
+# the pattern produces a successful (non)match. The `if..endif' may
+# be nested. There currently is no `else' operator.
+#
+# The syntax of access table results is described in the Postfix
+# access(5) manual page.
# Disallow sender-specified routing. This is a must if you relay mail
#for other domains.
# Sample regexp message body filter lookup "table". See regexp_table(5)
# for a description of the syntax.
#
-# Mail body lines are filtered one line at a time. In particular, multi-line
-# MIME headers in the message body are filtered one text line at a time.
+# Mail body lines are filtered one line at a time. MIME headers are
+# filtered as message headers, i.e. not as part of the mail body.
#
# The general format of a table entry is PATTERN RESULT.
#
-# The pattern format is /regexp/flags or /regexp/flags!/regexp/flags
-# where regexp is a regular expression as found in regexp(5), and flags are
+# The pattern format is `/regexp/flags' or `!/regexp/flags' where regexp
+# is a regular expression as found in re_format(7), and flags are
# i: toggle ignore case (REG_ICASE - default is to ignore case)
# x: toggle extended expression (REG_EXTENDED - default is extended)
# m: toggle multiline mode (REG_NEWLINE - default is non-multiline mode)
#
-# In order for a line to match, the first regexp must match, and the
-# second (if present) must not match. The first matching line wins,
-# terminating processing of the ruleset.
+# In order for a line to match, the regexp must match. If the regexp
+# is prefixed with !, it must not match. The first line with a successful
+# (non)match wins, terminating processing of the ruleset.
+#
+# A block of table entries may be "enclosed" by a line with `if
+# /pattern/flags' or `if !/pattern/flags' and a line with `endif'.
+# This causes the block of table entries to be examined only when
+# the pattern produces a successful (non)match. The `if..endif' may
+# be nested. There currently is no `else' operator.
#
# The result is one of the following:
# REJECT [optional text...]
#
# The general format of a table entry is PATTERN RESULT.
#
-# The pattern format is /regexp/flags or /regexp/flags!/regexp/flags
-# where regexp is a regular expression as found in regexp(5), and flags are
+# The pattern format is `/regexp/flags' or `!/regexp/flags' where regexp
+# is a regular expression as found in re_format(7), and flags are
# i: toggle ignore case (REG_ICASE - default is to ignore case)
# x: toggle extended expression (REG_EXTENDED - default is extended)
# m: toggle multiline mode (REG_NEWLINE - default is non-multiline mode)
#
-# In order for a line to match, the first regexp must match, and the
-# second (if present) must not match. The first matching line wins,
-# terminating processing of the ruleset.
+# In order for a line to match, the regexp must match. If the regexp
+# is prefixed with !, it must not match. The first line with a successful
+# (non)match wins, terminating processing of the ruleset.
+#
+# A block of table entries may be "enclosed" by a line with `if
+# /pattern/flags' or `if !/pattern/flags' and a line with `endif'.
+# This causes the block of table entries to be examined only when
+# the pattern produces a successful (non)match. The `if..endif' may
+# be nested. There currently is no `else' operator.
#
# The result is one of the following:
# REJECT [optional text...]
# SYNOPSIS
# postmap /etc/postfix/transport
#
+# postmap -q "string" /etc/postfix/transport
+#
+# postmap -q - /etc/postfix/transport <inputfile
+#
# DESCRIPTION
# The optional transport table specifies a mapping from
# email addresses to message delivery transports and/or
# SYNOPSIS
# postmap /etc/postfix/virtual
#
+# postmap -q "string" /etc/postfix/virtual
+#
+# postmap -q - /etc/postfix/virtual <inputfile
+#
# DESCRIPTION
# The optional virtual table specifies address redirections
# for local and non-local recipients or domains. The redi-
<b>SYNOPSIS</b>
<b>postmap</b> <b>/etc/postfix/access</b>
+ <b>postmap</b> <b>-q</b> <b>"</b><i>string</i><b>"</b> <b>/etc/postfix/access</b>
+
+ <b>postmap</b> <b>-q</b> <b>-</b> <b>/etc/postfix/access</b> <<i>inputfile</i>
+
<b>DESCRIPTION</b>
The optional <b>access</b> table directs the Postfix SMTP server
to selectively reject or accept mail. Access can be
<html> <head> </head> <body> <pre>
-
CANONICAL(5) CANONICAL(5)
<b>NAME</b>
<b>SYNOPSIS</b>
<b>postmap</b> <b>/etc/postfix/canonical</b>
+ <b>postmap</b> <b>-q</b> <b>"</b><i>string</i><b>"</b> <b>/etc/postfix/canonical</b>
+
+ <b>postmap</b> <b>-q</b> <b>-</b> <b>/etc/postfix/canonical</b> <<i>inputfile</i>
+
<b>DESCRIPTION</b>
The optional <b>canonical</b> table specifies an address mapping
for local and non-local addresses. The mapping is used by
P.O. Box 704
Yorktown Heights, NY 10598, USA
- 1
-
+ CANONICAL(5)
</pre> </body> </html>
pcre_table - format of Postfix PCRE tables
<b>SYNOPSIS</b>
- pcre:/etc/postfix/filename
+ <b>pcre:/etc/postfix/</b><i>filename</i>
+
+ <b>postmap</b> <b>-q</b> <b>"</b><i>string</i><b>"</b> <b>pcre:/etc/postfix/</b><i>filename</i>
+
+ <b>postmap</b> <b>-q</b> <b>-</b> <b>pcre:/etc/postfix/</b><i>filename</i> <<i>inputfile</i>
<b>DESCRIPTION</b>
The Postfix mail system uses optional tables for address
To find out what types of lookup tables your Postfix sys-
tem supports use the <b>postconf</b> <b>-m</b> command.
+ To test lookup tables, use the <b>postmap</b> command as
+ described in the SYNOPSIS above.
+
The general form of a PCRE table is:
- <i>pattern</i> <i>result</i>
- When <i>pattern</i> matches a search string, use the cor-
- responding <i>result</i>.
+ <b>/</b><i>pattern</i><b>/</b><i>flags</i> <i>result</i>
+ When <i>pattern</i> matches a search string, use the cor-
+ responding <i>result</i> value.
blank lines and comments
- Empty lines and whitespace-only lines are ignored,
- as are lines whose first non-whitespace character
+ Empty lines and whitespace-only lines are ignored,
+ as are lines whose first non-whitespace character
is a `#'.
multi-line text
- A logical line starts with non-whitespace text. A
- line that starts with whitespace continues a logi-
+ A logical line starts with non-whitespace text. A
+ line that starts with whitespace continues a logi-
cal line.
+ <b>if</b> <b>/</b><i>pattern</i><b>/</b><i>flags</i>
+
+ <b>endif</b> Examine the lines between <b>if</b>..<b>endif</b> only if <i>pattern</i>
+ matches. The <b>if</b>..<b>endif</b> can nest. Do not prepend
+ whitespace to patterns inside <b>if</b>..<b>endif</b>.
+
Each pattern is a perl-like regular expression. The
- expression delimiter can be any character, except whites-
- pace or characters that have special meaning (tradition-
- ally the forward slash is used). The regular expression
+ expression delimiter can be any character, except whites-
+ pace or characters that have special meaning (tradition-
+ ally the forward slash is used). The regular expression
can contain whitespace.
By default, matching is case-insensitive, and newlines are
- not treated as special characters. The behavior is con-
- trolled by flags, which are toggled by appending one or
+ not treated as special characters. The behavior is con-
+ trolled by flags, which are toggled by appending one or
more of the following characters after the pattern:
<b>i</b> (default: on)
- Toggles the case sensitivity flag. By default,
+ Toggles the case sensitivity flag. By default,
matching is case insensitive.
<b>m</b> (default: off)
- Toggles the PCRE_MULTILINE flag. When this flag is
- on, the <b>^</b> and $ metacharacters match immediately
- after and immediately before a newline character,
- respectively, in addition to matching at the start
+ Toggles the PCRE_MULTILINE flag. When this flag is
+ on, the <b>^</b> and $ metacharacters match immediately
+ after and immediately before a newline character,
+ respectively, in addition to matching at the start
and end of the subject string.
<b>s</b> (default: on)
Toggles the PCRE_DOTALL flag. When this flag is on,
the <b>.</b> metacharacter matches the newline character.
- With Postfix versions prior to 20020528, The flag
+ With Postfix versions prior to 20020528, The flag
is off by default, which is inconvenient for multi-
line message header matching.
<b>x</b> (default: off)
- Toggles the pcre extended flag. When this flag is
- on, whitespace in the pattern (other than in a
+ Toggles the pcre extended flag. When this flag is
+ on, whitespace in the pattern (other than in a
character class) and characters between a <b>#</b> outside
- a character class and the next newline character
- are ignored. An escaping backslash can be used to
- include a whitespace or <b>#</b> character as part of the
+ a character class and the next newline character
+ are ignored. An escaping backslash can be used to
+ include a whitespace or <b>#</b> character as part of the
pattern.
<b>A</b> (default: off)
- Toggles the PCRE_ANCHORED flag. When this flag is
- on, the pattern is forced to be "anchored", that
+ Toggles the PCRE_ANCHORED flag. When this flag is
+ on, the pattern is forced to be "anchored", that
is, it is constrained to match only at the start of
- the string which is being searched (the "subject
- string"). This effect can also be achieved by
+ the string which is being searched (the "subject
+ string"). This effect can also be achieved by
appropriate constructs in the pattern itself.
<b>E</b> (default: off)
- Toggles the PCRE_DOLLAR_ENDONLY flag. When this
- flag is on, a <b>$</b> metacharacter in the pattern
- matches only at the end of the subject string.
- Without this flag, a dollar also matches immedi-
+ Toggles the PCRE_DOLLAR_ENDONLY flag. When this
+ flag is on, a <b>$</b> metacharacter in the pattern
+ matches only at the end of the subject string.
+ Without this flag, a dollar also matches immedi-
ately before the final character if it is a newline
character (but not before any other newline charac-
- ters). This flag is ignored if PCRE_MULTILINE flag
+ ters). This flag is ignored if PCRE_MULTILINE flag
is set.
<b>U</b> (default: off)
Toggles the ungreedy matching flag. When this flag
- is on, the pattern matching engine inverts the
- "greediness" of the quantifiers so that they are
- not greedy by default, but become greedy if fol-
- lowed by "?". This flag can also set by a (?U)
+ is on, the pattern matching engine inverts the
+ "greediness" of the quantifiers so that they are
+ not greedy by default, but become greedy if fol-
+ lowed by "?". This flag can also set by a (?U)
modifier within the pattern.
<b>X</b> (default: off)
Toggles the PCRE_EXTRA flag. When this flag is on,
- any backslash in a pattern that is followed by a
+ any backslash in a pattern that is followed by a
letter that has no special meaning causes an error,
thus reserving these combinations for future expan-
sion.
- Each pattern is applied to the entire lookup key string.
- Depending on the application, that string is an entire
+ Each pattern is applied to the entire lookup key string.
+ Depending on the application, that string is an entire
client hostname, an entire client IP address, or an entire
- mail address. Thus, no parent domain or parent network
- search is done, and <i>user@domain</i> mail addresses are not
- broken up into their <i>user</i> and <i>domain</i> constituent parts,
+ mail address. Thus, no parent domain or parent network
+ search is done, and <i>user@domain</i> mail addresses are not
+ broken up into their <i>user</i> and <i>domain</i> constituent parts,
nor is <i>user+foo</i> broken up into <i>user</i> and <i>foo</i>.
- Patterns are applied in the order as specified in the
- table, until a pattern is found that matches the search
+ Patterns are applied in the order as specified in the
+ table, until a pattern is found that matches the search
string.
- Substitution of substrings from the matched expression
- into the result string is possible using the conventional
- perl syntax ($1, $2, etc.). The macros in the result
- string may need to be written as ${n} or $(n) if they
+ Substitution of substrings from the matched expression
+ into the result string is possible using the conventional
+ perl syntax ($1, $2, etc.). The macros in the result
+ string may need to be written as ${n} or $(n) if they
aren't followed by whitespace.
<b>EXAMPLE</b> <b>SMTPD</b> <b>ACCESS</b> <b>MAP</b>
is specified, the corresponding group ID is used
instead of the group ID of <i>username</i>.
- <b>eol=string</b> (default: <b>\n</b>)
+ <b>eol=string</b> (optional, default: <b>\n</b>)
The output record delimiter. Typically one would
use either <b>\r\n</b> or <b>\n</b>. The usual C-style backslash
escape sequences are recognized: <b>\a</b> <b>\b</b> <b>\f</b> <b>\n</b> <b>\r</b> <b>\t</b>
regexp_table - format of Postfix regular expression tables
<b>SYNOPSIS</b>
- regexp:/etc/postfix/filename
+ <b>regexp:/etc/postfix/</b><i>filename</i>
+
+ <b>postmap</b> <b>-q</b> <b>"</b><i>string</i><b>"</b> <b>regexp:/etc/postfix/</b><i>filename</i>
+
+ <b>postmap</b> <b>-q</b> <b>-</b> <b>regexp:/etc/postfix/</b><i>filename</i> <<i>inputfile</i>
<b>DESCRIPTION</b>
The Postfix mail system uses optional tables for address
To find out what types of lookup tables your Postfix sys-
tem supports use the <b>postconf</b> <b>-m</b> command.
+ To test lookup tables, use the <b>postmap</b> command as
+ described in the SYNOPSIS above.
+
The general form of a Postfix regular expression table is:
- <i>pattern</i> <i>result</i>
- When <i>pattern</i> matches a search string, use the cor-
- responding <i>result</i>.
+ <b>/</b><i>pattern</i><b>/</b><i>flags</i> <i>result</i>
+
+ <b>!/</b><i>pattern</i><b>/</b><i>flags</i> <i>result</i>
+ When <i>pattern</i> matches (does not match) a search
+ string, use the corresponding <i>result</i> value.
blank lines and comments
- Empty lines and whitespace-only lines are ignored,
- as are lines whose first non-whitespace character
+ Empty lines and whitespace-only lines are ignored,
+ as are lines whose first non-whitespace character
is a `#'.
multi-line text
- A logical line starts with non-whitespace text. A
- line that starts with whitespace continues a logi-
+ A logical line starts with non-whitespace text. A
+ line that starts with whitespace continues a logi-
cal line.
- <i>pattern1!pattern2</i> <i>result</i>
- Matches <i>pattern1</i> but not <i>pattern2</i>.
+ <b>if</b> <b>/</b><i>pattern</i><b>/</b><i>flags</i>
+
+ <b>if</b> <b>!/</b><i>pattern</i><b>/</b><i>flags</i>
+
+ <b>endif</b> Examine the lines between <b>if</b>..<b>endif</b> only if <i>pattern</i>
+ matches (does not match). The <b>if</b>..<b>endif</b> can nest.
+ Do not prepend whitespace to patterns inside
+ <b>if</b>..<b>endif</b>.
Each pattern is a regular expression enclosed by a pair of
delimiters. The regular expression syntax is described in
<b>SYNOPSIS</b>
<b>postmap</b> <b>/etc/postfix/transport</b>
+ <b>postmap</b> <b>-q</b> <b>"</b><i>string</i><b>"</b> <b>/etc/postfix/transport</b>
+
+ <b>postmap</b> <b>-q</b> <b>-</b> <b>/etc/postfix/transport</b> <<i>inputfile</i>
+
<b>DESCRIPTION</b>
The optional <b>transport</b> table specifies a mapping from
email addresses to message delivery transports and/or
<b>SYNOPSIS</b>
<b>postmap</b> <b>/etc/postfix/virtual</b>
+ <b>postmap</b> <b>-q</b> <b>"</b><i>string</i><b>"</b> <b>/etc/postfix/virtual</b>
+
+ <b>postmap</b> <b>-q</b> <b>-</b> <b>/etc/postfix/virtual</b> <<i>inputfile</i>
+
<b>DESCRIPTION</b>
The optional <b>virtual</b> table specifies address redirections
for local and non-local recipients or domains. The redi-
echo "See the RELEASE_NOTES file for more information." 1>&2
exit 1
fi
+ if [ -f /usr/include/pcre/pcre.h ]
+ then
+ CCARGS="$CCARGS -DHAS_PCRE -I/usr/include/pcre"
+ fi
# GDBM locks the DBM .pag file after open. This breaks postmap.
# if [ -f /usr/include/gdbm-ndbm.h ]
# then
# GDBM_LIBS=gdbm
# fi
SYSLIBS="-ldb"
- for name in nsl resolv $GDBM_LIBS
+ for name in nsl resolv pcre $GDBM_LIBS
do
test -e /usr/lib/lib$name.a -o -e /usr/lib/lib$name.so \
-o -e /lib/lib$name.a -o -e /lib/lib$name.so \
.na
.nf
\fBpostmap /etc/postfix/access\fR
+
+\fBpostmap -q "\fIstring\fB" /etc/postfix/access\fR
+
+\fBpostmap -q - /etc/postfix/access <\fIinputfile\fR
.SH DESCRIPTION
.ad
.fi
.na
.nf
\fBpostmap /etc/postfix/canonical\fR
+
+\fBpostmap -q "\fIstring\fB" /etc/postfix/canonical\fR
+
+\fBpostmap -q - /etc/postfix/canonical <\fIinputfile\fR
.SH DESCRIPTION
.ad
.fi
.SH SYNOPSIS
.na
.nf
-pcre:/etc/postfix/filename
+\fBpcre:/etc/postfix/\fIfilename\fR
+
+\fBpostmap -q "\fIstring\fB" pcre:/etc/postfix/\fIfilename\fR
+
+\fBpostmap -q - pcre:/etc/postfix/\fIfilename\fR <\fIinputfile\fR
.SH DESCRIPTION
.ad
.fi
To find out what types of lookup tables your Postfix system
supports use the \fBpostconf -m\fR command.
+To test lookup tables, use the \fBpostmap\fR command as
+described in the SYNOPSIS above.
+
The general form of a PCRE table is:
-.IP "\fIpattern result\fR"
+.IP "\fB/\fIpattern\fB/\fIflags result\fR"
When \fIpattern\fR matches a search string, use the corresponding
-\fIresult\fR.
+\fIresult\fR value.
.IP "blank lines and comments"
Empty lines and whitespace-only lines are ignored, as
are lines whose first non-whitespace character is a `#'.
.IP "multi-line text"
A logical line starts with non-whitespace text. A line that
starts with whitespace continues a logical line.
+.IP "\fBif /\fIpattern\fB/\fIflags\fR"
+.IP "\fBendif\fR"
+Examine the lines between \fBif\fR..\fBendif\fR only if
+\fIpattern\fR matches. The \fBif\fR..\fBendif\fR can nest.
+Do not prepend whitespace to patterns inside \fBif\fR..\fBendif\fR.
.PP
Each pattern is a perl-like regular expression. The expression
delimiter can be any character, except whitespace or characters
.SH SYNOPSIS
.na
.nf
-regexp:/etc/postfix/filename
+\fBregexp:/etc/postfix/\fIfilename\fR
+
+\fBpostmap -q "\fIstring\fB" regexp:/etc/postfix/\fIfilename\fR
+
+\fBpostmap -q - regexp:/etc/postfix/\fIfilename\fR <\fIinputfile\fR
.SH DESCRIPTION
.ad
.fi
To find out what types of lookup tables your Postfix system
supports use the \fBpostconf -m\fR command.
+To test lookup tables, use the \fBpostmap\fR command as
+described in the SYNOPSIS above.
+
The general form of a Postfix regular expression table is:
-.IP "\fIpattern result\fR"
-When \fIpattern\fR matches a search string, use the corresponding
-\fIresult\fR.
+.IP "\fB/\fIpattern\fB/\fIflags result\fR"
+.IP "\fB!/\fIpattern\fB/\fIflags result\fR"
+When \fIpattern\fR matches (does not match) a search string,
+use the corresponding \fIresult\fR value.
.IP "blank lines and comments"
Empty lines and whitespace-only lines are ignored, as
are lines whose first non-whitespace character is a `#'.
.IP "multi-line text"
A logical line starts with non-whitespace text. A line that
starts with whitespace continues a logical line.
-.IP "\fIpattern1!pattern2 result\fR"
-Matches \fIpattern1\fR but not \fIpattern2\fR.
+.IP "\fBif /\fIpattern\fB/\fIflags\fR"
+.IP "\fBif !/\fIpattern\fB/\fIflags\fR"
+.IP "\fBendif\fR"
+Examine the lines between \fBif\fR..\fBendif\fR only if
+\fIpattern\fR matches (does not match). The \fBif\fR..\fBendif\fR
+can nest.
+Do not prepend whitespace to patterns inside \fBif\fR..\fBendif\fR.
.PP
Each pattern is a regular expression enclosed by a pair of delimiters.
The regular expression syntax is described in \fIre_format\fR(7).
.na
.nf
\fBpostmap /etc/postfix/transport\fR
+
+\fBpostmap -q "\fIstring\fB" /etc/postfix/transport\fR
+
+\fBpostmap -q - /etc/postfix/transport <\fIinputfile\fR
.SH DESCRIPTION
.ad
.fi
.na
.nf
\fBpostmap /etc/postfix/virtual\fR
+
+\fBpostmap -q "\fIstring\fB" /etc/postfix/virtual\fR
+
+\fBpostmap -q - /etc/postfix/virtual <\fIinputfile\fR
.SH DESCRIPTION
.ad
.fi
mail system owner. If \fIgroupname\fR is specified, the
corresponding group ID is used instead of the group ID of
\fIusername\fR.
-.IP "\fBeol=string\fR (default: \fB\en\fR)"
+.IP "\fBeol=string\fR (optional, default: \fB\en\fR)"
The output record delimiter. Typically one would use either
\fB\er\en\fR or \fB\en\fR. The usual C-style backslash escape
sequences are recognized: \fB\ea \eb \ef \en \er \et \ev
# format of Postfix access table
# SYNOPSIS
# \fBpostmap /etc/postfix/access\fR
+#
+# \fBpostmap -q "\fIstring\fB" /etc/postfix/access\fR
+#
+# \fBpostmap -q - /etc/postfix/access <\fIinputfile\fR
# DESCRIPTION
# The optional \fBaccess\fR table directs the Postfix SMTP server
# to selectively reject or accept mail. Access can be allowed or
# format of Postfix canonical table
# SYNOPSIS
# \fBpostmap /etc/postfix/canonical\fR
+#
+# \fBpostmap -q "\fIstring\fB" /etc/postfix/canonical\fR
+#
+# \fBpostmap -q - /etc/postfix/canonical <\fIinputfile\fR
# DESCRIPTION
# The optional \fBcanonical\fR table specifies an address mapping for
# local and non-local addresses. The mapping is used by the
# SUMMARY
# format of Postfix PCRE tables
# SYNOPSIS
-# pcre:/etc/postfix/filename
+# \fBpcre:/etc/postfix/\fIfilename\fR
+#
+# \fBpostmap -q "\fIstring\fB" pcre:/etc/postfix/\fIfilename\fR
+#
+# \fBpostmap -q - pcre:/etc/postfix/\fIfilename\fR <\fIinputfile\fR
# DESCRIPTION
# The Postfix mail system uses optional tables for address
# rewriting or mail routing. These tables are usually in
# To find out what types of lookup tables your Postfix system
# supports use the \fBpostconf -m\fR command.
#
+# To test lookup tables, use the \fBpostmap\fR command as
+# described in the SYNOPSIS above.
+#
# The general form of a PCRE table is:
-# .IP "\fIpattern result\fR"
+# .IP "\fB/\fIpattern\fB/\fIflags result\fR"
# When \fIpattern\fR matches a search string, use the corresponding
-# \fIresult\fR.
+# \fIresult\fR value.
# .IP "blank lines and comments"
# Empty lines and whitespace-only lines are ignored, as
# are lines whose first non-whitespace character is a `#'.
# .IP "multi-line text"
# A logical line starts with non-whitespace text. A line that
# starts with whitespace continues a logical line.
+# .IP "\fBif /\fIpattern\fB/\fIflags\fR"
+# .IP "\fBendif\fR"
+# Examine the lines between \fBif\fR..\fBendif\fR only if
+# \fIpattern\fR matches. The \fBif\fR..\fBendif\fR can nest.
+# Do not prepend whitespace to patterns inside \fBif\fR..\fBendif\fR.
# .PP
# Each pattern is a perl-like regular expression. The expression
# delimiter can be any character, except whitespace or characters
# SUMMARY
# format of Postfix regular expression tables
# SYNOPSIS
-# regexp:/etc/postfix/filename
+# \fBregexp:/etc/postfix/\fIfilename\fR
+#
+# \fBpostmap -q "\fIstring\fB" regexp:/etc/postfix/\fIfilename\fR
+#
+# \fBpostmap -q - regexp:/etc/postfix/\fIfilename\fR <\fIinputfile\fR
# DESCRIPTION
# The Postfix mail system uses optional tables for address
# rewriting or mail routing. These tables are usually in
# To find out what types of lookup tables your Postfix system
# supports use the \fBpostconf -m\fR command.
#
+# To test lookup tables, use the \fBpostmap\fR command as
+# described in the SYNOPSIS above.
+#
# The general form of a Postfix regular expression table is:
-# .IP "\fIpattern result\fR"
-# When \fIpattern\fR matches a search string, use the corresponding
-# \fIresult\fR.
+# .IP "\fB/\fIpattern\fB/\fIflags result\fR"
+# .IP "\fB!/\fIpattern\fB/\fIflags result\fR"
+# When \fIpattern\fR matches (does not match) a search string,
+# use the corresponding \fIresult\fR value.
# .IP "blank lines and comments"
# Empty lines and whitespace-only lines are ignored, as
# are lines whose first non-whitespace character is a `#'.
# .IP "multi-line text"
# A logical line starts with non-whitespace text. A line that
# starts with whitespace continues a logical line.
-# .IP "\fIpattern1!pattern2 result\fR"
-# Matches \fIpattern1\fR but not \fIpattern2\fR.
+# .IP "\fBif /\fIpattern\fB/\fIflags\fR"
+# .IP "\fBif !/\fIpattern\fB/\fIflags\fR"
+# .IP "\fBendif\fR"
+# Examine the lines between \fBif\fR..\fBendif\fR only if
+# \fIpattern\fR matches (does not match). The \fBif\fR..\fBendif\fR
+# can nest.
+# Do not prepend whitespace to patterns inside \fBif\fR..\fBendif\fR.
# .PP
# Each pattern is a regular expression enclosed by a pair of delimiters.
# The regular expression syntax is described in \fIre_format\fR(7).
# format of Postfix transport table
# SYNOPSIS
# \fBpostmap /etc/postfix/transport\fR
+#
+# \fBpostmap -q "\fIstring\fB" /etc/postfix/transport\fR
+#
+# \fBpostmap -q - /etc/postfix/transport <\fIinputfile\fR
# DESCRIPTION
# The optional \fBtransport\fR table specifies a mapping from email
# addresses to message delivery transports and/or relay hosts. The
# format of Postfix virtual table
# SYNOPSIS
# \fBpostmap /etc/postfix/virtual\fR
+#
+# \fBpostmap -q "\fIstring\fB" /etc/postfix/virtual\fR
+#
+# \fBpostmap -q - /etc/postfix/virtual <\fIinputfile\fR
# DESCRIPTION
# The optional \fBvirtual\fR table specifies address redirections for
# local and non-local recipients or domains. The redirections are used
* Patches change the patchlevel and the release date. Snapshots change the
* release date only, unless they include the same bugfix as a patch release.
*/
-#define MAIL_RELEASE_DATE "20020916"
+#define MAIL_RELEASE_DATE "20020917"
#define VAR_MAIL_VERSION "mail_version"
#define DEF_MAIL_VERSION "1.1.11-" MAIL_RELEASE_DATE
/* mail system owner. If \fIgroupname\fR is specified, the
/* corresponding group ID is used instead of the group ID of
/* \fIusername\fR.
-/* .IP "\fBeol=string\fR (default: \fB\en\fR)"
+/* .IP "\fBeol=string\fR (optional, default: \fB\en\fR)"
/* The output record delimiter. Typically one would use either
/* \fB\er\en\fR or \fB\en\fR. The usual C-style backslash escape
/* sequences are recognized: \fB\ea \eb \ef \en \er \et \ev
case DICT_PCRE_OP_ENDIF:
break;
default:
- msg_panic("dict_regexp_close: unknown operation %d", rule->op);
+ msg_panic("dict_pcre_close: unknown operation %d", rule->op);
}
myfree((char *) rule);
}
last_rule = rule;
}
+ if (nesting)
+ msg_warn("pcre map %s, line %d: more IFs than ENDIFs",
+ mapname, lineno);
+
vstring_free(line_buffer);
vstream_fclose(map_fp);
#define FREE_EXPR_AND_RETURN(expr, rval) \
{ regfree(expr); myfree((char *) (expr)); return (rval); }
- if (prescan_context.max_sub == 0)
+ if (prescan_context.max_sub == 0 || first_pat.match == 0)
first_pat.options |= REG_NOSUB;
if ((first_exp = dict_regexp_compile_pat(mapname, lineno,
&first_pat)) == 0)
return (0);
+ if (prescan_context.max_sub > 0 && first_pat.match == 0) {
+ msg_warn("regexp map %s, line %d: $number found in negative match replacement text: "
+ "skipping this rule", mapname, lineno);
+ FREE_EXPR_AND_RETURN(first_exp, 0);
+ }
if (prescan_context.max_sub > first_exp->re_nsub) {
msg_warn("regexp map %s, line %d: out of range replacement index \"%d\": "
"skipping this rule", mapname, lineno,