5
/* Postfix zombie blocker
7
/* \fBpostscreen\fR [generic Postfix daemon options]
9
/* The Postfix \fBpostscreen\fR(8) server performs triage on
10
/* multiple inbound SMTP connections at the same time. While
11
/* a single \fBpostscreen\fR(8) process keeps spambots away
12
/* from Postfix SMTP server processes, more Postfix SMTP server
13
/* processes remain available for legitimate clients.
15
/* This program should not be used on SMTP ports that receive
16
/* mail from end-user clients (MUAs). In a typical deployment,
17
/* \fBpostscreen\fR(8) is used on the "port 25" service, while
18
/* MUA clients submit mail via the \fBsubmission\fR service.
20
/* \fBpostscreen\fR(8) maintains a temporary whitelist for
21
/* clients that have passed a number of tests. When an SMTP
22
/* client IP address is whitelisted, \fBpostscreen\fR(8) hands
23
/* off the connection immediately to a Postfix SMTP server
24
/* process. This minimizes the overhead for legitimate mail.
26
/* By default, \fBpostscreen\fR(8) logs statistics and hands
27
/* off every connection to a Postfix SMTP server process, while
28
/* excluding clients in mynetworks from all tests (primarily,
29
/* to avoid problems with non-standard SMTP implementations
30
/* in network appliances). This mode is useful for non-destructive
33
/* In a typical production setting, \fBpostscreen\fR(8) is
34
/* configured to reject mail from clients that fail one or
35
/* more tests. \fBpostscreen\fR(8) logs rejected mail with the
36
/* client address, helo, sender and recipient information.
38
/* \fBpostscreen\fR(8) is not an SMTP proxy; this is intentional.
39
/* The purpose is to keep spambots away from Postfix SMTP
40
/* server processes, while minimizing overhead for legitimate
45
/* The \fBpostscreen\fR(8) server is moderately security-sensitive.
46
/* It talks to untrusted clients on the network. The process
47
/* can be run chrooted at fixed low privilege.
49
/* RFC 821 (SMTP protocol)
50
/* RFC 1123 (Host requirements)
51
/* RFC 1652 (8bit-MIME transport)
52
/* RFC 1869 (SMTP service extensions)
53
/* RFC 1870 (Message Size Declaration)
54
/* RFC 1985 (ETRN command)
55
/* RFC 2034 (SMTP Enhanced Status Codes)
56
/* RFC 2821 (SMTP protocol)
57
/* RFC 2920 (SMTP Pipelining)
58
/* RFC 3207 (STARTTLS command)
59
/* RFC 3461 (SMTP DSN Extension)
60
/* RFC 3463 (Enhanced Status Codes)
61
/* RFC 5321 (SMTP protocol, including multi-line 220 banners)
63
/* Problems and transactions are logged to \fBsyslogd\fR(8).
65
/* The \fBpostscreen\fR(8) built-in SMTP protocol engine
66
/* currently does not announce support for AUTH, XCLIENT or
68
/* Support for AUTH may be added in the future.
69
/* In the mean time, if you need to make these services available
70
/* on port 25, then do not enable the optional "after 220
71
/* server greeting" tests.
73
/* The optional "after 220 server greeting" tests involve
74
/* \fBpostscreen\fR(8)'s built-in SMTP protocol engine. When
75
/* these tests succeed, \fBpostscreen\fR(8) adds the client
76
/* to the temporary whitelist but it cannot not hand off the
77
/* "live" connection to a Postfix SMTP server process in the
78
/* middle of a session. Instead, \fBpostscreen\fR(8) defers
79
/* attempts to deliver mail with a 4XX status, and waits for
80
/* the client to disconnect. The next time a good client
81
/* connects, it will be allowed to talk to a Postfix SMTP
82
/* server process to deliver mail. \fBpostscreen\fR(8) mitigates
83
/* the impact of this limitation by giving such tests a long
85
/* CONFIGURATION PARAMETERS
88
/* Changes to main.cf are not picked up automatically, as
89
/* \fBpostscreen\fR(8) processes may run for several hours.
90
/* Use the command "postfix reload" after a configuration
93
/* The text below provides only a parameter summary. See
94
/* \fBpostconf\fR(5) for more details including examples.
96
/* NOTE: Some \fBpostscreen\fR(8) parameters implement
97
/* stress-dependent behavior. This is supported only when the
98
/* default parameter value is stress-dependent (that is, it
99
/* looks like ${stress?X}${stress:Y}, or it is the $\fIname\fR
100
/* of an smtpd parameter with a stress-dependent default).
101
/* Other parameters always evaluate as if the \fBstress\fR
102
/* parameter value is the empty string.
103
/* COMPATIBILITY CONTROLS
106
/* .IP "\fBpostscreen_command_filter ($smtpd_command_filter)\fR"
107
/* A mechanism to transform commands from remote SMTP clients.
108
/* .IP "\fBpostscreen_discard_ehlo_keyword_address_maps ($smtpd_discard_ehlo_keyword_address_maps)\fR"
109
/* Lookup tables, indexed by the remote SMTP client address, with
110
/* case insensitive lists of EHLO keywords (pipelining, starttls, auth,
111
/* etc.) that the \fBpostscreen\fR(8) server will not send in the EHLO response
112
/* to a remote SMTP client.
113
/* .IP "\fBpostscreen_discard_ehlo_keywords ($smtpd_discard_ehlo_keywords)\fR"
114
/* A case insensitive list of EHLO keywords (pipelining, starttls,
115
/* auth, etc.) that the \fBpostscreen\fR(8) server will not send in the EHLO
116
/* response to a remote SMTP client.
117
/* TROUBLE SHOOTING CONTROLS
120
/* .IP "\fBpostscreen_expansion_filter (see 'postconf -d' output)\fR"
121
/* List of characters that are permitted in postscreen_reject_footer
122
/* attribute expansions.
123
/* .IP "\fBpostscreen_reject_footer ($smtpd_reject_footer)\fR"
124
/* Optional information that is appended after a 4XX or 5XX server
126
/* .IP "\fBsoft_bounce (no)\fR"
127
/* Safety net to keep mail queued that would otherwise be returned to
129
/* PERMANENT WHITE/BLACKLIST TEST
132
/* This test is executed immediately after a remote SMTP client
133
/* connects. If a client is permanently whitelisted, the client
134
/* will be handed off immediately to a Postfix SMTP server
136
/* .IP "\fBpostscreen_access_list (permit_mynetworks)\fR"
137
/* Permanent white/blacklist for remote SMTP client IP addresses.
138
/* .IP "\fBpostscreen_blacklist_action (ignore)\fR"
139
/* The action that \fBpostscreen\fR(8) takes when an SMTP client is
140
/* permanently blacklisted with the postscreen_access_list parameter.
141
/* BEFORE-GREETING TESTS
144
/* These tests are executed before the remote SMTP client
145
/* receives the "220 servername" greeting. If no tests remain
146
/* after the successful completion of this phase, the client
147
/* will be handed off immediately to a Postfix SMTP server
149
/* .IP "\fBdnsblog_service_name (dnsblog)\fR"
150
/* The name of the \fBdnsblog\fR(8) service entry in master.cf.
151
/* .IP "\fBpostscreen_dnsbl_action (ignore)\fR"
152
/* The action that \fBpostscreen\fR(8) takes when an SMTP client's combined
153
/* DNSBL score is equal to or greater than a threshold (as defined
154
/* with the postscreen_dnsbl_sites and postscreen_dnsbl_threshold
156
/* .IP "\fBpostscreen_dnsbl_reply_map (empty)\fR"
157
/* A mapping from actual DNSBL domain name which includes a secret
158
/* password, to the DNSBL domain name that postscreen will reply with
159
/* when it rejects mail.
160
/* .IP "\fBpostscreen_dnsbl_sites (empty)\fR"
161
/* Optional list of DNS white/blacklist domains, filters and weight
163
/* .IP "\fBpostscreen_dnsbl_threshold (1)\fR"
164
/* The inclusive lower bound for blocking an SMTP client, based on
165
/* its combined DNSBL score as defined with the postscreen_dnsbl_sites
167
/* .IP "\fBpostscreen_greet_action (ignore)\fR"
168
/* The action that \fBpostscreen\fR(8) takes when an SMTP client speaks
169
/* before its turn within the time specified with the postscreen_greet_wait
171
/* .IP "\fBpostscreen_greet_banner ($smtpd_banner)\fR"
172
/* The \fItext\fR in the optional "220-\fItext\fR..." server
174
/* \fBpostscreen\fR(8) sends ahead of the real Postfix SMTP server's "220
175
/* text..." response, in an attempt to confuse bad SMTP clients so
176
/* that they speak before their turn (pre-greet).
177
/* .IP "\fBpostscreen_greet_wait (${stress?2}${stress:6}s)\fR"
178
/* The amount of time that \fBpostscreen\fR(8) will wait for an SMTP
179
/* client to send a command before its turn, and for DNS blocklist
180
/* lookup results to arrive (default: up to 2 seconds under stress,
181
/* up to 6 seconds otherwise).
182
/* .IP "\fBsmtpd_service_name (smtpd)\fR"
183
/* The internal service that \fBpostscreen\fR(8) forwards allowed
185
/* AFTER-GREETING TESTS
188
/* These tests are executed after the remote SMTP client
189
/* receives the "220 servername" greeting. If a client passes
190
/* all tests during this phase, it will receive a 4XX response
191
/* to RCPT TO commands until the client hangs up. After this,
192
/* the client will be allowed to talk directly to a Postfix
193
/* SMTP server process.
194
/* .IP "\fBpostscreen_bare_newline_action (ignore)\fR"
195
/* The action that \fBpostscreen\fR(8) takes when an SMTP client sends
196
/* a bare newline character, that is, a newline not preceded by carriage
198
/* .IP "\fBpostscreen_bare_newline_enable (no)\fR"
199
/* Enable "bare newline" SMTP protocol tests in the \fBpostscreen\fR(8)
201
/* .IP "\fBpostscreen_disable_vrfy_command ($disable_vrfy_command)\fR"
202
/* Disable the SMTP VRFY command in the \fBpostscreen\fR(8) daemon.
203
/* .IP "\fBpostscreen_forbidden_commands ($smtpd_forbidden_commands)\fR"
204
/* List of commands that the \fBpostscreen\fR(8) server considers in
205
/* violation of the SMTP protocol.
206
/* .IP "\fBpostscreen_helo_required ($smtpd_helo_required)\fR"
207
/* Require that a remote SMTP client sends HELO or EHLO before
208
/* commencing a MAIL transaction.
209
/* .IP "\fBpostscreen_non_smtp_command_action (drop)\fR"
210
/* The action that \fBpostscreen\fR(8) takes when an SMTP client sends
211
/* non-SMTP commands as specified with the postscreen_forbidden_commands
213
/* .IP "\fBpostscreen_non_smtp_command_enable (no)\fR"
214
/* Enable "non-SMTP command" tests in the \fBpostscreen\fR(8) server.
215
/* .IP "\fBpostscreen_pipelining_action (enforce)\fR"
216
/* The action that \fBpostscreen\fR(8) takes when an SMTP client sends
217
/* multiple commands instead of sending one command and waiting for
218
/* the server to respond.
219
/* .IP "\fBpostscreen_pipelining_enable (no)\fR"
220
/* Enable "pipelining" SMTP protocol tests in the \fBpostscreen\fR(8)
225
/* .IP "\fBpostscreen_cache_cleanup_interval (12h)\fR"
226
/* The amount of time between \fBpostscreen\fR(8) cache cleanup runs.
227
/* .IP "\fBpostscreen_cache_map (btree:$data_directory/postscreen_cache)\fR"
228
/* Persistent storage for the \fBpostscreen\fR(8) server decisions.
229
/* .IP "\fBpostscreen_cache_retention_time (7d)\fR"
230
/* The amount of time that \fBpostscreen\fR(8) will cache an expired
231
/* temporary whitelist entry before it is removed.
232
/* .IP "\fBpostscreen_bare_newline_ttl (30d)\fR"
233
/* The amount of time that \fBpostscreen\fR(8) will use the result from
234
/* a successful "bare newline" SMTP protocol test.
235
/* .IP "\fBpostscreen_dnsbl_ttl (1h)\fR"
236
/* The amount of time that \fBpostscreen\fR(8) will use the result from
237
/* a successful DNS blocklist test.
238
/* .IP "\fBpostscreen_greet_ttl (1d)\fR"
239
/* The amount of time that \fBpostscreen\fR(8) will use the result from
240
/* a successful PREGREET test.
241
/* .IP "\fBpostscreen_non_smtp_command_ttl (30d)\fR"
242
/* The amount of time that \fBpostscreen\fR(8) will use the result from
243
/* a successful "non_smtp_command" SMTP protocol test.
244
/* .IP "\fBpostscreen_pipelining_ttl (30d)\fR"
245
/* The amount of time that \fBpostscreen\fR(8) will use the result from
246
/* a successful "pipelining" SMTP protocol test.
250
/* .IP "\fBline_length_limit (2048)\fR"
251
/* Upon input, long lines are chopped up into pieces of at most
252
/* this length; upon delivery, long lines are reconstructed.
253
/* .IP "\fBpostscreen_client_connection_count_limit ($smtpd_client_connection_count_limit)\fR"
254
/* How many simultaneous connections any client is allowed to have
255
/* with the \fBpostscreen\fR(8) daemon.
256
/* .IP "\fBpostscreen_command_count_limit (20)\fR"
257
/* The limit on the total number of commands per SMTP session for
258
/* \fBpostscreen\fR(8)'s built-in SMTP protocol engine.
259
/* .IP "\fBpostscreen_command_time_limit (${stress?10}${stress:300}s)\fR"
260
/* The time limit to read an entire command line with \fBpostscreen\fR(8)'s
261
/* built-in SMTP protocol engine.
262
/* .IP "\fBpostscreen_post_queue_limit ($default_process_limit)\fR"
263
/* The number of clients that can be waiting for service from a
264
/* real SMTP server process.
265
/* .IP "\fBpostscreen_pre_queue_limit ($default_process_limit)\fR"
266
/* The number of non-whitelisted clients that can be waiting for
267
/* a decision whether they will receive service from a real SMTP server
269
/* .IP "\fBpostscreen_watchdog_timeout (10s)\fR"
270
/* How much time a \fBpostscreen\fR(8) process may take to respond to
271
/* an SMTP client command or to perform a cache operation before it
272
/* is terminated by a built-in watchdog timer.
276
/* .IP "\fBpostscreen_tls_security_level ($smtpd_tls_security_level)\fR"
277
/* The SMTP TLS security level for the \fBpostscreen\fR(8) server; when
278
/* a non-empty value is specified, this overrides the obsolete parameters
279
/* postscreen_use_tls and postscreen_enforce_tls.
280
/* .IP "\fBtlsproxy_service_name (tlsproxy)\fR"
281
/* The name of the \fBtlsproxy\fR(8) service entry in master.cf.
282
/* OBSOLETE STARTTLS SUPPORT CONTROLS
285
/* These parameters are supported for compatibility with
286
/* \fBsmtpd\fR(8) legacy parameters.
287
/* .IP "\fBpostscreen_use_tls ($smtpd_use_tls)\fR"
288
/* Opportunistic TLS: announce STARTTLS support to SMTP clients,
289
/* but do not require that clients use TLS encryption.
290
/* .IP "\fBpostscreen_enforce_tls ($smtpd_enforce_tls)\fR"
291
/* Mandatory TLS: announce STARTTLS support to SMTP clients, and
292
/* require that clients use TLS encryption.
293
/* MISCELLANEOUS CONTROLS
296
/* .IP "\fBconfig_directory (see 'postconf -d' output)\fR"
297
/* The default location of the Postfix main.cf and master.cf
298
/* configuration files.
299
/* .IP "\fBdelay_logging_resolution_limit (2)\fR"
300
/* The maximal number of digits after the decimal point when logging
301
/* sub-second delay values.
302
/* .IP "\fBcommand_directory (see 'postconf -d' output)\fR"
303
/* The location of all postfix administrative commands.
304
/* .IP "\fBmax_idle (100s)\fR"
305
/* The maximum amount of time that an idle Postfix daemon process waits
306
/* for an incoming connection before terminating voluntarily.
307
/* .IP "\fBprocess_id (read-only)\fR"
308
/* The process ID of a Postfix command or daemon process.
309
/* .IP "\fBprocess_name (read-only)\fR"
310
/* The process name of a Postfix command or daemon process.
311
/* .IP "\fBsyslog_facility (mail)\fR"
312
/* The syslog facility of Postfix logging.
313
/* .IP "\fBsyslog_name (see 'postconf -d' output)\fR"
314
/* The mail system name that is prepended to the process name in syslog
315
/* records, so that "smtpd" becomes, for example, "postfix/smtpd".
317
/* smtpd(8), Postfix SMTP server
318
/* tlsproxy(8), Postfix TLS proxy server
319
/* dnsblog(8), DNS black/whitelist logger
320
/* syslogd(8), system logging
324
/* Use "\fBpostconf readme_directory\fR" or "\fBpostconf
325
/* html_directory\fR" to locate this information.
328
/* POSTSCREEN_README, Postfix Postscreen Howto
332
/* The Secure Mailer license must be distributed with this software.
336
/* This service was introduced with Postfix version 2.8.
338
/* Many ideas in \fBpostscreen\fR(8) were explored in earlier
339
/* work by Michael Tokarev, in OpenBSD spamd, and in MailChannels
343
/* IBM T.J. Watson Research
345
/* Yorktown Heights, NY 10598, USA
348
/* System library. */
350
#include <sys_defs.h>
351
#include <sys/stat.h>
354
/* Utility library. */
357
#include <mymalloc.h>
359
#include <myaddrinfo.h>
360
#include <dict_cache.h>
361
#include <set_eugid.h>
363
#include <name_code.h>
365
/* Global library. */
367
#include <mail_conf.h>
368
#include <mail_params.h>
369
#include <mail_version.h>
370
#include <mail_proto.h>
371
#include <data_redirect.h>
372
#include <string_list.h>
374
/* Master server protocols. */
376
#include <mail_server.h>
378
/* Application-specific. */
380
#include <postscreen.h>
383
* Configuration parameters.
386
char *var_smtpd_service;
387
char *var_smtpd_banner;
388
bool var_disable_vrfy_cmd;
389
bool var_helo_required;
391
char *var_smtpd_cmd_filter;
392
char *var_psc_cmd_filter;
394
char *var_smtpd_forbid_cmds;
395
char *var_psc_forbid_cmds;
397
char *var_smtpd_ehlo_dis_words;
398
char *var_smtpd_ehlo_dis_maps;
399
char *var_psc_ehlo_dis_words;
400
char *var_psc_ehlo_dis_maps;
402
char *var_smtpd_tls_level;
403
bool var_smtpd_use_tls;
404
bool var_smtpd_enforce_tls;
405
char *var_psc_tls_level;
406
bool var_psc_use_tls;
407
bool var_psc_enforce_tls;
409
bool var_psc_disable_vrfy;
410
bool var_psc_helo_required;
412
char *var_psc_cache_map;
413
int var_psc_cache_scan;
414
int var_psc_cache_ret;
415
int var_psc_post_queue_limit;
416
int var_psc_pre_queue_limit;
417
int var_psc_watchdog;
419
#undef MIGRATION_WARNING
421
#ifdef MIGRATION_WARNING
422
char *var_psc_wlist_nets;
423
char *var_psc_blist_nets;
427
char *var_psc_blist_action;
429
char *var_psc_greet_ttl;
430
int var_psc_greet_wait;
432
char *var_psc_pregr_banner;
433
char *var_psc_pregr_action;
434
int var_psc_pregr_ttl;
436
char *var_psc_dnsbl_sites;
437
char *var_psc_dnsbl_reply;
438
int var_psc_dnsbl_thresh;
439
char *var_psc_dnsbl_action;
440
int var_psc_dnsbl_ttl;
442
bool var_psc_pipel_enable;
443
char *var_psc_pipel_action;
444
int var_psc_pipel_ttl;
446
bool var_psc_nsmtp_enable;
447
char *var_psc_nsmtp_action;
448
int var_psc_nsmtp_ttl;
450
bool var_psc_barlf_enable;
451
char *var_psc_barlf_action;
452
int var_psc_barlf_ttl;
454
int var_psc_cmd_count;
455
char *var_psc_cmd_time;
457
char *var_dnsblog_service;
458
char *var_tlsproxy_service;
460
char *var_smtpd_rej_footer;
461
char *var_psc_rej_footer;
463
int var_smtpd_cconn_limit;
464
int var_psc_cconn_limit;
466
char *var_smtpd_exp_filter;
467
char *var_psc_exp_filter;
472
int psc_check_queue_length; /* connections being checked */
473
int psc_post_queue_length; /* being sent to real SMTPD */
474
DICT_CACHE *psc_cache_map; /* cache table handle */
475
VSTRING *psc_temp; /* scratchpad */
476
char *psc_smtpd_service_name; /* path to real SMTPD */
477
int psc_pregr_action; /* PSC_ACT_DROP/ENFORCE/etc */
478
int psc_dnsbl_action; /* PSC_ACT_DROP/ENFORCE/etc */
479
int psc_pipel_action; /* PSC_ACT_DROP/ENFORCE/etc */
480
int psc_nsmtp_action; /* PSC_ACT_DROP/ENFORCE/etc */
481
int psc_barlf_action; /* PSC_ACT_DROP/ENFORCE/etc */
482
int psc_min_ttl; /* Update with new tests! */
483
int psc_max_ttl; /* Update with new tests! */
484
STRING_LIST *psc_forbid_cmds; /* CONNECT GET POST */
485
int psc_stress_greet_wait; /* stressed greet wait */
486
int psc_normal_greet_wait; /* stressed greet wait */
487
int psc_stress_cmd_time_limit; /* stressed command limit */
488
int psc_normal_cmd_time_limit; /* normal command time limit */
489
int psc_stress; /* stress level */
490
int psc_lowat_check_queue_length; /* stress low-water mark */
491
int psc_hiwat_check_queue_length; /* stress high-water mark */
492
DICT *psc_dnsbl_reply; /* DNSBL name mapper */
493
HTABLE *psc_client_concurrency; /* per-client concurrency */
498
#ifdef MIGRATION_WARNING
499
static ADDR_MATCH_LIST *psc_wlist_nets; /* permanently whitelisted networks */
500
static ADDR_MATCH_LIST *psc_blist_nets; /* permanently blacklisted networks */
503
static ARGV *psc_acl; /* permanent white/backlist */
504
static int psc_blist_action; /* PSC_ACT_DROP/ENFORCE/etc */
506
/* psc_dump - dump some statistics before exit */
508
static void psc_dump(void)
512
* Dump preliminary cache cleanup statistics when the process commits
513
* suicide while a cache cleanup run is in progress. We can't currently
514
* distinguish between "postfix reload" (we should restart) or "maximal
515
* idle time reached" (we could finish the cache cleanup first).
518
dict_cache_close(psc_cache_map);
523
/* psc_drain - delayed exit after "postfix reload" */
525
static void psc_drain(char *unused_service, char **unused_argv)
530
* After "postfix reload", complete work-in-progress in the background,
531
* instead of dropping already-accepted connections on the floor.
533
* Unfortunately we must close all writable tables, so we can't store or
534
* look up reputation information. The reason is that we don't have any
535
* multi-writer safety guarantees. We also can't use the single-writer
536
* proxywrite service, because its latency guarantees are too weak.
538
* All error retry counts shall be limited. Instead of blocking here, we
539
* could retry failed fork() operations in the event call-back routines,
540
* but we don't need perfection. The host system is severely overloaded
541
* and service levels are already way down.
543
* XXX Some Berkeley DB versions break with close-after-fork. Every new
544
* version is an improvement over its predecessor.
546
if (psc_cache_map != 0) {
547
dict_cache_close(psc_cache_map);
550
for (count = 0; /* see below */ ; count++) {
552
msg_fatal("fork: %m");
553
} else if (event_server_drain() != 0) {
554
msg_warn("fork: %m");
563
/* psc_service - handle new client connection */
565
static void psc_service(VSTREAM *smtp_client_stream,
566
char *unused_service,
569
const char *myname = "psc_service";
571
struct sockaddr_storage addr_storage;
572
SOCKADDR_SIZE addr_storage_len = sizeof(addr_storage);
573
MAI_HOSTADDR_STR smtp_client_addr;
574
MAI_SERVPORT_STR smtp_client_port;
576
const char *stamp_str;
580
* This program handles all incoming connections, so it must not block.
581
* We use event-driven code for all operations that introduce latency.
583
* Note: instead of using VSTREAM-level timeouts, we enforce limits on the
584
* total amount of time to receive a complete SMTP command line.
586
non_blocking(vstream_fileno(smtp_client_stream), NON_BLOCKING);
589
* We use the event_server framework. This means we get already-accepted
590
* connections so we have to invoke getpeername() to find out the remote
593
#define PSC_SERVICE_DISCONNECT_AND_RETURN(stream) do { \
594
event_server_disconnect(stream); \
599
* Look up the remote SMTP client address and port.
601
if (getpeername(vstream_fileno(smtp_client_stream), (struct sockaddr *)
602
& addr_storage, &addr_storage_len) < 0) {
603
msg_warn("getpeername: %m -- dropping this connection");
604
/* Best effort - if this non-blocking write(2) fails, so be it. */
605
(void) write(vstream_fileno(smtp_client_stream),
606
"421 4.3.2 No system resources\r\n",
607
sizeof("421 4.3.2 No system resources\r\n") - 1);
608
PSC_SERVICE_DISCONNECT_AND_RETURN(smtp_client_stream);
612
* Convert the remote SMTP client address and port to printable form for
613
* logging and access control.
615
if ((aierr = sockaddr_to_hostaddr((struct sockaddr *) & addr_storage,
616
addr_storage_len, &smtp_client_addr,
617
&smtp_client_port, 0)) != 0) {
618
msg_warn("cannot convert client address/port to string: %s"
619
" -- dropping this connection",
620
MAI_STRERROR(aierr));
621
/* Best effort - if this non-blocking write(2) fails, so be it. */
622
(void) write(vstream_fileno(smtp_client_stream),
623
"421 4.3.2 No system resources\r\n",
624
sizeof("421 4.3.2 No system resources\r\n") - 1);
625
PSC_SERVICE_DISCONNECT_AND_RETURN(smtp_client_stream);
627
if (strncasecmp("::ffff:", smtp_client_addr.buf, 7) == 0)
628
memmove(smtp_client_addr.buf, smtp_client_addr.buf + 7,
629
sizeof(smtp_client_addr.buf) - 7);
631
msg_info("%s: sq=%d cq=%d connect from [%s]:%s",
632
myname, psc_post_queue_length, psc_check_queue_length,
633
smtp_client_addr.buf, smtp_client_port.buf);
635
msg_info("CONNECT from [%s]:%s", smtp_client_addr.buf, smtp_client_port.buf);
638
* Bundle up all the loose session pieces. This zeroes all flags and time
641
state = psc_new_session_state(smtp_client_stream, smtp_client_addr.buf,
642
smtp_client_port.buf);
645
* Reply with 421 when the client has too many open connections.
647
if (var_psc_cconn_limit > 0
648
&& state->client_concurrency > var_psc_cconn_limit) {
649
msg_info("NOQUEUE: reject: CONNECT from [%s]:%s: too many connections",
650
state->smtp_client_addr, state->smtp_client_port);
651
PSC_DROP_SESSION_STATE(state,
652
"421 4.7.0 Error: too many connections\r\n");
657
* Reply with 421 when we can't forward more connections.
659
if (var_psc_post_queue_limit > 0
660
&& psc_post_queue_length >= var_psc_post_queue_limit) {
661
msg_info("NOQUEUE: reject: CONNECT from [%s]:%s: all server ports busy",
662
state->smtp_client_addr, state->smtp_client_port);
663
PSC_DROP_SESSION_STATE(state,
664
"421 4.3.2 All server ports are busy\r\n");
669
* The permanent white/blacklist has highest precedence.
672
switch (psc_acl_eval(state, psc_acl, VAR_PSC_ACL)) {
675
* Permanently blacklisted.
677
case PSC_ACL_ACT_BLACKLIST:
678
msg_info("BLACKLISTED [%s]:%s", PSC_CLIENT_ADDR_PORT(state));
679
PSC_FAIL_SESSION_STATE(state, PSC_STATE_FLAG_BLIST_FAIL);
680
switch (psc_blist_action) {
682
PSC_DROP_SESSION_STATE(state,
683
"521 5.3.2 Service currently unavailable\r\n");
685
case PSC_ACT_ENFORCE:
686
PSC_ENFORCE_SESSION_STATE(state,
687
"550 5.3.2 Service currently unavailable\r\n");
690
PSC_UNFAIL_SESSION_STATE(state, PSC_STATE_FLAG_BLIST_FAIL);
693
* Not: PSC_PASS_SESSION_STATE. Repeat this test the next
698
msg_panic("%s: unknown blacklist action value %d",
699
myname, psc_blist_action);
704
* Permanently whitelisted.
706
case PSC_ACL_ACT_WHITELIST:
707
msg_info("WHITELISTED [%s]:%s", PSC_CLIENT_ADDR_PORT(state));
712
* Other: dunno (don't know) or error.
718
#ifdef MIGRATION_WARNING
721
* The permanent whitelist has highest precedence (never block mail from
722
* whitelisted sites, and never run tests against those sites).
724
if (psc_wlist_nets != 0
725
&& psc_addr_match_list_match(psc_wlist_nets, state->smtp_client_addr)) {
726
msg_info("WHITELISTED [%s]:%s", PSC_CLIENT_ADDR_PORT(state));
732
* The permanent blacklist has second precedence. If the client is
733
* permanently blacklisted, send some generic reply and hang up
734
* immediately, or run more tests for logging purposes.
736
if (psc_blist_nets != 0
737
&& psc_addr_match_list_match(psc_blist_nets, state->smtp_client_addr)) {
738
msg_info("BLACKLISTED [%s]:%s", PSC_CLIENT_ADDR_PORT(state));
739
PSC_FAIL_SESSION_STATE(state, PSC_STATE_FLAG_BLIST_FAIL);
740
switch (psc_blist_action) {
742
PSC_DROP_SESSION_STATE(state,
743
"521 5.3.2 Service currently unavailable\r\n");
745
case PSC_ACT_ENFORCE:
746
PSC_ENFORCE_SESSION_STATE(state,
747
"550 5.3.2 Service currently unavailable\r\n");
750
PSC_UNFAIL_SESSION_STATE(state, PSC_STATE_FLAG_BLIST_FAIL);
751
/* Not: PSC_PASS_SESSION_STATE. Repeat this test the next time. */
754
msg_panic("%s: unknown blacklist action value %d",
755
myname, psc_blist_action);
761
* The temporary whitelist (i.e. the postscreen cache) has the lowest
762
* precedence. This cache contains information about the results of prior
763
* tests. Whitelist the client when all enabled test results are still
766
if ((state->flags & PSC_STATE_MASK_ANY_FAIL) == 0
767
&& psc_cache_map != 0
768
&& (stamp_str = psc_cache_lookup(psc_cache_map, state->smtp_client_addr)) != 0) {
769
saved_flags = state->flags;
770
psc_parse_tests(state, stamp_str, event_time());
771
state->flags |= saved_flags;
773
msg_info("%s: cached + recent flags: %s",
774
myname, psc_print_state_flags(state->flags, myname));
775
if ((state->flags & PSC_STATE_MASK_ANY_TODO_FAIL) == 0) {
776
msg_info("PASS OLD [%s]:%s", PSC_CLIENT_ADDR_PORT(state));
781
saved_flags = state->flags;
782
psc_new_tests(state);
783
state->flags |= saved_flags;
785
msg_info("%s: new + recent flags: %s",
786
myname, psc_print_state_flags(state->flags, myname));
790
* Reply with 421 when we can't analyze more connections.
792
if (var_psc_pre_queue_limit > 0
793
&& psc_check_queue_length - psc_post_queue_length
794
>= var_psc_pre_queue_limit) {
795
msg_info("reject: connect from [%s]:%s: all screening ports busy",
796
state->smtp_client_addr, state->smtp_client_port);
797
PSC_DROP_SESSION_STATE(state,
798
"421 4.3.2 All screening ports are busy\r\n");
803
* If the client has no up-to-date results for some tests, do those tests
804
* first. Otherwise, skip the tests and hand off the connection.
806
if (state->flags & PSC_STATE_MASK_EARLY_TODO)
807
psc_early_tests(state);
808
else if (state->flags & (PSC_STATE_MASK_SMTPD_TODO | PSC_STATE_FLAG_NOFORWARD))
809
psc_smtpd_tests(state);
814
/* psc_cache_validator - validate one cache entry */
816
static int psc_cache_validator(const char *client_addr,
817
const char *stamp_str,
818
char *unused_context)
823
* This function is called by the cache cleanup pseudo thread.
825
* When an entry is removed from the cache, the client will be reported as
826
* "NEW" in the next session where it passes all tests again. To avoid
827
* silly logging we remove the cache entry only after all tests have
828
* expired longer ago than the cache retention time.
830
psc_parse_tests(&dummy, stamp_str, event_time() - var_psc_cache_ret);
831
return ((dummy.flags & PSC_STATE_MASK_ANY_TODO) == 0);
834
/* pre_jail_init - pre-jail initialization */
836
static void pre_jail_init(char *unused_name, char **unused_argv)
841
* Open read-only maps before dropping privilege, for consistency with
842
* other Postfix daemons.
844
#ifdef MIGRATION_WARNING
845
if (*var_psc_wlist_nets)
847
addr_match_list_init(MATCH_FLAG_NONE, var_psc_wlist_nets);
849
if (*var_psc_blist_nets)
850
psc_blist_nets = addr_match_list_init(MATCH_FLAG_NONE,
852
if (psc_blist_nets || psc_wlist_nets) {
853
msg_warn("The %s and %s features will be removed soon. Use %s instead",
854
VAR_PSC_WLIST_NETS, VAR_PSC_BLIST_NETS, VAR_PSC_ACL);
855
msg_warn("To stop this warning, specify empty values for %s and %s",
856
VAR_PSC_WLIST_NETS, VAR_PSC_BLIST_NETS);
859
psc_acl_pre_jail_init();
861
psc_acl = psc_acl_parse(var_psc_acl, VAR_PSC_ACL);
862
if (*var_psc_forbid_cmds)
863
psc_forbid_cmds = string_list_init(MATCH_FLAG_NONE,
864
var_psc_forbid_cmds);
865
if (*var_psc_dnsbl_reply)
866
psc_dnsbl_reply = dict_open(var_psc_dnsbl_reply, O_RDONLY,
870
* Never, ever, get killed by a master signal, as that would corrupt the
871
* database when we're in the middle of an update.
874
msg_warn("setsid: %m");
877
* Security: don't create root-owned files that contain untrusted data.
878
* And don't create Postfix-owned files in root-owned directories,
879
* either. We want a correct relationship between (file or directory)
880
* ownership and (file or directory) content. To open files before going
881
* to jail, temporarily drop root privileges.
883
SAVE_AND_SET_EUGID(var_owner_uid, var_owner_gid);
884
redirect = vstring_alloc(100);
887
* Keep state in persistent external map. As a safety measure we sync the
888
* database on each update. This hurts on LINUX file systems that sync
889
* all dirty disk blocks whenever any application invokes fsync().
891
* Start the cache maintenance pseudo thread after dropping privileges.
893
#define PSC_DICT_OPEN_FLAGS (DICT_FLAG_DUP_REPLACE | DICT_FLAG_SYNC_UPDATE)
895
if (*var_psc_cache_map)
897
dict_cache_open(data_redirect_map(redirect, var_psc_cache_map),
898
O_CREAT | O_RDWR, PSC_DICT_OPEN_FLAGS);
901
* Clean up and restore privilege.
903
vstring_free(redirect);
904
RESTORE_SAVED_EUGID();
907
* Initialize the dummy SMTP engine.
909
psc_smtpd_pre_jail_init();
912
/* pre_accept - see if tables have changed */
914
static void pre_accept(char *unused_name, char **unused_argv)
916
static time_t last_event_time;
917
time_t new_event_time;
921
* If some table has changed then stop accepting new connections. Don't
922
* check the tables more than once a second.
924
new_event_time = event_time();
925
if (new_event_time >= last_event_time + 1
926
&& (name = dict_changed_name()) != 0) {
927
msg_info("table %s has changed - finishing in the background", name);
928
event_server_drain();
930
last_event_time = new_event_time;
934
/* post_jail_init - post-jail initialization */
936
static void post_jail_init(char *unused_name, char **unused_argv)
938
const NAME_CODE actions[] = {
939
PSC_NAME_ACT_DROP, PSC_ACT_DROP,
940
PSC_NAME_ACT_ENFORCE, PSC_ACT_ENFORCE,
941
PSC_NAME_ACT_IGNORE, PSC_ACT_IGNORE,
942
PSC_NAME_ACT_CONT, PSC_ACT_IGNORE, /* compatibility */
949
* This routine runs after the skeleton code has entered the chroot jail.
950
* Prevent automatic process suicide after a limited number of client
951
* requests. It is OK to terminate after a limited amount of idle time.
956
* Workaround for parameters whose values may contain "$", and that have
957
* a default of "$parametername". Not sure if it would be a good idea to
958
* always to this in the mail_conf_raw(3) module.
960
if (*var_psc_rej_footer == '$'
961
&& mail_conf_lookup(var_psc_rej_footer + 1)) {
962
tmp = mail_conf_eval_once(var_psc_rej_footer);
963
myfree(var_psc_rej_footer);
964
var_psc_rej_footer = mystrdup(tmp);
966
if (*var_psc_exp_filter == '$'
967
&& mail_conf_lookup(var_psc_exp_filter + 1)) {
968
tmp = mail_conf_eval_once(var_psc_exp_filter);
969
myfree(var_psc_exp_filter);
970
var_psc_exp_filter = mystrdup(tmp);
974
* Other one-time initialization.
976
psc_temp = vstring_alloc(10);
977
vstring_sprintf(psc_temp, "%s/%s", MAIL_CLASS_PRIVATE, var_smtpd_service);
978
psc_smtpd_service_name = mystrdup(STR(psc_temp));
983
if ((psc_blist_action = name_code(actions, NAME_CODE_FLAG_NONE,
984
var_psc_blist_action)) < 0)
985
msg_fatal("bad %s value: %s", VAR_PSC_BLIST_ACTION,
986
var_psc_blist_action);
987
if ((psc_dnsbl_action = name_code(actions, NAME_CODE_FLAG_NONE,
988
var_psc_dnsbl_action)) < 0)
989
msg_fatal("bad %s value: %s", VAR_PSC_DNSBL_ACTION,
990
var_psc_dnsbl_action);
991
if ((psc_pregr_action = name_code(actions, NAME_CODE_FLAG_NONE,
992
var_psc_pregr_action)) < 0)
993
msg_fatal("bad %s value: %s", VAR_PSC_PREGR_ACTION,
994
var_psc_pregr_action);
995
if ((psc_pipel_action = name_code(actions, NAME_CODE_FLAG_NONE,
996
var_psc_pipel_action)) < 0)
997
msg_fatal("bad %s value: %s", VAR_PSC_PIPEL_ACTION,
998
var_psc_pipel_action);
999
if ((psc_nsmtp_action = name_code(actions, NAME_CODE_FLAG_NONE,
1000
var_psc_nsmtp_action)) < 0)
1001
msg_fatal("bad %s value: %s", VAR_PSC_NSMTP_ACTION,
1002
var_psc_nsmtp_action);
1003
if ((psc_barlf_action = name_code(actions, NAME_CODE_FLAG_NONE,
1004
var_psc_barlf_action)) < 0)
1005
msg_fatal("bad %s value: %s", VAR_PSC_BARLF_ACTION,
1006
var_psc_barlf_action);
1009
* Start the cache maintenance pseudo thread last. Early cleanup makes
1010
* verbose logging more informative (we get positive confirmation that
1011
* the cleanup thread runs).
1013
cache_flags = DICT_CACHE_FLAG_STATISTICS;
1014
if (msg_verbose > 1)
1015
cache_flags |= DICT_CACHE_FLAG_VERBOSE;
1016
if (psc_cache_map != 0 && var_psc_cache_scan > 0)
1017
dict_cache_control(psc_cache_map,
1018
DICT_CACHE_CTL_FLAGS, cache_flags,
1019
DICT_CACHE_CTL_INTERVAL, var_psc_cache_scan,
1020
DICT_CACHE_CTL_VALIDATOR, psc_cache_validator,
1021
DICT_CACHE_CTL_CONTEXT, (char *) 0,
1022
DICT_CACHE_CTL_END);
1025
* Pre-compute the minimal and maximal TTL.
1028
PSC_MIN(PSC_MIN(var_psc_pregr_ttl, var_psc_dnsbl_ttl),
1029
PSC_MIN(PSC_MIN(var_psc_pipel_ttl, var_psc_nsmtp_ttl),
1030
var_psc_barlf_ttl));
1032
PSC_MAX(PSC_MAX(var_psc_pregr_ttl, var_psc_dnsbl_ttl),
1033
PSC_MAX(PSC_MAX(var_psc_pipel_ttl, var_psc_nsmtp_ttl),
1034
var_psc_barlf_ttl));
1037
* Pre-compute the stress and normal command time limits.
1039
mail_conf_update(VAR_STRESS, "yes");
1040
psc_stress_cmd_time_limit =
1041
get_mail_conf_time(VAR_PSC_CMD_TIME, DEF_PSC_CMD_TIME, 1, 0);
1042
psc_stress_greet_wait =
1043
get_mail_conf_time(VAR_PSC_GREET_WAIT, DEF_PSC_GREET_WAIT, 1, 0);
1045
mail_conf_update(VAR_STRESS, "");
1046
psc_normal_cmd_time_limit =
1047
get_mail_conf_time(VAR_PSC_CMD_TIME, DEF_PSC_CMD_TIME, 1, 0);
1048
psc_normal_greet_wait =
1049
get_mail_conf_time(VAR_PSC_GREET_WAIT, DEF_PSC_GREET_WAIT, 1, 0);
1051
psc_lowat_check_queue_length = .7 * var_psc_pre_queue_limit;
1052
psc_hiwat_check_queue_length = .9 * var_psc_pre_queue_limit;
1054
msg_info(VAR_PSC_CMD_TIME ": stress=%d normal=%d lowat=%d hiwat=%d",
1055
psc_stress_cmd_time_limit, psc_normal_cmd_time_limit,
1056
psc_lowat_check_queue_length, psc_hiwat_check_queue_length);
1058
if (psc_lowat_check_queue_length == 0)
1059
msg_panic("compiler error: 0.7 * %d = %d", var_psc_pre_queue_limit,
1060
psc_lowat_check_queue_length);
1061
if (psc_hiwat_check_queue_length == 0)
1062
msg_panic("compiler error: 0.9 * %d = %d", var_psc_pre_queue_limit,
1063
psc_hiwat_check_queue_length);
1066
* Per-client concurrency.
1068
psc_client_concurrency = htable_create(var_psc_pre_queue_limit);
1071
MAIL_VERSION_STAMP_DECLARE;
1073
/* main - pass control to the multi-threaded skeleton */
1075
int main(int argc, char **argv)
1079
* List smtpd(8) parameters before any postscreen(8) parameters that have
1080
* defaults dependencies on them.
1082
static const CONFIG_STR_TABLE str_table[] = {
1083
VAR_SMTPD_SERVICE, DEF_SMTPD_SERVICE, &var_smtpd_service, 1, 0,
1084
VAR_SMTPD_BANNER, DEF_SMTPD_BANNER, &var_smtpd_banner, 1, 0,
1085
VAR_SMTPD_FORBID_CMDS, DEF_SMTPD_FORBID_CMDS, &var_smtpd_forbid_cmds, 0, 0,
1086
VAR_SMTPD_EHLO_DIS_WORDS, DEF_SMTPD_EHLO_DIS_WORDS, &var_smtpd_ehlo_dis_words, 0, 0,
1087
VAR_SMTPD_EHLO_DIS_MAPS, DEF_SMTPD_EHLO_DIS_MAPS, &var_smtpd_ehlo_dis_maps, 0, 0,
1088
VAR_SMTPD_TLS_LEVEL, DEF_SMTPD_TLS_LEVEL, &var_smtpd_tls_level, 0, 0,
1089
VAR_SMTPD_CMD_FILTER, DEF_SMTPD_CMD_FILTER, &var_smtpd_cmd_filter, 0, 0,
1090
VAR_PSC_CACHE_MAP, DEF_PSC_CACHE_MAP, &var_psc_cache_map, 0, 0,
1091
VAR_PSC_PREGR_BANNER, DEF_PSC_PREGR_BANNER, &var_psc_pregr_banner, 0, 0,
1092
VAR_PSC_PREGR_ACTION, DEF_PSC_PREGR_ACTION, &var_psc_pregr_action, 1, 0,
1093
VAR_PSC_DNSBL_SITES, DEF_PSC_DNSBL_SITES, &var_psc_dnsbl_sites, 0, 0,
1094
VAR_PSC_DNSBL_ACTION, DEF_PSC_DNSBL_ACTION, &var_psc_dnsbl_action, 1, 0,
1095
VAR_PSC_PIPEL_ACTION, DEF_PSC_PIPEL_ACTION, &var_psc_pipel_action, 1, 0,
1096
VAR_PSC_NSMTP_ACTION, DEF_PSC_NSMTP_ACTION, &var_psc_nsmtp_action, 1, 0,
1097
VAR_PSC_BARLF_ACTION, DEF_PSC_BARLF_ACTION, &var_psc_barlf_action, 1, 0,
1098
#ifdef MIGRATION_WARNING
1099
VAR_PSC_WLIST_NETS, DEF_PSC_WLIST_NETS, &var_psc_wlist_nets, 0, 0,
1100
VAR_PSC_BLIST_NETS, DEF_PSC_BLIST_NETS, &var_psc_blist_nets, 0, 0,
1102
VAR_PSC_ACL, DEF_PSC_ACL, &var_psc_acl, 0, 0,
1103
VAR_PSC_BLIST_ACTION, DEF_PSC_BLIST_ACTION, &var_psc_blist_action, 1, 0,
1104
VAR_PSC_FORBID_CMDS, DEF_PSC_FORBID_CMDS, &var_psc_forbid_cmds, 0, 0,
1105
VAR_PSC_EHLO_DIS_WORDS, DEF_PSC_EHLO_DIS_WORDS, &var_psc_ehlo_dis_words, 0, 0,
1106
VAR_PSC_EHLO_DIS_MAPS, DEF_PSC_EHLO_DIS_MAPS, &var_psc_ehlo_dis_maps, 0, 0,
1107
VAR_PSC_DNSBL_REPLY, DEF_PSC_DNSBL_REPLY, &var_psc_dnsbl_reply, 0, 0,
1108
VAR_PSC_TLS_LEVEL, DEF_PSC_TLS_LEVEL, &var_psc_tls_level, 0, 0,
1109
VAR_PSC_CMD_FILTER, DEF_PSC_CMD_FILTER, &var_psc_cmd_filter, 0, 0,
1110
VAR_DNSBLOG_SERVICE, DEF_DNSBLOG_SERVICE, &var_dnsblog_service, 1, 0,
1111
VAR_TLSPROXY_SERVICE, DEF_TLSPROXY_SERVICE, &var_tlsproxy_service, 1, 0,
1114
static const CONFIG_INT_TABLE int_table[] = {
1115
VAR_PROC_LIMIT, DEF_PROC_LIMIT, &var_proc_limit, 1, 0,
1116
VAR_PSC_DNSBL_THRESH, DEF_PSC_DNSBL_THRESH, &var_psc_dnsbl_thresh, 0, 0,
1117
VAR_PSC_CMD_COUNT, DEF_PSC_CMD_COUNT, &var_psc_cmd_count, 1, 0,
1118
VAR_SMTPD_CCONN_LIMIT, DEF_SMTPD_CCONN_LIMIT, &var_smtpd_cconn_limit, 0, 0,
1121
static const CONFIG_NINT_TABLE nint_table[] = {
1122
VAR_PSC_POST_QLIMIT, DEF_PSC_POST_QLIMIT, &var_psc_post_queue_limit, 5, 0,
1123
VAR_PSC_PRE_QLIMIT, DEF_PSC_PRE_QLIMIT, &var_psc_pre_queue_limit, 10, 0,
1124
VAR_PSC_CCONN_LIMIT, DEF_PSC_CCONN_LIMIT, &var_psc_cconn_limit, 0, 0,
1127
static const CONFIG_TIME_TABLE time_table[] = {
1128
VAR_PSC_GREET_WAIT, DEF_PSC_GREET_WAIT, &var_psc_greet_wait, 1, 0,
1129
VAR_PSC_PREGR_TTL, DEF_PSC_PREGR_TTL, &var_psc_pregr_ttl, 1, 0,
1130
VAR_PSC_DNSBL_TTL, DEF_PSC_DNSBL_TTL, &var_psc_dnsbl_ttl, 1, 0,
1131
VAR_PSC_PIPEL_TTL, DEF_PSC_PIPEL_TTL, &var_psc_pipel_ttl, 1, 0,
1132
VAR_PSC_NSMTP_TTL, DEF_PSC_NSMTP_TTL, &var_psc_nsmtp_ttl, 1, 0,
1133
VAR_PSC_BARLF_TTL, DEF_PSC_BARLF_TTL, &var_psc_barlf_ttl, 1, 0,
1134
VAR_PSC_CACHE_RET, DEF_PSC_CACHE_RET, &var_psc_cache_ret, 1, 0,
1135
VAR_PSC_CACHE_SCAN, DEF_PSC_CACHE_SCAN, &var_psc_cache_scan, 1, 0,
1136
VAR_PSC_WATCHDOG, DEF_PSC_WATCHDOG, &var_psc_watchdog, 10, 0,
1139
static const CONFIG_BOOL_TABLE bool_table[] = {
1140
VAR_HELO_REQUIRED, DEF_HELO_REQUIRED, &var_helo_required,
1141
VAR_DISABLE_VRFY_CMD, DEF_DISABLE_VRFY_CMD, &var_disable_vrfy_cmd,
1142
VAR_SMTPD_USE_TLS, DEF_SMTPD_USE_TLS, &var_smtpd_use_tls,
1143
VAR_SMTPD_ENFORCE_TLS, DEF_SMTPD_ENFORCE_TLS, &var_smtpd_enforce_tls,
1144
VAR_PSC_PIPEL_ENABLE, DEF_PSC_PIPEL_ENABLE, &var_psc_pipel_enable,
1145
VAR_PSC_NSMTP_ENABLE, DEF_PSC_NSMTP_ENABLE, &var_psc_nsmtp_enable,
1146
VAR_PSC_BARLF_ENABLE, DEF_PSC_BARLF_ENABLE, &var_psc_barlf_enable,
1149
static const CONFIG_RAW_TABLE raw_table[] = {
1150
VAR_PSC_CMD_TIME, DEF_PSC_CMD_TIME, &var_psc_cmd_time, 1, 0,
1151
VAR_SMTPD_REJ_FOOTER, DEF_SMTPD_REJ_FOOTER, &var_smtpd_rej_footer, 0, 0,
1152
VAR_PSC_REJ_FOOTER, DEF_PSC_REJ_FOOTER, &var_psc_rej_footer, 0, 0,
1153
VAR_SMTPD_EXP_FILTER, DEF_SMTPD_EXP_FILTER, &var_smtpd_exp_filter, 1, 0,
1154
VAR_PSC_EXP_FILTER, DEF_PSC_EXP_FILTER, &var_psc_exp_filter, 1, 0,
1157
static const CONFIG_NBOOL_TABLE nbool_table[] = {
1158
VAR_PSC_HELO_REQUIRED, DEF_PSC_HELO_REQUIRED, &var_psc_helo_required,
1159
VAR_PSC_DISABLE_VRFY, DEF_PSC_DISABLE_VRFY, &var_psc_disable_vrfy,
1160
VAR_PSC_USE_TLS, DEF_PSC_USE_TLS, &var_psc_use_tls,
1161
VAR_PSC_ENFORCE_TLS, DEF_PSC_ENFORCE_TLS, &var_psc_enforce_tls,
1166
* Fingerprint executables and core dumps.
1168
MAIL_VERSION_STAMP_ALLOCATE;
1170
event_server_main(argc, argv, psc_service,
1171
MAIL_SERVER_STR_TABLE, str_table,
1172
MAIL_SERVER_INT_TABLE, int_table,
1173
MAIL_SERVER_NINT_TABLE, nint_table,
1174
MAIL_SERVER_TIME_TABLE, time_table,
1175
MAIL_SERVER_BOOL_TABLE, bool_table,
1176
MAIL_SERVER_RAW_TABLE, raw_table,
1177
MAIL_SERVER_NBOOL_TABLE, nbool_table,
1178
MAIL_SERVER_PRE_INIT, pre_jail_init,
1179
MAIL_SERVER_POST_INIT, post_jail_init,
1180
MAIL_SERVER_PRE_ACCEPT, pre_accept,
1181
MAIL_SERVER_SOLITARY,
1182
MAIL_SERVER_SLOW_EXIT, psc_drain,
1183
MAIL_SERVER_EXIT, psc_dump,
1184
MAIL_SERVER_WATCHDOG, &var_psc_watchdog,