Allow query-format strings in answers.
[apps/pfixtools.git] / example / postlicyd.conf
1 # POSTLICYD configuration
2 #
3 # Postlicyd configuration contains:
4 #  - a set of filter definition
5 #  - the entry point in the filters for each smtp states
6 #
7 # The configuration format use 2 types of data:
8 #   Token:  [[:alpha:]]([[:alnum:]_]*)
9 #   String: string format is a bit more complex. It can be one of the two following
10 #           format:
11 #       - C-like strings "[^\n\r]*". In this kind of string, the \ character is used to
12 #         escape any character \c = c (\n = n, \\ = \, ...). This format allow non-ascii
13 #         strings and string concatenation " abcd " "ef" = " abcd ef".
14 #       - ASCII-only strings can be written without double-quotes. They can be splitted
15 #         into several lines using shell-like escaping of EOL. A string begins and ends on
16 #         on a non-blank character. This king of string can not contain semi-colons.
17 # eg:
18 #  The following format are equivalent:
19 #   (1) this is a str\
20 #   (1)    ing
21 #
22 #   (2) "this is a string"
23 #
24 #   (3) "this " "is a "
25 #   (3) "string"
26 #
27 # Most of the configuration use a format:
28 #     Token = String ;
29 #
30 # When not in a string, spaces and line breaks are ignored. You can use comments
31 # everywhere out of a string. It starts with a '#' character and ends at the end of the
32 # line. Comments are strictly equivalents to white spaces.
33
34 # FILTER DEFINITION
35 #
36 # A definition of a filter contains:
37 #  - the name of the filter. This name MUST be uniq (non-uniq names can lead to undefined
38 #    behaviour)
39 #  - a type
40 #  - a list of type-specific parameters
41 #  - a list of hooks (on_hookname)
42 #
43 # Format:
44 #  A filter look likes that:
45 #
46 #  filter_name {
47 #    type = type_name;
48 #    param1 = parameter value 1;
49 #    ...
50 #    on_hook1 = action1;
51 #    on_hook2 = action2;
52 #    ...
53 #  }
54 #
55 # Hooks:
56 #   A filter can returns different values. Each return value is given a name. The
57 #   configuration associates an action to run to a return value name.
58 #
59 #   The action can be either a postfix access(5) value or a filter name. Postfix access
60 #   parameters must be prefixed by 'postfix:'. The text argument given to a postfix reply
61 #   may contain format strings to be replaced by the parameters of the query. This arguments
62 #   have the following format: ${fieldname}
63 #
64 # eg:
65 #   on_match = postfix:REJECT Blacklisted;
66 #   on_fail  = postfix:450 Greylisted, see http://www.example.org/${sender_domain}.html
67 #
68 # Filter:
69 #   Current defined filter types are:
70 #     - iplist: match the client_address against one or more blacklist files from a rbl
71 #        Parameters:
72 #           - file: (no)?lock:weight:filename
73 #             declare a file to load. If lock is given, the klist is locked into the
74 #             RAM. The weight is a number giving the weight of this blaclist file in the
75 #             score of the IP
76 #           - rbldns: (no)?lock:weight:filename
77 #             this is an alias for file.
78 #           - dns: weight:hostname
79 #             use a rbl via DNS resolution with the given weight. If a DNS lookup error occurs
80 #             the IP is considered as beeing "not found".
81 #           - soft_threshold: score (default: 1)
82 #             minimum score to match the soft_match return value
83 #           - hard_threshold: score (default: 1)
84 #             minimum score to match the hard_match return value
85 #        Return value:
86 #          The score of a query is the sum of the weight of the blacklist it matched.
87 #           - If the IP can not be parsed, returns error
88 #           - If no rbl was available (no file and all dns down), returns error.
89 #           - If the score is strictly greater >= than hard_threshold, returns hard_match
90 #           - If the score is strictly greater >= than soft_threshold, returns soft_match
91 #           - Else, returns fail
92
93 # Lookup in a rbl
94 spamhaus_and_abuseat {
95   type   = iplist;
96
97   # configuration
98   file   = lock:10:/var/spool/postlicyd/rbl.spamhaus.org;
99   file   = lock:1:/var/spool/postlicyd/cbl.abuseat.org;
100   soft_threshold = 1;
101   hard_threshold = 11;
102
103   # hooks
104   on_soft_match = greylist;
105   on_hard_match = postfix:REJECT optional text;
106   on_fail       = postfix:OK;
107   on_error      = postfix:DUNNO;
108 }
109
110
111 #     - strlist: match strings from the query against a list of list.
112 #        Parameters:
113 #           - file: (no)?lock:(partial-)?(pre|suf)fix:weight:filename
114 #             declare a file to load. If lock is given, the list is locked into the
115 #             RAM. Prefix/Suffix is a parameter to tell the matcher which is the most
116 #             efficient storage order. The strings are internally stored into a trie that
117 #             allow high compression if a lot of prefix are shared by several strings. If
118 #             you choose "prefix", string are stored in the natural order in memory and
119 #             prefix compression is performed. If you choose "suffix", strings are stored
120 #             in reverse order in memory and suffix compression is performed. If you add "partial-"
121 #             to the match order, the entry will match if the file contains a prefix (resp. suffix)
122 #             of the string. The weight is a number giving the weight of this list in the string score.
123 #               e.g.:
124 #                * a file that contains ".polytechnique.org" in "partial-suffix" mode will match
125 #                 all subdomains of "polytechnique.org".
126 #                * a file that contains "postmaster@" in "partial-prefix" mode will match all
127 #                 postmaster emails.
128 #                * a file open without "partial-" modifier match exact strings.
129 #           - rbldns: (no)?lock:weight:filename
130 #             declare a rbldns zone file to load. This is exactly the same as file excepted that it wraps
131 #             parsing of hostname to split them into 2 categories:
132 #               * names beginning with '*' are sorted as 'domains' and are matched as suffix
133 #               * names starting with an alphanumirical character are sorted as 'hostnames' and are
134 #                process via exact matching.
135 #           - dns: weight:hostname
136 #             use a rhbl via DNS resolution with the given weight. If a DNS lookup error occurs
137 #             the hostname is considered as beeing "not found". This can only be used with "hostnames"
138 #             typed fields.
139 #           - soft_threshold: score (default: 1)
140 #             minimum score to match the soft_match return value
141 #           - hard_threshold: score (default: 1)
142 #             minimum score to match the hard_match return value
143 #           - fields: field_name(,field_name)*
144 #             list of field the match the string against.
145 #             currently only email OR hostname fields are supported. You MUST choose only
146 #             one of these types per strlist, and be carefull that the field you requested
147 #             are available in the protocol state you want to use this filter for.
148 #              * hostname fields: helo_name, client_name, reverse_client_name, sender_domain,
149 #                         recipient_domain
150 #              * email fields: sender, recipient
151 #             No space is allowed in this parameter.
152 #        Return value:
153 #          The score of a query is the sum of the weight of the list it matched.
154 #           - If no rhbl was available (no file and all dns down), returns error.
155 #           - If the score is strictly greater >= than hard_threshold, returns hard_match
156 #           - If the score is strictly greater >= than soft_threshold, returns soft_match
157 #           - Else, returns fail
158 #        State:
159 #           - to match helo_name, you must be on HELO state or later
160 #           (stmpd_helo_restrictions)
161 #           - to match sender, you must be on MAIL state or later
162 #           (smtpd_sender_restrictions)
163 #           - to match recipient, you must on RCPT state (stmpd_recipient_restrictions)
164 #           - client_name and reverse_client_name are always available
165
166 # Whitelist some clients
167 client_whitelist {
168   type  = strlist;
169
170   # configuration
171   file    = lock:1:suffix:/var/spool/postlicyd/client_whitelist;
172   rbldns  = lock:1:/va/spool/postlicyd/abuse.rfc-ignorant.org;
173   fields  = client_name,sender_domain,helo_name;
174
175   # hooks
176   on_hard_match = postfix:OK;
177   on_fail       = spamhaus_and_abuseat;
178 }
179
180
181 #     - greylist: greylister
182 #        Paramters:
183 #           - path: /my/path/ (required)
184 #             path where to store the greylist database
185 #           - prefix: name (default: "")
186 #             prefix to the name of the greylist database
187 #           - lookup_by_host: boolean (default: false)
188 #             perform lookup per host instead of domain.
189 #           - delay: number (default: 300)
190 #             number of seconds the client must wait before retrial.
191 #           - retry_window: (default: 2 * 24 * 3600)
192 #             number of seconds we wait for a retry.
193 #           - client_awl: number (default: 5)
194 #             number of successful greylisting before the client get whitelisted (0 means,
195 #             no-auto-whitelist).
196 #           - max_age: number (default: 30 * 3600)
197 #             lifetime of a greylist/whitelist session: ie, if a client does ne reappear during
198 #             max_age seconds, the entries associated to this client are invalidated.
199 #         Return value:
200 #           - if the client is whitelisted, returns whitelist
201 #           - if the client is greylisted, returns greylist
202 #           - if a error occured (not currently possible), returns error
203 #         State:
204 #           this filter is a recipient filter and works in RCPT state only
205 #           (smtpd_recipient_restrictions).
206
207 # Perform greylisting
208 greylist {
209   type   = greylist;
210
211   # configuration
212   path   = /var/spool/postlicyd/;
213   prefix = greylist_;
214
215   # hooks
216   on_greylist  = postfix:DEFER_IF_PERMIT optional text;
217   on_whitelist = postfix:OK;
218 }
219
220
221 #     - match: direct matching against the query fields
222 #        Parameters:
223 #           - match_all: boolean
224 #             if true, the filter won't match until all conditions
225 #             are verified. If false, the filter match on the first
226 #             verified condition.
227 #           - condition: field_name OP (value)
228 #             * the field_name is one of the field name of the query
229 #              emitted by postfix. This list with description of each
230 #              field is available at:
231 #               http://www.postfix.org/SMTPD_POLICY_README.html
232 #              postlicyd also support fields sender_domain and recipient_domain
233 #             * OP is an operator. Available operators are:
234 #                == field_name is strictly equal to value
235 #                =i field_name is case insensitively equal to value
236 #                != field_name is not equal to value
237 #                !i field_name is not case insensitively equal to value
238 #                >= field_name contains value
239 #                >i field_name contains case insensitively value
240 #                <= field_name is contained by value
241 #                <i field_name is contained case insensitively by value
242 #                #= field_name is empty or not set
243 #                #i field_name is not empty
244 #         Return value:
245 #           - if the conditions are verified (according to match_all strategy), return match
246 #           - if the conditions are not verified, return fail
247
248 # match one of the condition: "stress mode activated", "client_name contains debian.org" or
249 #                             "recipient is empty"
250 match {
251   type = match;
252
253   # configuration
254   match_all = false;
255   condition = stress == yes;
256   condition = client_name >= debian.org;
257   condition = recipient #=;
258
259   # hook
260   on_match = postfix:OK;
261   on_fail = greylist;
262 }
263
264
265 # ENTRY POINTS
266 #
267 # Access policy daemon can be used at several protocol states. For each of this states,
268 # you can define a different entry point in the filtering tree. This entry points have
269 # the following format:
270 #
271 #  state = filter_name;
272 #
273 # The filter_name MUST be one of the filter you previously defined.
274 #
275 # The available states are:
276 #  - client_filter: called on CONNECT state (smtpd_client_restrictions)
277 #  - helo_filter (or ehlo_filter): called on HELO/EHLO command (smtpd_helo_restrictions)
278 #  - sender_filter: called on the MAIL FROM command (stmpd_sender_restrictions)
279 #  - recipient_filter: called on the RCPT TO command (smtpd_recipient_restrictions)
280 #  - data_filter: called on the DATA command (smtpd_data_restrictions)
281 #  - end_of_data_filter: called on the END-OF-DATA command
282 #    (smtpd_end_of_data_restrictions)
283 #  - etrn_filter: called on the ETRN command (stmpd_etrn_restrictions)
284 #  - verify_filter: called on the VRFY command (no postfix hook ?)
285
286 recipient_filter = client_whitelist;
287
288
289 # SERVER PORT
290 #
291 # Port to which the server is bound. The default is 10000. If the port is specified as
292 # a command line parameter, the value specified on command line overides this value.
293 #
294 # You must RESTART the server to change the port (reload does not affect the port).
295
296 port = 10000;
297
298 # vim:set syntax=conf: