1<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN" 2 "http://www.w3.org/TR/html4/loose.dtd"> 3 4<html> 5 6<head> 7 8<title>Postfix PCRE Support</title> 9 10<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 11<link rel='stylesheet' type='text/css' href='postfix-doc.css'> 12 13</head> 14 15<body> 16 17<h1><img src="postfix-logo.jpg" width="203" height="98" ALT="">Postfix PCRE Support</h1> 18 19<hr> 20 21<h2>PCRE (Perl Compatible Regular Expressions) map support</h2> 22 23<p> The optional "pcre" map type allows you to specify regular 24expressions with the PERL style notation such as \s for space and 25\S for non-space. The main benefit, however, is that pcre lookups 26are often faster than regexp lookups. This is because the pcre 27implementation is often more efficient than the POSIX regular 28expression implementation that you find on many systems. </p> 29 30<p> A description of how to use pcre tables, including examples, 31is given in the <a href="pcre_table.5.html">pcre_table(5)</a> manual page. Information about PCRE 32itself can be found at <a href="http://www.pcre.org/">http://www.pcre.org/</a>. </p> 33 34<h2>Using Postfix packages with PCRE support</h2> 35 36<p> To use pcre with Debian GNU/Linux's Postfix, or with Fedora or 37RHEL Postfix, all you 38need is to install the postfix-pcre package and you're done. There 39is no need to recompile Postfix. </p> 40 41<h2>Building Postfix from source with PCRE support</h2> 42 43<p> These instructions assume that you build Postfix from source 44code as described in the <a href="INSTALL.html">INSTALL</a> document. </p> 45 46<p> To build Postfix from source with pcre support, you need a pcre 47library. Install a vendor package, or download the source code from 48locations in <a href="https://www.pcre.org/">https://www.pcre.org/</a> and build that yourself. 49 50<p> Postfix can build with the pcre2 library or the legacy pcre 51library. It's probably easiest to let the Postfix build procedure 52pick one. The following commands will first discover if the pcre2 53library is installed, and if that is not available, will discover 54if the legacy pcre library is installed. </p> 55 56<blockquote> 57<pre> 58$ make -f Makefile.init makefiles 59$ make 60</pre> 61</blockquote> 62 63<p> To build Postfix explicitly with a pcre2 library (Postfix 3.7 64and later): </p> 65 66<blockquote> 67<pre> 68$ make -f Makefile.init makefiles \ 69 "CCARGS=-DHAS_PCRE=2 `pcre2-config --cflags`" \ 70 "<a href="PCRE_README.html">AUXLIBS_PCRE</a>=`pcre2-config --libs8`" 71$ make 72</pre> 73</blockquote> 74 75<p> To build Postfix explicitly with a legacy pcre library (all 76Postfix versions): </p> 77 78<blockquote> 79<pre> 80$ make -f Makefile.init makefiles \ 81 "CCARGS=-DHAS_PCRE=1 `pcre-config --cflags`" \ 82 "<a href="PCRE_README.html">AUXLIBS_PCRE</a>=`pcre-config --libs`" 83$ make 84</pre> 85</blockquote> 86 87<p> Postfix versions before 3.0 use AUXLIBS instead of <a href="PCRE_README.html">AUXLIBS_PCRE</a>. 88With Postfix 3.0 and later, the old AUXLIBS variable still supports 89building a statically-loaded PCRE database client, but only the new 90<a href="PCRE_README.html">AUXLIBS_PCRE</a> variable supports building a dynamically-loaded or 91statically-loaded PCRE database client. </p> 92 93<blockquote> 94 95<p> Failure to use the <a href="PCRE_README.html">AUXLIBS_PCRE</a> variable will defeat the purpose 96of dynamic database client loading. Every Postfix executable file 97will have PCRE library dependencies. And that was exactly 98what dynamic database client loading was meant to avoid. </p> 99 100</blockquote> 101 102<h2>Things to know</h2> 103 104<ul> 105 106<li> <p> When Postfix searches a <a href="pcre_table.5.html">pcre</a>: or <a href="regexp_table.5.html">regexp</a>: lookup table, 107each pattern is applied to the entire input string. Depending on 108the application, that string is an entire client hostname, an entire 109client IP address, or an entire mail address. Thus, no parent domain 110or parent network search is done, "user@domain" mail addresses are 111not broken up into their user and domain constituent parts, and 112"user+foo" is not broken up into user and foo. </p> 113 114<li> <p> Regular expression tables such as <a href="pcre_table.5.html">pcre</a>: or <a href="regexp_table.5.html">regexp</a>: are 115not allowed to do $number substitution in lookup results that can 116be security sensitive: currently, that restriction applies to the 117local <a href="aliases.5.html">aliases(5)</a> database or the <a href="virtual.8.html">virtual(8)</a> delivery agent tables. 118</p> 119 120</ul> 121 122</body> 123 124</html> 125