Support for sender_domain and recipient_domain in match filter.
[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:'.
61 #
62 # eg:
63 #   on_match = postfix:REJECT Blacklisted;
64 #
65 # Filter:
66 #   Current defined filter types are:
67 #     - iplist: match the client_address against one or more blacklist files from a rbl
68 #        Parameters:
69 #           - file: (no)?lock:weight:filename
70 #             declare a file to load. If lock is given, the klist is locked into the
71 #             RAM. The weight is a number giving the weight of this blaclist file in the
72 #             score of the IP
73 #           - soft_threshold: score (default: 1)
74 #             minimum score to match the soft_match return value
75 #           - hard_threshold: score (default: 1)
76 #             minimum score to match the hard_match return value
77 #        Return value:
78 #          The score of a query is the sum of the weight of the blacklist it matched.
79 #           - If the IP can not be parsed, returns error
80 #           - If the score is strictly greater >= than hard_threshold, returns hard_match
81 #           - If the score is strictly greater >= than soft_threshold, returns soft_match
82 #           - Else, returns fail
83
84 # Lookup in a rbl
85 spamhaus_and_abuseat {
86   type   = iplist;
87
88   # configuration
89   file   = lock:10:/var/spool/postlicyd/rbl.spamhaus.org;
90   file   = lock:1:/var/spool/postlicyd/cbl.abuseat.org;
91   soft_threshold = 1;
92   hard_threshold = 11;
93
94   # hooks
95   on_soft_match = greylist;
96   on_hard_match = postfix:REJECT optional text;
97   on_fail       = postfix:OK;
98   on_error      = postfix:DUNNO;
99 }
100
101
102 #     - strlist: match strings from the query against a list of list.
103 #        Parameters:
104 #           - file: (no)?lock:(partial-)?(pre|suf)fix:weight:filename
105 #             declare a file to load. If lock is given, the list is locked into the
106 #             RAM. Prefix/Suffix is a parameter to tell the matcher which is the most
107 #             efficient storage order. The strings are internally stored into a trie that
108 #             allow high compression if a lot of prefix are shared by several strings. If
109 #             you choose "prefix", string are stored in the natural order in memory and
110 #             prefix compression is performed. If you choose "suffix", strings are stored
111 #             in reverse order in memory and suffix compression is performed. If you add "partial-"
112 #             to the match order, the entry will match if the file contains a prefix (resp. suffix)
113 #             of the string. The weight is a number giving the weight of this list in the string score.
114 #               e.g.:
115 #                * a file that contains ".polytechnique.org" in "partial-suffix" mode will match
116 #                 all subdomains of "polytechnique.org".
117 #                * a file that contains "postmaster@" in "partial-prefix" mode will match all
118 #                 postmaster emails.
119 #                * a file open without "partial-" modifier match exact strings.
120 #           - soft_threshold: score (default: 1)
121 #             minimum score to match the soft_match return value
122 #           - hard_threshold: score (default: 1)
123 #             minimum score to match the hard_match return value
124 #           - fields: field_name(,field_name)*
125 #             list of field the match the string against.
126 #             currently only email OR hostname fields are supported. You MUST choose only
127 #             one of these types per strlist, and be carefull that the field you requested
128 #             are available in the protocol state you want to use this filter for.
129 #              * hostname fields: helo_name, client_name, reverse_client_name, sender_domain,
130 #                         recipient_domain
131 #              * email fields: sender, recipient
132 #             No space is allowed in this parameter.
133 #        Return value:
134 #          The score of a query is the sum of the weight of the list it matched.
135 #           - If the score is strictly greater >= than hard_threshold, returns hard_match
136 #           - If the score is strictly greater >= than soft_threshold, returns soft_match
137 #           - Else, returns fail
138 #        State:
139 #           - to match helo_name, you must be on HELO state or later
140 #           (stmpd_helo_restrictions)
141 #           - to match sender, you must be on MAIL state or later
142 #           (smtpd_sender_restrictions)
143 #           - to match recipient, you must on RCPT state (stmpd_recipient_restrictions)
144 #           - client_name and reverse_client_name are always available
145
146 # Whitelist some clients
147 client_whitelist {
148   type  = strlist;
149
150   # configuration
151   file    = lock:1:suffix:/var/spool/postlicyd/client_whitelist;
152   fields  = client_name;
153
154   # hooks
155   on_hard_match = postfix:OK;
156   on_fail       = spamhaus_and_abuseat;
157 }
158
159
160 #     - greylist: greylister
161 #        Paramters:
162 #           - path: /my/path/ (required)
163 #             path where to store the greylist database
164 #           - prefix: name (default: "")
165 #             prefix to the name of the greylist database
166 #           - lookup_by_host: boolean (default: false)
167 #             perform lookup per host instead of domain.
168 #           - delay: number (default: 300)
169 #             number of seconds the client must wait before retrial.
170 #           - retry_window: (default: 2 * 24 * 3600)
171 #             number of seconds we wait for a retry.
172 #           - client_awl: number (default: 5)
173 #             number of successful greylisting before the client get whitelisted (0 means,
174 #             no-auto-whitelist).
175 #           - max_age: number (default: 30 * 3600)
176 #             lifetime of a greylist/whitelist session: ie, if a client does ne reappear during
177 #             max_age seconds, the entries associated to this client are invalidated.
178 #         Return value:
179 #           - if the client is whitelisted, returns whitelist
180 #           - if the client is greylisted, returns greylist
181 #           - if a error occured (not currently possible), returns error
182 #         State:
183 #           this filter is a recipient filter and works in RCPT state only
184 #           (smtpd_recipient_restrictions).
185
186 # Perform greylisting
187 greylist {
188   type   = greylist;
189
190   # configuration
191   path   = /var/spool/postlicyd/;
192   prefix = greylist_;
193
194   # hooks
195   on_greylist  = postfix:DEFER_IF_PERMIT optional text;
196   on_whitelist = postfix:OK;
197 }
198
199
200 #     - match: direct matching against the query fields
201 #        Parameters:
202 #           - match_all: boolean
203 #             if true, the filter won't match until all conditions
204 #             are verified. If false, the filter match on the first
205 #             verified condition.
206 #           - condition: field_name OP (value)
207 #             * the field_name is one of the field name of the query
208 #              emitted by postfix. This list with description of each
209 #              field is available at:
210 #               http://www.postfix.org/SMTPD_POLICY_README.html
211 #              postlicyd also support fields sender_domain and recipient_domain
212 #             * OP is an operator. Available operators are:
213 #                == field_name is strictly equal to value
214 #                =i field_name is case insensitively equal to value
215 #                != field_name is not equal to value
216 #                !i field_name is not case insensitively equal to value
217 #                >= field_name contains value
218 #                >i field_name contains case insensitively value
219 #                <= field_name is contained by value
220 #                <i field_name is contained case insensitively by value
221 #                #= field_name is empty or not set
222 #                #i field_name is not empty
223 #         Return value:
224 #           - if the conditions are verified (according to match_all strategy), return match
225 #           - if the conditions are not verified, return fail
226
227 # match one of the condition: "stress mode activated", "client_name contains debian.org" or
228 #                             "recipient is empty"
229 match {
230   type = match;
231
232   # configuration
233   match_all = false;
234   condition = stress == yes;
235   condition = client_name >= debian.org;
236   condition = recipient #=;
237
238   # hook
239   on_match = postfix:OK;
240   on_fail = greylist;
241 }
242
243
244 # ENTRY POINTS
245 #
246 # Access policy daemon can be used at several protocol states. For each of this states,
247 # you can define a different entry point in the filtering tree. This entry points have
248 # the following format:
249 #
250 #  state = filter_name;
251 #
252 # The filter_name MUST be one of the filter you previously defined.
253 #
254 # The available states are:
255 #  - client_filter: called on CONNECT state (smtpd_client_restrictions)
256 #  - helo_filter (or ehlo_filter): called on HELO/EHLO command (smtpd_helo_restrictions)
257 #  - sender_filter: called on the MAIL FROM command (stmpd_sender_restrictions)
258 #  - recipient_filter: called on the RCPT TO command (smtpd_recipient_restrictions)
259 #  - data_filter: called on the DATA command (smtpd_data_restrictions)
260 #  - end_of_data_filter: called on the END-OF-DATA command
261 #    (smtpd_end_of_data_restrictions)
262 #  - etrn_filter: called on the ETRN command (stmpd_etrn_restrictions)
263 #  - verify_filter: called on the VRFY command (no postfix hook ?)
264
265 recipient_filter = client_whitelist;
266
267
268 # SERVER PORT
269 #
270 # Port to which the server is bound. The default is 10000. If the port is specified as
271 # a command line parameter, the value specified on command line overides this value.
272 #
273 # You must RESTART the server to change the port (reload does not affect the port).
274
275 port = 10000;
276
277 # vim:set syntax=conf: