Postfix3.3.1
smtpd.c
[詳解]
1 /*++
2 /* NAME
3 /* smtpd 8
4 /* SUMMARY
5 /* Postfix SMTP server
6 /* SYNOPSIS
7 /* \fBsmtpd\fR [generic Postfix daemon options]
8 /*
9 /* \fBsendmail -bs\fR
10 /* DESCRIPTION
11 /* The SMTP server accepts network connection requests
12 /* and performs zero or more SMTP transactions per connection.
13 /* Each received message is piped through the \fBcleanup\fR(8)
14 /* daemon, and is placed into the \fBincoming\fR queue as one
15 /* single queue file. For this mode of operation, the program
16 /* expects to be run from the \fBmaster\fR(8) process manager.
17 /*
18 /* Alternatively, the SMTP server be can run in stand-alone
19 /* mode; this is traditionally obtained with "\fBsendmail
20 /* -bs\fR". When the SMTP server runs stand-alone with non
21 /* $\fBmail_owner\fR privileges, it receives mail even while
22 /* the mail system is not running, deposits messages directly
23 /* into the \fBmaildrop\fR queue, and disables the SMTP server's
24 /* access policies. As of Postfix version 2.3, the SMTP server
25 /* refuses to receive mail from the network when it runs with
26 /* non $\fBmail_owner\fR privileges.
27 /*
28 /* The SMTP server implements a variety of policies for connection
29 /* requests, and for parameters given to \fBHELO, ETRN, MAIL FROM, VRFY\fR
30 /* and \fBRCPT TO\fR commands. They are detailed below and in the
31 /* \fBmain.cf\fR configuration file.
32 /* SECURITY
33 /* .ad
34 /* .fi
35 /* The SMTP server is moderately security-sensitive. It talks to SMTP
36 /* clients and to DNS servers on the network. The SMTP server can be
37 /* run chrooted at fixed low privilege.
38 /* STANDARDS
39 /* RFC 821 (SMTP protocol)
40 /* RFC 1123 (Host requirements)
41 /* RFC 1652 (8bit-MIME transport)
42 /* RFC 1869 (SMTP service extensions)
43 /* RFC 1870 (Message size declaration)
44 /* RFC 1985 (ETRN command)
45 /* RFC 2034 (SMTP enhanced status codes)
46 /* RFC 2554 (AUTH command)
47 /* RFC 2821 (SMTP protocol)
48 /* RFC 2920 (SMTP pipelining)
49 /* RFC 3207 (STARTTLS command)
50 /* RFC 3461 (SMTP DSN extension)
51 /* RFC 3463 (Enhanced status codes)
52 /* RFC 3848 (ESMTP transmission types)
53 /* RFC 4409 (Message submission)
54 /* RFC 4954 (AUTH command)
55 /* RFC 5321 (SMTP protocol)
56 /* RFC 6531 (Internationalized SMTP)
57 /* RFC 6533 (Internationalized Delivery Status Notifications)
58 /* RFC 7505 ("Null MX" No Service Resource Record)
59 /* DIAGNOSTICS
60 /* Problems and transactions are logged to \fBsyslogd\fR(8).
61 /*
62 /* Depending on the setting of the \fBnotify_classes\fR parameter,
63 /* the postmaster is notified of bounces, protocol problems,
64 /* policy violations, and of other trouble.
65 /* CONFIGURATION PARAMETERS
66 /* .ad
67 /* .fi
68 /* Changes to \fBmain.cf\fR are picked up automatically, as \fBsmtpd\fR(8)
69 /* processes run for only a limited amount of time. Use the command
70 /* "\fBpostfix reload\fR" to speed up a change.
71 /*
72 /* The text below provides only a parameter summary. See
73 /* \fBpostconf\fR(5) for more details including examples.
74 /* COMPATIBILITY CONTROLS
75 /* .ad
76 /* .fi
77 /* The following parameters work around implementation errors in other
78 /* software, and/or allow you to override standards in order to prevent
79 /* undesirable use.
80 /* .ad
81 /* .fi
82 /* .IP "\fBbroken_sasl_auth_clients (no)\fR"
83 /* Enable interoperability with remote SMTP clients that implement an obsolete
84 /* version of the AUTH command (RFC 4954).
85 /* .IP "\fBdisable_vrfy_command (no)\fR"
86 /* Disable the SMTP VRFY command.
87 /* .IP "\fBsmtpd_noop_commands (empty)\fR"
88 /* List of commands that the Postfix SMTP server replies to with "250
89 /* Ok", without doing any syntax checks and without changing state.
90 /* .IP "\fBstrict_rfc821_envelopes (no)\fR"
91 /* Require that addresses received in SMTP MAIL FROM and RCPT TO
92 /* commands are enclosed with <>, and that those addresses do
93 /* not contain RFC 822 style comments or phrases.
94 /* .PP
95 /* Available in Postfix version 2.1 and later:
96 /* .IP "\fBsmtpd_reject_unlisted_sender (no)\fR"
97 /* Request that the Postfix SMTP server rejects mail from unknown
98 /* sender addresses, even when no explicit reject_unlisted_sender
99 /* access restriction is specified.
100 /* .IP "\fBsmtpd_sasl_exceptions_networks (empty)\fR"
101 /* What remote SMTP clients the Postfix SMTP server will not offer
102 /* AUTH support to.
103 /* .PP
104 /* Available in Postfix version 2.2 and later:
105 /* .IP "\fBsmtpd_discard_ehlo_keyword_address_maps (empty)\fR"
106 /* Lookup tables, indexed by the remote SMTP client address, with
107 /* case insensitive lists of EHLO keywords (pipelining, starttls, auth,
108 /* etc.) that the Postfix SMTP server will not send in the EHLO response
109 /* to a
110 /* remote SMTP client.
111 /* .IP "\fBsmtpd_discard_ehlo_keywords (empty)\fR"
112 /* A case insensitive list of EHLO keywords (pipelining, starttls,
113 /* auth, etc.) that the Postfix SMTP server will not send in the EHLO
114 /* response
115 /* to a remote SMTP client.
116 /* .IP "\fBsmtpd_delay_open_until_valid_rcpt (yes)\fR"
117 /* Postpone the start of an SMTP mail transaction until a valid
118 /* RCPT TO command is received.
119 /* .PP
120 /* Available in Postfix version 2.3 and later:
121 /* .IP "\fBsmtpd_tls_always_issue_session_ids (yes)\fR"
122 /* Force the Postfix SMTP server to issue a TLS session id, even
123 /* when TLS session caching is turned off (smtpd_tls_session_cache_database
124 /* is empty).
125 /* .PP
126 /* Available in Postfix version 2.6 and later:
127 /* .IP "\fBtcp_windowsize (0)\fR"
128 /* An optional workaround for routers that break TCP window scaling.
129 /* .PP
130 /* Available in Postfix version 2.7 and later:
131 /* .IP "\fBsmtpd_command_filter (empty)\fR"
132 /* A mechanism to transform commands from remote SMTP clients.
133 /* .PP
134 /* Available in Postfix version 2.9 and later:
135 /* .IP "\fBsmtpd_per_record_deadline (normal: no, overload: yes)\fR"
136 /* Change the behavior of the smtpd_timeout and smtpd_starttls_timeout
137 /* time limits, from a
138 /* time limit per read or write system call, to a time limit to send
139 /* or receive a complete record (an SMTP command line, SMTP response
140 /* line, SMTP message content line, or TLS protocol message).
141 /* .PP
142 /* Available in Postfix version 3.0 and later:
143 /* .IP "\fBsmtpd_dns_reply_filter (empty)\fR"
144 /* Optional filter for Postfix SMTP server DNS lookup results.
145 /* ADDRESS REWRITING CONTROLS
146 /* .ad
147 /* .fi
148 /* See the ADDRESS_REWRITING_README document for a detailed
149 /* discussion of Postfix address rewriting.
150 /* .IP "\fBreceive_override_options (empty)\fR"
151 /* Enable or disable recipient validation, built-in content
152 /* filtering, or address mapping.
153 /* .PP
154 /* Available in Postfix version 2.2 and later:
155 /* .IP "\fBlocal_header_rewrite_clients (permit_inet_interfaces)\fR"
156 /* Rewrite message header addresses in mail from these clients and
157 /* update incomplete addresses with the domain name in $myorigin or
158 /* $mydomain; either don't rewrite message headers from other clients
159 /* at all, or rewrite message headers and update incomplete addresses
160 /* with the domain specified in the remote_header_rewrite_domain
161 /* parameter.
162 /* BEFORE-SMTPD PROXY AGENT
163 /* .ad
164 /* .fi
165 /* Available in Postfix version 2.10 and later:
166 /* .IP "\fBsmtpd_upstream_proxy_protocol (empty)\fR"
167 /* The name of the proxy protocol used by an optional before-smtpd
168 /* proxy agent.
169 /* .IP "\fBsmtpd_upstream_proxy_timeout (5s)\fR"
170 /* The time limit for the proxy protocol specified with the
171 /* smtpd_upstream_proxy_protocol parameter.
172 /* AFTER QUEUE EXTERNAL CONTENT INSPECTION CONTROLS
173 /* .ad
174 /* .fi
175 /* As of version 1.0, Postfix can be configured to send new mail to
176 /* an external content filter AFTER the mail is queued. This content
177 /* filter is expected to inject mail back into a (Postfix or other)
178 /* MTA for further delivery. See the FILTER_README document for details.
179 /* .IP "\fBcontent_filter (empty)\fR"
180 /* After the message is queued, send the entire message to the
181 /* specified \fItransport:destination\fR.
182 /* BEFORE QUEUE EXTERNAL CONTENT INSPECTION CONTROLS
183 /* .ad
184 /* .fi
185 /* As of version 2.1, the Postfix SMTP server can be configured
186 /* to send incoming mail to a real-time SMTP-based content filter
187 /* BEFORE mail is queued. This content filter is expected to inject
188 /* mail back into Postfix. See the SMTPD_PROXY_README document for
189 /* details on how to configure and operate this feature.
190 /* .IP "\fBsmtpd_proxy_filter (empty)\fR"
191 /* The hostname and TCP port of the mail filtering proxy server.
192 /* .IP "\fBsmtpd_proxy_ehlo ($myhostname)\fR"
193 /* How the Postfix SMTP server announces itself to the proxy filter.
194 /* .IP "\fBsmtpd_proxy_options (empty)\fR"
195 /* List of options that control how the Postfix SMTP server
196 /* communicates with a before-queue content filter.
197 /* .IP "\fBsmtpd_proxy_timeout (100s)\fR"
198 /* The time limit for connecting to a proxy filter and for sending or
199 /* receiving information.
200 /* BEFORE QUEUE MILTER CONTROLS
201 /* .ad
202 /* .fi
203 /* As of version 2.3, Postfix supports the Sendmail version 8
204 /* Milter (mail filter) protocol. These content filters run
205 /* outside Postfix. They can inspect the SMTP command stream
206 /* and the message content, and can request modifications before
207 /* mail is queued. For details see the MILTER_README document.
208 /* .IP "\fBsmtpd_milters (empty)\fR"
209 /* A list of Milter (mail filter) applications for new mail that
210 /* arrives via the Postfix \fBsmtpd\fR(8) server.
211 /* .IP "\fBmilter_protocol (6)\fR"
212 /* The mail filter protocol version and optional protocol extensions
213 /* for communication with a Milter application; prior to Postfix 2.6
214 /* the default protocol is 2.
215 /* .IP "\fBmilter_default_action (tempfail)\fR"
216 /* The default action when a Milter (mail filter) application is
217 /* unavailable or mis-configured.
218 /* .IP "\fBmilter_macro_daemon_name ($myhostname)\fR"
219 /* The {daemon_name} macro value for Milter (mail filter) applications.
220 /* .IP "\fBmilter_macro_v ($mail_name $mail_version)\fR"
221 /* The {v} macro value for Milter (mail filter) applications.
222 /* .IP "\fBmilter_connect_timeout (30s)\fR"
223 /* The time limit for connecting to a Milter (mail filter)
224 /* application, and for negotiating protocol options.
225 /* .IP "\fBmilter_command_timeout (30s)\fR"
226 /* The time limit for sending an SMTP command to a Milter (mail
227 /* filter) application, and for receiving the response.
228 /* .IP "\fBmilter_content_timeout (300s)\fR"
229 /* The time limit for sending message content to a Milter (mail
230 /* filter) application, and for receiving the response.
231 /* .IP "\fBmilter_connect_macros (see 'postconf -d' output)\fR"
232 /* The macros that are sent to Milter (mail filter) applications
233 /* after completion of an SMTP connection.
234 /* .IP "\fBmilter_helo_macros (see 'postconf -d' output)\fR"
235 /* The macros that are sent to Milter (mail filter) applications
236 /* after the SMTP HELO or EHLO command.
237 /* .IP "\fBmilter_mail_macros (see 'postconf -d' output)\fR"
238 /* The macros that are sent to Milter (mail filter) applications
239 /* after the SMTP MAIL FROM command.
240 /* .IP "\fBmilter_rcpt_macros (see 'postconf -d' output)\fR"
241 /* The macros that are sent to Milter (mail filter) applications
242 /* after the SMTP RCPT TO command.
243 /* .IP "\fBmilter_data_macros (see 'postconf -d' output)\fR"
244 /* The macros that are sent to version 4 or higher Milter (mail
245 /* filter) applications after the SMTP DATA command.
246 /* .IP "\fBmilter_unknown_command_macros (see 'postconf -d' output)\fR"
247 /* The macros that are sent to version 3 or higher Milter (mail
248 /* filter) applications after an unknown SMTP command.
249 /* .IP "\fBmilter_end_of_header_macros (see 'postconf -d' output)\fR"
250 /* The macros that are sent to Milter (mail filter) applications
251 /* after the end of the message header.
252 /* .IP "\fBmilter_end_of_data_macros (see 'postconf -d' output)\fR"
253 /* The macros that are sent to Milter (mail filter) applications
254 /* after the message end-of-data.
255 /* .PP
256 /* Available in Postfix version 3.1 and later:
257 /* .IP "\fBmilter_macro_defaults (empty)\fR"
258 /* Optional list of \fIname=value\fR pairs that specify default
259 /* values for arbitrary macros that Postfix may send to Milter
260 /* applications.
261 /* .PP
262 /* Available in Postfix version 3.2 and later:
263 /* .IP "\fBsmtpd_milter_maps (empty)\fR"
264 /* Lookup tables with Milter settings per remote SMTP client IP
265 /* address.
266 /* GENERAL CONTENT INSPECTION CONTROLS
267 /* .ad
268 /* .fi
269 /* The following parameters are applicable for both built-in
270 /* and external content filters.
271 /* .PP
272 /* Available in Postfix version 2.1 and later:
273 /* .IP "\fBreceive_override_options (empty)\fR"
274 /* Enable or disable recipient validation, built-in content
275 /* filtering, or address mapping.
276 /* EXTERNAL CONTENT INSPECTION CONTROLS
277 /* .ad
278 /* .fi
279 /* The following parameters are applicable for both before-queue
280 /* and after-queue content filtering.
281 /* .PP
282 /* Available in Postfix version 2.1 and later:
283 /* .IP "\fBsmtpd_authorized_xforward_hosts (empty)\fR"
284 /* What remote SMTP clients are allowed to use the XFORWARD feature.
285 /* SASL AUTHENTICATION CONTROLS
286 /* .ad
287 /* .fi
288 /* Postfix SASL support (RFC 4954) can be used to authenticate remote
289 /* SMTP clients to the Postfix SMTP server, and to authenticate the
290 /* Postfix SMTP client to a remote SMTP server.
291 /* See the SASL_README document for details.
292 /* .IP "\fBbroken_sasl_auth_clients (no)\fR"
293 /* Enable interoperability with remote SMTP clients that implement an obsolete
294 /* version of the AUTH command (RFC 4954).
295 /* .IP "\fBsmtpd_sasl_auth_enable (no)\fR"
296 /* Enable SASL authentication in the Postfix SMTP server.
297 /* .IP "\fBsmtpd_sasl_local_domain (empty)\fR"
298 /* The name of the Postfix SMTP server's local SASL authentication
299 /* realm.
300 /* .IP "\fBsmtpd_sasl_security_options (noanonymous)\fR"
301 /* Postfix SMTP server SASL security options; as of Postfix 2.3
302 /* the list of available
303 /* features depends on the SASL server implementation that is selected
304 /* with \fBsmtpd_sasl_type\fR.
305 /* .IP "\fBsmtpd_sender_login_maps (empty)\fR"
306 /* Optional lookup table with the SASL login names that own the sender
307 /* (MAIL FROM) addresses.
308 /* .PP
309 /* Available in Postfix version 2.1 and later:
310 /* .IP "\fBsmtpd_sasl_exceptions_networks (empty)\fR"
311 /* What remote SMTP clients the Postfix SMTP server will not offer
312 /* AUTH support to.
313 /* .PP
314 /* Available in Postfix version 2.1 and 2.2:
315 /* .IP "\fBsmtpd_sasl_application_name (smtpd)\fR"
316 /* The application name that the Postfix SMTP server uses for SASL
317 /* server initialization.
318 /* .PP
319 /* Available in Postfix version 2.3 and later:
320 /* .IP "\fBsmtpd_sasl_authenticated_header (no)\fR"
321 /* Report the SASL authenticated user name in the \fBsmtpd\fR(8) Received
322 /* message header.
323 /* .IP "\fBsmtpd_sasl_path (smtpd)\fR"
324 /* Implementation-specific information that the Postfix SMTP server
325 /* passes through to
326 /* the SASL plug-in implementation that is selected with
327 /* \fBsmtpd_sasl_type\fR.
328 /* .IP "\fBsmtpd_sasl_type (cyrus)\fR"
329 /* The SASL plug-in type that the Postfix SMTP server should use
330 /* for authentication.
331 /* .PP
332 /* Available in Postfix version 2.5 and later:
333 /* .IP "\fBcyrus_sasl_config_path (empty)\fR"
334 /* Search path for Cyrus SASL application configuration files,
335 /* currently used only to locate the $smtpd_sasl_path.conf file.
336 /* .PP
337 /* Available in Postfix version 2.11 and later:
338 /* .IP "\fBsmtpd_sasl_service (smtp)\fR"
339 /* The service name that is passed to the SASL plug-in that is
340 /* selected with \fBsmtpd_sasl_type\fR and \fBsmtpd_sasl_path\fR.
341 /* STARTTLS SUPPORT CONTROLS
342 /* .ad
343 /* .fi
344 /* Detailed information about STARTTLS configuration may be
345 /* found in the TLS_README document.
346 /* .IP "\fBsmtpd_tls_security_level (empty)\fR"
347 /* The SMTP TLS security level for the Postfix SMTP server; when
348 /* a non-empty value is specified, this overrides the obsolete parameters
349 /* smtpd_use_tls and smtpd_enforce_tls.
350 /* .IP "\fBsmtpd_sasl_tls_security_options ($smtpd_sasl_security_options)\fR"
351 /* The SASL authentication security options that the Postfix SMTP
352 /* server uses for TLS encrypted SMTP sessions.
353 /* .IP "\fBsmtpd_starttls_timeout (see 'postconf -d' output)\fR"
354 /* The time limit for Postfix SMTP server write and read operations
355 /* during TLS startup and shutdown handshake procedures.
356 /* .IP "\fBsmtpd_tls_CAfile (empty)\fR"
357 /* A file containing (PEM format) CA certificates of root CAs trusted
358 /* to sign either remote SMTP client certificates or intermediate CA
359 /* certificates.
360 /* .IP "\fBsmtpd_tls_CApath (empty)\fR"
361 /* A directory containing (PEM format) CA certificates of root CAs
362 /* trusted to sign either remote SMTP client certificates or intermediate CA
363 /* certificates.
364 /* .IP "\fBsmtpd_tls_always_issue_session_ids (yes)\fR"
365 /* Force the Postfix SMTP server to issue a TLS session id, even
366 /* when TLS session caching is turned off (smtpd_tls_session_cache_database
367 /* is empty).
368 /* .IP "\fBsmtpd_tls_ask_ccert (no)\fR"
369 /* Ask a remote SMTP client for a client certificate.
370 /* .IP "\fBsmtpd_tls_auth_only (no)\fR"
371 /* When TLS encryption is optional in the Postfix SMTP server, do
372 /* not announce or accept SASL authentication over unencrypted
373 /* connections.
374 /* .IP "\fBsmtpd_tls_ccert_verifydepth (9)\fR"
375 /* The verification depth for remote SMTP client certificates.
376 /* .IP "\fBsmtpd_tls_cert_file (empty)\fR"
377 /* File with the Postfix SMTP server RSA certificate in PEM format.
378 /* .IP "\fBsmtpd_tls_exclude_ciphers (empty)\fR"
379 /* List of ciphers or cipher types to exclude from the SMTP server
380 /* cipher list at all TLS security levels.
381 /* .IP "\fBsmtpd_tls_dcert_file (empty)\fR"
382 /* File with the Postfix SMTP server DSA certificate in PEM format.
383 /* .IP "\fBsmtpd_tls_dh1024_param_file (empty)\fR"
384 /* File with DH parameters that the Postfix SMTP server should
385 /* use with non-export EDH ciphers.
386 /* .IP "\fBsmtpd_tls_dh512_param_file (empty)\fR"
387 /* File with DH parameters that the Postfix SMTP server should
388 /* use with export-grade EDH ciphers.
389 /* .IP "\fBsmtpd_tls_dkey_file ($smtpd_tls_dcert_file)\fR"
390 /* File with the Postfix SMTP server DSA private key in PEM format.
391 /* .IP "\fBsmtpd_tls_key_file ($smtpd_tls_cert_file)\fR"
392 /* File with the Postfix SMTP server RSA private key in PEM format.
393 /* .IP "\fBsmtpd_tls_loglevel (0)\fR"
394 /* Enable additional Postfix SMTP server logging of TLS activity.
395 /* .IP "\fBsmtpd_tls_mandatory_ciphers (medium)\fR"
396 /* The minimum TLS cipher grade that the Postfix SMTP server will
397 /* use with mandatory TLS encryption.
398 /* .IP "\fBsmtpd_tls_mandatory_exclude_ciphers (empty)\fR"
399 /* Additional list of ciphers or cipher types to exclude from the
400 /* Postfix SMTP server cipher list at mandatory TLS security levels.
401 /* .IP "\fBsmtpd_tls_mandatory_protocols (!SSLv2, !SSLv3)\fR"
402 /* The SSL/TLS protocols accepted by the Postfix SMTP server with
403 /* mandatory TLS encryption.
404 /* .IP "\fBsmtpd_tls_received_header (no)\fR"
405 /* Request that the Postfix SMTP server produces Received: message
406 /* headers that include information about the protocol and cipher used,
407 /* as well as the remote SMTP client CommonName and client certificate issuer
408 /* CommonName.
409 /* .IP "\fBsmtpd_tls_req_ccert (no)\fR"
410 /* With mandatory TLS encryption, require a trusted remote SMTP client
411 /* certificate in order to allow TLS connections to proceed.
412 /* .IP "\fBsmtpd_tls_wrappermode (no)\fR"
413 /* Run the Postfix SMTP server in the non-standard "wrapper" mode,
414 /* instead of using the STARTTLS command.
415 /* .IP "\fBtls_daemon_random_bytes (32)\fR"
416 /* The number of pseudo-random bytes that an \fBsmtp\fR(8) or \fBsmtpd\fR(8)
417 /* process requests from the \fBtlsmgr\fR(8) server in order to seed its
418 /* internal pseudo random number generator (PRNG).
419 /* .IP "\fBtls_high_cipherlist (see 'postconf -d' output)\fR"
420 /* The OpenSSL cipherlist for "high" grade ciphers.
421 /* .IP "\fBtls_medium_cipherlist (see 'postconf -d' output)\fR"
422 /* The OpenSSL cipherlist for "medium" or higher grade ciphers.
423 /* .IP "\fBtls_low_cipherlist (see 'postconf -d' output)\fR"
424 /* The OpenSSL cipherlist for "low" or higher grade ciphers.
425 /* .IP "\fBtls_export_cipherlist (see 'postconf -d' output)\fR"
426 /* The OpenSSL cipherlist for "export" or higher grade ciphers.
427 /* .IP "\fBtls_null_cipherlist (eNULL:!aNULL)\fR"
428 /* The OpenSSL cipherlist for "NULL" grade ciphers that provide
429 /* authentication without encryption.
430 /* .PP
431 /* Available in Postfix version 2.5 and later:
432 /* .IP "\fBsmtpd_tls_fingerprint_digest (md5)\fR"
433 /* The message digest algorithm to construct remote SMTP
434 /* client-certificate
435 /* fingerprints or public key fingerprints (Postfix 2.9 and later)
436 /* for \fBcheck_ccert_access\fR and \fBpermit_tls_clientcerts\fR.
437 /* .PP
438 /* Available in Postfix version 2.6 and later:
439 /* .IP "\fBsmtpd_tls_protocols (!SSLv2, !SSLv3)\fR"
440 /* List of TLS protocols that the Postfix SMTP server will exclude
441 /* or include with opportunistic TLS encryption.
442 /* .IP "\fBsmtpd_tls_ciphers (medium)\fR"
443 /* The minimum TLS cipher grade that the Postfix SMTP server
444 /* will use with opportunistic TLS encryption.
445 /* .IP "\fBsmtpd_tls_eccert_file (empty)\fR"
446 /* File with the Postfix SMTP server ECDSA certificate in PEM format.
447 /* .IP "\fBsmtpd_tls_eckey_file ($smtpd_tls_eccert_file)\fR"
448 /* File with the Postfix SMTP server ECDSA private key in PEM format.
449 /* .IP "\fBsmtpd_tls_eecdh_grade (see 'postconf -d' output)\fR"
450 /* The Postfix SMTP server security grade for ephemeral elliptic-curve
451 /* Diffie-Hellman (EECDH) key exchange.
452 /* .IP "\fBtls_eecdh_strong_curve (prime256v1)\fR"
453 /* The elliptic curve used by the Postfix SMTP server for sensibly
454 /* strong
455 /* ephemeral ECDH key exchange.
456 /* .IP "\fBtls_eecdh_ultra_curve (secp384r1)\fR"
457 /* The elliptic curve used by the Postfix SMTP server for maximally
458 /* strong
459 /* ephemeral ECDH key exchange.
460 /* .PP
461 /* Available in Postfix version 2.8 and later:
462 /* .IP "\fBtls_preempt_cipherlist (no)\fR"
463 /* With SSLv3 and later, use the Postfix SMTP server's cipher
464 /* preference order instead of the remote client's cipher preference
465 /* order.
466 /* .IP "\fBtls_disable_workarounds (see 'postconf -d' output)\fR"
467 /* List or bit-mask of OpenSSL bug work-arounds to disable.
468 /* .PP
469 /* Available in Postfix version 2.11 and later:
470 /* .IP "\fBtlsmgr_service_name (tlsmgr)\fR"
471 /* The name of the \fBtlsmgr\fR(8) service entry in master.cf.
472 /* .PP
473 /* Available in Postfix version 3.0 and later:
474 /* .IP "\fBtls_session_ticket_cipher (Postfix >= 3.0: aes-256-cbc, Postfix < 3.0: aes-128-cbc)\fR"
475 /* Algorithm used to encrypt RFC5077 TLS session tickets.
476 /* .PP
477 /* Available in Postfix version 3.2 and later:
478 /* .IP "\fBtls_eecdh_auto_curves (see 'postconf -d' output)\fR"
479 /* The prioritized list of elliptic curves supported by the Postfix
480 /* SMTP client and server.
481 /* OBSOLETE STARTTLS CONTROLS
482 /* .ad
483 /* .fi
484 /* The following configuration parameters exist for compatibility
485 /* with Postfix versions before 2.3. Support for these will
486 /* be removed in a future release.
487 /* .IP "\fBsmtpd_use_tls (no)\fR"
488 /* Opportunistic TLS: announce STARTTLS support to remote SMTP clients,
489 /* but do not require that clients use TLS encryption.
490 /* .IP "\fBsmtpd_enforce_tls (no)\fR"
491 /* Mandatory TLS: announce STARTTLS support to remote SMTP clients,
492 /* and require that clients use TLS encryption.
493 /* .IP "\fBsmtpd_tls_cipherlist (empty)\fR"
494 /* Obsolete Postfix < 2.3 control for the Postfix SMTP server TLS
495 /* cipher list.
496 /* SMTPUTF8 CONTROLS
497 /* .ad
498 /* .fi
499 /* Preliminary SMTPUTF8 support is introduced with Postfix 3.0.
500 /* .IP "\fBsmtputf8_enable (yes)\fR"
501 /* Enable preliminary SMTPUTF8 support for the protocols described
502 /* in RFC 6531..6533.
503 /* .IP "\fBstrict_smtputf8 (no)\fR"
504 /* Enable stricter enforcement of the SMTPUTF8 protocol.
505 /* .IP "\fBsmtputf8_autodetect_classes (sendmail, verify)\fR"
506 /* Detect that a message requires SMTPUTF8 support for the specified
507 /* mail origin classes.
508 /* .PP
509 /* Available in Postfix version 3.2 and later:
510 /* .IP "\fBenable_idna2003_compatibility (no)\fR"
511 /* Enable 'transitional' compatibility between IDNA2003 and IDNA2008,
512 /* when converting UTF-8 domain names to/from the ASCII form that is
513 /* used for DNS lookups.
514 /* VERP SUPPORT CONTROLS
515 /* .ad
516 /* .fi
517 /* With VERP style delivery, each recipient of a message receives a
518 /* customized copy of the message with his/her own recipient address
519 /* encoded in the envelope sender address. The VERP_README file
520 /* describes configuration and operation details of Postfix support
521 /* for variable envelope return path addresses. VERP style delivery
522 /* is requested with the SMTP XVERP command or with the "sendmail
523 /* -V" command-line option and is available in Postfix version 1.1
524 /* and later.
525 /* .IP "\fBdefault_verp_delimiters (+=)\fR"
526 /* The two default VERP delimiter characters.
527 /* .IP "\fBverp_delimiter_filter (-=+)\fR"
528 /* The characters Postfix accepts as VERP delimiter characters on the
529 /* Postfix \fBsendmail\fR(1) command line and in SMTP commands.
530 /* .PP
531 /* Available in Postfix version 1.1 and 2.0:
532 /* .IP "\fBauthorized_verp_clients ($mynetworks)\fR"
533 /* What remote SMTP clients are allowed to specify the XVERP command.
534 /* .PP
535 /* Available in Postfix version 2.1 and later:
536 /* .IP "\fBsmtpd_authorized_verp_clients ($authorized_verp_clients)\fR"
537 /* What remote SMTP clients are allowed to specify the XVERP command.
538 /* TROUBLE SHOOTING CONTROLS
539 /* .ad
540 /* .fi
541 /* The DEBUG_README document describes how to debug parts of the
542 /* Postfix mail system. The methods vary from making the software log
543 /* a lot of detail, to running some daemon processes under control of
544 /* a call tracer or debugger.
545 /* .IP "\fBdebug_peer_level (2)\fR"
546 /* The increment in verbose logging level when a remote client or
547 /* server matches a pattern in the debug_peer_list parameter.
548 /* .IP "\fBdebug_peer_list (empty)\fR"
549 /* Optional list of remote client or server hostname or network
550 /* address patterns that cause the verbose logging level to increase
551 /* by the amount specified in $debug_peer_level.
552 /* .IP "\fBerror_notice_recipient (postmaster)\fR"
553 /* The recipient of postmaster notifications about mail delivery
554 /* problems that are caused by policy, resource, software or protocol
555 /* errors.
556 /* .IP "\fBinternal_mail_filter_classes (empty)\fR"
557 /* What categories of Postfix-generated mail are subject to
558 /* before-queue content inspection by non_smtpd_milters, header_checks
559 /* and body_checks.
560 /* .IP "\fBnotify_classes (resource, software)\fR"
561 /* The list of error classes that are reported to the postmaster.
562 /* .IP "\fBsmtpd_reject_footer (empty)\fR"
563 /* Optional information that is appended after each Postfix SMTP
564 /* server
565 /* 4XX or 5XX response.
566 /* .IP "\fBsoft_bounce (no)\fR"
567 /* Safety net to keep mail queued that would otherwise be returned to
568 /* the sender.
569 /* .PP
570 /* Available in Postfix version 2.1 and later:
571 /* .IP "\fBsmtpd_authorized_xclient_hosts (empty)\fR"
572 /* What remote SMTP clients are allowed to use the XCLIENT feature.
573 /* .PP
574 /* Available in Postfix version 2.10 and later:
575 /* .IP "\fBsmtpd_log_access_permit_actions (empty)\fR"
576 /* Enable logging of the named "permit" actions in SMTP server
577 /* access lists (by default, the SMTP server logs "reject" actions but
578 /* not "permit" actions).
579 /* KNOWN VERSUS UNKNOWN RECIPIENT CONTROLS
580 /* .ad
581 /* .fi
582 /* As of Postfix version 2.0, the SMTP server rejects mail for
583 /* unknown recipients. This prevents the mail queue from clogging up
584 /* with undeliverable MAILER-DAEMON messages. Additional information
585 /* on this topic is in the LOCAL_RECIPIENT_README and ADDRESS_CLASS_README
586 /* documents.
587 /* .IP "\fBshow_user_unknown_table_name (yes)\fR"
588 /* Display the name of the recipient table in the "User unknown"
589 /* responses.
590 /* .IP "\fBcanonical_maps (empty)\fR"
591 /* Optional address mapping lookup tables for message headers and
592 /* envelopes.
593 /* .IP "\fBrecipient_canonical_maps (empty)\fR"
594 /* Optional address mapping lookup tables for envelope and header
595 /* recipient addresses.
596 /* .IP "\fBsender_canonical_maps (empty)\fR"
597 /* Optional address mapping lookup tables for envelope and header
598 /* sender addresses.
599 /* .PP
600 /* Parameters concerning known/unknown local recipients:
601 /* .IP "\fBmydestination ($myhostname, localhost.$mydomain, localhost)\fR"
602 /* The list of domains that are delivered via the $local_transport
603 /* mail delivery transport.
604 /* .IP "\fBinet_interfaces (all)\fR"
605 /* The network interface addresses that this mail system receives
606 /* mail on.
607 /* .IP "\fBproxy_interfaces (empty)\fR"
608 /* The network interface addresses that this mail system receives mail
609 /* on by way of a proxy or network address translation unit.
610 /* .IP "\fBinet_protocols (all)\fR"
611 /* The Internet protocols Postfix will attempt to use when making
612 /* or accepting connections.
613 /* .IP "\fBlocal_recipient_maps (proxy:unix:passwd.byname $alias_maps)\fR"
614 /* Lookup tables with all names or addresses of local recipients:
615 /* a recipient address is local when its domain matches $mydestination,
616 /* $inet_interfaces or $proxy_interfaces.
617 /* .IP "\fBunknown_local_recipient_reject_code (550)\fR"
618 /* The numerical Postfix SMTP server response code when a recipient
619 /* address is local, and $local_recipient_maps specifies a list of
620 /* lookup tables that does not match the recipient.
621 /* .PP
622 /* Parameters concerning known/unknown recipients of relay destinations:
623 /* .IP "\fBrelay_domains (Postfix >= 3.0: empty, Postfix < 3.0: $mydestination)\fR"
624 /* What destination domains (and subdomains thereof) this system
625 /* will relay mail to.
626 /* .IP "\fBrelay_recipient_maps (empty)\fR"
627 /* Optional lookup tables with all valid addresses in the domains
628 /* that match $relay_domains.
629 /* .IP "\fBunknown_relay_recipient_reject_code (550)\fR"
630 /* The numerical Postfix SMTP server reply code when a recipient
631 /* address matches $relay_domains, and relay_recipient_maps specifies
632 /* a list of lookup tables that does not match the recipient address.
633 /* .PP
634 /* Parameters concerning known/unknown recipients in virtual alias
635 /* domains:
636 /* .IP "\fBvirtual_alias_domains ($virtual_alias_maps)\fR"
637 /* Postfix is final destination for the specified list of virtual
638 /* alias domains, that is, domains for which all addresses are aliased
639 /* to addresses in other local or remote domains.
640 /* .IP "\fBvirtual_alias_maps ($virtual_maps)\fR"
641 /* Optional lookup tables that alias specific mail addresses or domains
642 /* to other local or remote address.
643 /* .IP "\fBunknown_virtual_alias_reject_code (550)\fR"
644 /* The Postfix SMTP server reply code when a recipient address matches
645 /* $virtual_alias_domains, and $virtual_alias_maps specifies a list
646 /* of lookup tables that does not match the recipient address.
647 /* .PP
648 /* Parameters concerning known/unknown recipients in virtual mailbox
649 /* domains:
650 /* .IP "\fBvirtual_mailbox_domains ($virtual_mailbox_maps)\fR"
651 /* Postfix is final destination for the specified list of domains;
652 /* mail is delivered via the $virtual_transport mail delivery transport.
653 /* .IP "\fBvirtual_mailbox_maps (empty)\fR"
654 /* Optional lookup tables with all valid addresses in the domains that
655 /* match $virtual_mailbox_domains.
656 /* .IP "\fBunknown_virtual_mailbox_reject_code (550)\fR"
657 /* The Postfix SMTP server reply code when a recipient address matches
658 /* $virtual_mailbox_domains, and $virtual_mailbox_maps specifies a list
659 /* of lookup tables that does not match the recipient address.
660 /* RESOURCE AND RATE CONTROLS
661 /* .ad
662 /* .fi
663 /* The following parameters limit resource usage by the SMTP
664 /* server and/or control client request rates.
665 /* .IP "\fBline_length_limit (2048)\fR"
666 /* Upon input, long lines are chopped up into pieces of at most
667 /* this length; upon delivery, long lines are reconstructed.
668 /* .IP "\fBqueue_minfree (0)\fR"
669 /* The minimal amount of free space in bytes in the queue file system
670 /* that is needed to receive mail.
671 /* .IP "\fBmessage_size_limit (10240000)\fR"
672 /* The maximal size in bytes of a message, including envelope information.
673 /* .IP "\fBsmtpd_recipient_limit (1000)\fR"
674 /* The maximal number of recipients that the Postfix SMTP server
675 /* accepts per message delivery request.
676 /* .IP "\fBsmtpd_timeout (normal: 300s, overload: 10s)\fR"
677 /* The time limit for sending a Postfix SMTP server response and for
678 /* receiving a remote SMTP client request.
679 /* .IP "\fBsmtpd_history_flush_threshold (100)\fR"
680 /* The maximal number of lines in the Postfix SMTP server command history
681 /* before it is flushed upon receipt of EHLO, RSET, or end of DATA.
682 /* .PP
683 /* Available in Postfix version 2.3 and later:
684 /* .IP "\fBsmtpd_peername_lookup (yes)\fR"
685 /* Attempt to look up the remote SMTP client hostname, and verify that
686 /* the name matches the client IP address.
687 /* .PP
688 /* The per SMTP client connection count and request rate limits are
689 /* implemented in co-operation with the \fBanvil\fR(8) service, and
690 /* are available in Postfix version 2.2 and later.
691 /* .IP "\fBsmtpd_client_connection_count_limit (50)\fR"
692 /* How many simultaneous connections any client is allowed to
693 /* make to this service.
694 /* .IP "\fBsmtpd_client_connection_rate_limit (0)\fR"
695 /* The maximal number of connection attempts any client is allowed to
696 /* make to this service per time unit.
697 /* .IP "\fBsmtpd_client_message_rate_limit (0)\fR"
698 /* The maximal number of message delivery requests that any client is
699 /* allowed to make to this service per time unit, regardless of whether
700 /* or not Postfix actually accepts those messages.
701 /* .IP "\fBsmtpd_client_recipient_rate_limit (0)\fR"
702 /* The maximal number of recipient addresses that any client is allowed
703 /* to send to this service per time unit, regardless of whether or not
704 /* Postfix actually accepts those recipients.
705 /* .IP "\fBsmtpd_client_event_limit_exceptions ($mynetworks)\fR"
706 /* Clients that are excluded from smtpd_client_*_count/rate_limit
707 /* restrictions.
708 /* .PP
709 /* Available in Postfix version 2.3 and later:
710 /* .IP "\fBsmtpd_client_new_tls_session_rate_limit (0)\fR"
711 /* The maximal number of new (i.e., uncached) TLS sessions that a
712 /* remote SMTP client is allowed to negotiate with this service per
713 /* time unit.
714 /* .PP
715 /* Available in Postfix version 2.9 and later:
716 /* .IP "\fBsmtpd_per_record_deadline (normal: no, overload: yes)\fR"
717 /* Change the behavior of the smtpd_timeout and smtpd_starttls_timeout
718 /* time limits, from a
719 /* time limit per read or write system call, to a time limit to send
720 /* or receive a complete record (an SMTP command line, SMTP response
721 /* line, SMTP message content line, or TLS protocol message).
722 /* .PP
723 /* Available in Postfix version 3.1 and later:
724 /* .IP "\fBsmtpd_client_auth_rate_limit (0)\fR"
725 /* The maximal number of AUTH commands that any client is allowed to
726 /* send to this service per time unit, regardless of whether or not
727 /* Postfix actually accepts those commands.
728 /* TARPIT CONTROLS
729 /* .ad
730 /* .fi
731 /* When a remote SMTP client makes errors, the Postfix SMTP server
732 /* can insert delays before responding. This can help to slow down
733 /* run-away software. The behavior is controlled by an error counter
734 /* that counts the number of errors within an SMTP session that a
735 /* client makes without delivering mail.
736 /* .IP "\fBsmtpd_error_sleep_time (1s)\fR"
737 /* With Postfix version 2.1 and later: the SMTP server response delay after
738 /* a client has made more than $smtpd_soft_error_limit errors, and
739 /* fewer than $smtpd_hard_error_limit errors, without delivering mail.
740 /* .IP "\fBsmtpd_soft_error_limit (10)\fR"
741 /* The number of errors a remote SMTP client is allowed to make without
742 /* delivering mail before the Postfix SMTP server slows down all its
743 /* responses.
744 /* .IP "\fBsmtpd_hard_error_limit (normal: 20, overload: 1)\fR"
745 /* The maximal number of errors a remote SMTP client is allowed to
746 /* make without delivering mail.
747 /* .IP "\fBsmtpd_junk_command_limit (normal: 100, overload: 1)\fR"
748 /* The number of junk commands (NOOP, VRFY, ETRN or RSET) that a remote
749 /* SMTP client can send before the Postfix SMTP server starts to
750 /* increment the error counter with each junk command.
751 /* .PP
752 /* Available in Postfix version 2.1 and later:
753 /* .IP "\fBsmtpd_recipient_overshoot_limit (1000)\fR"
754 /* The number of recipients that a remote SMTP client can send in
755 /* excess of the limit specified with $smtpd_recipient_limit, before
756 /* the Postfix SMTP server increments the per-session error count
757 /* for each excess recipient.
758 /* ACCESS POLICY DELEGATION CONTROLS
759 /* .ad
760 /* .fi
761 /* As of version 2.1, Postfix can be configured to delegate access
762 /* policy decisions to an external server that runs outside Postfix.
763 /* See the file SMTPD_POLICY_README for more information.
764 /* .IP "\fBsmtpd_policy_service_max_idle (300s)\fR"
765 /* The time after which an idle SMTPD policy service connection is
766 /* closed.
767 /* .IP "\fBsmtpd_policy_service_max_ttl (1000s)\fR"
768 /* The time after which an active SMTPD policy service connection is
769 /* closed.
770 /* .IP "\fBsmtpd_policy_service_timeout (100s)\fR"
771 /* The time limit for connecting to, writing to, or receiving from a
772 /* delegated SMTPD policy server.
773 /* .PP
774 /* Available in Postfix version 3.0 and later:
775 /* .IP "\fBsmtpd_policy_service_default_action (451 4.3.5 Server configuration problem)\fR"
776 /* The default action when an SMTPD policy service request fails.
777 /* .IP "\fBsmtpd_policy_service_request_limit (0)\fR"
778 /* The maximal number of requests per SMTPD policy service connection,
779 /* or zero (no limit).
780 /* .IP "\fBsmtpd_policy_service_try_limit (2)\fR"
781 /* The maximal number of attempts to send an SMTPD policy service
782 /* request before giving up.
783 /* .IP "\fBsmtpd_policy_service_retry_delay (1s)\fR"
784 /* The delay between attempts to resend a failed SMTPD policy
785 /* service request.
786 /* .PP
787 /* Available in Postfix version 3.1 and later:
788 /* .IP "\fBsmtpd_policy_service_policy_context (empty)\fR"
789 /* Optional information that the Postfix SMTP server specifies in
790 /* the "policy_context" attribute of a policy service request (originally,
791 /* to share the same service endpoint among multiple check_policy_service
792 /* clients).
793 /* ACCESS CONTROLS
794 /* .ad
795 /* .fi
796 /* The SMTPD_ACCESS_README document gives an introduction to all the
797 /* SMTP server access control features.
798 /* .IP "\fBsmtpd_delay_reject (yes)\fR"
799 /* Wait until the RCPT TO command before evaluating
800 /* $smtpd_client_restrictions, $smtpd_helo_restrictions and
801 /* $smtpd_sender_restrictions, or wait until the ETRN command before
802 /* evaluating $smtpd_client_restrictions and $smtpd_helo_restrictions.
803 /* .IP "\fBparent_domain_matches_subdomains (see 'postconf -d' output)\fR"
804 /* A list of Postfix features where the pattern "example.com" also
805 /* matches subdomains of example.com,
806 /* instead of requiring an explicit ".example.com" pattern.
807 /* .IP "\fBsmtpd_client_restrictions (empty)\fR"
808 /* Optional restrictions that the Postfix SMTP server applies in the
809 /* context of a client connection request.
810 /* .IP "\fBsmtpd_helo_required (no)\fR"
811 /* Require that a remote SMTP client introduces itself with the HELO
812 /* or EHLO command before sending the MAIL command or other commands
813 /* that require EHLO negotiation.
814 /* .IP "\fBsmtpd_helo_restrictions (empty)\fR"
815 /* Optional restrictions that the Postfix SMTP server applies in the
816 /* context of a client HELO command.
817 /* .IP "\fBsmtpd_sender_restrictions (empty)\fR"
818 /* Optional restrictions that the Postfix SMTP server applies in the
819 /* context of a client MAIL FROM command.
820 /* .IP "\fBsmtpd_recipient_restrictions (see 'postconf -d' output)\fR"
821 /* Optional restrictions that the Postfix SMTP server applies in the
822 /* context of a client RCPT TO command, after smtpd_relay_restrictions.
823 /* .IP "\fBsmtpd_etrn_restrictions (empty)\fR"
824 /* Optional restrictions that the Postfix SMTP server applies in the
825 /* context of a client ETRN command.
826 /* .IP "\fBallow_untrusted_routing (no)\fR"
827 /* Forward mail with sender-specified routing (user[@%!]remote[@%!]site)
828 /* from untrusted clients to destinations matching $relay_domains.
829 /* .IP "\fBsmtpd_restriction_classes (empty)\fR"
830 /* User-defined aliases for groups of access restrictions.
831 /* .IP "\fBsmtpd_null_access_lookup_key (<>)\fR"
832 /* The lookup key to be used in SMTP \fBaccess\fR(5) tables instead of the
833 /* null sender address.
834 /* .IP "\fBpermit_mx_backup_networks (empty)\fR"
835 /* Restrict the use of the permit_mx_backup SMTP access feature to
836 /* only domains whose primary MX hosts match the listed networks.
837 /* .PP
838 /* Available in Postfix version 2.0 and later:
839 /* .IP "\fBsmtpd_data_restrictions (empty)\fR"
840 /* Optional access restrictions that the Postfix SMTP server applies
841 /* in the context of the SMTP DATA command.
842 /* .IP "\fBsmtpd_expansion_filter (see 'postconf -d' output)\fR"
843 /* What characters are allowed in $name expansions of RBL reply
844 /* templates.
845 /* .PP
846 /* Available in Postfix version 2.1 and later:
847 /* .IP "\fBsmtpd_reject_unlisted_sender (no)\fR"
848 /* Request that the Postfix SMTP server rejects mail from unknown
849 /* sender addresses, even when no explicit reject_unlisted_sender
850 /* access restriction is specified.
851 /* .IP "\fBsmtpd_reject_unlisted_recipient (yes)\fR"
852 /* Request that the Postfix SMTP server rejects mail for unknown
853 /* recipient addresses, even when no explicit reject_unlisted_recipient
854 /* access restriction is specified.
855 /* .PP
856 /* Available in Postfix version 2.2 and later:
857 /* .IP "\fBsmtpd_end_of_data_restrictions (empty)\fR"
858 /* Optional access restrictions that the Postfix SMTP server
859 /* applies in the context of the SMTP END-OF-DATA command.
860 /* .PP
861 /* Available in Postfix version 2.10 and later:
862 /* .IP "\fBsmtpd_relay_restrictions (permit_mynetworks, permit_sasl_authenticated, defer_unauth_destination)\fR"
863 /* Access restrictions for mail relay control that the Postfix
864 /* SMTP server applies in the context of the RCPT TO command, before
865 /* smtpd_recipient_restrictions.
866 /* SENDER AND RECIPIENT ADDRESS VERIFICATION CONTROLS
867 /* .ad
868 /* .fi
869 /* Postfix version 2.1 introduces sender and recipient address verification.
870 /* This feature is implemented by sending probe email messages that
871 /* are not actually delivered.
872 /* This feature is requested via the reject_unverified_sender and
873 /* reject_unverified_recipient access restrictions. The status of
874 /* verification probes is maintained by the \fBverify\fR(8) server.
875 /* See the file ADDRESS_VERIFICATION_README for information
876 /* about how to configure and operate the Postfix sender/recipient
877 /* address verification service.
878 /* .IP "\fBaddress_verify_poll_count (normal: 3, overload: 1)\fR"
879 /* How many times to query the \fBverify\fR(8) service for the completion
880 /* of an address verification request in progress.
881 /* .IP "\fBaddress_verify_poll_delay (3s)\fR"
882 /* The delay between queries for the completion of an address
883 /* verification request in progress.
884 /* .IP "\fBaddress_verify_sender ($double_bounce_sender)\fR"
885 /* The sender address to use in address verification probes; prior
886 /* to Postfix 2.5 the default was "postmaster".
887 /* .IP "\fBunverified_sender_reject_code (450)\fR"
888 /* The numerical Postfix SMTP server response code when a recipient
889 /* address is rejected by the reject_unverified_sender restriction.
890 /* .IP "\fBunverified_recipient_reject_code (450)\fR"
891 /* The numerical Postfix SMTP server response when a recipient address
892 /* is rejected by the reject_unverified_recipient restriction.
893 /* .PP
894 /* Available in Postfix version 2.6 and later:
895 /* .IP "\fBunverified_sender_defer_code (450)\fR"
896 /* The numerical Postfix SMTP server response code when a sender address
897 /* probe fails due to a temporary error condition.
898 /* .IP "\fBunverified_recipient_defer_code (450)\fR"
899 /* The numerical Postfix SMTP server response when a recipient address
900 /* probe fails due to a temporary error condition.
901 /* .IP "\fBunverified_sender_reject_reason (empty)\fR"
902 /* The Postfix SMTP server's reply when rejecting mail with
903 /* reject_unverified_sender.
904 /* .IP "\fBunverified_recipient_reject_reason (empty)\fR"
905 /* The Postfix SMTP server's reply when rejecting mail with
906 /* reject_unverified_recipient.
907 /* .IP "\fBunverified_sender_tempfail_action ($reject_tempfail_action)\fR"
908 /* The Postfix SMTP server's action when reject_unverified_sender
909 /* fails due to a temporary error condition.
910 /* .IP "\fBunverified_recipient_tempfail_action ($reject_tempfail_action)\fR"
911 /* The Postfix SMTP server's action when reject_unverified_recipient
912 /* fails due to a temporary error condition.
913 /* .PP
914 /* Available with Postfix 2.9 and later:
915 /* .IP "\fBaddress_verify_sender_ttl (0s)\fR"
916 /* The time between changes in the time-dependent portion of address
917 /* verification probe sender addresses.
918 /* ACCESS CONTROL RESPONSES
919 /* .ad
920 /* .fi
921 /* The following parameters control numerical SMTP reply codes
922 /* and/or text responses.
923 /* .IP "\fBaccess_map_reject_code (554)\fR"
924 /* The numerical Postfix SMTP server response code for
925 /* an \fBaccess\fR(5) map "reject" action.
926 /* .IP "\fBdefer_code (450)\fR"
927 /* The numerical Postfix SMTP server response code when a remote SMTP
928 /* client request is rejected by the "defer" restriction.
929 /* .IP "\fBinvalid_hostname_reject_code (501)\fR"
930 /* The numerical Postfix SMTP server response code when the client
931 /* HELO or EHLO command parameter is rejected by the reject_invalid_helo_hostname
932 /* restriction.
933 /* .IP "\fBmaps_rbl_reject_code (554)\fR"
934 /* The numerical Postfix SMTP server response code when a remote SMTP
935 /* client request is blocked by the reject_rbl_client, reject_rhsbl_client,
936 /* reject_rhsbl_reverse_client, reject_rhsbl_sender or
937 /* reject_rhsbl_recipient restriction.
938 /* .IP "\fBnon_fqdn_reject_code (504)\fR"
939 /* The numerical Postfix SMTP server reply code when a client request
940 /* is rejected by the reject_non_fqdn_helo_hostname, reject_non_fqdn_sender
941 /* or reject_non_fqdn_recipient restriction.
942 /* .IP "\fBplaintext_reject_code (450)\fR"
943 /* The numerical Postfix SMTP server response code when a request
944 /* is rejected by the \fBreject_plaintext_session\fR restriction.
945 /* .IP "\fBreject_code (554)\fR"
946 /* The numerical Postfix SMTP server response code when a remote SMTP
947 /* client request is rejected by the "reject" restriction.
948 /* .IP "\fBrelay_domains_reject_code (554)\fR"
949 /* The numerical Postfix SMTP server response code when a client
950 /* request is rejected by the reject_unauth_destination recipient
951 /* restriction.
952 /* .IP "\fBunknown_address_reject_code (450)\fR"
953 /* The numerical response code when the Postfix SMTP server rejects a
954 /* sender or recipient address because its domain is unknown.
955 /* .IP "\fBunknown_client_reject_code (450)\fR"
956 /* The numerical Postfix SMTP server response code when a client
957 /* without valid address <=> name mapping is rejected by the
958 /* reject_unknown_client_hostname restriction.
959 /* .IP "\fBunknown_hostname_reject_code (450)\fR"
960 /* The numerical Postfix SMTP server response code when the hostname
961 /* specified with the HELO or EHLO command is rejected by the
962 /* reject_unknown_helo_hostname restriction.
963 /* .PP
964 /* Available in Postfix version 2.0 and later:
965 /* .IP "\fBdefault_rbl_reply (see 'postconf -d' output)\fR"
966 /* The default Postfix SMTP server response template for a request that is
967 /* rejected by an RBL-based restriction.
968 /* .IP "\fBmulti_recipient_bounce_reject_code (550)\fR"
969 /* The numerical Postfix SMTP server response code when a remote SMTP
970 /* client request is blocked by the reject_multi_recipient_bounce
971 /* restriction.
972 /* .IP "\fBrbl_reply_maps (empty)\fR"
973 /* Optional lookup tables with RBL response templates.
974 /* .PP
975 /* Available in Postfix version 2.6 and later:
976 /* .IP "\fBaccess_map_defer_code (450)\fR"
977 /* The numerical Postfix SMTP server response code for
978 /* an \fBaccess\fR(5) map "defer" action, including "defer_if_permit"
979 /* or "defer_if_reject".
980 /* .IP "\fBreject_tempfail_action (defer_if_permit)\fR"
981 /* The Postfix SMTP server's action when a reject-type restriction
982 /* fails due to a temporary error condition.
983 /* .IP "\fBunknown_helo_hostname_tempfail_action ($reject_tempfail_action)\fR"
984 /* The Postfix SMTP server's action when reject_unknown_helo_hostname
985 /* fails due to an temporary error condition.
986 /* .IP "\fBunknown_address_tempfail_action ($reject_tempfail_action)\fR"
987 /* The Postfix SMTP server's action when reject_unknown_sender_domain
988 /* or reject_unknown_recipient_domain fail due to a temporary error
989 /* condition.
990 /* MISCELLANEOUS CONTROLS
991 /* .ad
992 /* .fi
993 /* .IP "\fBconfig_directory (see 'postconf -d' output)\fR"
994 /* The default location of the Postfix main.cf and master.cf
995 /* configuration files.
996 /* .IP "\fBdaemon_timeout (18000s)\fR"
997 /* How much time a Postfix daemon process may take to handle a
998 /* request before it is terminated by a built-in watchdog timer.
999 /* .IP "\fBcommand_directory (see 'postconf -d' output)\fR"
1000 /* The location of all postfix administrative commands.
1001 /* .IP "\fBdouble_bounce_sender (double-bounce)\fR"
1002 /* The sender address of postmaster notifications that are generated
1003 /* by the mail system.
1004 /* .IP "\fBipc_timeout (3600s)\fR"
1005 /* The time limit for sending or receiving information over an internal
1006 /* communication channel.
1007 /* .IP "\fBmail_name (Postfix)\fR"
1008 /* The mail system name that is displayed in Received: headers, in
1009 /* the SMTP greeting banner, and in bounced mail.
1010 /* .IP "\fBmail_owner (postfix)\fR"
1011 /* The UNIX system account that owns the Postfix queue and most Postfix
1012 /* daemon processes.
1013 /* .IP "\fBmax_idle (100s)\fR"
1014 /* The maximum amount of time that an idle Postfix daemon process waits
1015 /* for an incoming connection before terminating voluntarily.
1016 /* .IP "\fBmax_use (100)\fR"
1017 /* The maximal number of incoming connections that a Postfix daemon
1018 /* process will service before terminating voluntarily.
1019 /* .IP "\fBmyhostname (see 'postconf -d' output)\fR"
1020 /* The internet hostname of this mail system.
1021 /* .IP "\fBmynetworks (see 'postconf -d' output)\fR"
1022 /* The list of "trusted" remote SMTP clients that have more privileges than
1023 /* "strangers".
1024 /* .IP "\fBmyorigin ($myhostname)\fR"
1025 /* The domain name that locally-posted mail appears to come
1026 /* from, and that locally posted mail is delivered to.
1027 /* .IP "\fBprocess_id (read-only)\fR"
1028 /* The process ID of a Postfix command or daemon process.
1029 /* .IP "\fBprocess_name (read-only)\fR"
1030 /* The process name of a Postfix command or daemon process.
1031 /* .IP "\fBqueue_directory (see 'postconf -d' output)\fR"
1032 /* The location of the Postfix top-level queue directory.
1033 /* .IP "\fBrecipient_delimiter (empty)\fR"
1034 /* The set of characters that can separate a user name from its
1035 /* extension (example: user+foo), or a .forward file name from its
1036 /* extension (example: .forward+foo).
1037 /* .IP "\fBsmtpd_banner ($myhostname ESMTP $mail_name)\fR"
1038 /* The text that follows the 220 status code in the SMTP greeting
1039 /* banner.
1040 /* .IP "\fBsyslog_facility (mail)\fR"
1041 /* The syslog facility of Postfix logging.
1042 /* .IP "\fBsyslog_name (see 'postconf -d' output)\fR"
1043 /* A prefix that is prepended to the process name in syslog
1044 /* records, so that, for example, "smtpd" becomes "prefix/smtpd".
1045 /* .PP
1046 /* Available in Postfix version 2.2 and later:
1047 /* .IP "\fBsmtpd_forbidden_commands (CONNECT, GET, POST)\fR"
1048 /* List of commands that cause the Postfix SMTP server to immediately
1049 /* terminate the session with a 221 code.
1050 /* .PP
1051 /* Available in Postfix version 2.5 and later:
1052 /* .IP "\fBsmtpd_client_port_logging (no)\fR"
1053 /* Enable logging of the remote SMTP client port in addition to
1054 /* the hostname and IP address.
1055 /* .PP
1056 /* Available in Postfix 3.3 and later:
1057 /* .IP "\fBservice_name (read-only)\fR"
1058 /* The master.cf service name of a Postfix daemon process.
1059 /* SEE ALSO
1060 /* anvil(8), connection/rate limiting
1061 /* cleanup(8), message canonicalization
1062 /* tlsmgr(8), TLS session and PRNG management
1063 /* trivial-rewrite(8), address resolver
1064 /* verify(8), address verification service
1065 /* postconf(5), configuration parameters
1066 /* master(5), generic daemon options
1067 /* master(8), process manager
1068 /* syslogd(8), system logging
1069 /* README FILES
1070 /* .ad
1071 /* .fi
1072 /* Use "\fBpostconf readme_directory\fR" or
1073 /* "\fBpostconf html_directory\fR" to locate this information.
1074 /* .na
1075 /* .nf
1076 /* ADDRESS_CLASS_README, blocking unknown hosted or relay recipients
1077 /* ADDRESS_REWRITING_README Postfix address manipulation
1078 /* FILTER_README, external after-queue content filter
1079 /* LOCAL_RECIPIENT_README, blocking unknown local recipients
1080 /* MILTER_README, before-queue mail filter applications
1081 /* SMTPD_ACCESS_README, built-in access policies
1082 /* SMTPD_POLICY_README, external policy server
1083 /* SMTPD_PROXY_README, external before-queue content filter
1084 /* SASL_README, Postfix SASL howto
1085 /* TLS_README, Postfix STARTTLS howto
1086 /* VERP_README, Postfix XVERP extension
1087 /* XCLIENT_README, Postfix XCLIENT extension
1088 /* XFORWARD_README, Postfix XFORWARD extension
1089 /* LICENSE
1090 /* .ad
1091 /* .fi
1092 /* The Secure Mailer license must be distributed with this software.
1093 /* AUTHOR(S)
1094 /* Wietse Venema
1095 /* IBM T.J. Watson Research
1096 /* P.O. Box 704
1097 /* Yorktown Heights, NY 10598, USA
1098 /*
1099 /* Wietse Venema
1100 /* Google, Inc.
1101 /* 111 8th Avenue
1102 /* New York, NY 10011, USA
1103 /*
1104 /* SASL support originally by:
1105 /* Till Franke
1106 /* SuSE Rhein/Main AG
1107 /* 65760 Eschborn, Germany
1108 /*
1109 /* TLS support originally by:
1110 /* Lutz Jaenicke
1111 /* BTU Cottbus
1112 /* Allgemeine Elektrotechnik
1113 /* Universitaetsplatz 3-4
1114 /* D-03044 Cottbus, Germany
1115 /*
1116 /* Revised TLS support by:
1117 /* Victor Duchovni
1118 /* Morgan Stanley
1119 /*--*/
1120 
1121 /* System library. */
1122 
1123 #include <sys_defs.h>
1124 #include <sys/socket.h>
1125 #include <sys/stat.h>
1126 #include <netinet/in.h>
1127 #include <arpa/inet.h>
1128 #include <netdb.h>
1129 #include <string.h>
1130 #include <stdio.h> /* remove() */
1131 #include <unistd.h>
1132 #include <stdlib.h>
1133 #include <errno.h>
1134 #include <ctype.h>
1135 #include <signal.h>
1136 #include <stddef.h> /* offsetof() */
1137 
1138 #ifdef STRCASECMP_IN_STRINGS_H
1139 #include <strings.h>
1140 #endif
1141 
1142 /* Utility library. */
1143 
1144 #include <msg.h>
1145 #include <mymalloc.h>
1146 #include <vstring.h>
1147 #include <vstream.h>
1148 #include <vstring_vstream.h>
1149 #include <stringops.h>
1150 #include <events.h>
1151 #include <smtp_stream.h>
1152 #include <valid_hostname.h>
1153 #include <dict.h>
1154 #include <watchdog.h>
1155 #include <iostuff.h>
1156 #include <split_at.h>
1157 #include <name_code.h>
1158 #include <inet_proto.h>
1159 
1160 /* Global library. */
1161 
1162 #include <mail_params.h>
1163 #include <mail_version.h> /* milter_macro_v */
1164 #include <record.h>
1165 #include <rec_type.h>
1166 #include <mail_proto.h>
1167 #include <cleanup_user.h>
1168 #include <mail_date.h>
1169 #include <mail_conf.h>
1170 #include <off_cvt.h>
1171 #include <debug_peer.h>
1172 #include <mail_error.h>
1173 #include <flush_clnt.h>
1174 #include <mail_stream.h>
1175 #include <mail_queue.h>
1176 #include <tok822.h>
1177 #include <verp_sender.h>
1178 #include <string_list.h>
1179 #include <quote_822_local.h>
1180 #include <lex_822.h>
1181 #include <namadr_list.h>
1182 #include <input_transp.h>
1183 #include <is_header.h>
1184 #include <anvil_clnt.h>
1185 #include <flush_clnt.h>
1186 #include <ehlo_mask.h> /* ehlo filter */
1187 #include <maps.h> /* ehlo filter */
1188 #include <valid_mailhost_addr.h>
1189 #include <dsn_mask.h>
1190 #include <xtext.h>
1191 #include <uxtext.h>
1192 #include <tls_proxy.h>
1193 #include <verify_sender_addr.h>
1194 #include <smtputf8.h>
1195 #include <match_parent_style.h>
1196 
1197 /* Single-threaded server skeleton. */
1198 
1199 #include <mail_server.h>
1200 
1201 /* Mail filter library. */
1202 
1203 #include <milter.h>
1204 
1205 /* DNS library. */
1206 
1207 #include <dns.h>
1208 
1209 /* Application-specific */
1210 
1211 #include <smtpd_token.h>
1212 #include <smtpd.h>
1213 #include <smtpd_check.h>
1214 #include <smtpd_chat.h>
1215 #include <smtpd_sasl_proto.h>
1216 #include <smtpd_sasl_glue.h>
1217 #include <smtpd_proxy.h>
1218 #include <smtpd_milter.h>
1219 #include <smtpd_expand.h>
1220 
1221  /*
1222  * Tunable parameters. Make sure that there is some bound on the length of
1223  * an SMTP command, so that the mail system stays in control even when a
1224  * malicious client sends commands of unreasonable length (qmail-dos-1).
1225  * Make sure there is some bound on the number of recipients, so that the
1226  * mail system stays in control even when a malicious client sends an
1227  * unreasonable number of recipients (qmail-dos-2).
1228  */
1233 int var_queue_minfree; /* XXX use off_t */
1336 
1346 
1347 #ifdef USE_TLS
1351 char *var_smtpd_tls_CAfile;
1352 char *var_smtpd_tls_CApath;
1370 char *var_smtpd_tls_ciph;
1371 char *var_smtpd_tls_proto;
1372 char *var_smtpd_tls_eecdh;
1375 
1376 #endif
1377 
1401 
1408 
1410 
1411 #ifdef USE_TLSPROXY
1412 char *var_tlsproxy_service;
1413 
1414 #endif
1415 
1418 
1419  /*
1420  * Silly little macros.
1421  */
1422 #define STR(x) vstring_str(x)
1423 #define LEN(x) VSTRING_LEN(x)
1424 
1425  /*
1426  * EHLO keyword filter
1427  */
1428 static MAPS *ehlo_discard_maps;
1429 
1430  /*
1431  * Per-client Milter support.
1432  */
1433 static MAPS *smtpd_milter_maps;
1434 static void setup_milters(SMTPD_STATE *);
1435 static void teardown_milters(SMTPD_STATE *);
1436 
1437  /*
1438  * VERP command name.
1439  */
1440 #define VERP_CMD "XVERP"
1441 #define VERP_CMD_LEN 5
1442 
1443 static NAMADR_LIST *verp_clients;
1444 
1445  /*
1446  * XCLIENT command. Access control is cached, so that XCLIENT can't override
1447  * its own access control.
1448  */
1449 static NAMADR_LIST *xclient_hosts;
1450 static int xclient_allowed; /* XXX should be SMTPD_STATE member */
1451 
1452  /*
1453  * XFORWARD command. Access control is cached.
1454  */
1455 static NAMADR_LIST *xforward_hosts;
1456 static int xforward_allowed; /* XXX should be SMTPD_STATE member */
1457 
1458  /*
1459  * Client connection and rate limiting.
1460  */
1462 static NAMADR_LIST *hogger_list;
1463 
1464  /*
1465  * Other application-specific globals.
1466  */
1468 
1469  /*
1470  * Forward declarations.
1471  */
1472 static void helo_reset(SMTPD_STATE *);
1473 static void mail_reset(SMTPD_STATE *);
1474 static void rcpt_reset(SMTPD_STATE *);
1475 static void chat_reset(SMTPD_STATE *, int);
1476 
1477 #ifdef USE_TLS
1478 static void tls_reset(SMTPD_STATE *);
1479 
1480 #endif
1481 
1482  /*
1483  * This filter is applied after printable().
1484  */
1485 #define NEUTER_CHARACTERS " <>()\\\";@"
1486 
1487  /*
1488  * Reasons for losing the client.
1489  */
1490 #define REASON_TIMEOUT "timeout"
1491 #define REASON_LOST_CONNECTION "lost connection"
1492 #define REASON_ERROR_LIMIT "too many errors"
1493 
1494 #ifdef USE_TLS
1495 
1496  /*
1497  * TLS initialization status.
1498  */
1499 static TLS_APPL_STATE *smtpd_tls_ctx;
1500 static int ask_client_cert;
1501 
1502 #endif
1503 
1504  /*
1505  * SMTP command mapping for broken clients.
1506  */
1507 static DICT *smtpd_cmd_filter;
1508 
1509 #ifdef USE_SASL_AUTH
1510 
1511  /*
1512  * SASL exceptions.
1513  */
1514 static NAMADR_LIST *sasl_exceptions_networks;
1515 
1516 /* sasl_client_exception - can we offer AUTH for this client */
1517 
1518 static int sasl_client_exception(SMTPD_STATE *state)
1519 {
1520  int match;
1521 
1522  /*
1523  * This is to work around a Netscape mail client bug where it tries to
1524  * use AUTH if available, even if user has not configured it. Returns
1525  * TRUE if AUTH should be offered in the EHLO.
1526  */
1527  if (sasl_exceptions_networks == 0)
1528  return (0);
1529 
1530  if ((match = namadr_list_match(sasl_exceptions_networks,
1531  state->name, state->addr)) == 0)
1532  match = sasl_exceptions_networks->error;
1533 
1534  if (msg_verbose)
1535  msg_info("sasl_exceptions: %s, match=%d",
1536  state->namaddr, match);
1537 
1538  return (match);
1539 }
1540 
1541 #endif
1542 
1543 /* smtpd_whatsup - gather available evidence for logging */
1544 
1545 static const char *smtpd_whatsup(SMTPD_STATE *state)
1546 {
1547  static VSTRING *buf = 0;
1548 
1549  if (buf == 0)
1550  buf = vstring_alloc(100);
1551  else
1552  VSTRING_RESET(buf);
1553  if (state->sender)
1554  vstring_sprintf_append(buf, " from=<%s>", state->sender);
1555  if (state->recipient)
1556  vstring_sprintf_append(buf, " to=<%s>", state->recipient);
1557  if (state->protocol)
1558  vstring_sprintf_append(buf, " proto=%s", state->protocol);
1559  if (state->helo_name)
1560  vstring_sprintf_append(buf, " helo=<%s>", state->helo_name);
1561 #ifdef USE_SASL_AUTH
1562  if (state->sasl_username)
1563  vstring_sprintf_append(buf, " sasl_username=<%s>",
1564  state->sasl_username);
1565 #endif
1566  return (STR(buf));
1567 }
1568 
1569 /* collapse_args - put arguments together again */
1570 
1571 static void collapse_args(int argc, SMTPD_TOKEN *argv)
1572 {
1573  int i;
1574 
1575  for (i = 1; i < argc; i++) {
1576  vstring_strcat(argv[0].vstrval, " ");
1577  vstring_strcat(argv[0].vstrval, argv[i].strval);
1578  }
1579  argv[0].strval = STR(argv[0].vstrval);
1580 }
1581 
1582 /* check_milter_reply - process reply from Milter */
1583 
1584 static const char *check_milter_reply(SMTPD_STATE *state, const char *reply)
1585 {
1586  const char *queue_id = state->queue_id ? state->queue_id : "NOQUEUE";
1587  const char *action;
1588  const char *text;
1589 
1590  /*
1591  * The syntax of user-specified SMTP replies is checked by the Milter
1592  * module, because the replies are also used in the cleanup server.
1593  * Automatically disconnect after 421 (shutdown) reply. The Sendmail 8
1594  * Milter quarantine action is not final, so it is not included in
1595  * MILTER_SKIP_FLAGS.
1596  */
1597 #define MILTER_SKIP_FLAGS (CLEANUP_FLAG_DISCARD)
1598 
1599  switch (reply[0]) {
1600  case 'H':
1601  state->saved_flags |= CLEANUP_FLAG_HOLD;
1602  action = "milter-hold";
1603  reply = 0;
1604  text = "milter triggers HOLD action";
1605  break;
1606  case 'D':
1608  action = "milter-discard";
1609  reply = 0;
1610  text = "milter triggers DISCARD action";
1611  break;
1612  case 'S':
1613  state->error_mask |= MAIL_ERROR_POLICY;
1614  action = "milter-reject";
1615  reply = "421 4.7.0 Server closing connection";
1616  text = 0;
1617  break;
1618  case '4':
1619  case '5':
1620  state->error_mask |= MAIL_ERROR_POLICY;
1621  action = "milter-reject";
1622  text = 0;
1623  break;
1624  default:
1625  state->error_mask |= MAIL_ERROR_SOFTWARE;
1626  action = "reject";
1627  reply = "421 4.3.5 Server configuration error";
1628  text = 0;
1629  break;
1630  }
1631  msg_info("%s: %s: %s from %s: %s;%s", queue_id, action, state->where,
1632  state->namaddr, reply ? reply : text, smtpd_whatsup(state));
1633  return (reply);
1634 }
1635 
1636 /* helo_cmd - process HELO command */
1637 
1638 static int helo_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
1639 {
1640  const char *err;
1641 
1642  /*
1643  * RFC 2034: the text part of all 2xx, 4xx, and 5xx SMTP responses other
1644  * than the initial greeting and any response to HELO or EHLO are
1645  * prefaced with a status code as defined in RFC 3463.
1646  */
1647  if (argc < 2) {
1648  state->error_mask |= MAIL_ERROR_PROTOCOL;
1649  smtpd_chat_reply(state, "501 Syntax: HELO hostname");
1650  return (-1);
1651  }
1652  if (argc > 2)
1653  collapse_args(argc - 1, argv + 1);
1654  if (SMTPD_STAND_ALONE(state) == 0
1655  && var_smtpd_delay_reject == 0
1656  && (err = smtpd_check_helo(state, argv[1].strval)) != 0) {
1657  smtpd_chat_reply(state, "%s", err);
1658  return (-1);
1659  }
1660 
1661  /*
1662  * XXX Sendmail compatibility: if a Milter rejects CONNECT, EHLO, or
1663  * HELO, reply with 250 except in case of 421 (disconnect). The reply
1664  * persists so it will apply to MAIL FROM and to other commands such as
1665  * AUTH, STARTTLS, and VRFY.
1666  */
1667 #define PUSH_STRING(old, curr, new) { char *old = (curr); (curr) = (new);
1668 #define POP_STRING(old, curr) (curr) = old; }
1669 
1670  if (state->milters != 0
1671  && (state->saved_flags & MILTER_SKIP_FLAGS) == 0
1672  && (err = milter_helo_event(state->milters, argv[1].strval, 0)) != 0) {
1673  /* Log reject etc. with correct HELO information. */
1674  PUSH_STRING(saved_helo, state->helo_name, argv[1].strval);
1675  err = check_milter_reply(state, err);
1676  POP_STRING(saved_helo, state->helo_name);
1677  if (err != 0 && strncmp(err, "421", 3) == 0) {
1678  smtpd_chat_reply(state, "%s", err);
1679  return (-1);
1680  }
1681  }
1682  if (state->helo_name != 0)
1683  helo_reset(state);
1684  chat_reset(state, var_smtpd_hist_thrsh);
1685  mail_reset(state);
1686  rcpt_reset(state);
1687  state->helo_name = mystrdup(printable(argv[1].strval, '?'));
1688  neuter(state->helo_name, NEUTER_CHARACTERS, '?');
1689  /* Downgrading the protocol name breaks the unauthorized pipelining test. */
1690  if (strcasecmp(state->protocol, MAIL_PROTO_ESMTP) != 0
1691  && strcasecmp(state->protocol, MAIL_PROTO_SMTP) != 0) {
1692  myfree(state->protocol);
1693  state->protocol = mystrdup(MAIL_PROTO_SMTP);
1694  }
1695  smtpd_chat_reply(state, "250 %s", var_myhostname);
1696  return (0);
1697 }
1698 
1699 /* cant_announce_feature - explain and terminate this session */
1700 
1701 static NORETURN cant_announce_feature(SMTPD_STATE *state, const char *feature)
1702 {
1703  msg_warn("don't know if EHLO feature %s should be announced to %s",
1704  feature, state->namaddr);
1706 }
1707 
1708 /* cant_permit_command - explain and terminate this session */
1709 
1710 static NORETURN cant_permit_command(SMTPD_STATE *state, const char *command)
1711 {
1712  msg_warn("don't know if command %s should be allowed from %s",
1713  command, state->namaddr);
1715 }
1716 
1717 /* ehlo_cmd - process EHLO command */
1718 
1719 static int ehlo_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
1720 {
1721  const char *err;
1722  int discard_mask;
1723  char **cpp;
1724 
1725  /*
1726  * XXX 2821 new feature: Section 4.1.4 specifies that a server must clear
1727  * all buffers and reset the state exactly as if a RSET command had been
1728  * issued.
1729  *
1730  * RFC 2034: the text part of all 2xx, 4xx, and 5xx SMTP responses other
1731  * than the initial greeting and any response to HELO or EHLO are
1732  * prefaced with a status code as defined in RFC 3463.
1733  */
1734  if (argc < 2) {
1735  state->error_mask |= MAIL_ERROR_PROTOCOL;
1736  smtpd_chat_reply(state, "501 Syntax: EHLO hostname");
1737  return (-1);
1738  }
1739  if (argc > 2)
1740  collapse_args(argc - 1, argv + 1);
1741  if (SMTPD_STAND_ALONE(state) == 0
1742  && var_smtpd_delay_reject == 0
1743  && (err = smtpd_check_helo(state, argv[1].strval)) != 0) {
1744  smtpd_chat_reply(state, "%s", err);
1745  return (-1);
1746  }
1747 
1748  /*
1749  * XXX Sendmail compatibility: if a Milter 5xx rejects CONNECT, EHLO, or
1750  * HELO, reply with ENHANCEDSTATUSCODES except in case of immediate
1751  * disconnect. The reply persists so it will apply to MAIL FROM and to
1752  * other commands such as AUTH, STARTTLS, and VRFY.
1753  */
1754  err = 0;
1755  if (state->milters != 0
1756  && (state->saved_flags & MILTER_SKIP_FLAGS) == 0
1757  && (err = milter_helo_event(state->milters, argv[1].strval, 1)) != 0) {
1758  /* Log reject etc. with correct HELO information. */
1759  PUSH_STRING(saved_helo, state->helo_name, argv[1].strval);
1760  err = check_milter_reply(state, err);
1761  POP_STRING(saved_helo, state->helo_name);
1762  if (err != 0 && strncmp(err, "421", 3) == 0) {
1763  smtpd_chat_reply(state, "%s", err);
1764  return (-1);
1765  }
1766  }
1767  if (state->helo_name != 0)
1768  helo_reset(state);
1769  chat_reset(state, var_smtpd_hist_thrsh);
1770  mail_reset(state);
1771  rcpt_reset(state);
1772  state->helo_name = mystrdup(printable(argv[1].strval, '?'));
1773  neuter(state->helo_name, NEUTER_CHARACTERS, '?');
1774 
1775  /*
1776  * XXX reject_unauth_pipelining depends on the following. If the user
1777  * sends EHLO then we announce PIPELINING and we can't accuse them of
1778  * using pipelining in places where it is allowed.
1779  *
1780  * XXX The reject_unauth_pipelining test needs to change and also account
1781  * for mechanisms that disable PIPELINING selectively.
1782  */
1783  if (strcasecmp(state->protocol, MAIL_PROTO_ESMTP) != 0) {
1784  myfree(state->protocol);
1786  }
1787 
1788  /*
1789  * Build the EHLO response, producing no output until we know what to
1790  * send - this simplifies exception handling. The CRLF record boundaries
1791  * don't exist at this level in the code, so we represent multi-line
1792  * output as an array of single-line responses.
1793  */
1794 #define EHLO_APPEND(state, cmd) \
1795  do { \
1796  vstring_sprintf((state)->ehlo_buf, (cmd)); \
1797  argv_add((state)->ehlo_argv, STR((state)->ehlo_buf), (char *) 0); \
1798  } while (0)
1799 
1800 #define EHLO_APPEND1(state, cmd, arg) \
1801  do { \
1802  vstring_sprintf((state)->ehlo_buf, (cmd), (arg)); \
1803  argv_add((state)->ehlo_argv, STR((state)->ehlo_buf), (char *) 0); \
1804  } while (0)
1805 
1806  /*
1807  * XXX Sendmail compatibility: if a Milter 5XX rejects CONNECT, EHLO, or
1808  * HELO, reply with ENHANCEDSTATUSCODES only. The reply persists so it
1809  * will apply to MAIL FROM, but we currently don't have a proper
1810  * mechanism to apply Milter rejects to AUTH, STARTTLS, VRFY, and other
1811  * commands while still allowing HELO/EHLO.
1812  */
1813  discard_mask = state->ehlo_discard_mask;
1814  if (err != 0 && err[0] == '5')
1815  discard_mask |= ~EHLO_MASK_ENHANCEDSTATUSCODES;
1816  if ((discard_mask & EHLO_MASK_ENHANCEDSTATUSCODES) == 0)
1817  if (discard_mask && !(discard_mask & EHLO_MASK_SILENT))
1818  msg_info("discarding EHLO keywords: %s", str_ehlo_mask(discard_mask));
1819  if (ehlo_discard_maps && ehlo_discard_maps->error) {
1820  msg_warn("don't know what EHLO features to announce to %s",
1821  state->namaddr);
1823  }
1824 
1825  /*
1826  * These may still exist after a prior exception.
1827  */
1828  if (state->ehlo_argv == 0) {
1829  state->ehlo_argv = argv_alloc(10);
1830  state->ehlo_buf = vstring_alloc(10);
1831  } else
1832  argv_truncate(state->ehlo_argv, 0);
1833 
1834  EHLO_APPEND1(state, "%s", var_myhostname);
1835  if ((discard_mask & EHLO_MASK_PIPELINING) == 0)
1836  EHLO_APPEND(state, "PIPELINING");
1837  if ((discard_mask & EHLO_MASK_SIZE) == 0) {
1838  if (var_message_limit)
1839  EHLO_APPEND1(state, "SIZE %lu",
1840  (unsigned long) var_message_limit); /* XXX */
1841  else
1842  EHLO_APPEND(state, "SIZE");
1843  }
1844  if ((discard_mask & EHLO_MASK_VRFY) == 0)
1845  if (var_disable_vrfy_cmd == 0)
1846  EHLO_APPEND(state, SMTPD_CMD_VRFY);
1847  if ((discard_mask & EHLO_MASK_ETRN) == 0)
1848  EHLO_APPEND(state, SMTPD_CMD_ETRN);
1849 #ifdef USE_TLS
1850  if ((discard_mask & EHLO_MASK_STARTTLS) == 0)
1851  if (var_smtpd_use_tls && (!state->tls_context))
1853 #endif
1854 #ifdef USE_SASL_AUTH
1855 #ifndef AUTH_CMD
1856 #define AUTH_CMD "AUTH"
1857 #endif
1858  if ((discard_mask & EHLO_MASK_AUTH) == 0) {
1859  if (smtpd_sasl_is_active(state) && !sasl_client_exception(state)) {
1860  EHLO_APPEND1(state, "AUTH %s", state->sasl_mechanism_list);
1862  EHLO_APPEND1(state, "AUTH=%s", state->sasl_mechanism_list);
1863  } else if (sasl_exceptions_networks && sasl_exceptions_networks->error)
1864  cant_announce_feature(state, AUTH_CMD);
1865  }
1866 #define XCLIENT_LOGIN_KLUDGE " " XCLIENT_LOGIN
1867 #else
1868 #define XCLIENT_LOGIN_KLUDGE ""
1869 #endif
1870  if ((discard_mask & EHLO_MASK_VERP) == 0) {
1871  if (namadr_list_match(verp_clients, state->name, state->addr))
1872  EHLO_APPEND(state, VERP_CMD);
1873  else if (verp_clients && verp_clients->error)
1874  cant_announce_feature(state, VERP_CMD);
1875  }
1876  /* XCLIENT must not override its own access control. */
1877  if ((discard_mask & EHLO_MASK_XCLIENT) == 0) {
1878  if (xclient_allowed)
1879  EHLO_APPEND(state, XCLIENT_CMD
1880  " " XCLIENT_NAME " " XCLIENT_ADDR
1881  " " XCLIENT_PROTO " " XCLIENT_HELO
1884  " " XCLIENT_DESTADDR
1885  " " XCLIENT_DESTPORT);
1886  else if (xclient_hosts && xclient_hosts->error)
1887  cant_announce_feature(state, XCLIENT_CMD);
1888  }
1889  if ((discard_mask & EHLO_MASK_XFORWARD) == 0) {
1890  if (xforward_allowed)
1891  EHLO_APPEND(state, XFORWARD_CMD
1895  " " XFORWARD_IDENT);
1896  else if (xforward_hosts && xforward_hosts->error)
1897  cant_announce_feature(state, XFORWARD_CMD);
1898  }
1899  if ((discard_mask & EHLO_MASK_ENHANCEDSTATUSCODES) == 0)
1900  EHLO_APPEND(state, "ENHANCEDSTATUSCODES");
1901  if ((discard_mask & EHLO_MASK_8BITMIME) == 0)
1902  EHLO_APPEND(state, "8BITMIME");
1903  if ((discard_mask & EHLO_MASK_DSN) == 0)
1904  EHLO_APPEND(state, "DSN");
1905  if (var_smtputf8_enable && (discard_mask & EHLO_MASK_SMTPUTF8) == 0)
1906  EHLO_APPEND(state, "SMTPUTF8");
1907 
1908  /*
1909  * Send the reply.
1910  */
1911  for (cpp = state->ehlo_argv->argv; *cpp; cpp++)
1912  smtpd_chat_reply(state, "250%c%s", cpp[1] ? '-' : ' ', *cpp);
1913 
1914  /*
1915  * Clean up.
1916  */
1917  argv_free(state->ehlo_argv);
1918  state->ehlo_argv = 0;
1919  vstring_free(state->ehlo_buf);
1920  state->ehlo_buf = 0;
1921 
1922  return (0);
1923 }
1924 
1925 /* helo_reset - reset HELO/EHLO command stuff */
1926 
1927 static void helo_reset(SMTPD_STATE *state)
1928 {
1929  if (state->helo_name) {
1930  myfree(state->helo_name);
1931  state->helo_name = 0;
1932  if (state->milters != 0)
1933  milter_abort(state->milters);
1934  }
1935  if (state->ehlo_argv) {
1936  argv_free(state->ehlo_argv);
1937  state->ehlo_argv = 0;
1938  }
1939  if (state->ehlo_buf) {
1940  vstring_free(state->ehlo_buf);
1941  state->ehlo_buf = 0;
1942  }
1943 }
1944 
1945 #ifdef USE_SASL_AUTH
1946 
1947 /* smtpd_sasl_auth_cmd_wrapper - smtpd_sasl_auth_cmd front-end */
1948 
1949 static int smtpd_sasl_auth_cmd_wrapper(SMTPD_STATE *state, int argc,
1950  SMTPD_TOKEN *argv)
1951 {
1952  int rate;
1953 
1954  if (SMTPD_STAND_ALONE(state) == 0
1955  && !xclient_allowed
1956  && anvil_clnt
1957  && var_smtpd_cauth_limit > 0
1958  && !namadr_list_match(hogger_list, state->name, state->addr)
1959  && anvil_clnt_auth(anvil_clnt, state->service, state->addr,
1960  &rate) == ANVIL_STAT_OK
1961  && rate > var_smtpd_cauth_limit) {
1962  state->error_mask |= MAIL_ERROR_POLICY;
1963  msg_warn("AUTH command rate limit exceeded: %d from %s for service %s",
1964  rate, state->namaddr, state->service);
1965  smtpd_chat_reply(state,
1966  "450 4.7.1 Error: too many AUTH commands from %s",
1967  state->addr);
1968  return (-1);
1969  }
1970  return (smtpd_sasl_auth_cmd(state, argc, argv));
1971 }
1972 
1973 #endif
1974 
1975 /* mail_open_stream - open mail queue file or IPC stream */
1976 
1977 static int mail_open_stream(SMTPD_STATE *state)
1978 {
1979 
1980  /*
1981  * Connect to the before-queue filter when one is configured. The MAIL
1982  * FROM and RCPT TO commands are forwarded as received (including DSN
1983  * attributes), with the exception that the before-filter smtpd process
1984  * handles all authentication, encryption, access control and relay
1985  * control, and that the before-filter smtpd process does not forward
1986  * blocked commands. If the after-filter smtp server does not support
1987  * some of Postfix's ESMTP features, then they must be turned off in the
1988  * before-filter smtpd process with the smtpd_discard_ehlo_keywords
1989  * feature.
1990  */
1991  if (state->proxy_mail) {
1994  state->proxy_mail) != 0) {
1995  smtpd_chat_reply(state, "%s", STR(state->proxy->reply));
1996  smtpd_proxy_free(state);
1997  return (-1);
1998  }
1999  }
2000 
2001  /*
2002  * If running from the master or from inetd, connect to the cleanup
2003  * service.
2004  *
2005  * XXX 2821: An SMTP server is not allowed to "clean up" mail except in the
2006  * case of original submissions.
2007  *
2008  * We implement this by distinguishing between mail that we are willing to
2009  * rewrite (the local rewrite context) and mail from elsewhere.
2010  */
2011  else if (SMTPD_STAND_ALONE(state) == 0) {
2012  int cleanup_flags;
2013 
2017  if (state->flags & SMTPD_FLAG_SMTPUTF8)
2018  cleanup_flags |= CLEANUP_FLAG_SMTPUTF8;
2019  else
2020  cleanup_flags |= smtputf8_autodetect(MAIL_SRC_MASK_SMTPD);
2023  if (state->dest == 0
2024  || attr_print(state->dest->stream, ATTR_FLAG_NONE,
2025  SEND_ATTR_INT(MAIL_ATTR_FLAGS, cleanup_flags),
2026  ATTR_TYPE_END) != 0)
2027  msg_fatal("unable to connect to the %s %s service",
2029  }
2030 
2031  /*
2032  * Otherwise, pipe the message through the privileged postdrop helper.
2033  * XXX Make postdrop a manifest constant.
2034  */
2035  else {
2036  char *postdrop_command;
2037 
2038  postdrop_command = concatenate(var_command_dir, "/postdrop",
2039  msg_verbose ? " -v" : (char *) 0, (char *) 0);
2040  state->dest = mail_stream_command(postdrop_command);
2041  if (state->dest == 0)
2042  msg_fatal("unable to execute %s", postdrop_command);
2043  myfree(postdrop_command);
2044  }
2045 
2046  /*
2047  * Record the time of arrival, the SASL-related stuff if applicable, the
2048  * sender envelope address, some session information, and some additional
2049  * attributes.
2050  *
2051  * XXX Send Milter information first, because this will hang when cleanup
2052  * goes into "throw away" mode. Also, cleanup needs to know early on
2053  * whether or not it has to do its own SMTP event emulation.
2054  *
2055  * XXX At this point we send only dummy information to keep the cleanup
2056  * server from using its non_smtpd_milters settings. We have to send
2057  * up-to-date Milter information after DATA so that the cleanup server
2058  * knows the actual Milter state.
2059  */
2060  if (state->dest) {
2061  state->cleanup = state->dest->stream;
2062  state->queue_id = mystrdup(state->dest->id);
2063  if (SMTPD_STAND_ALONE(state) == 0) {
2064  if (state->milters != 0
2065  && (state->saved_flags & MILTER_SKIP_FLAGS) == 0)
2066  /* Send place-holder smtpd_milters list. */
2067  (void) milter_dummy(state->milters, state->cleanup);
2070  if (*var_filter_xport)
2072  if (FORWARD_IDENT(state))
2073  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
2075  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
2077 #ifdef USE_SASL_AUTH
2078  /* Make external authentication painless (e.g., XCLIENT). */
2079  if (state->sasl_method)
2080  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
2081  MAIL_ATTR_SASL_METHOD, state->sasl_method);
2082  if (state->sasl_username)
2083  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
2084  MAIL_ATTR_SASL_USERNAME, state->sasl_username);
2085  if (state->sasl_sender)
2086  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
2087  MAIL_ATTR_SASL_SENDER, state->sasl_sender);
2088 #endif
2089 
2090  /*
2091  * Record DSN related information that was received with the MAIL
2092  * FROM command.
2093  *
2094  * RFC 3461 Section 5.2.1. If no ENVID parameter was included in the
2095  * MAIL command when the message was received, the ENVID
2096  * parameter MUST NOT be supplied when the message is relayed.
2097  * Ditto for the RET parameter.
2098  *
2099  * In other words, we can't simply make up our default ENVID or RET
2100  * values. We have to remember whether the client sent any.
2101  *
2102  * We store DSN information as named attribute records so that we
2103  * don't have to pollute the queue file with records that are
2104  * incompatible with past Postfix versions. Preferably, people
2105  * should be able to back out from an upgrade without losing
2106  * mail.
2107  */
2108  if (state->dsn_envid)
2109  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
2110  MAIL_ATTR_DSN_ENVID, state->dsn_envid);
2111  if (state->dsn_ret)
2112  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%d",
2113  MAIL_ATTR_DSN_RET, state->dsn_ret);
2114  }
2115  rec_fputs(state->cleanup, REC_TYPE_FROM, state->sender);
2116  if (state->encoding != 0)
2117  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
2118  MAIL_ATTR_ENCODING, state->encoding);
2119 
2120  /*
2121  * Store client attributes.
2122  */
2123  if (SMTPD_STAND_ALONE(state) == 0) {
2124 
2125  /*
2126  * Attributes for logging, also used for XFORWARD.
2127  *
2128  * We store all client attributes, including ones with unknown
2129  * values. Otherwise, an unknown client hostname would be treated
2130  * as a non-existent hostname (i.e. local submission).
2131  */
2132  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
2134  /* XXX Note: state->rfc_addr, not state->addr. */
2135  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
2137  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
2139  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
2141  if (FORWARD_HELO(state))
2142  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
2144  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
2146 
2147  /*
2148  * Attributes with actual client information. These are used by
2149  * the smtpd Milter client for policy decisions. Mail that is
2150  * requeued with "postsuper -r" is not subject to processing by
2151  * the cleanup Milter client, because a) it has already been
2152  * filtered, and b) we don't have sufficient information to
2153  * reproduce the exact same SMTP events and Sendmail macros that
2154  * the smtpd Milter client received when the message originally
2155  * arrived in Postfix.
2156  */
2157  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
2159  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
2161  /* XXX Note: state->addr, not state->rfc_addr. */
2162  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
2164  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
2166  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
2168  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
2170  if (state->helo_name)
2171  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
2173  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
2175  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%u",
2177 
2178  /*
2179  * Don't send client certificate down the pipeline unless it is
2180  * a) verified or b) just a fingerprint.
2181  */
2182  }
2183  if (state->verp_delims)
2184  rec_fputs(state->cleanup, REC_TYPE_VERP, state->verp_delims);
2185  }
2186 
2187  /*
2188  * Log the queue ID with the message origin.
2189  */
2190 #define PRINT_OR_NULL(cond, str) \
2191  ((cond) ? (str) : "")
2192 #define PRINT2_OR_NULL(cond, name, value) \
2193  PRINT_OR_NULL((cond), (name)), PRINT_OR_NULL((cond), (value))
2194 
2195  msg_info("%s: client=%s%s%s%s%s%s%s%s%s%s%s",
2196  (state->queue_id ? state->queue_id : "NOQUEUE"),
2197  state->namaddr,
2198 #ifdef USE_SASL_AUTH
2199  PRINT2_OR_NULL(state->sasl_method,
2200  ", sasl_method=", state->sasl_method),
2201  PRINT2_OR_NULL(state->sasl_username,
2202  ", sasl_username=", state->sasl_username),
2203  PRINT2_OR_NULL(state->sasl_sender,
2204  ", sasl_sender=", state->sasl_sender),
2205 #else
2206  "", "", "", "", "", "",
2207 #endif
2208  /* Insert transaction TLS status here. */
2210  ", orig_queue_id=", FORWARD_IDENT(state)),
2212  ", orig_client=", FORWARD_NAMADDR(state)));
2213  return (0);
2214 }
2215 
2216 /* extract_addr - extract address from rubble */
2217 
2218 static int extract_addr(SMTPD_STATE *state, SMTPD_TOKEN *arg,
2219  int allow_empty_addr, int strict_rfc821,
2220  int smtputf8)
2221 {
2222  const char *myname = "extract_addr";
2223  TOK822 *tree;
2224  TOK822 *tp;
2225  TOK822 *addr = 0;
2226  int naddr;
2227  int non_addr;
2228  int err = 0;
2229  char *junk = 0;
2230  char *text;
2231  char *colon;
2232 
2233  /*
2234  * Special case.
2235  */
2236 #define PERMIT_EMPTY_ADDR 1
2237 #define REJECT_EMPTY_ADDR 0
2238 
2239  /*
2240  * Some mailers send RFC822-style address forms (with comments and such)
2241  * in SMTP envelopes. We cannot blame users for this: the blame is with
2242  * programmers violating the RFC, and with sendmail for being permissive.
2243  *
2244  * XXX The SMTP command tokenizer must leave the address in externalized
2245  * (quoted) form, so that the address parser can correctly extract the
2246  * address from surrounding junk.
2247  *
2248  * XXX We have only one address parser, written according to the rules of
2249  * RFC 822. That standard differs subtly from RFC 821.
2250  */
2251  if (msg_verbose)
2252  msg_info("%s: input: %s", myname, STR(arg->vstrval));
2253  if (STR(arg->vstrval)[0] == '<'
2254  && STR(arg->vstrval)[LEN(arg->vstrval) - 1] == '>') {
2255  junk = text = mystrndup(STR(arg->vstrval) + 1, LEN(arg->vstrval) - 2);
2256  } else
2257  text = STR(arg->vstrval);
2258 
2259  /*
2260  * Truncate deprecated route address form.
2261  */
2262  if (*text == '@' && (colon = strchr(text, ':')) != 0)
2263  text = colon + 1;
2264  tree = tok822_parse(text);
2265 
2266  if (junk)
2267  myfree(junk);
2268 
2269  /*
2270  * Find trouble.
2271  */
2272  for (naddr = non_addr = 0, tp = tree; tp != 0; tp = tp->next) {
2273  if (tp->type == TOK822_ADDR) {
2274  addr = tp;
2275  naddr += 1; /* count address forms */
2276  } else if (tp->type == '<' || tp->type == '>') {
2277  /* void */ ; /* ignore brackets */
2278  } else {
2279  non_addr += 1; /* count non-address forms */
2280  }
2281  }
2282 
2283  /*
2284  * Report trouble. XXX Should log a warning only if we are going to
2285  * sleep+reject so that attackers can't flood our logfiles.
2286  *
2287  * XXX Unfortunately, the sleep-before-reject feature had to be abandoned
2288  * (at least for small error counts) because servers were DOS-ing
2289  * themselves when flooded by backscatter traffic.
2290  */
2291  if (naddr > 1
2292  || (strict_rfc821 && (non_addr || *STR(arg->vstrval) != '<'))) {
2293  msg_warn("Illegal address syntax from %s in %s command: %s",
2294  state->namaddr, state->where,
2295  printable(STR(arg->vstrval), '?'));
2296  err = 1;
2297  }
2298 
2299  /*
2300  * Don't overwrite the input with the extracted address. We need the
2301  * original (external) form in case the client does not send ORCPT
2302  * information; and error messages are more accurate if we log the
2303  * unmodified form. We need the internal form for all other purposes.
2304  */
2305  if (addr)
2307  else
2308  vstring_strcpy(state->addr_buf, "");
2309 
2310  /*
2311  * Report trouble. XXX Should log a warning only if we are going to
2312  * sleep+reject so that attackers can't flood our logfiles. Log the
2313  * original address.
2314  */
2315  if (err == 0)
2316  if ((STR(state->addr_buf)[0] == 0 && !allow_empty_addr)
2317  || (strict_rfc821 && STR(state->addr_buf)[0] == '@')
2318  || (SMTPD_STAND_ALONE(state) == 0
2319  && smtpd_check_addr(strcmp(state->where, SMTPD_CMD_MAIL) == 0 ?
2320  state->recipient : state->sender,
2321  STR(state->addr_buf), smtputf8) != 0)) {
2322  msg_warn("Illegal address syntax from %s in %s command: %s",
2323  state->namaddr, state->where,
2324  printable(STR(arg->vstrval), '?'));
2325  err = 1;
2326  }
2327 
2328  /*
2329  * Cleanup.
2330  */
2331  tok822_free_tree(tree);
2332  if (msg_verbose)
2333  msg_info("%s: in: %s, result: %s",
2334  myname, STR(arg->vstrval), STR(state->addr_buf));
2335  return (err);
2336 }
2337 
2338 /* milter_argv - impedance adapter */
2339 
2340 static const char **milter_argv(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
2341 {
2342  int n;
2343  ssize_t len = argc + 1;
2344 
2345  if (state->milter_argc < len) {
2346  if (state->milter_argc > 0)
2347  state->milter_argv = (const char **)
2348  myrealloc((void *) state->milter_argv,
2349  sizeof(const char *) * len);
2350  else
2351  state->milter_argv = (const char **)
2352  mymalloc(sizeof(const char *) * len);
2353  state->milter_argc = len;
2354  }
2355  for (n = 0; n < argc; n++)
2356  state->milter_argv[n] = argv[n].strval;
2357  state->milter_argv[n] = 0;
2358  return (state->milter_argv);
2359 }
2360 
2361 /* mail_cmd - process MAIL command */
2362 
2363 static int mail_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
2364 {
2365  const char *err;
2366  int narg;
2367  char *arg;
2368  char *verp_delims = 0;
2369  int rate;
2370  int dsn_envid = 0;
2371 
2372  state->flags &= ~SMTPD_FLAG_SMTPUTF8;
2373  state->encoding = 0;
2374  state->dsn_ret = 0;
2375 
2376  /*
2377  * Sanity checks.
2378  *
2379  * XXX 2821 pedantism: Section 4.1.2 says that SMTP servers that receive a
2380  * command in which invalid character codes have been employed, and for
2381  * which there are no other reasons for rejection, MUST reject that
2382  * command with a 501 response. Postfix attempts to be 8-bit clean.
2383  */
2384  if (var_helo_required && state->helo_name == 0) {
2385  state->error_mask |= MAIL_ERROR_POLICY;
2386  smtpd_chat_reply(state, "503 5.5.1 Error: send HELO/EHLO first");
2387  return (-1);
2388  }
2389  if (SMTPD_IN_MAIL_TRANSACTION(state)) {
2390  state->error_mask |= MAIL_ERROR_PROTOCOL;
2391  smtpd_chat_reply(state, "503 5.5.1 Error: nested MAIL command");
2392  return (-1);
2393  }
2394  if (argc < 3
2395  || strcasecmp(argv[1].strval, "from:") != 0) {
2396  state->error_mask |= MAIL_ERROR_PROTOCOL;
2397  smtpd_chat_reply(state, "501 5.5.4 Syntax: MAIL FROM:<address>");
2398  return (-1);
2399  }
2400 
2401  /*
2402  * XXX The client event count/rate control must be consistent in its use
2403  * of client address information in connect and disconnect events. For
2404  * now we exclude xclient authorized hosts from event count/rate control.
2405  */
2406  if (SMTPD_STAND_ALONE(state) == 0
2407  && !xclient_allowed
2408  && anvil_clnt
2409  && var_smtpd_cmail_limit > 0
2410  && !namadr_list_match(hogger_list, state->name, state->addr)
2411  && anvil_clnt_mail(anvil_clnt, state->service, state->addr,
2412  &rate) == ANVIL_STAT_OK
2413  && rate > var_smtpd_cmail_limit) {
2414  state->error_mask |= MAIL_ERROR_POLICY;
2415  smtpd_chat_reply(state, "450 4.7.1 Error: too much mail from %s",
2416  state->addr);
2417  msg_warn("Message delivery request rate limit exceeded: %d from %s for service %s",
2418  rate, state->namaddr, state->service);
2419  return (-1);
2420  }
2421  if (argv[2].tokval == SMTPD_TOK_ERROR) {
2422  state->error_mask |= MAIL_ERROR_PROTOCOL;
2423  smtpd_chat_reply(state, "501 5.1.7 Bad sender address syntax");
2424  return (-1);
2425  }
2426 
2427  /*
2428  * XXX The sender address comes first, but the optional SMTPUTF8
2429  * parameter determines what address syntax is permitted. We must process
2430  * this parameter early.
2431  */
2433  && (state->ehlo_discard_mask & EHLO_MASK_SMTPUTF8) == 0) {
2434  for (narg = 3; narg < argc; narg++) {
2435  arg = argv[narg].strval;
2436  if (strcasecmp(arg, "SMTPUTF8") == 0) { /* RFC 6531 */
2437  /* Fix 20161206: allow UTF8 in smtpd_sender_restrictions. */
2438  state->flags |= SMTPD_FLAG_SMTPUTF8;
2439  break;
2440  }
2441  }
2442  }
2443  if (extract_addr(state, argv + 2, PERMIT_EMPTY_ADDR,
2445  state->flags & SMTPD_FLAG_SMTPUTF8) != 0) {
2446  state->error_mask |= MAIL_ERROR_PROTOCOL;
2447  smtpd_chat_reply(state, "501 5.1.7 Bad sender address syntax");
2448  return (-1);
2449  }
2450  for (narg = 3; narg < argc; narg++) {
2451  arg = argv[narg].strval;
2452  if (strcasecmp(arg, "BODY=8BITMIME") == 0) { /* RFC 1652 */
2453  state->encoding = MAIL_ATTR_ENC_8BIT;
2454  } else if (strcasecmp(arg, "BODY=7BIT") == 0) { /* RFC 1652 */
2455  state->encoding = MAIL_ATTR_ENC_7BIT;
2456  } else if (strncasecmp(arg, "SIZE=", 5) == 0) { /* RFC 1870 */
2457  /* Reject non-numeric size. */
2458  if (!alldig(arg + 5)) {
2459  state->error_mask |= MAIL_ERROR_PROTOCOL;
2460  smtpd_chat_reply(state, "501 5.5.4 Bad message size syntax");
2461  return (-1);
2462  }
2463  /* Reject size overflow. */
2464  if ((state->msg_size = off_cvt_string(arg + 5)) < 0) {
2465  state->error_mask |= MAIL_ERROR_POLICY;
2466  smtpd_chat_reply(state, "552 5.3.4 Message size exceeds file system imposed limit");
2467  return (-1);
2468  }
2469  } else if (var_smtputf8_enable
2470  && (state->ehlo_discard_mask & EHLO_MASK_SMTPUTF8) == 0
2471  && strcasecmp(arg, "SMTPUTF8") == 0) { /* RFC 6531 */
2472  /* Already processed early. */ ;
2473 #ifdef USE_SASL_AUTH
2474  } else if (strncasecmp(arg, "AUTH=", 5) == 0) {
2475  if ((err = smtpd_sasl_mail_opt(state, arg + 5)) != 0) {
2476  smtpd_chat_reply(state, "%s", err);
2477  return (-1);
2478  }
2479 #endif
2480  } else if (namadr_list_match(verp_clients, state->name, state->addr)
2481  && strncasecmp(arg, VERP_CMD, VERP_CMD_LEN) == 0
2482  && (arg[VERP_CMD_LEN] == '=' || arg[VERP_CMD_LEN] == 0)) {
2483  if (arg[VERP_CMD_LEN] == 0) {
2484  verp_delims = var_verp_delims;
2485  } else {
2486  verp_delims = arg + VERP_CMD_LEN + 1;
2487  if (verp_delims_verify(verp_delims) != 0) {
2488  state->error_mask |= MAIL_ERROR_PROTOCOL;
2489  smtpd_chat_reply(state,
2490  "501 5.5.4 Error: %s needs two characters from %s",
2492  return (-1);
2493  }
2494  }
2495  } else if (strncasecmp(arg, "RET=", 4) == 0) { /* RFC 3461 */
2496  /* Sanitized on input. */
2497  if (state->ehlo_discard_mask & EHLO_MASK_DSN) {
2498  state->error_mask |= MAIL_ERROR_PROTOCOL;
2499  smtpd_chat_reply(state, "501 5.7.1 DSN support is disabled");
2500  return (-1);
2501  }
2502  if (state->dsn_ret
2503  || (state->dsn_ret = dsn_ret_code(arg + 4)) == 0) {
2504  state->error_mask |= MAIL_ERROR_PROTOCOL;
2505  smtpd_chat_reply(state,
2506  "501 5.5.4 Bad RET parameter syntax");
2507  return (-1);
2508  }
2509  } else if (strncasecmp(arg, "ENVID=", 6) == 0) { /* RFC 3461 */
2510  /* Sanitized by bounce server. */
2511  if (state->ehlo_discard_mask & EHLO_MASK_DSN) {
2512  state->error_mask |= MAIL_ERROR_PROTOCOL;
2513  smtpd_chat_reply(state, "501 5.7.1 DSN support is disabled");
2514  return (-1);
2515  }
2516  if (dsn_envid
2517  || xtext_unquote(state->dsn_buf, arg + 6) == 0
2518  || !allprint(STR(state->dsn_buf))) {
2519  state->error_mask |= MAIL_ERROR_PROTOCOL;
2520  smtpd_chat_reply(state, "501 5.5.4 Bad ENVID parameter syntax");
2521  return (-1);
2522  }
2523  dsn_envid = 1;
2524  } else {
2525  state->error_mask |= MAIL_ERROR_PROTOCOL;
2526  smtpd_chat_reply(state, "555 5.5.4 Unsupported option: %s", arg);
2527  return (-1);
2528  }
2529  }
2530  /* Fix 20161205: show the envelope sender in reject logging. */
2531  PUSH_STRING(saved_sender, state->sender, STR(state->addr_buf));
2532  err = smtpd_check_size(state, state->msg_size);
2533  POP_STRING(saved_sender, state->sender);
2534  if (err != 0) {
2535  smtpd_chat_reply(state, "%s", err);
2536  return (-1);
2537  }
2538  if (verp_delims && STR(state->addr_buf)[0] == 0) {
2539  smtpd_chat_reply(state, "503 5.5.4 Error: %s requires non-null sender",
2540  VERP_CMD);
2541  return (-1);
2542  }
2543  if (SMTPD_STAND_ALONE(state) == 0) {
2544  const char *verify_sender;
2545 
2546  /*
2547  * XXX Don't reject the address when we're probed with our own
2548  * address verification sender address. Otherwise, some timeout or
2549  * some UCE block may result in mutual negative caching, making it
2550  * painful to get the mail through. Unfortunately we still have to
2551  * send the address to the Milters otherwise they may bail out with a
2552  * "missing recipient" protocol error.
2553  */
2554  verify_sender = valid_verify_sender_addr(STR(state->addr_buf));
2555  if (verify_sender != 0)
2556  vstring_strcpy(state->addr_buf, verify_sender);
2557  }
2558  if (SMTPD_STAND_ALONE(state) == 0
2559  && var_smtpd_delay_reject == 0
2560  && (err = smtpd_check_mail(state, STR(state->addr_buf))) != 0) {
2561  /* XXX Reset access map side effects. */
2562  mail_reset(state);
2563  smtpd_chat_reply(state, "%s", err);
2564  return (-1);
2565  }
2566  if (state->milters != 0
2567  && (state->saved_flags & MILTER_SKIP_FLAGS) == 0) {
2568  PUSH_STRING(saved_sender, state->sender, STR(state->addr_buf));
2569  err = milter_mail_event(state->milters,
2570  milter_argv(state, argc - 2, argv + 2));
2571  if (err != 0) {
2572  /* Log reject etc. with correct sender information. */
2573  err = check_milter_reply(state, err);
2574  }
2575  POP_STRING(saved_sender, state->sender);
2576  if (err != 0) {
2577  /* XXX Reset access map side effects. */
2578  mail_reset(state);
2579  smtpd_chat_reply(state, "%s", err);
2580  return (-1);
2581  }
2582  }
2583  if (SMTPD_STAND_ALONE(state) == 0) {
2584  err = smtpd_check_rewrite(state);
2585  if (err != 0) {
2586  /* XXX Reset access map side effects. */
2587  mail_reset(state);
2588  smtpd_chat_reply(state, "%s", err);
2589  return (-1);
2590  }
2591  }
2592 
2593  /*
2594  * Historically, Postfix does not forbid 8-bit envelope localparts.
2595  * Changing this would be a compatibility break. That can't happen in the
2596  * foreseeable future.
2597  */
2599  && (state->flags & SMTPD_FLAG_SMTPUTF8) == 0
2600  && *STR(state->addr_buf) && !allascii(STR(state->addr_buf))) {
2601  if (var_strict_smtputf8) {
2602  smtpd_chat_reply(state, "553 5.6.7 Must declare SMTPUTF8 to "
2603  "send unicode address");
2604  return (-1);
2605  }
2606 
2607  /*
2608  * Not: #ifndef NO_EAI. They must configure SMTPUTF8_ENABLE=no if a
2609  * warning message is logged, so that they don't suddenly start to
2610  * lose mail after Postfix is built with EAI support.
2611  */
2613  msg_info("using backwards-compatible default setting "
2614  VAR_SMTPUTF8_ENABLE "=no to accept non-ASCII sender "
2615  "address \"%s\" from %s", STR(state->addr_buf),
2616  state->namaddr);
2617  }
2618 
2619  /*
2620  * Check the queue file space, if applicable. The optional before-filter
2621  * speed-adjust buffers use disk space. However, we don't know if they
2622  * compete for storage space with the after-filter queue, so we can't
2623  * simply bump up the free space requirement to 2.5 * message_size_limit.
2624  */
2625  if (!USE_SMTPD_PROXY(state)
2627  if (SMTPD_STAND_ALONE(state) == 0
2628  && (err = smtpd_check_queue(state)) != 0) {
2629  /* XXX Reset access map side effects. */
2630  mail_reset(state);
2631  smtpd_chat_reply(state, "%s", err);
2632  return (-1);
2633  }
2634  }
2635 
2636  /*
2637  * No more early returns. The mail transaction is in progress.
2638  */
2639  GETTIMEOFDAY(&state->arrival_time);
2640  state->sender = mystrdup(STR(state->addr_buf));
2641  vstring_sprintf(state->instance, "%x.%lx.%lx.%x",
2642  var_pid, (unsigned long) state->arrival_time.tv_sec,
2643  (unsigned long) state->arrival_time.tv_usec, state->seqno++);
2644  if (verp_delims)
2645  state->verp_delims = mystrdup(verp_delims);
2646  if (dsn_envid)
2647  state->dsn_envid = mystrdup(STR(state->dsn_buf));
2648  if (USE_SMTPD_PROXY(state))
2649  state->proxy_mail = mystrdup(STR(state->buffer));
2650  if (var_smtpd_delay_open == 0 && mail_open_stream(state) < 0) {
2651  /* XXX Reset access map side effects. */
2652  mail_reset(state);
2653  return (-1);
2654  }
2655  smtpd_chat_reply(state, "250 2.1.0 Ok");
2656  return (0);
2657 }
2658 
2659 /* mail_reset - reset MAIL command stuff */
2660 
2661 static void mail_reset(SMTPD_STATE *state)
2662 {
2663  state->msg_size = 0;
2664  state->act_size = 0;
2665  state->flags &= SMTPD_MASK_MAIL_KEEP;
2666 
2667  /*
2668  * Unceremoniously close the pipe to the cleanup service. The cleanup
2669  * service will delete the queue file when it detects a premature
2670  * end-of-file condition on input.
2671  */
2672  if (state->cleanup != 0) {
2673  mail_stream_cleanup(state->dest);
2674  state->dest = 0;
2675  state->cleanup = 0;
2676  }
2677  state->err = 0;
2678  if (state->queue_id != 0) {
2679  myfree(state->queue_id);
2680  state->queue_id = 0;
2681  }
2682  if (state->sender) {
2683  if (state->milters != 0)
2684  milter_abort(state->milters);
2685  myfree(state->sender);
2686  state->sender = 0;
2687  }
2688  if (state->verp_delims) {
2689  myfree(state->verp_delims);
2690  state->verp_delims = 0;
2691  }
2692  if (state->proxy_mail) {
2693  myfree(state->proxy_mail);
2694  state->proxy_mail = 0;
2695  }
2696  if (state->saved_filter) {
2697  myfree(state->saved_filter);
2698  state->saved_filter = 0;
2699  }
2700  if (state->saved_redirect) {
2701  myfree(state->saved_redirect);
2702  state->saved_redirect = 0;
2703  }
2704  if (state->saved_bcc) {
2705  argv_free(state->saved_bcc);
2706  state->saved_bcc = 0;
2707  }
2708  state->saved_flags = 0;
2709 #ifdef DELAY_ACTION
2710  state->saved_delay = 0;
2711 #endif
2712 #ifdef USE_SASL_AUTH
2713  if (state->sasl_sender)
2714  smtpd_sasl_mail_reset(state);
2715 #endif
2716  state->discard = 0;
2717  VSTRING_RESET(state->instance);
2718  VSTRING_TERMINATE(state->instance);
2719 
2720  if (state->proxy)
2721  smtpd_proxy_free(state);
2722  if (state->xforward.flags)
2723  smtpd_xforward_reset(state);
2724  if (state->prepend)
2725  state->prepend = argv_free(state->prepend);
2726  if (state->dsn_envid) {
2727  myfree(state->dsn_envid);
2728  state->dsn_envid = 0;
2729  }
2730  if (state->milter_argv) {
2731  myfree((void *) state->milter_argv);
2732  state->milter_argv = 0;
2733  state->milter_argc = 0;
2734  }
2735 }
2736 
2737 /* rcpt_cmd - process RCPT TO command */
2738 
2739 static int rcpt_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
2740 {
2741  SMTPD_PROXY *proxy;
2742  const char *err;
2743  int narg;
2744  char *arg;
2745  int rate;
2746  const char *dsn_orcpt_addr = 0;
2747  ssize_t dsn_orcpt_addr_len = 0;
2748  const char *dsn_orcpt_type = 0;
2749  int dsn_notify = 0;
2750  const char *coded_addr;
2751  const char *milter_err;
2752 
2753  /*
2754  * Sanity checks.
2755  *
2756  * XXX 2821 pedantism: Section 4.1.2 says that SMTP servers that receive a
2757  * command in which invalid character codes have been employed, and for
2758  * which there are no other reasons for rejection, MUST reject that
2759  * command with a 501 response. So much for the principle of "be liberal
2760  * in what you accept, be strict in what you send".
2761  */
2762  if (!SMTPD_IN_MAIL_TRANSACTION(state)) {
2763  state->error_mask |= MAIL_ERROR_PROTOCOL;
2764  smtpd_chat_reply(state, "503 5.5.1 Error: need MAIL command");
2765  return (-1);
2766  }
2767  if (argc < 3
2768  || strcasecmp(argv[1].strval, "to:") != 0) {
2769  state->error_mask |= MAIL_ERROR_PROTOCOL;
2770  smtpd_chat_reply(state, "501 5.5.4 Syntax: RCPT TO:<address>");
2771  return (-1);
2772  }
2773 
2774  /*
2775  * XXX The client event count/rate control must be consistent in its use
2776  * of client address information in connect and disconnect events. For
2777  * now we exclude xclient authorized hosts from event count/rate control.
2778  */
2779  if (SMTPD_STAND_ALONE(state) == 0
2780  && !xclient_allowed
2781  && anvil_clnt
2782  && var_smtpd_crcpt_limit > 0
2783  && !namadr_list_match(hogger_list, state->name, state->addr)
2784  && anvil_clnt_rcpt(anvil_clnt, state->service, state->addr,
2785  &rate) == ANVIL_STAT_OK
2786  && rate > var_smtpd_crcpt_limit) {
2787  state->error_mask |= MAIL_ERROR_POLICY;
2788  msg_warn("Recipient address rate limit exceeded: %d from %s for service %s",
2789  rate, state->namaddr, state->service);
2790  smtpd_chat_reply(state, "450 4.7.1 Error: too many recipients from %s",
2791  state->addr);
2792  return (-1);
2793  }
2794  if (argv[2].tokval == SMTPD_TOK_ERROR) {
2795  state->error_mask |= MAIL_ERROR_PROTOCOL;
2796  smtpd_chat_reply(state, "501 5.1.3 Bad recipient address syntax");
2797  return (-1);
2798  }
2799  if (extract_addr(state, argv + 2, REJECT_EMPTY_ADDR, var_strict_rfc821_env,
2800  state->flags & SMTPD_FLAG_SMTPUTF8) != 0) {
2801  state->error_mask |= MAIL_ERROR_PROTOCOL;
2802  smtpd_chat_reply(state, "501 5.1.3 Bad recipient address syntax");
2803  return (-1);
2804  }
2805  for (narg = 3; narg < argc; narg++) {
2806  arg = argv[narg].strval;
2807  if (strncasecmp(arg, "NOTIFY=", 7) == 0) { /* RFC 3461 */
2808  /* Sanitized on input. */
2809  if (state->ehlo_discard_mask & EHLO_MASK_DSN) {
2810  state->error_mask |= MAIL_ERROR_PROTOCOL;
2811  smtpd_chat_reply(state, "501 5.7.1 DSN support is disabled");
2812  return (-1);
2813  }
2814  if (dsn_notify || (dsn_notify = dsn_notify_mask(arg + 7)) == 0) {
2815  state->error_mask |= MAIL_ERROR_PROTOCOL;
2816  smtpd_chat_reply(state,
2817  "501 5.5.4 Error: Bad NOTIFY parameter syntax");
2818  return (-1);
2819  }
2820  } else if (strncasecmp(arg, "ORCPT=", 6) == 0) { /* RFC 3461 */
2821  /* Sanitized by bounce server. */
2822  if (state->ehlo_discard_mask & EHLO_MASK_DSN) {
2823  state->error_mask |= MAIL_ERROR_PROTOCOL;
2824  smtpd_chat_reply(state, "501 5.7.1 DSN support is disabled");
2825  return (-1);
2826  }
2827  vstring_strcpy(state->dsn_orcpt_buf, arg + 6);
2828  if (dsn_orcpt_addr
2829  || (coded_addr = split_at(STR(state->dsn_orcpt_buf), ';')) == 0
2830  || *(dsn_orcpt_type = STR(state->dsn_orcpt_buf)) == 0
2831  || (strcasecmp(dsn_orcpt_type, "utf-8") == 0 ?
2832  uxtext_unquote(state->dsn_buf, coded_addr) == 0 :
2833  xtext_unquote(state->dsn_buf, coded_addr) == 0)) {
2834  state->error_mask |= MAIL_ERROR_PROTOCOL;
2835  smtpd_chat_reply(state,
2836  "501 5.5.4 Error: Bad ORCPT parameter syntax");
2837  return (-1);
2838  }
2839  dsn_orcpt_addr = STR(state->dsn_buf);
2840  dsn_orcpt_addr_len = LEN(state->dsn_buf);
2841  } else {
2842  state->error_mask |= MAIL_ERROR_PROTOCOL;
2843  smtpd_chat_reply(state, "555 5.5.4 Unsupported option: %s", arg);
2844  return (-1);
2845  }
2846  }
2848  smtpd_chat_reply(state, "452 4.5.3 Error: too many recipients");
2849  if (state->rcpt_overshoot++ < var_smtpd_rcpt_overlim)
2850  return (0);
2851  state->error_mask |= MAIL_ERROR_POLICY;
2852  return (-1);
2853  }
2854 
2855  /*
2856  * Historically, Postfix does not forbid 8-bit envelope localparts.
2857  * Changing this would be a compatibility break. That can't happen in the
2858  * foreseeable future.
2859  */
2861  && (state->flags & SMTPD_FLAG_SMTPUTF8) == 0
2862  && *STR(state->addr_buf) && !allascii(STR(state->addr_buf))) {
2863  if (var_strict_smtputf8) {
2864  smtpd_chat_reply(state, "553 5.6.7 Must declare SMTPUTF8 to "
2865  "send unicode address");
2866  return (-1);
2867  }
2868 
2869  /*
2870  * Not: #ifndef NO_EAI. They must configure SMTPUTF8_ENABLE=no if a
2871  * warning message is logged, so that they don't suddenly start to
2872  * lose mail after Postfix is built with EAI support.
2873  */
2875  msg_info("using backwards-compatible default setting "
2876  VAR_SMTPUTF8_ENABLE "=no to accept non-ASCII recipient "
2877  "address \"%s\" from %s", STR(state->addr_buf),
2878  state->namaddr);
2879  }
2880  if (SMTPD_STAND_ALONE(state) == 0) {
2881  const char *verify_sender;
2882 
2883  /*
2884  * XXX Don't reject the address when we're probed with our own
2885  * address verification sender address. Otherwise, some timeout or
2886  * some UCE block may result in mutual negative caching, making it
2887  * painful to get the mail through. Unfortunately we still have to
2888  * send the address to the Milters otherwise they may bail out with a
2889  * "missing recipient" protocol error.
2890  */
2891  verify_sender = valid_verify_sender_addr(STR(state->addr_buf));
2892  if (verify_sender != 0) {
2893  vstring_strcpy(state->addr_buf, verify_sender);
2894  err = 0;
2895  } else {
2896  err = smtpd_check_rcpt(state, STR(state->addr_buf));
2897  }
2898  if (state->milters != 0
2899  && (state->saved_flags & MILTER_SKIP_FLAGS) == 0) {
2900  PUSH_STRING(saved_rcpt, state->recipient, STR(state->addr_buf));
2901  state->milter_reject_text = err;
2902  milter_err = milter_rcpt_event(state->milters,
2903  err == 0 ? MILTER_FLAG_NONE :
2905  milter_argv(state, argc - 2, argv + 2));
2906  if (err == 0 && milter_err != 0) {
2907  /* Log reject etc. with correct recipient information. */
2908  err = check_milter_reply(state, milter_err);
2909  }
2910  POP_STRING(saved_rcpt, state->recipient);
2911  }
2912  if (err != 0) {
2913  smtpd_chat_reply(state, "%s", err);
2914  return (-1);
2915  }
2916  }
2917 
2918  /*
2919  * Don't access the proxy, queue file, or queue file writer process until
2920  * we have a valid recipient address.
2921  */
2922  if (state->proxy == 0 && state->cleanup == 0 && mail_open_stream(state) < 0)
2923  return (-1);
2924 
2925  /*
2926  * Proxy the recipient. OK, so we lied. If the real-time proxy rejects
2927  * the recipient then we can have a proxy connection without having
2928  * accepted a recipient.
2929  */
2930  proxy = state->proxy;
2931  if (proxy != 0 && proxy->cmd(state, SMTPD_PROX_WANT_OK,
2932  "%s", STR(state->buffer)) != 0) {
2933  smtpd_chat_reply(state, "%s", STR(proxy->reply));
2934  return (-1);
2935  }
2936 
2937  /*
2938  * Store the recipient. Remember the first one.
2939  *
2940  * Flush recipients to maintain a stiffer coupling with the next stage and
2941  * to better utilize parallelism.
2942  *
2943  * RFC 3461 Section 5.2.1: If the NOTIFY parameter was not supplied for a
2944  * recipient when the message was received, the NOTIFY parameter MUST NOT
2945  * be supplied for that recipient when the message is relayed.
2946  *
2947  * In other words, we can't simply make up our default NOTIFY value. We have
2948  * to remember whether the client sent any.
2949  *
2950  * RFC 3461 Section 5.2.1: If no ORCPT parameter was present when the
2951  * message was received, an ORCPT parameter MAY be added to the RCPT
2952  * command when the message is relayed. If an ORCPT parameter is added
2953  * by the relaying MTA, it MUST contain the recipient address from the
2954  * RCPT command used when the message was received by that MTA.
2955  *
2956  * In other words, it is OK to make up our own DSN original recipient when
2957  * the client didn't send one. Although the RFC mentions mail relaying
2958  * only, we also make up our own original recipient for the purpose of
2959  * final delivery. For now, we do this here, rather than on the fly.
2960  *
2961  * XXX We use REC_TYPE_ATTR for DSN-related recipient attributes even though
2962  * 1) REC_TYPE_ATTR is not meant for multiple instances of the same named
2963  * attribute, and 2) mixing REC_TYPE_ATTR with REC_TYPE_(not attr)
2964  * requires that we map attributes with rec_attr_map() in order to
2965  * simplify the recipient record processing loops in the cleanup and qmgr
2966  * servers.
2967  *
2968  * Another possibility, yet to be explored, is to leave the additional
2969  * recipient information in the queue file and just pass queue file
2970  * offsets along with the delivery request. This is a trade off between
2971  * memory allocation versus numeric conversion overhead.
2972  *
2973  * Since we have no record grouping mechanism, all recipient-specific
2974  * parameters must be sent to the cleanup server before the actual
2975  * recipient address.
2976  */
2977  state->rcpt_count++;
2978  if (state->recipient == 0)
2979  state->recipient = mystrdup(STR(state->addr_buf));
2980  if (state->cleanup) {
2981  /* Note: RFC(2)821 externalized address! */
2982  if (dsn_orcpt_addr == 0) {
2983  dsn_orcpt_type = "rfc822";
2984  dsn_orcpt_addr = argv[2].strval;
2985  dsn_orcpt_addr_len = strlen(argv[2].strval);
2986  if (dsn_orcpt_addr[0] == '<'
2987  && dsn_orcpt_addr[dsn_orcpt_addr_len - 1] == '>') {
2988  dsn_orcpt_addr += 1;
2989  dsn_orcpt_addr_len -= 2;
2990  }
2991  }
2992  if (dsn_notify)
2993  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%d",
2994  MAIL_ATTR_DSN_NOTIFY, dsn_notify);
2995  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s;%.*s",
2996  MAIL_ATTR_DSN_ORCPT, dsn_orcpt_type,
2997  (int) dsn_orcpt_addr_len, dsn_orcpt_addr);
2998  rec_fputs(state->cleanup, REC_TYPE_RCPT, STR(state->addr_buf));
2999  vstream_fflush(state->cleanup);
3000  }
3001  smtpd_chat_reply(state, "250 2.1.5 Ok");
3002  return (0);
3003 }
3004 
3005 /* rcpt_reset - reset RCPT stuff */
3006 
3007 static void rcpt_reset(SMTPD_STATE *state)
3008 {
3009  if (state->recipient) {
3010  myfree(state->recipient);
3011  state->recipient = 0;
3012  }
3013  state->rcpt_count = 0;
3014  /* XXX Must flush the command history. */
3015  state->rcpt_overshoot = 0;
3016 }
3017 
3018 #if 0
3019 
3020 /* rfc2047_comment_encode - encode comment string */
3021 
3022 static VSTRING *rfc2047_comment_encode(const char *str, const char *charset)
3023 {
3024  VSTRING *buf = vstring_alloc(30);
3025  const unsigned char *cp;
3026  int ch;
3027 
3028  /*
3029  * XXX This is problematic code.
3030  *
3031  * XXX Most of the RFC 2047 "especials" are not special in RFC*822 comments,
3032  * but we encode them anyway to avoid complaints.
3033  *
3034  * XXX In Received: header comments we enclose peer and issuer common names
3035  * with "" quotes (inherited from the Lutz Jaenicke patch). This is the
3036  * cause of several quirks.
3037  *
3038  * 1) We encode text that contains the " character, even though that
3039  * character is not special for RFC*822 comments.
3040  *
3041  * 2) We ignore the recommended limit of 75 characters per encoded word,
3042  * because long comments look ugly when folded in-between quotes.
3043  *
3044  * 3) We encode the enclosing quotes, to avoid producing invalid encoded
3045  * words. Microsoft abuses RFC 2047 encoding with attachment names, but
3046  * we have no information on what decoders do with malformed encoding in
3047  * comments. This means the comments are Jaenicke-compatible only after
3048  * decoding.
3049  */
3050 #define ESPECIALS "()<>@,;:\"/[]?.=" /* Special in RFC 2047 */
3051 #define QSPECIALS "_" ESPECIALS /* Special in RFC 2047 'Q' */
3052 #define CSPECIALS "\\\"()" /* Special in our comments */
3053 
3054  /* Don't encode if not needed. */
3055  for (cp = (unsigned char *) str; /* see below */ ; ++cp) {
3056  if ((ch = *cp) == 0) {
3057  vstring_sprintf(buf, "\"%s\"", str);
3058  return (buf);
3059  }
3060  if (!ISPRINT(ch) || strchr(CSPECIALS, ch))
3061  break;
3062  }
3063 
3064  /*
3065  * Use quoted-printable (like) encoding with spaces mapped to underscore.
3066  */
3067  vstring_sprintf(buf, "=?%s?Q?=%02X", charset, '"');
3068  for (cp = (unsigned char *) str; (ch = *cp) != 0; ++cp) {
3069  if (!ISPRINT(ch) || strchr(QSPECIALS CSPECIALS, ch)) {
3070  vstring_sprintf_append(buf, "=%02X", ch);
3071  } else if (ch == ' ') {
3072  VSTRING_ADDCH(buf, '_');
3073  } else {
3074  VSTRING_ADDCH(buf, ch);
3075  }
3076  }
3077  vstring_sprintf_append(buf, "=%02X?=", '"');
3078  return (buf);
3079 }
3080 
3081 #endif
3082 
3083 /* comment_sanitize - clean up comment string */
3084 
3085 static void comment_sanitize(VSTRING *comment_string)
3086 {
3087  unsigned char *cp;
3088  int ch;
3089  int pc;
3090 
3091  /*
3092  * Postfix Received: headers can be configured to include a comment with
3093  * the CN (CommonName) of the peer and its issuer, or the login name of a
3094  * SASL authenticated user. To avoid problems with RFC 822 etc. syntax,
3095  * we limit this information to printable ASCII text, and neutralize
3096  * characters that affect comment parsing: the backslash and unbalanced
3097  * parentheses.
3098  */
3099  for (pc = 0, cp = (unsigned char *) STR(comment_string); (ch = *cp) != 0; cp++) {
3100  if (!ISASCII(ch) || !ISPRINT(ch) || ch == '\\') {
3101  *cp = '?';
3102  } else if (ch == '(') {
3103  pc++;
3104  } else if (ch == ')') {
3105  if (pc > 0)
3106  pc--;
3107  else
3108  *cp = '?';
3109  }
3110  }
3111  while (pc-- > 0)
3112  VSTRING_ADDCH(comment_string, ')');
3113  VSTRING_TERMINATE(comment_string);
3114 }
3115 
3116 /* data_cmd - process DATA command */
3117 
3118 static int data_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *unused_argv)
3119 {
3120  SMTPD_PROXY *proxy;
3121  const char *err;
3122  char *start;
3123  int len;
3124  int curr_rec_type;
3125  int prev_rec_type;
3126  int first = 1;
3127  VSTRING *why = 0;
3128  int saved_err;
3129  int (*out_record) (VSTREAM *, int, const char *, ssize_t);
3130  int (*out_fprintf) (VSTREAM *, int, const char *,...);
3131  VSTREAM *out_stream;
3132  int out_error;
3133  char **cpp;
3134  const CLEANUP_STAT_DETAIL *detail;
3135  const char *rfc3848_sess;
3136  const char *rfc3848_auth;
3137  const char *with_protocol = (state->flags & SMTPD_FLAG_SMTPUTF8) ?
3138  "UTF8SMTP" : state->protocol;
3139 
3140 #ifdef USE_TLS
3141  VSTRING *peer_CN;
3142  VSTRING *issuer_CN;
3143 
3144 #endif
3145 #ifdef USE_SASL_AUTH
3146  VSTRING *username;
3147 
3148 #endif
3149 
3150  /*
3151  * Sanity checks. With ESMTP command pipelining the client can send DATA
3152  * before all recipients are rejected, so don't report that as a protocol
3153  * error.
3154  */
3155  if (state->rcpt_count == 0) {
3156  if (!SMTPD_IN_MAIL_TRANSACTION(state)) {
3157  state->error_mask |= MAIL_ERROR_PROTOCOL;
3158  smtpd_chat_reply(state, "503 5.5.1 Error: need RCPT command");
3159  } else {
3160  smtpd_chat_reply(state, "554 5.5.1 Error: no valid recipients");
3161  }
3162  return (-1);
3163  }
3164  if (argc != 1) {
3165  state->error_mask |= MAIL_ERROR_PROTOCOL;
3166  smtpd_chat_reply(state, "501 5.5.4 Syntax: DATA");
3167  return (-1);
3168  }
3169  if (SMTPD_STAND_ALONE(state) == 0 && (err = smtpd_check_data(state)) != 0) {
3170  smtpd_chat_reply(state, "%s", err);
3171  return (-1);
3172  }
3173  if (state->milters != 0
3174  && (state->saved_flags & MILTER_SKIP_FLAGS) == 0
3175  && (err = milter_data_event(state->milters)) != 0
3176  && (err = check_milter_reply(state, err)) != 0) {
3177  smtpd_chat_reply(state, "%s", err);
3178  return (-1);
3179  }
3180  proxy = state->proxy;
3181  if (proxy != 0 && proxy->cmd(state, SMTPD_PROX_WANT_MORE,
3182  "%s", STR(state->buffer)) != 0) {
3183  smtpd_chat_reply(state, "%s", STR(proxy->reply));
3184  return (-1);
3185  }
3186 
3187  /*
3188  * One level of indirection to choose between normal or proxied
3189  * operation. We want to avoid massive code duplication within tons of
3190  * if-else clauses.
3191  */
3192  if (proxy) {
3193  out_stream = proxy->stream;
3194  out_record = proxy->rec_put;
3195  out_fprintf = proxy->rec_fprintf;
3196  out_error = CLEANUP_STAT_PROXY;
3197  } else {
3198  out_stream = state->cleanup;
3199  out_record = rec_put;
3200  out_fprintf = rec_fprintf;
3201  out_error = CLEANUP_STAT_WRITE;
3202  }
3203 
3204  /*
3205  * Flush out a first batch of access table actions that are delegated to
3206  * the cleanup server, and that may trigger before we accept the first
3207  * valid recipient. There will be more after end-of-data.
3208  *
3209  * Terminate the message envelope segment. Start the message content
3210  * segment, and prepend our own Received: header. If there is only one
3211  * recipient, list the recipient address.
3212  */
3213  if (state->cleanup) {
3214  if (SMTPD_STAND_ALONE(state) == 0) {
3215  if (state->milters != 0
3216  && (state->saved_flags & MILTER_SKIP_FLAGS) == 0)
3217  /* Send actual smtpd_milters list. */
3218  (void) milter_send(state->milters, state->cleanup);
3219  if (state->saved_flags)
3220  rec_fprintf(state->cleanup, REC_TYPE_FLGS, "%d",
3221  state->saved_flags);
3222  }
3223  rec_fputs(state->cleanup, REC_TYPE_MESG, "");
3224  }
3225 
3226  /*
3227  * PREPEND message headers above our own Received: header.
3228  */
3229  if (state->prepend)
3230  for (cpp = state->prepend->argv; *cpp; cpp++)
3231  out_fprintf(out_stream, REC_TYPE_NORM, "%s", *cpp);
3232 
3233  /*
3234  * Suppress our own Received: header in the unlikely case that we are an
3235  * intermediate proxy.
3236  */
3237  if (!proxy || state->xforward.flags == 0) {
3238  out_fprintf(out_stream, REC_TYPE_NORM,
3239  "Received: from %s (%s [%s])",
3240  state->helo_name ? state->helo_name : state->name,
3241  state->name, state->rfc_addr);
3242 
3243 #define VSTRING_STRDUP(s) vstring_strcpy(vstring_alloc(strlen(s) + 1), (s))
3244 
3245 #ifdef USE_TLS
3246  if (var_smtpd_tls_received_header && state->tls_context) {
3247  out_fprintf(out_stream, REC_TYPE_NORM,
3248  "\t(using %s with cipher %s (%d/%d bits))",
3249  state->tls_context->protocol,
3250  state->tls_context->cipher_name,
3251  state->tls_context->cipher_usebits,
3252  state->tls_context->cipher_algbits);
3253  if (TLS_CERT_IS_PRESENT(state->tls_context)) {
3254  peer_CN = VSTRING_STRDUP(state->tls_context->peer_CN);
3255  comment_sanitize(peer_CN);
3256  issuer_CN = VSTRING_STRDUP(state->tls_context->issuer_CN ?
3257  state->tls_context->issuer_CN : "");
3258  comment_sanitize(issuer_CN);
3259  out_fprintf(out_stream, REC_TYPE_NORM,
3260  "\t(Client CN \"%s\", Issuer \"%s\" (%s))",
3261  STR(peer_CN), STR(issuer_CN),
3262  TLS_CERT_IS_TRUSTED(state->tls_context) ?
3263  "verified OK" : "not verified");
3264  vstring_free(issuer_CN);
3265  vstring_free(peer_CN);
3266  } else if (var_smtpd_tls_ask_ccert)
3267  out_fprintf(out_stream, REC_TYPE_NORM,
3268  "\t(Client did not present a certificate)");
3269  else
3270  out_fprintf(out_stream, REC_TYPE_NORM,
3271  "\t(No client certificate requested)");
3272  }
3273  /* RFC 3848 is defined for ESMTP only. */
3274  if (state->tls_context != 0
3275  && strcmp(state->protocol, MAIL_PROTO_ESMTP) == 0)
3276  rfc3848_sess = "S";
3277  else
3278 #endif
3279  rfc3848_sess = "";
3280 #ifdef USE_SASL_AUTH
3281  if (var_smtpd_sasl_auth_hdr && state->sasl_username) {
3282  username = VSTRING_STRDUP(state->sasl_username);
3283  comment_sanitize(username);
3284  out_fprintf(out_stream, REC_TYPE_NORM,
3285  "\t(Authenticated sender: %s)", STR(username));
3287  }
3288  /* RFC 3848 is defined for ESMTP only. */
3289  if (state->sasl_username
3290  && strcmp(state->protocol, MAIL_PROTO_ESMTP) == 0)
3291  rfc3848_auth = "A";
3292  else
3293 #endif
3294  rfc3848_auth = "";
3295  if (state->rcpt_count == 1 && state->recipient) {
3296  out_fprintf(out_stream, REC_TYPE_NORM,
3297  state->cleanup ? "\tby %s (%s) with %s%s%s id %s" :
3298  "\tby %s (%s) with %s%s%s",
3300  with_protocol, rfc3848_sess,
3301  rfc3848_auth, state->queue_id);
3302  quote_822_local(state->buffer, state->recipient);
3303  out_fprintf(out_stream, REC_TYPE_NORM,
3304  "\tfor <%s>; %s", STR(state->buffer),
3305  mail_date(state->arrival_time.tv_sec));
3306  } else {
3307  out_fprintf(out_stream, REC_TYPE_NORM,
3308  state->cleanup ? "\tby %s (%s) with %s%s%s id %s;" :
3309  "\tby %s (%s) with %s%s%s;",
3311  with_protocol, rfc3848_sess,
3312  rfc3848_auth, state->queue_id);
3313  out_fprintf(out_stream, REC_TYPE_NORM,
3314  "\t%s", mail_date(state->arrival_time.tv_sec));
3315  }
3316 #ifdef RECEIVED_ENVELOPE_FROM
3317  quote_822_local(state->buffer, state->sender);
3318  out_fprintf(out_stream, REC_TYPE_NORM,
3319  "\t(envelope-from %s)", STR(state->buffer));
3320 #endif
3321  }
3322  smtpd_chat_reply(state, "354 End data with <CR><LF>.<CR><LF>");
3323  state->where = SMTPD_AFTER_DATA;
3324 
3325  /*
3326  * Copy the message content. If the cleanup process has a problem, keep
3327  * reading until the remote stops sending, then complain. Produce typed
3328  * records from the SMTP stream so we can handle data that spans buffers.
3329  *
3330  * XXX Force an empty record when the queue file content begins with
3331  * whitespace, so that it won't be considered as being part of our own
3332  * Received: header. What an ugly Kluge.
3333  *
3334  * XXX Deal with UNIX-style From_ lines at the start of message content
3335  * because sendmail permits it.
3336  */
3337  for (prev_rec_type = 0; /* void */ ; prev_rec_type = curr_rec_type) {
3338  if (smtp_get(state->buffer, state->client, var_line_limit,
3339  SMTP_GET_FLAG_NONE) == '\n')
3340  curr_rec_type = REC_TYPE_NORM;
3341  else
3342  curr_rec_type = REC_TYPE_CONT;
3343  start = vstring_str(state->buffer);
3344  len = VSTRING_LEN(state->buffer);
3345  if (first) {
3346  if (strncmp(start + strspn(start, ">"), "From ", 5) == 0) {
3347  out_fprintf(out_stream, curr_rec_type,
3348  "X-Mailbox-Line: %s", start);
3349  continue;
3350  }
3351  first = 0;
3352  if (len > 0 && IS_SPACE_TAB(start[0]))
3353  out_record(out_stream, REC_TYPE_NORM, "", 0);
3354  }
3355  if (prev_rec_type != REC_TYPE_CONT && *start == '.'
3356  && (proxy == 0 ? (++start, --len) == 0 : len == 1))
3357  break;
3358  if (state->err == CLEANUP_STAT_OK) {
3359  if (var_message_limit > 0 && var_message_limit - state->act_size < len + 2) {
3360  state->err = CLEANUP_STAT_SIZE;
3361  msg_warn("%s: queue file size limit exceeded",
3362  state->queue_id ? state->queue_id : "NOQUEUE");
3363  } else {
3364  state->act_size += len + 2;
3365  if (out_record(out_stream, curr_rec_type, start, len) < 0)
3366  state->err = out_error;
3367  }
3368  }
3369  }
3370  state->where = SMTPD_AFTER_DOT;
3371  if (state->err == CLEANUP_STAT_OK
3372  && SMTPD_STAND_ALONE(state) == 0
3373  && (err = smtpd_check_eod(state)) != 0) {
3374  smtpd_chat_reply(state, "%s", err);
3375  if (proxy) {
3376  smtpd_proxy_close(state);
3377  } else {
3378  mail_stream_cleanup(state->dest);
3379  state->dest = 0;
3380  state->cleanup = 0;
3381  }
3382  return (-1);
3383  }
3384 
3385  /*
3386  * Send the end of DATA and finish the proxy connection. Set the
3387  * CLEANUP_STAT_PROXY error flag in case of trouble.
3388  */
3389  if (proxy) {
3390  if (state->err == CLEANUP_STAT_OK) {
3391  (void) proxy->cmd(state, SMTPD_PROX_WANT_ANY, ".");
3392  if (state->err == CLEANUP_STAT_OK &&
3393  *STR(proxy->reply) != '2')
3394  state->err = CLEANUP_STAT_CONT;
3395  }
3396  }
3397 
3398  /*
3399  * Flush out access table actions that are delegated to the cleanup
3400  * server. There is similar code at the beginning of the DATA command.
3401  *
3402  * Send the end-of-segment markers and finish the queue file record stream.
3403  */
3404  else {
3405  if (state->err == CLEANUP_STAT_OK) {
3406  rec_fputs(state->cleanup, REC_TYPE_XTRA, "");
3407  if (state->saved_filter)
3408  rec_fprintf(state->cleanup, REC_TYPE_FILT, "%s",
3409  state->saved_filter);
3410  if (state->saved_redirect)
3411  rec_fprintf(state->cleanup, REC_TYPE_RDR, "%s",
3412  state->saved_redirect);
3413  if (state->saved_bcc) {
3414  char **cpp;
3415 
3416  for (cpp = state->saved_bcc->argv; *cpp; cpp++) {
3417  rec_fprintf(state->cleanup, REC_TYPE_RCPT, "%s",
3418  *cpp);
3419  rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%d",
3421  }
3422  }
3423  if (state->saved_flags)
3424  rec_fprintf(state->cleanup, REC_TYPE_FLGS, "%d",
3425  state->saved_flags);
3426 #ifdef DELAY_ACTION
3427  if (state->saved_delay)
3428  rec_fprintf(state->cleanup, REC_TYPE_DELAY, "%d",
3429  state->saved_delay);
3430 #endif
3431  if (vstream_ferror(state->cleanup))
3432  state->err = CLEANUP_STAT_WRITE;
3433  }
3434  if (state->err == CLEANUP_STAT_OK)
3435  if (rec_fputs(state->cleanup, REC_TYPE_END, "") < 0
3436  || vstream_fflush(state->cleanup))
3437  state->err = CLEANUP_STAT_WRITE;
3438  if (state->err == 0) {
3439  why = vstring_alloc(10);
3440  state->err = mail_stream_finish(state->dest, why);
3441  printable(STR(why), ' ');
3442  } else
3443  mail_stream_cleanup(state->dest);
3444  state->dest = 0;
3445  state->cleanup = 0;
3446  }
3447 
3448  /*
3449  * XXX If we lose the cleanup server while it is editing a queue file,
3450  * the Postfix SMTP server will be out of sync with Milter applications.
3451  * Sending an ABORT to the Milters is not sufficient to restore
3452  * synchronization, because there may be any number of Milter replies
3453  * already in flight. Destroying and recreating the Milters (and faking
3454  * the connect and ehlo events) is too much trouble for testing and
3455  * maintenance. Workaround: force the Postfix SMTP server to hang up with
3456  * a 421 response in the rare case that the cleanup server breaks AND
3457  * that the remote SMTP client continues the session after end-of-data.
3458  *
3459  * XXX Should use something other than CLEANUP_STAT_WRITE when we lose
3460  * contact with the cleanup server. This requires changes to the
3461  * mail_stream module and its users (smtpd, qmqpd, perhaps sendmail).
3462  *
3463  * XXX See exception below in code that overrides state->access_denied for
3464  * compliance with RFC 2821 Sec 3.1.
3465  */
3466  if (state->milters != 0 && (state->err & CLEANUP_STAT_WRITE) != 0)
3467  state->access_denied = mystrdup("421 4.3.0 Mail system error");
3468 
3469  /*
3470  * Handle any errors. One message may suffer from multiple errors, so
3471  * complain only about the most severe error. Forgive any previous client
3472  * errors when a message was received successfully.
3473  *
3474  * See also: qmqpd.c
3475  */
3476 #define IS_SMTP_REJECT(s) \
3477  (((s)[0] == '4' || (s)[0] == '5') \
3478  && ISDIGIT((s)[1]) && ISDIGIT((s)[2]) \
3479  && ((s)[3] == '\0' || (s)[3] == ' ' || (s)[3] == '-'))
3480 
3481  if (state->err == CLEANUP_STAT_OK) {
3482  state->error_count = 0;
3483  state->error_mask = 0;
3484  state->junk_cmds = 0;
3485  if (proxy)
3486  smtpd_chat_reply(state, "%s", STR(proxy->reply));
3487  else
3488  smtpd_chat_reply(state,
3489  "250 2.0.0 Ok: queued as %s", state->queue_id);
3490  } else if (why && IS_SMTP_REJECT(STR(why))) {
3491  state->error_mask |= MAIL_ERROR_POLICY;
3492  smtpd_chat_reply(state, "%s", STR(why));
3493  } else if ((state->err & CLEANUP_STAT_DEFER) != 0) {
3494  state->error_mask |= MAIL_ERROR_POLICY;
3496  if (why && LEN(why) > 0) {
3497  /* Allow address-specific DSN status in header/body_checks. */
3498  smtpd_chat_reply(state, "%d %s", detail->smtp, STR(why));
3499  } else {
3500  smtpd_chat_reply(state, "%d %s Error: %s",
3501  detail->smtp, detail->dsn, detail->text);
3502  }
3503  } else if ((state->err & CLEANUP_STAT_BAD) != 0) {
3504  state->error_mask |= MAIL_ERROR_SOFTWARE;
3506  smtpd_chat_reply(state, "%d %s Error: internal error %d",
3507  detail->smtp, detail->dsn, state->err);
3508  } else if ((state->err & CLEANUP_STAT_SIZE) != 0) {
3509  state->error_mask |= MAIL_ERROR_BOUNCE;
3511  smtpd_chat_reply(state, "%d %s Error: %s",
3512  detail->smtp, detail->dsn, detail->text);
3513  } else if ((state->err & CLEANUP_STAT_HOPS) != 0) {
3514  state->error_mask |= MAIL_ERROR_BOUNCE;
3516  smtpd_chat_reply(state, "%d %s Error: %s",
3517  detail->smtp, detail->dsn, detail->text);
3518  } else if ((state->err & CLEANUP_STAT_CONT) != 0) {
3519  state->error_mask |= MAIL_ERROR_POLICY;
3521  if (proxy) {
3522  smtpd_chat_reply(state, "%s", STR(proxy->reply));
3523  } else if (why && LEN(why) > 0) {
3524  /* Allow address-specific DSN status in header/body_checks. */
3525  smtpd_chat_reply(state, "%d %s", detail->smtp, STR(why));
3526  } else {
3527  smtpd_chat_reply(state, "%d %s Error: %s",
3528  detail->smtp, detail->dsn, detail->text);
3529  }
3530  } else if ((state->err & CLEANUP_STAT_WRITE) != 0) {
3531  state->error_mask |= MAIL_ERROR_RESOURCE;
3533  smtpd_chat_reply(state, "%d %s Error: %s",
3534  detail->smtp, detail->dsn, detail->text);
3535  } else if ((state->err & CLEANUP_STAT_PROXY) != 0) {
3536  state->error_mask |= MAIL_ERROR_SOFTWARE;
3537  smtpd_chat_reply(state, "%s", STR(proxy->reply));
3538  } else {
3539  state->error_mask |= MAIL_ERROR_SOFTWARE;
3541  smtpd_chat_reply(state, "%d %s Error: internal error %d",
3542  detail->smtp, detail->dsn, state->err);
3543  }
3544 
3545  /*
3546  * By popular command: the proxy's end-of-data reply.
3547  */
3548  if (proxy)
3549  msg_info("proxy-%s: %s: %s;%s",
3550  (state->err == CLEANUP_STAT_OK) ? "accept" : "reject",
3551  state->where, STR(proxy->reply), smtpd_whatsup(state));
3552 
3553  /*
3554  * Cleanup. The client may send another MAIL command.
3555  */
3556  saved_err = state->err;
3557  chat_reset(state, var_smtpd_hist_thrsh);
3558  mail_reset(state);
3559  rcpt_reset(state);
3560  if (why)
3561  vstring_free(why);
3562  return (saved_err);
3563 }
3564 
3565 /* rset_cmd - process RSET */
3566 
3567 static int rset_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *unused_argv)
3568 {
3569 
3570  /*
3571  * Sanity checks.
3572  */
3573  if (argc != 1) {
3574  state->error_mask |= MAIL_ERROR_PROTOCOL;
3575  smtpd_chat_reply(state, "501 5.5.4 Syntax: RSET");
3576  return (-1);
3577  }
3578 
3579  /*
3580  * Restore state to right after HELO/EHLO command.
3581  */
3582  chat_reset(state, var_smtpd_hist_thrsh);
3583  mail_reset(state);
3584  rcpt_reset(state);
3585  smtpd_chat_reply(state, "250 2.0.0 Ok");
3586  return (0);
3587 }
3588 
3589 /* noop_cmd - process NOOP */
3590 
3591 static int noop_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *unused_argv)
3592 {
3593 
3594  /*
3595  * XXX 2821 incompatibility: Section 4.1.1.9 says that NOOP can have a
3596  * parameter string which is to be ignored. NOOP instructions with
3597  * parameters? Go figure.
3598  *
3599  * RFC 2821 violates RFC 821, which says that NOOP takes no parameters.
3600  */
3601 #ifdef RFC821_SYNTAX
3602 
3603  /*
3604  * Sanity checks.
3605  */
3606  if (argc != 1) {
3607  state->error_mask |= MAIL_ERROR_PROTOCOL;
3608  smtpd_chat_reply(state, "501 5.5.4 Syntax: NOOP");
3609  return (-1);
3610  }
3611 #endif
3612  smtpd_chat_reply(state, "250 2.0.0 Ok");
3613  return (0);
3614 }
3615 
3616 /* vrfy_cmd - process VRFY */
3617 
3618 static int vrfy_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
3619 {
3620  const char *err = 0;
3621  int rate;
3622  int smtputf8 = 0;
3623  int saved_flags;
3624 
3625  /*
3626  * The SMTP standard (RFC 821) disallows unquoted special characters in
3627  * the VRFY argument. Common practice violates the standard, however.
3628  * Postfix accommodates common practice where it violates the standard.
3629  *
3630  * XXX Impedance mismatch! The SMTP command tokenizer preserves quoting,
3631  * whereas the recipient restrictions checks expect unquoted (internal)
3632  * address forms. Therefore we must parse out the address, or we must
3633  * stop doing recipient restriction checks and lose the opportunity to
3634  * say "user unknown" at the SMTP port.
3635  *
3636  * XXX 2821 incompatibility and brain damage: Section 4.5.1 requires that
3637  * VRFY is implemented. RFC 821 specifies that VRFY is optional. It gets
3638  * even worse: section 3.5.3 says that a 502 (command recognized but not
3639  * implemented) reply is not fully compliant.
3640  *
3641  * Thus, an RFC 2821 compliant implementation cannot refuse to supply
3642  * information in reply to VRFY queries. That is simply bogus. The only
3643  * reply we could supply is a generic 252 reply. This causes spammers to
3644  * add tons of bogus addresses to their mailing lists (spam harvesting by
3645  * trying out large lists of potential recipient names with VRFY).
3646  */
3647 #define SLOPPY 0
3648 
3649  if (var_disable_vrfy_cmd) {
3650  state->error_mask |= MAIL_ERROR_POLICY;
3651  smtpd_chat_reply(state, "502 5.5.1 VRFY command is disabled");
3652  return (-1);
3653  }
3654  /* Fix 20140707: handle missing address. */
3656  && (state->ehlo_discard_mask & EHLO_MASK_SMTPUTF8) == 0
3657  && argc > 1 && strcasecmp(argv[argc - 1].strval, "SMTPUTF8") == 0) {
3658  argc--; /* RFC 6531 */
3659  smtputf8 = 1;
3660  }
3661  if (argc < 2) {
3662  state->error_mask |= MAIL_ERROR_PROTOCOL;
3663  smtpd_chat_reply(state, "501 5.5.4 Syntax: VRFY address%s",
3664  var_smtputf8_enable ? " [SMTPUTF8]" : "");
3665  return (-1);
3666  }
3667 
3668  /*
3669  * XXX The client event count/rate control must be consistent in its use
3670  * of client address information in connect and disconnect events. For
3671  * now we exclude xclient authorized hosts from event count/rate control.
3672  */
3673  if (SMTPD_STAND_ALONE(state) == 0
3674  && !xclient_allowed
3675  && anvil_clnt
3676  && var_smtpd_crcpt_limit > 0
3677  && !namadr_list_match(hogger_list, state->name, state->addr)
3678  && anvil_clnt_rcpt(anvil_clnt, state->service, state->addr,
3679  &rate) == ANVIL_STAT_OK
3680  && rate > var_smtpd_crcpt_limit) {
3681  state->error_mask |= MAIL_ERROR_POLICY;
3682  msg_warn("Recipient address rate limit exceeded: %d from %s for service %s",
3683  rate, state->namaddr, state->service);
3684  smtpd_chat_reply(state, "450 4.7.1 Error: too many recipients from %s",
3685  state->addr);
3686  return (-1);
3687  }
3688  if (state->milters != 0 && (err = milter_other_event(state->milters)) != 0
3689  && (err[0] == '5' || err[0] == '4')) {
3690  state->error_mask |= MAIL_ERROR_POLICY;
3691  smtpd_chat_reply(state, "%s", err);
3692  return (-1);
3693  }
3694  if (argc > 2)
3695  collapse_args(argc - 1, argv + 1);
3696  if (extract_addr(state, argv + 1, REJECT_EMPTY_ADDR, SLOPPY, smtputf8) != 0) {
3697  state->error_mask |= MAIL_ERROR_PROTOCOL;
3698  smtpd_chat_reply(state, "501 5.1.3 Bad recipient address syntax");
3699  return (-1);
3700  }
3701  /* Fix 20140707: Check the VRFY command. */
3702  if (smtputf8 == 0 && var_strict_smtputf8) {
3703  if (*STR(state->addr_buf) && !allascii(STR(state->addr_buf))) {
3704  mail_reset(state);
3705  smtpd_chat_reply(state, "553 5.6.7 Must declare SMTPUTF8 to send unicode address");
3706  return (-1);
3707  }
3708  }
3709  /* Use state->addr_buf, with the unquoted result from extract_addr() */
3710  if (SMTPD_STAND_ALONE(state) == 0) {
3711  /* Fix 20161206: allow UTF8 in smtpd_recipient_restrictions. */
3712  saved_flags = state->flags;
3713  if (smtputf8)
3714  state->flags |= SMTPD_FLAG_SMTPUTF8;
3715  err = smtpd_check_rcpt(state, STR(state->addr_buf));
3716  state->flags = saved_flags;
3717  if (err != 0) {
3718  smtpd_chat_reply(state, "%s", err);
3719  return (-1);
3720  }
3721  }
3722 
3723  /*
3724  * XXX 2821 new feature: Section 3.5.1 requires that the VRFY response is
3725  * either "full name <user@domain>" or "user@domain". Postfix replies
3726  * with the string that was provided by the client, whether or not it is
3727  * in fully qualified domain form and the address is in <>.
3728  *
3729  * Reply code 250 is reserved for the case where the address is verified;
3730  * reply code 252 should be used when no definitive certainty exists.
3731  */
3732  smtpd_chat_reply(state, "252 2.0.0 %s", argv[1].strval);
3733  return (0);
3734 }
3735 
3736 /* etrn_cmd - process ETRN command */
3737 
3738 static int etrn_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
3739 {
3740  const char *err;
3741 
3742  /*
3743  * Sanity checks.
3744  */
3745  if (var_helo_required && state->helo_name == 0) {
3746  state->error_mask |= MAIL_ERROR_POLICY;
3747  smtpd_chat_reply(state, "503 Error: send HELO/EHLO first");
3748  return (-1);
3749  }
3750  if (state->milters != 0 && (err = milter_other_event(state->milters)) != 0
3751  && (err[0] == '5' || err[0] == '4')) {
3752  state->error_mask |= MAIL_ERROR_POLICY;
3753  smtpd_chat_reply(state, "%s", err);
3754  return (-1);
3755  }
3756  if (SMTPD_IN_MAIL_TRANSACTION(state)) {
3757  state->error_mask |= MAIL_ERROR_PROTOCOL;
3758  smtpd_chat_reply(state, "503 Error: MAIL transaction in progress");
3759  return (-1);
3760  }
3761  if (argc != 2) {
3762  state->error_mask |= MAIL_ERROR_PROTOCOL;
3763  smtpd_chat_reply(state, "500 Syntax: ETRN domain");
3764  return (-1);
3765  }
3766  if (argv[1].strval[0] == '@' || argv[1].strval[0] == '#')
3767  argv[1].strval++;
3768 
3769  /*
3770  * As an extension to RFC 1985 we also allow an RFC 2821 address literal
3771  * enclosed in [].
3772  *
3773  * XXX There does not appear to be an ETRN parameter to indicate that the
3774  * domain name is UTF-8.
3775  */
3776  if (!valid_hostname(argv[1].strval, DONT_GRIPE)
3777  && !valid_mailhost_literal(argv[1].strval, DONT_GRIPE)) {
3778  state->error_mask |= MAIL_ERROR_PROTOCOL;
3779  smtpd_chat_reply(state, "501 Error: invalid parameter syntax");
3780  return (-1);
3781  }
3782 
3783  /*
3784  * XXX The implementation borrows heavily from the code that implements
3785  * UCE restrictions. These typically return 450 or 550 when a request is
3786  * rejected. RFC 1985 requires that 459 be sent when the server refuses
3787  * to perform the request.
3788  */
3789  if (SMTPD_STAND_ALONE(state)) {
3790  msg_warn("do not use ETRN in \"sendmail -bs\" mode");
3791  smtpd_chat_reply(state, "458 Unable to queue messages");
3792  return (-1);
3793  }
3794  if ((err = smtpd_check_etrn(state, argv[1].strval)) != 0) {
3795  smtpd_chat_reply(state, "%s", err);
3796  return (-1);
3797  }
3798  switch (flush_send_site(argv[1].strval)) {
3799  case FLUSH_STAT_OK:
3800  smtpd_chat_reply(state, "250 Queuing started");
3801  return (0);
3802  case FLUSH_STAT_DENY:
3803  msg_warn("reject: ETRN %.100s... from %s",
3804  argv[1].strval, state->namaddr);
3805  smtpd_chat_reply(state, "459 <%s>: service unavailable",
3806  argv[1].strval);
3807  return (-1);
3808  case FLUSH_STAT_BAD:
3809  msg_warn("bad ETRN %.100s... from %s", argv[1].strval, state->namaddr);
3810  smtpd_chat_reply(state, "458 Unable to queue messages");
3811  return (-1);
3812  default:
3813  msg_warn("unable to talk to fast flush service");
3814  smtpd_chat_reply(state, "458 Unable to queue messages");
3815  return (-1);
3816  }
3817 }
3818 
3819 /* quit_cmd - process QUIT command */
3820 
3821 static int quit_cmd(SMTPD_STATE *state, int unused_argc, SMTPD_TOKEN *unused_argv)
3822 {
3823  int out_pending = vstream_bufstat(state->client, VSTREAM_BST_OUT_PEND);
3824 
3825  /*
3826  * Don't bother checking the syntax.
3827  */
3828  smtpd_chat_reply(state, "221 2.0.0 Bye");
3829 
3830  /*
3831  * When the "." and quit replies are pipelined, make sure they are
3832  * flushed now, to avoid repeated mail deliveries in case of a crash in
3833  * the "clean up before disconnect" code.
3834  *
3835  * XXX When this was added in Postfix 2.1 we used vstream_fflush(). As of
3836  * Postfix 2.3 we use smtp_flush() for better error reporting.
3837  */
3838  if (out_pending > 0)
3839  smtp_flush(state->client);
3840  return (0);
3841 }
3842 
3843 /* xclient_cmd - override SMTP client attributes */
3844 
3845 static int xclient_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
3846 {
3847  SMTPD_TOKEN *argp;
3848  char *raw_value;
3849  char *attr_value;
3850  const char *bare_value;
3851  char *attr_name;
3852  int update_namaddr = 0;
3853  int name_status;
3854  static const NAME_CODE peer_codes[] = {
3857  0, SMTPD_PEER_CODE_OK,
3858  };
3859  static const NAME_CODE proto_names[] = {
3860  MAIL_PROTO_SMTP, 1,
3861  MAIL_PROTO_ESMTP, 2,
3862  0, -1,
3863  };
3864  int got_helo = 0;
3865  int got_proto = 0;
3866 
3867 #ifdef USE_SASL_AUTH
3868  int got_login = 0;
3869  char *saved_username;
3870 
3871 #endif
3872 
3873  /*
3874  * Sanity checks.
3875  *
3876  * XXX The XCLIENT command will override its own access control, so that
3877  * connection count/rate restrictions can be correctly simulated.
3878  */
3879  if (SMTPD_IN_MAIL_TRANSACTION(state)) {
3880  state->error_mask |= MAIL_ERROR_PROTOCOL;
3881  smtpd_chat_reply(state, "503 5.5.1 Error: MAIL transaction in progress");
3882  return (-1);
3883  }
3884  if (argc < 2) {
3885  state->error_mask |= MAIL_ERROR_PROTOCOL;
3886  smtpd_chat_reply(state, "501 5.5.4 Syntax: %s attribute=value...",
3887  XCLIENT_CMD);
3888  return (-1);
3889  }
3890  if (xclient_hosts && xclient_hosts->error)
3891  cant_permit_command(state, XCLIENT_CMD);
3892  if (!xclient_allowed) {
3893  state->error_mask |= MAIL_ERROR_POLICY;
3894  smtpd_chat_reply(state, "550 5.7.0 Error: insufficient authorization");
3895  return (-1);
3896  }
3897 #define STREQ(x,y) (strcasecmp((x), (y)) == 0)
3898 #define UPDATE_STR(s, v) do { \
3899  const char *_v = (v); \
3900  if (s) myfree(s); \
3901  s = (_v) ? mystrdup(_v) : 0; \
3902  } while(0)
3903 
3904  /*
3905  * Initialize.
3906  */
3907  if (state->expand_buf == 0)
3908  state->expand_buf = vstring_alloc(100);
3909 
3910  /*
3911  * Iterate over all attribute=value elements.
3912  */
3913  for (argp = argv + 1; argp < argv + argc; argp++) {
3914  attr_name = argp->strval;
3915 
3916  if ((raw_value = split_at(attr_name, '=')) == 0 || *raw_value == 0) {
3917  state->error_mask |= MAIL_ERROR_PROTOCOL;
3918  smtpd_chat_reply(state, "501 5.5.4 Error: attribute=value expected");
3919  return (-1);
3920  }
3921  if (strlen(raw_value) > 255) {
3922  state->error_mask |= MAIL_ERROR_PROTOCOL;
3923  smtpd_chat_reply(state, "501 5.5.4 Error: attribute value too long");
3924  return (-1);
3925  }
3926 
3927  /*
3928  * Backwards compatibility: Postfix prior to version 2.3 does not
3929  * xtext encode attribute values.
3930  */
3931  attr_value = xtext_unquote(state->expand_buf, raw_value) ?
3932  STR(state->expand_buf) : raw_value;
3933 
3934  /*
3935  * For safety's sake mask non-printable characters. We'll do more
3936  * specific censoring later.
3937  */
3938  printable(attr_value, '?');
3939 
3940  /*
3941  * NAME=substitute SMTP client hostname (and reverse/forward name, in
3942  * case of success). Also updates the client hostname lookup status
3943  * code.
3944  */
3945  if (STREQ(attr_name, XCLIENT_NAME)) {
3946  name_status = name_code(peer_codes, NAME_CODE_FLAG_NONE, attr_value);
3947  if (name_status != SMTPD_PEER_CODE_OK) {
3948  attr_value = CLIENT_NAME_UNKNOWN;
3949  } else {
3950  /* XXX EAI */
3951  if (!valid_hostname(attr_value, DONT_GRIPE)) {
3952  state->error_mask |= MAIL_ERROR_PROTOCOL;
3953  smtpd_chat_reply(state, "501 5.5.4 Bad %s syntax: %s",
3954  XCLIENT_NAME, attr_value);
3955  return (-1);
3956  }
3957  }
3958  state->name_status = name_status;
3959  UPDATE_STR(state->name, attr_value);
3960  update_namaddr = 1;
3961  if (name_status == SMTPD_PEER_CODE_OK) {
3962  UPDATE_STR(state->reverse_name, attr_value);
3963  state->reverse_name_status = name_status;
3964  }
3965  }
3966 
3967  /*
3968  * REVERSE_NAME=substitute SMTP client reverse hostname. Also updates
3969  * the client reverse hostname lookup status code.
3970  */
3971  else if (STREQ(attr_name, XCLIENT_REVERSE_NAME)) {
3972  name_status = name_code(peer_codes, NAME_CODE_FLAG_NONE, attr_value);
3973  if (name_status != SMTPD_PEER_CODE_OK) {
3974  attr_value = CLIENT_NAME_UNKNOWN;
3975  } else {
3976  /* XXX EAI */
3977  if (!valid_hostname(attr_value, DONT_GRIPE)) {
3978  state->error_mask |= MAIL_ERROR_PROTOCOL;
3979  smtpd_chat_reply(state, "501 5.5.4 Bad %s syntax: %s",
3980  XCLIENT_REVERSE_NAME, attr_value);
3981  return (-1);
3982  }
3983  }
3984  state->reverse_name_status = name_status;
3985  UPDATE_STR(state->reverse_name, attr_value);
3986  }
3987 
3988  /*
3989  * ADDR=substitute SMTP client network address.
3990  */
3991  else if (STREQ(attr_name, XCLIENT_ADDR)) {
3992  if (STREQ(attr_value, XCLIENT_UNAVAILABLE)) {
3993  attr_value = CLIENT_ADDR_UNKNOWN;
3994  bare_value = attr_value;
3995  } else {
3996  if ((bare_value = valid_mailhost_addr(attr_value, DONT_GRIPE)) == 0) {
3997  state->error_mask |= MAIL_ERROR_PROTOCOL;
3998  smtpd_chat_reply(state, "501 5.5.4 Bad %s syntax: %s",
3999  XCLIENT_ADDR, attr_value);
4000  return (-1);
4001  }
4002  }
4003  UPDATE_STR(state->addr, bare_value);
4004  UPDATE_STR(state->rfc_addr, attr_value);
4005 #ifdef HAS_IPV6
4006  if (strncasecmp(attr_value, INET_PROTO_NAME_IPV6 ":",
4007  sizeof(INET_PROTO_NAME_IPV6 ":") - 1) == 0)
4008  state->addr_family = AF_INET6;
4009  else
4010 #endif
4011  state->addr_family = AF_INET;
4012  update_namaddr = 1;
4013  }
4014 
4015  /*
4016  * PORT=substitute SMTP client port number.
4017  */
4018  else if (STREQ(attr_name, XCLIENT_PORT)) {
4019  if (STREQ(attr_value, XCLIENT_UNAVAILABLE)) {
4020  attr_value = CLIENT_PORT_UNKNOWN;
4021  } else {
4022  if (!alldig(attr_value)
4023  || strlen(attr_value) > sizeof("65535") - 1) {
4024  state->error_mask |= MAIL_ERROR_PROTOCOL;
4025  smtpd_chat_reply(state, "501 5.5.4 Bad %s syntax: %s",
4026  XCLIENT_PORT, attr_value);
4027  return (-1);
4028  }
4029  }
4030  UPDATE_STR(state->port, attr_value);
4031  update_namaddr = 1;
4032  }
4033 
4034  /*
4035  * HELO=substitute SMTP client HELO parameter. Censor special
4036  * characters that could mess up message headers.
4037  */
4038  else if (STREQ(attr_name, XCLIENT_HELO)) {
4039  if (STREQ(attr_value, XCLIENT_UNAVAILABLE)) {
4040  attr_value = CLIENT_HELO_UNKNOWN;
4041  } else {
4042  if (strlen(attr_value) > VALID_HOSTNAME_LEN) {
4043  state->error_mask |= MAIL_ERROR_PROTOCOL;
4044  smtpd_chat_reply(state, "501 5.5.4 Bad %s syntax: %s",
4045  XCLIENT_HELO, attr_value);
4046  return (-1);
4047  }
4048  neuter(attr_value, NEUTER_CHARACTERS, '?');
4049  }
4050  UPDATE_STR(state->helo_name, attr_value);
4051  got_helo = 1;
4052  }
4053 
4054  /*
4055  * PROTO=SMTP protocol name.
4056  */
4057  else if (STREQ(attr_name, XCLIENT_PROTO)) {
4058  if (name_code(proto_names, NAME_CODE_FLAG_NONE, attr_value) < 0) {
4059  state->error_mask |= MAIL_ERROR_PROTOCOL;
4060  smtpd_chat_reply(state, "501 5.5.4 Bad %s syntax: %s",
4061  XCLIENT_PROTO, attr_value);
4062  return (-1);
4063  }
4064  UPDATE_STR(state->protocol, uppercase(attr_value));
4065  got_proto = 1;
4066  }
4067 
4068  /*
4069  * LOGIN=sasl_username. Sets the authentication method as XCLIENT.
4070  * This can be used even if SASL authentication is turned off in
4071  * main.cf. We can't make it easier than that.
4072  */
4073 #ifdef USE_SASL_AUTH
4074  else if (STREQ(attr_name, XCLIENT_LOGIN)) {
4075  if (STREQ(attr_value, XCLIENT_UNAVAILABLE) == 0) {
4076  smtpd_sasl_auth_extern(state, attr_value, XCLIENT_CMD);
4077  got_login = 1;
4078  }
4079  }
4080 #endif
4081 
4082  /*
4083  * DESTADDR=substitute SMTP server network address.
4084  */
4085  else if (STREQ(attr_name, XCLIENT_DESTADDR)) {
4086  if (STREQ(attr_value, XCLIENT_UNAVAILABLE)) {
4087  attr_value = SERVER_ADDR_UNKNOWN;
4088  bare_value = attr_value;
4089  } else {
4090  if ((bare_value = valid_mailhost_addr(attr_value, DONT_GRIPE)) == 0) {
4091  state->error_mask |= MAIL_ERROR_PROTOCOL;
4092  smtpd_chat_reply(state, "501 5.5.4 Bad %s syntax: %s",
4093  XCLIENT_DESTADDR, attr_value);
4094  return (-1);
4095  }
4096  }
4097  UPDATE_STR(state->dest_addr, bare_value);
4098  /* XXX Require same address family as client address. */
4099  }
4100 
4101  /*
4102  * DESTPORT=substitute SMTP server port number.
4103  */
4104  else if (STREQ(attr_name, XCLIENT_DESTPORT)) {
4105  if (STREQ(attr_value, XCLIENT_UNAVAILABLE)) {
4106  attr_value = SERVER_PORT_UNKNOWN;
4107  } else {
4108  if (!alldig(attr_value)
4109  || strlen(attr_value) > sizeof("65535") - 1) {
4110  state->error_mask |= MAIL_ERROR_PROTOCOL;
4111  smtpd_chat_reply(state, "501 5.5.4 Bad %s syntax: %s",
4112  XCLIENT_DESTPORT, attr_value);
4113  return (-1);
4114  }
4115  }
4116  UPDATE_STR(state->dest_port, attr_value);
4117  }
4118 
4119  /*
4120  * Unknown attribute name. Complain.
4121  */
4122  else {
4123  state->error_mask |= MAIL_ERROR_PROTOCOL;
4124  smtpd_chat_reply(state, "501 5.5.4 Bad %s attribute name: %s",
4125  XCLIENT_CMD, attr_name);
4126  return (-1);
4127  }
4128  }
4129 
4130  /*
4131  * Update the combined name and address when either has changed.
4132  */
4133  if (update_namaddr) {
4134  if (state->namaddr)
4135  myfree(state->namaddr);
4136  state->namaddr =
4137  SMTPD_BUILD_NAMADDRPORT(state->name, state->addr, state->port);
4138  }
4139 
4140  /*
4141  * XXX Compatibility: when the client issues XCLIENT then we have to go
4142  * back to initial server greeting stage, otherwise we can't correctly
4143  * simulate smtpd_client_restrictions (with smtpd_delay_reject=0) and
4144  * Milter connect restrictions.
4145  *
4146  * XXX Compatibility: for accurate simulation we must also reset the HELO
4147  * information. We keep the information if it was specified in the
4148  * XCLIENT command.
4149  *
4150  * XXX The client connection count/rate control must be consistent in its
4151  * use of client address information in connect and disconnect events. We
4152  * re-evaluate xclient so that we correctly simulate connection
4153  * concurrency and connection rate restrictions.
4154  *
4155  * XXX Duplicated from smtpd_proto().
4156  */
4157  xclient_allowed =
4158  namadr_list_match(xclient_hosts, state->name, state->addr);
4159  /* NOT: tls_reset() */
4160  if (got_helo == 0)
4161  helo_reset(state);
4162  if (got_proto == 0 && strcasecmp(state->protocol, MAIL_PROTO_SMTP) != 0) {
4163  myfree(state->protocol);
4164  state->protocol = mystrdup(MAIL_PROTO_SMTP);
4165  }
4166 #ifdef USE_SASL_AUTH
4167  /* XXX What if they send the parameters via multiple commands? */
4168  if (got_login == 0)
4169  smtpd_sasl_auth_reset(state);
4170  if (smtpd_sasl_is_active(state)) {
4171  if (got_login)
4172  saved_username = mystrdup(state->sasl_username);
4173  smtpd_sasl_deactivate(state);
4174 #ifdef USE_TLS
4175  if (state->tls_context != 0) /* TLS from XCLIENT proxy? */
4178  else
4179 #endif
4182  if (got_login) {
4183  smtpd_sasl_auth_extern(state, saved_username, XCLIENT_CMD);
4184  myfree(saved_username);
4185  }
4186  }
4187 #endif
4188  chat_reset(state, 0);
4189  mail_reset(state);
4190  rcpt_reset(state);
4191  if (state->milters)
4192  milter_disc_event(state->milters);
4193  /* Following duplicates the top-level connect/disconnect handler. */
4194  teardown_milters(state);
4195  setup_milters(state);
4197  return (0);
4198 }
4199 
4200 /* xforward_cmd - forward logging attributes */
4201 
4202 static int xforward_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
4203 {
4204  SMTPD_TOKEN *argp;
4205  char *raw_value;
4206  char *attr_value;
4207  const char *bare_value;
4208  char *attr_name;
4209  int updated = 0;
4210  static const NAME_CODE xforward_flags[] = {
4218  0, 0,
4219  };
4220  static const char *context_name[] = {
4221  MAIL_ATTR_RWR_LOCAL, /* Postfix internal form */
4222  MAIL_ATTR_RWR_REMOTE, /* Postfix internal form */
4223  };
4224  static const NAME_CODE xforward_to_context[] = {
4225  XFORWARD_DOM_LOCAL, 0, /* XFORWARD representation */
4226  XFORWARD_DOM_REMOTE, 1, /* XFORWARD representation */
4227  0, -1,
4228  };
4229  int flag;
4230  int context_code;
4231 
4232  /*
4233  * Sanity checks.
4234  */
4235  if (SMTPD_IN_MAIL_TRANSACTION(state)) {
4236  state->error_mask |= MAIL_ERROR_PROTOCOL;
4237  smtpd_chat_reply(state, "503 5.5.1 Error: MAIL transaction in progress");
4238  return (-1);
4239  }
4240  if (argc < 2) {
4241  state->error_mask |= MAIL_ERROR_PROTOCOL;
4242  smtpd_chat_reply(state, "501 5.5.4 Syntax: %s attribute=value...",
4243  XFORWARD_CMD);
4244  return (-1);
4245  }
4246  if (xforward_hosts && xforward_hosts->error)
4247  cant_permit_command(state, XFORWARD_CMD);
4248  if (!xforward_allowed) {
4249  state->error_mask |= MAIL_ERROR_POLICY;
4250  smtpd_chat_reply(state, "550 5.7.0 Error: insufficient authorization");
4251  return (-1);
4252  }
4253 
4254  /*
4255  * Initialize.
4256  */
4257  if (state->xforward.flags == 0)
4258  smtpd_xforward_preset(state);
4259  if (state->expand_buf == 0)
4260  state->expand_buf = vstring_alloc(100);
4261 
4262  /*
4263  * Iterate over all attribute=value elements.
4264  */
4265  for (argp = argv + 1; argp < argv + argc; argp++) {
4266  attr_name = argp->strval;
4267 
4268  if ((raw_value = split_at(attr_name, '=')) == 0 || *raw_value == 0) {
4269  state->error_mask |= MAIL_ERROR_PROTOCOL;
4270  smtpd_chat_reply(state, "501 5.5.4 Error: attribute=value expected");
4271  return (-1);
4272  }
4273  if (strlen(raw_value) > 255) {
4274  state->error_mask |= MAIL_ERROR_PROTOCOL;
4275  smtpd_chat_reply(state, "501 5.5.4 Error: attribute value too long");
4276  return (-1);
4277  }
4278 
4279  /*
4280  * Backwards compatibility: Postfix prior to version 2.3 does not
4281  * xtext encode attribute values.
4282  */
4283  attr_value = xtext_unquote(state->expand_buf, raw_value) ?
4284  STR(state->expand_buf) : raw_value;
4285 
4286  /*
4287  * For safety's sake mask non-printable characters. We'll do more
4288  * specific censoring later.
4289  */
4290  printable(attr_value, '?');
4291 
4292  flag = name_code(xforward_flags, NAME_CODE_FLAG_NONE, attr_name);
4293  switch (flag) {
4294 
4295  /*
4296  * NAME=up-stream host name, not necessarily in the DNS. Censor
4297  * special characters that could mess up message headers.
4298  */
4300  if (STREQ(attr_value, XFORWARD_UNAVAILABLE)) {
4301  attr_value = CLIENT_NAME_UNKNOWN;
4302  } else {
4303  /* XXX EAI */
4304  neuter(attr_value, NEUTER_CHARACTERS, '?');
4305  if (!valid_hostname(attr_value, DONT_GRIPE)) {
4306  state->error_mask |= MAIL_ERROR_PROTOCOL;
4307  smtpd_chat_reply(state, "501 5.5.4 Bad %s syntax: %s",
4308  XFORWARD_NAME, attr_value);
4309  return (-1);
4310  }
4311  }
4312  UPDATE_STR(state->xforward.name, attr_value);
4313  break;
4314 
4315  /*
4316  * ADDR=up-stream host network address, not necessarily on the
4317  * Internet. Censor special characters that could mess up message
4318  * headers.
4319  */
4321  if (STREQ(attr_value, XFORWARD_UNAVAILABLE)) {
4322  attr_value = CLIENT_ADDR_UNKNOWN;
4323  bare_value = attr_value;
4324  } else {
4325  neuter(attr_value, NEUTER_CHARACTERS, '?');
4326  if ((bare_value = valid_mailhost_addr(attr_value, DONT_GRIPE)) == 0) {
4327  state->error_mask |= MAIL_ERROR_PROTOCOL;
4328  smtpd_chat_reply(state, "501 5.5.4 Bad %s syntax: %s",
4329  XFORWARD_ADDR, attr_value);
4330  return (-1);
4331  }
4332  }
4333  UPDATE_STR(state->xforward.addr, bare_value);
4334  UPDATE_STR(state->xforward.rfc_addr, attr_value);
4335  break;
4336 
4337  /*
4338  * PORT=up-stream port number.
4339  */
4341  if (STREQ(attr_value, XFORWARD_UNAVAILABLE)) {
4342  attr_value = CLIENT_PORT_UNKNOWN;
4343  } else {
4344  if (!alldig(attr_value)
4345  || strlen(attr_value) > sizeof("65535") - 1) {
4346  state->error_mask |= MAIL_ERROR_PROTOCOL;
4347  smtpd_chat_reply(state, "501 5.5.4 Bad %s syntax: %s",
4348  XFORWARD_PORT, attr_value);
4349  return (-1);
4350  }
4351  }
4352  UPDATE_STR(state->xforward.port, attr_value);
4353  break;
4354 
4355  /*
4356  * HELO=hostname that the up-stream MTA introduced itself with
4357  * (not necessarily SMTP HELO). Censor special characters that
4358  * could mess up message headers.
4359  */
4361  if (STREQ(attr_value, XFORWARD_UNAVAILABLE)) {
4362  attr_value = CLIENT_HELO_UNKNOWN;
4363  } else {
4364  neuter(attr_value, NEUTER_CHARACTERS, '?');
4365  }
4366  UPDATE_STR(state->xforward.helo_name, attr_value);
4367  break;
4368 
4369  /*
4370  * PROTO=up-stream protocol, not necessarily SMTP or ESMTP.
4371  * Censor special characters that could mess up message headers.
4372  */
4374  if (STREQ(attr_value, XFORWARD_UNAVAILABLE)) {
4375  attr_value = CLIENT_PROTO_UNKNOWN;
4376  } else {
4377  if (strlen(attr_value) > 64) {
4378  state->error_mask |= MAIL_ERROR_PROTOCOL;
4379  smtpd_chat_reply(state, "501 5.5.4 Bad %s syntax: %s",
4380  XFORWARD_PROTO, attr_value);
4381  return (-1);
4382  }
4383  neuter(attr_value, NEUTER_CHARACTERS, '?');
4384  }
4385  UPDATE_STR(state->xforward.protocol, attr_value);
4386  break;
4387 
4388  /*
4389  * IDENT=local message identifier on the up-stream MTA. Censor
4390  * special characters that could mess up logging or macro
4391  * expansions.
4392  */
4394  if (STREQ(attr_value, XFORWARD_UNAVAILABLE)) {
4395  attr_value = CLIENT_IDENT_UNKNOWN;
4396  } else {
4397  neuter(attr_value, NEUTER_CHARACTERS, '?');
4398  }
4399  UPDATE_STR(state->xforward.ident, attr_value);
4400  break;
4401 
4402  /*
4403  * DOMAIN=local or remote.
4404  */
4406  if (STREQ(attr_value, XFORWARD_UNAVAILABLE))
4407  attr_value = XFORWARD_DOM_LOCAL;
4408  if ((context_code = name_code(xforward_to_context,
4410  attr_value)) < 0) {
4411  state->error_mask |= MAIL_ERROR_PROTOCOL;
4412  smtpd_chat_reply(state, "501 5.5.4 Bad %s syntax: %s",
4413  XFORWARD_DOMAIN, attr_value);
4414  return (-1);
4415  }
4416  UPDATE_STR(state->xforward.domain, context_name[context_code]);
4417  break;
4418 
4419  /*
4420  * Unknown attribute name. Complain.
4421  */
4422  default:
4423  state->error_mask |= MAIL_ERROR_PROTOCOL;
4424  smtpd_chat_reply(state, "501 5.5.4 Bad %s attribute name: %s",
4425  XFORWARD_CMD, attr_name);
4426  return (-1);
4427  }
4428  updated |= flag;
4429  }
4430  state->xforward.flags |= updated;
4431 
4432  /*
4433  * Update the combined name and address when either has changed. Use only
4434  * the name when no address is available.
4435  */
4437  if (state->xforward.namaddr)
4438  myfree(state->xforward.namaddr);
4439  state->xforward.namaddr =
4442  state->xforward.addr,
4443  state->xforward.port) :
4444  mystrdup(state->xforward.name);
4445  }
4446  smtpd_chat_reply(state, "250 2.0.0 Ok");
4447  return (0);
4448 }
4449 
4450 /* chat_reset - notify postmaster and reset conversation log */
4451 
4452 static void chat_reset(SMTPD_STATE *state, int threshold)
4453 {
4454 
4455  /*
4456  * Notify the postmaster if there were errors. This usually indicates a
4457  * client configuration problem, or that someone is trying nasty things.
4458  * Either is significant enough to bother the postmaster. XXX Can't
4459  * report problems when running in stand-alone mode: postmaster notices
4460  * require availability of the cleanup service.
4461  */
4462  if (state->history != 0 && state->history->argc > threshold) {
4463  if (SMTPD_STAND_ALONE(state) == 0
4464  && (state->error_mask & state->notify_mask))
4465  smtpd_chat_notify(state);
4466  state->error_mask = 0;
4467  smtpd_chat_reset(state);
4468  }
4469 }
4470 
4471 #ifdef USE_TLS
4472 
4473 /* smtpd_start_tls - turn on TLS or force disconnect */
4474 
4475 static void smtpd_start_tls(SMTPD_STATE *state)
4476 {
4477  int rate;
4478  int cert_present;
4479  int requirecert;
4480 
4481 #ifdef USE_TLSPROXY
4482 
4483  /*
4484  * This is non-production code, for tlsproxy(8) load testing only. It
4485  * implements enough to enable some Postfix features that depend on TLS
4486  * encryption.
4487  *
4488  * To insert tlsproxy(8) between this process and the SMTP client, we swap
4489  * the file descriptors between the state->tlsproxy and state->client
4490  * VSTREAMS, so that we don't lose all the user-configurable
4491  * state->client attributes (such as longjump buffers or timeouts).
4492  *
4493  * As we implement tlsproxy support in the Postfix SMTP client we should
4494  * develop a usable abstraction that encapsulates this stream plumbing in
4495  * a library module.
4496  */
4498  vstream_control(state->client, CA_VSTREAM_CTL_SWAP_FD(state->tlsproxy),
4500  (void) vstream_fclose(state->tlsproxy); /* direct-to-client stream! */
4501  state->tlsproxy = 0;
4502 
4503  /*
4504  * After plumbing the plaintext stream, receive the TLS context object.
4505  * For this we must use the same VSTREAM buffer that we also use to
4506  * receive subsequent SMTP commands. The attribute protocol is robust
4507  * enough that an adversary cannot inject their own bogus TLS context
4508  * attributes into the stream.
4509  */
4510  state->tls_context = tls_proxy_context_receive(state->client);
4511 
4512  /*
4513  * XXX Maybe it is better to send this information to tlsproxy(8) when
4514  * requesting service, effectively making a remote tls_server_start()
4515  * call.
4516  */
4518 
4519 #else /* USE_TLSPROXY */
4520  TLS_SERVER_START_PROPS props;
4521  static char *cipher_grade;
4522  static VSTRING *cipher_exclusions;
4523 
4524  /*
4525  * Wrapper mode uses a dedicated port and always requires TLS.
4526  *
4527  * XXX In non-wrapper mode, it is possible to require client certificate
4528  * verification without requiring TLS. Since certificates can be verified
4529  * only while TLS is turned on, this means that Postfix will happily
4530  * perform SMTP transactions when the client does not use the STARTTLS
4531  * command. For this reason, Postfix does not require client certificate
4532  * verification unless TLS is required.
4533  *
4534  * The cipher grade and exclusions don't change between sessions. Compute
4535  * just once and cache.
4536  */
4537 #define ADD_EXCLUDE(vstr, str) \
4538  do { \
4539  if (*(str)) \
4540  vstring_sprintf_append((vstr), "%s%s", \
4541  VSTRING_LEN(vstr) ? " " : "", (str)); \
4542  } while (0)
4543 
4544  if (cipher_grade == 0) {
4545  cipher_grade = var_smtpd_enforce_tls ?
4547  cipher_exclusions = vstring_alloc(10);
4548  ADD_EXCLUDE(cipher_exclusions, var_smtpd_tls_excl_ciph);
4550  ADD_EXCLUDE(cipher_exclusions, var_smtpd_tls_mand_excl);
4551  if (ask_client_cert)
4552  ADD_EXCLUDE(cipher_exclusions, "aNULL");
4553  }
4554 
4555  /*
4556  * Perform the TLS handshake now. Check the client certificate
4557  * requirements later, if necessary.
4558  */
4560 
4561  state->tls_context =
4562  TLS_SERVER_START(&props,
4563  ctx = smtpd_tls_ctx,
4564  stream = state->client,
4565  fd = -1,
4566  timeout = var_smtpd_starttls_tmout,
4567  requirecert = requirecert,
4568  serverid = state->service,
4569  namaddr = state->namaddr,
4570  cipher_grade = cipher_grade,
4571  cipher_exclusions = STR(cipher_exclusions),
4572  mdalg = var_smtpd_tls_fpt_dgst);
4573 
4574 #endif /* USE_TLSPROXY */
4575 
4576  /*
4577  * For new (i.e. not re-used) TLS sessions, increment the client's new
4578  * TLS session rate counter. We enforce the limit here only for human
4579  * factors reasons (reduce the WTF factor), even though it is too late to
4580  * save the CPU that was already burnt on PKI ops. The real safety
4581  * mechanism applies with future STARTTLS commands (or wrappermode
4582  * connections), prior to the SSL handshake.
4583  *
4584  * XXX The client event count/rate control must be consistent in its use of
4585  * client address information in connect and disconnect events. For now
4586  * we exclude xclient authorized hosts from event count/rate control.
4587  */
4588  if (var_smtpd_cntls_limit > 0
4589  && (state->tls_context == 0 || state->tls_context->session_reused == 0)
4590  && SMTPD_STAND_ALONE(state) == 0
4591  && !xclient_allowed
4592  && anvil_clnt
4593  && !namadr_list_match(hogger_list, state->name, state->addr)
4594  && anvil_clnt_newtls(anvil_clnt, state->service, state->addr,
4595  &rate) == ANVIL_STAT_OK
4596  && rate > var_smtpd_cntls_limit) {
4597  state->error_mask |= MAIL_ERROR_POLICY;
4598  msg_warn("New TLS session rate limit exceeded: %d from %s for service %s",
4599  rate, state->namaddr, state->service);
4600  if (state->tls_context)
4601  smtpd_chat_reply(state,
4602  "421 4.7.0 %s Error: too many new TLS sessions from %s",
4603  var_myhostname, state->namaddr);
4604  /* XXX Use regular return to signal end of session. */
4606  }
4607 
4608  /*
4609  * When the TLS handshake fails, the conversation is in an unknown state.
4610  * There is nothing we can do except to disconnect from the client.
4611  */
4612  if (state->tls_context == 0)
4614 
4615  /*
4616  * If we are requiring verified client certs, enforce the constraint
4617  * here. We have a usable TLS session with the client, so no need to
4618  * disable I/O, ... we can even be polite and send "421 ...".
4619  */
4620  if (requirecert && TLS_CERT_IS_TRUSTED(state->tls_context) == 0) {
4621 
4622  /*
4623  * Fetch and reject the next command (should be EHLO), then
4624  * disconnect (side-effect of returning "421 ...".
4625  */
4626  cert_present = TLS_CERT_IS_PRESENT(state->tls_context);
4627  msg_info("NOQUEUE: abort: TLS from %s: %s",
4628  state->namaddr, cert_present ?
4629  "Client certificate not trusted" :
4630  "No client certificate presented");
4631  smtpd_chat_query(state);
4632  smtpd_chat_reply(state, "421 4.7.1 %s Error: %s",
4633  var_myhostname, cert_present ?
4634  "Client certificate not trusted" :
4635  "No client certificate presented");
4636  state->error_mask |= MAIL_ERROR_POLICY;
4637  return;
4638  }
4639 
4640  /*
4641  * When TLS is turned on, we may offer AUTH methods that would not be
4642  * offered within a plain-text session.
4643  *
4644  * XXX Always refresh SASL the mechanism list after STARTTLS. Dovecot
4645  * responses may depend on whether the SMTP connection is encrypted.
4646  */
4647 #ifdef USE_SASL_AUTH
4648  if (var_smtpd_sasl_enable) {
4649  /* Non-wrappermode, presumably. */
4650  if (smtpd_sasl_is_active(state)) {
4651  smtpd_sasl_auth_reset(state);
4652  smtpd_sasl_deactivate(state);
4653  }
4654  /* Wrappermode and non-wrappermode. */
4655  if (smtpd_sasl_is_active(state) == 0)
4658  }
4659 #endif
4660 }
4661 
4662 /* starttls_cmd - respond to STARTTLS */
4663 
4664 static int starttls_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *unused_argv)
4665 {
4666  const char *err;
4667  int rate;
4668 
4669  if (argc != 1) {
4670  state->error_mask |= MAIL_ERROR_PROTOCOL;
4671  smtpd_chat_reply(state, "501 5.5.4 Syntax: STARTTLS");
4672  return (-1);
4673  }
4674  if (state->milters != 0 && (err = milter_other_event(state->milters)) != 0) {
4675  if (err[0] == '5') {
4676  state->error_mask |= MAIL_ERROR_POLICY;
4677  smtpd_chat_reply(state, "%s", err);
4678  return (-1);
4679  }
4680  /* Sendmail compatibility: map 4xx into 454. */
4681  else if (err[0] == '4') {
4682  state->error_mask |= MAIL_ERROR_POLICY;
4683  smtpd_chat_reply(state, "454 4.3.0 Try again later");
4684  return (-1);
4685  }
4686  }
4687  if (state->tls_context != 0) {
4688  state->error_mask |= MAIL_ERROR_PROTOCOL;
4689  smtpd_chat_reply(state, "554 5.5.1 Error: TLS already active");
4690  return (-1);
4691  }
4692  if (var_smtpd_use_tls == 0
4693  || (state->ehlo_discard_mask & EHLO_MASK_STARTTLS)) {
4694  state->error_mask |= MAIL_ERROR_PROTOCOL;
4695  smtpd_chat_reply(state, "502 5.5.1 Error: command not implemented");
4696  return (-1);
4697  }
4698 #ifdef USE_TLSPROXY
4699 
4700  /*
4701  * Note: state->tlsproxy is left open when smtp_flush() calls longjmp(),
4702  * so we garbage-collect the VSTREAM in smtpd_state_reset().
4703  */
4704 #define PROXY_OPEN_FLAGS \
4705  (TLS_PROXY_FLAG_ROLE_SERVER | TLS_PROXY_FLAG_SEND_CONTEXT)
4706 
4707  state->tlsproxy = tls_proxy_open(var_tlsproxy_service, PROXY_OPEN_FLAGS,
4708  state->client, state->addr,
4709  state->port, var_smtpd_tmout);
4710  if (state->tlsproxy == 0) {
4711  state->error_mask |= MAIL_ERROR_SOFTWARE;
4712  /* RFC 3207 Section 4. */
4713  smtpd_chat_reply(state, "454 4.7.0 TLS not available due to local problem");
4714  return (-1);
4715  }
4716 #else /* USE_TLSPROXY */
4717  if (smtpd_tls_ctx == 0) {
4718  state->error_mask |= MAIL_ERROR_SOFTWARE;
4719  /* RFC 3207 Section 4. */
4720  smtpd_chat_reply(state, "454 4.7.0 TLS not available due to local problem");
4721  return (-1);
4722  }
4723 #endif /* USE_TLSPROXY */
4724 
4725  /*
4726  * Enforce TLS handshake rate limit when this client negotiated too many
4727  * new TLS sessions in the recent past.
4728  *
4729  * XXX The client event count/rate control must be consistent in its use of
4730  * client address information in connect and disconnect events. For now
4731  * we exclude xclient authorized hosts from event count/rate control.
4732  */
4733  if (var_smtpd_cntls_limit > 0
4734  && SMTPD_STAND_ALONE(state) == 0
4735  && !xclient_allowed
4736  && anvil_clnt
4737  && !namadr_list_match(hogger_list, state->name, state->addr)
4738  && anvil_clnt_newtls_stat(anvil_clnt, state->service, state->addr,
4739  &rate) == ANVIL_STAT_OK
4740  && rate > var_smtpd_cntls_limit) {
4741  state->error_mask |= MAIL_ERROR_POLICY;
4742  msg_warn("Refusing STARTTLS request from %s for service %s",
4743  state->namaddr, state->service);
4744  smtpd_chat_reply(state,
4745  "454 4.7.0 Error: too many new TLS sessions from %s",
4746  state->namaddr);
4747 #ifdef USE_TLSPROXY
4748  (void) vstream_fclose(state->tlsproxy);
4749  state->tlsproxy = 0;
4750 #endif
4751  return (-1);
4752  }
4753  smtpd_chat_reply(state, "220 2.0.0 Ready to start TLS");
4754  /* Flush before we switch read/write routines or file descriptors. */
4755  smtp_flush(state->client);
4756  /* At this point there must not be any pending plaintext. */
4758 
4759  /*
4760  * Reset all inputs to the initial state.
4761  *
4762  * XXX RFC 2487 does not forbid the use of STARTTLS while mail transfer is
4763  * in progress, so we have to allow it even when it makes no sense.
4764  */
4765  helo_reset(state);
4766  mail_reset(state);
4767  rcpt_reset(state);
4768 
4769  /*
4770  * Turn on TLS, using code that is shared with TLS wrapper mode. This
4771  * code does not return when the handshake fails.
4772  */
4773  smtpd_start_tls(state);
4774  return (0);
4775 }
4776 
4777 /* tls_reset - undo STARTTLS */
4778 
4779 static void tls_reset(SMTPD_STATE *state)
4780 {
4781  int failure = 0;
4782 
4783  /*
4784  * Don't waste time when we lost contact.
4785  */
4786  if (state->tls_context) {
4787  if (vstream_feof(state->client) || vstream_ferror(state->client))
4788  failure = 1;
4789  vstream_fflush(state->client); /* NOT: smtp_flush() */
4790 #ifdef USE_TLSPROXY
4791  tls_proxy_context_free(state->tls_context);
4792 #else
4793  tls_server_stop(smtpd_tls_ctx, state->client, var_smtpd_starttls_tmout,
4794  failure, state->tls_context);
4795 #endif
4796  state->tls_context = 0;
4797  }
4798 }
4799 
4800 #endif
4801 
4802 #if !defined(USE_TLS) || !defined(USE_SASL_AUTH)
4803 
4804 /* unimpl_cmd - dummy for functionality that is not compiled in */
4805 
4806 static int unimpl_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *unused_argv)
4807 {
4808 
4809  /*
4810  * When a connection is closed we want to log the request counts for
4811  * unimplemented STARTTLS or AUTH commands separately, instead of logging
4812  * those commands as "unknown". By handling unimplemented commands with
4813  * this dummy function, we avoid messing up the command processing loop.
4814  */
4815  state->error_mask |= MAIL_ERROR_PROTOCOL;
4816  smtpd_chat_reply(state, "502 5.5.1 Error: command not implemented");
4817  return (-1);
4818 }
4819 
4820 #endif
4821 
4822  /*
4823  * The table of all SMTP commands that we know. Set the junk limit flag on
4824  * any command that can be repeated an arbitrary number of times without
4825  * triggering a tarpit delay of some sort.
4826  */
4827 typedef struct SMTPD_CMD {
4828  char *name;
4829  int (*action) (SMTPD_STATE *, int, SMTPD_TOKEN *);
4830  int flags;
4833 } SMTPD_CMD;
4834 
4835 #define SMTPD_CMD_FLAG_LIMIT (1<<0) /* limit usage */
4836 #define SMTPD_CMD_FLAG_PRE_TLS (1<<1) /* allow before STARTTLS */
4837 #define SMTPD_CMD_FLAG_LAST (1<<2) /* last in PIPELINING command group */
4838 
4839 static SMTPD_CMD smtpd_cmd_table[] = {
4842  {SMTPD_CMD_XCLIENT, xclient_cmd, SMTPD_CMD_FLAG_PRE_TLS},
4843  {SMTPD_CMD_XFORWARD, xforward_cmd,},
4844 #ifdef USE_TLS
4845  {SMTPD_CMD_STARTTLS, starttls_cmd, SMTPD_CMD_FLAG_PRE_TLS,},
4846 #else
4848 #endif
4849 #ifdef USE_SASL_AUTH
4850  {SMTPD_CMD_AUTH, smtpd_sasl_auth_cmd_wrapper,},
4851 #else
4852  {SMTPD_CMD_AUTH, unimpl_cmd,},
4853 #endif
4854  {SMTPD_CMD_MAIL, mail_cmd,},
4855  {SMTPD_CMD_RCPT, rcpt_cmd,},
4856  {SMTPD_CMD_DATA, data_cmd, SMTPD_CMD_FLAG_LAST,},
4857  {SMTPD_CMD_RSET, rset_cmd, SMTPD_CMD_FLAG_LIMIT,},
4860  {SMTPD_CMD_ETRN, etrn_cmd, SMTPD_CMD_FLAG_LIMIT,},
4861  {SMTPD_CMD_QUIT, quit_cmd, SMTPD_CMD_FLAG_PRE_TLS,},
4862  {0,},
4863 };
4864 
4865 static STRING_LIST *smtpd_noop_cmds;
4866 static STRING_LIST *smtpd_forbid_cmds;
4867 
4868 /* smtpd_proto - talk the SMTP protocol */
4869 
4870 static void smtpd_proto(SMTPD_STATE *state)
4871 {
4872  int argc;
4873  SMTPD_TOKEN *argv;
4874  SMTPD_CMD *cmdp;
4875  const char *ehlo_words;
4876  const char *err;
4877  int status;
4878  const char *cp;
4879 
4880 #ifdef USE_TLS
4881  int tls_rate;
4882 
4883 #endif
4884 
4885  /*
4886  * Print a greeting banner and run the state machine. Read SMTP commands
4887  * one line at a time. According to the standard, a sender or recipient
4888  * address could contain an escaped newline. I think this is perverse,
4889  * and anyone depending on this is really asking for trouble.
4890  *
4891  * In case of mail protocol trouble, the program jumps back to this place,
4892  * so that it can perform the necessary cleanup before talking to the
4893  * next client. The setjmp/longjmp primitives are like a sharp tool: use
4894  * with care. I would certainly recommend against the use of
4895  * setjmp/longjmp in programs that change privilege levels.
4896  *
4897  * In case of file system trouble the program terminates after logging the
4898  * error and after informing the client. In all other cases (out of
4899  * memory, panic) the error is logged, and the msg_cleanup() exit handler
4900  * cleans up, but no attempt is made to inform the client of the nature
4901  * of the problem.
4902  */
4904 
4905  while ((status = vstream_setjmp(state->client)) == SMTP_ERR_NONE)
4906  /* void */ ;
4907  switch (status) {
4908 
4909  default:
4910  msg_panic("smtpd_proto: unknown error reading from %s",
4911  state->namaddr);
4912  break;
4913 
4914  case SMTP_ERR_TIME:
4915  state->reason = REASON_TIMEOUT;
4916  if (vstream_setjmp(state->client) == 0)
4917  smtpd_chat_reply(state, "421 4.4.2 %s Error: timeout exceeded",
4918  var_myhostname);
4919  break;
4920 
4921  case SMTP_ERR_EOF:
4922  state->reason = REASON_LOST_CONNECTION;
4923  break;
4924 
4925  case SMTP_ERR_QUIET:
4926  break;
4927 
4928  case SMTP_ERR_DATA:
4929  msg_info("%s: reject: %s from %s: "
4930  "421 4.3.0 %s Server local data error",
4931  (state->queue_id ? state->queue_id : "NOQUEUE"),
4932  state->where, state->namaddr, var_myhostname);
4933  state->error_mask |= MAIL_ERROR_DATA;
4934  if (vstream_setjmp(state->client) == 0)
4935  smtpd_chat_reply(state, "421 4.3.0 %s Server local data error",
4936  var_myhostname);
4937  break;
4938 
4939  case 0:
4940 
4941  /*
4942  * Reset the per-command counters.
4943  */
4944  for (cmdp = smtpd_cmd_table; /* see below */ ; cmdp++) {
4945  cmdp->success_count = cmdp->total_count = 0;
4946  if (cmdp->name == 0)
4947  break;
4948  }
4949 
4950  /*
4951  * In TLS wrapper mode, turn on TLS using code that is shared with
4952  * the STARTTLS command. This code does not return when the handshake
4953  * fails.
4954  *
4955  * Enforce TLS handshake rate limit when this client negotiated too many
4956  * new TLS sessions in the recent past.
4957  *
4958  * XXX This means we don't complete a TLS handshake just to tell the
4959  * client that we don't provide service. TLS wrapper mode is
4960  * obsolete, so we don't have to provide perfect support.
4961  */
4962 #ifdef USE_TLS
4963  if (SMTPD_STAND_ALONE(state) == 0 && var_smtpd_tls_wrappermode) {
4964 #ifdef USE_TLSPROXY
4965  /* We garbage-collect the VSTREAM in smtpd_state_reset() */
4966  state->tlsproxy = tls_proxy_open(var_tlsproxy_service,
4967  PROXY_OPEN_FLAGS,
4968  state->client, state->addr,
4969  state->port, var_smtpd_tmout);
4970  if (state->tlsproxy == 0) {
4971  msg_warn("Wrapper-mode request dropped from %s for service %s."
4972  " TLS context initialization failed. For details see"
4973  " earlier warnings in your logs.",
4974  state->namaddr, state->service);
4975  break;
4976  }
4977 #else /* USE_TLSPROXY */
4978  if (smtpd_tls_ctx == 0) {
4979  msg_warn("Wrapper-mode request dropped from %s for service %s."
4980  " TLS context initialization failed. For details see"
4981  " earlier warnings in your logs.",
4982  state->namaddr, state->service);
4983  break;
4984  }
4985 #endif /* USE_TLSPROXY */
4986  if (var_smtpd_cntls_limit > 0
4987  && !xclient_allowed
4988  && anvil_clnt
4989  && !namadr_list_match(hogger_list, state->name, state->addr)
4991  state->addr, &tls_rate) == ANVIL_STAT_OK
4992  && tls_rate > var_smtpd_cntls_limit) {
4993  state->error_mask |= MAIL_ERROR_POLICY;
4994  msg_warn("Refusing TLS service request from %s for service %s",
4995  state->namaddr, state->service);
4996  break;
4997  }
4998  smtpd_start_tls(state);
4999  }
5000 #endif
5001 
5002  /*
5003  * XXX The client connection count/rate control must be consistent in
5004  * its use of client address information in connect and disconnect
5005  * events. For now we exclude xclient authorized hosts from
5006  * connection count/rate control.
5007  *
5008  * XXX Must send connect/disconnect events to the anvil server even when
5009  * this service is not connection count or rate limited, otherwise it
5010  * will discard client message or recipient rate information too
5011  * early or too late.
5012  */
5013  if (SMTPD_STAND_ALONE(state) == 0
5014  && !xclient_allowed
5015  && anvil_clnt
5016  && !namadr_list_match(hogger_list, state->name, state->addr)
5017  && anvil_clnt_connect(anvil_clnt, state->service, state->addr,
5018  &state->conn_count, &state->conn_rate)
5019  == ANVIL_STAT_OK) {
5020  if (var_smtpd_cconn_limit > 0
5021  && state->conn_count > var_smtpd_cconn_limit) {
5022  state->error_mask |= MAIL_ERROR_POLICY;
5023  msg_warn("Connection concurrency limit exceeded: %d from %s for service %s",
5024  state->conn_count, state->namaddr, state->service);
5025  smtpd_chat_reply(state, "421 4.7.0 %s Error: too many connections from %s",
5026  var_myhostname, state->addr);
5027  break;
5028  }
5029  if (var_smtpd_crate_limit > 0
5030  && state->conn_rate > var_smtpd_crate_limit) {
5031  msg_warn("Connection rate limit exceeded: %d from %s for service %s",
5032  state->conn_rate, state->namaddr, state->service);
5033  smtpd_chat_reply(state, "421 4.7.0 %s Error: too many connections from %s",
5034  var_myhostname, state->addr);
5035  break;
5036  }
5037  }
5038 
5039  /*
5040  * Determine what server ESMTP features to suppress, typically to
5041  * avoid inter-operability problems. Moved up so we don't send 421
5042  * immediately after sending the initial server response.
5043  */
5044  if (ehlo_discard_maps == 0
5045  || (ehlo_words = maps_find(ehlo_discard_maps, state->addr, 0)) == 0)
5046  ehlo_words = var_smtpd_ehlo_dis_words;
5047  state->ehlo_discard_mask = ehlo_mask(ehlo_words);
5048 
5049  /* XXX We use the real client for connect access control. */
5050  if (SMTPD_STAND_ALONE(state) == 0
5051  && var_smtpd_delay_reject == 0
5052  && (err = smtpd_check_client(state)) != 0) {
5053  state->error_mask |= MAIL_ERROR_POLICY;
5054  state->access_denied = mystrdup(err);
5055  smtpd_chat_reply(state, "%s", state->access_denied);
5056  state->error_count++;
5057  }
5058 
5059  /*
5060  * RFC 2034: the text part of all 2xx, 4xx, and 5xx SMTP responses
5061  * other than the initial greeting and any response to HELO or EHLO
5062  * are prefaced with a status code as defined in RFC 3463.
5063  */
5064 
5065  /*
5066  * XXX If a Milter rejects CONNECT, reply with 220 except in case of
5067  * hard reject or 421 (disconnect). The reply persists so it will
5068  * apply to MAIL FROM and to other commands such as AUTH, STARTTLS,
5069  * and VRFY. Note: after a Milter CONNECT reject, we must not reject
5070  * HELO or EHLO, but we do change the feature list that is announced
5071  * in the EHLO response.
5072  */
5073  else {
5074  err = 0;
5075  if (state->milters != 0) {
5077  (void *) state);
5078  if ((err = milter_conn_event(state->milters, state->name,
5079  state->addr,
5080  strcmp(state->port, CLIENT_PORT_UNKNOWN) ?
5081  state->port : "0",
5082  state->addr_family)) != 0)
5083  err = check_milter_reply(state, err);
5084  }
5085  if (err && err[0] == '5') {
5086  state->error_mask |= MAIL_ERROR_POLICY;
5087  smtpd_chat_reply(state, "554 %s ESMTP not accepting connections",
5088  var_myhostname);
5089  state->error_count++;
5090  } else if (err && strncmp(err, "421", 3) == 0) {
5091  state->error_mask |= MAIL_ERROR_POLICY;
5092  smtpd_chat_reply(state, "421 %s Service unavailable - try again later",
5093  var_myhostname);
5094  /* Not: state->error_count++; */
5095  } else {
5096  smtpd_chat_reply(state, "220 %s", var_smtpd_banner);
5097  }
5098  }
5099 
5100  /*
5101  * SASL initialization for plaintext mode.
5102  *
5103  * XXX Backwards compatibility: allow AUTH commands when the AUTH
5104  * announcement is suppressed via smtpd_sasl_exceptions_networks.
5105  *
5106  * XXX Safety: don't enable SASL with "smtpd_tls_auth_only = yes" and
5107  * non-TLS build.
5108  */
5109 #ifdef USE_SASL_AUTH
5110  if (var_smtpd_sasl_enable && smtpd_sasl_is_active(state) == 0
5111 #ifdef USE_TLS
5112  && state->tls_context == 0 && !var_smtpd_tls_auth_only
5113 #else
5114  && var_smtpd_tls_auth_only == 0
5115 #endif
5116  )
5119 #endif
5120 
5121  /*
5122  * The command read/execute loop.
5123  */
5124  for (;;) {
5125  if (state->flags & SMTPD_FLAG_HANGUP)
5126  break;
5127  if (state->error_count >= var_smtpd_hard_erlim) {
5128  state->reason = REASON_ERROR_LIMIT;
5129  state->error_mask |= MAIL_ERROR_PROTOCOL;
5130  smtpd_chat_reply(state, "421 4.7.0 %s Error: too many errors",
5131  var_myhostname);
5132  break;
5133  }
5134  watchdog_pat();
5135  smtpd_chat_query(state);
5136  /* Safety: protect internal interfaces against malformed UTF-8. */
5138  LEN(state->buffer)) == 0) {
5139  state->error_mask |= MAIL_ERROR_PROTOCOL;
5140  smtpd_chat_reply(state, "500 5.5.2 Error: bad UTF-8 syntax");
5141  state->error_count++;
5142  continue;
5143  }
5144  /* Move into smtpd_chat_query() and update session transcript. */
5145  if (smtpd_cmd_filter != 0) {
5146  for (cp = STR(state->buffer); *cp && IS_SPACE_TAB(*cp); cp++)
5147  /* void */ ;
5148  if ((cp = dict_get(smtpd_cmd_filter, cp)) != 0) {
5149  msg_info("%s: replacing command \"%.100s\" with \"%.100s\"",
5150  state->namaddr, STR(state->buffer), cp);
5151  vstring_strcpy(state->buffer, cp);
5152  } else if (smtpd_cmd_filter->error != 0) {
5153  msg_warn("%s:%s lookup error for \"%.100s\"",
5154  smtpd_cmd_filter->type, smtpd_cmd_filter->name,
5155  printable(STR(state->buffer), '?'));
5157  }
5158  }
5159  if ((argc = smtpd_token(vstring_str(state->buffer), &argv)) == 0) {
5160  state->error_mask |= MAIL_ERROR_PROTOCOL;
5161  smtpd_chat_reply(state, "500 5.5.2 Error: bad syntax");
5162  state->error_count++;
5163  continue;
5164  }
5165  /* Ignore smtpd_noop_cmds lookup errors. Non-critical feature. */
5166  if (*var_smtpd_noop_cmds
5167  && string_list_match(smtpd_noop_cmds, argv[0].strval)) {
5168  smtpd_chat_reply(state, "250 2.0.0 Ok");
5169  if (state->junk_cmds++ > var_smtpd_junk_cmd_limit)
5170  state->error_count++;
5171  continue;
5172  }
5173  for (cmdp = smtpd_cmd_table; cmdp->name != 0; cmdp++)
5174  if (strcasecmp(argv[0].strval, cmdp->name) == 0)
5175  break;
5176  cmdp->total_count += 1;
5177  /* Ignore smtpd_forbid_cmds lookup errors. Non-critical feature. */
5178  if (cmdp->name == 0) {
5179  state->where = SMTPD_CMD_UNKNOWN;
5180  if (is_header(argv[0].strval)
5182  && string_list_match(smtpd_forbid_cmds, argv[0].strval))) {
5183  msg_warn("non-SMTP command from %s: %.100s",
5184  state->namaddr, vstring_str(state->buffer));
5185  smtpd_chat_reply(state, "221 2.7.0 Error: I can break rules, too. Goodbye.");
5186  break;
5187  }
5188  }
5189  /* XXX We use the real client for connect access control. */
5190  if (state->access_denied && cmdp->action != quit_cmd) {
5191  /* XXX Exception for Milter override. */
5192  if (strncmp(state->access_denied + 1, "21", 2) == 0) {
5193  smtpd_chat_reply(state, "%s", state->access_denied);
5194  continue;
5195  }
5196  smtpd_chat_reply(state, "503 5.7.0 Error: access denied for %s",
5197  state->namaddr); /* RFC 2821 Sec 3.1 */
5198  state->error_count++;
5199  continue;
5200  }
5201  /* state->access_denied == 0 || cmdp->action == quit_cmd */
5202  if (cmdp->name == 0) {
5203  if (state->milters != 0
5204  && (err = milter_unknown_event(state->milters,
5205  argv[0].strval)) != 0
5206  && (err = check_milter_reply(state, err)) != 0) {
5207  smtpd_chat_reply(state, "%s", err);
5208  } else
5209  smtpd_chat_reply(state, "502 5.5.2 Error: command not recognized");
5210  state->error_mask |= MAIL_ERROR_PROTOCOL;
5211  state->error_count++;
5212  continue;
5213  }
5214 #ifdef USE_TLS
5215  if (var_smtpd_enforce_tls &&
5216  !state->tls_context &&
5217  (cmdp->flags & SMTPD_CMD_FLAG_PRE_TLS) == 0) {
5218  smtpd_chat_reply(state,
5219  "530 5.7.0 Must issue a STARTTLS command first");
5220  state->error_count++;
5221  continue;
5222  }
5223 #endif
5224  state->where = cmdp->name;
5225  if (SMTPD_STAND_ALONE(state) == 0
5226  && (strcasecmp(state->protocol, MAIL_PROTO_ESMTP) != 0
5227  || (cmdp->flags & SMTPD_CMD_FLAG_LAST))
5228  && (state->flags & SMTPD_FLAG_ILL_PIPELINING) == 0
5229  && (vstream_peek(state->client) > 0
5230  || peekfd(vstream_fileno(state->client)) > 0)) {
5231  if (state->expand_buf == 0)
5232  state->expand_buf = vstring_alloc(100);
5233  escape(state->expand_buf, vstream_peek_data(state->client),
5234  vstream_peek(state->client) < 100 ?
5235  vstream_peek(state->client) : 100);
5236  msg_info("improper command pipelining after %s from %s: %s",
5237  cmdp->name, state->namaddr, STR(state->expand_buf));
5238  state->flags |= SMTPD_FLAG_ILL_PIPELINING;
5239  }
5240  if (cmdp->action(state, argc, argv) != 0)
5241  state->error_count++;
5242  else
5243  cmdp->success_count += 1;
5244  if ((cmdp->flags & SMTPD_CMD_FLAG_LIMIT)
5245  && state->junk_cmds++ > var_smtpd_junk_cmd_limit)
5246  state->error_count++;
5247  if (cmdp->action == quit_cmd)
5248  break;
5249  }
5250  break;
5251  }
5252 
5253  /*
5254  * XXX The client connection count/rate control must be consistent in its
5255  * use of client address information in connect and disconnect events.
5256  * For now we exclude xclient authorized hosts from connection count/rate
5257  * control.
5258  *
5259  * XXX Must send connect/disconnect events to the anvil server even when
5260  * this service is not connection count or rate limited, otherwise it
5261  * will discard client message or recipient rate information too early or
5262  * too late.
5263  */
5264  if (SMTPD_STAND_ALONE(state) == 0
5265  && !xclient_allowed
5266  && anvil_clnt
5267  && !namadr_list_match(hogger_list, state->name, state->addr))
5268  anvil_clnt_disconnect(anvil_clnt, state->service, state->addr);
5269 
5270  /*
5271  * Log abnormal session termination, in case postmaster notification has
5272  * been turned off. In the log, indicate the last recognized state before
5273  * things went wrong. Don't complain about clients that go away without
5274  * sending QUIT. Log the byte count after DATA to help diagnose MTU
5275  * troubles.
5276  */
5277  if (state->reason && state->where) {
5278  if (strcmp(state->where, SMTPD_AFTER_DATA) == 0) {
5279  msg_info("%s after %s (%lu bytes) from %s", /* 2.5 compat */
5280  state->reason, SMTPD_CMD_DATA, /* 2.5 compat */
5281  (long) (state->act_size + vstream_peek(state->client)),
5282  state->namaddr);
5283  } else if (strcmp(state->where, SMTPD_AFTER_DOT)
5284  || strcmp(state->reason, REASON_LOST_CONNECTION)) {
5285  msg_info("%s after %s from %s",
5286  state->reason, state->where, state->namaddr);
5287  }
5288  }
5289 
5290  /*
5291  * Cleanup whatever information the client gave us during the SMTP
5292  * dialog.
5293  *
5294  * XXX Duplicated in xclient_cmd().
5295  */
5296 #ifdef USE_TLS
5297  tls_reset(state);
5298 #endif
5299  helo_reset(state);
5300 #ifdef USE_SASL_AUTH
5301  smtpd_sasl_auth_reset(state);
5302  if (smtpd_sasl_is_active(state)) {
5303  smtpd_sasl_deactivate(state);
5304  }
5305 #endif
5306  chat_reset(state, 0);
5307  mail_reset(state);
5308  rcpt_reset(state);
5309  if (state->milters)
5310  milter_disc_event(state->milters);
5311 }
5312 
5313 /* smtpd_format_cmd_stats - format per-command statistics */
5314 
5315 static char *smtpd_format_cmd_stats(VSTRING *buf)
5316 {
5317  SMTPD_CMD *cmdp;
5318  int all_success = 0;
5319  int all_total = 0;
5320 
5321  /*
5322  * Log the statistics. Note that this loop produces no output when no
5323  * command was received. We address that after the loop.
5324  */
5325  VSTRING_RESET(buf);
5326  for (cmdp = smtpd_cmd_table; /* see below */ ; cmdp++) {
5327  if (cmdp->total_count > 0) {
5328  vstring_sprintf_append(buf, " %s=%d",
5329  cmdp->name ? cmdp->name : "unknown",
5330  cmdp->success_count);
5331  if (cmdp->success_count != cmdp->total_count)
5332  vstring_sprintf_append(buf, "/%d", cmdp->total_count);
5333  all_success += cmdp->success_count;
5334  all_total += cmdp->total_count;
5335  }
5336  if (cmdp->name == 0)
5337  break;
5338  }
5339 
5340  /*
5341  * Log total numbers, so that logfile analyzers will see something even
5342  * if the above loop produced no output. When no commands were received
5343  * log "0/0" to simplify the identification of abnormal sessions: any
5344  * statistics with [0-9]/ indicate that there was a problem.
5345  */
5346  vstring_sprintf_append(buf, " commands=%d", all_success);
5347  if (all_success != all_total || all_total == 0)
5348  vstring_sprintf_append(buf, "/%d", all_total);
5349  return (lowercase(STR(buf)));
5350 }
5351 
5352 /* setup_milters - set up Milters after a connection is established */
5353 
5354 static void setup_milters(SMTPD_STATE *state)
5355 {
5356  const char *milter_string;
5357 
5358  /*
5359  * Postcondition: either state->milters is set, or the
5360  * INPUT_TRANSP_MILTER flag is passed down-stream.
5361  */
5362  if (SMTPD_STAND_ALONE(state) == 0
5364  && ((smtpd_milter_maps
5365  && (milter_string =
5366  maps_find(smtpd_milter_maps, state->addr, 0)) != 0)
5367  || *(milter_string = var_smtpd_milters) != 0)
5368  && strcasecmp(milter_string, SMTPD_MILTERS_DISABLE) != 0) {
5369  state->milters = milter_create(milter_string,
5384  }
5385 
5386  /*
5387  * Safety: disable non_smtpd_milters when not sending our own mail filter
5388  * list. Otherwise the next stage could handle this message as a local
5389  * submission.
5390  */
5391  if (state->milters == 0)
5393 }
5394 
5395 /* teardown_milters - release resources */
5396 
5397 static void teardown_milters(SMTPD_STATE *state)
5398 {
5399  if (state->milters) {
5400  milter_free(state->milters);
5401  state->milters = 0;
5402  }
5405 }
5406 
5407 
5408 /* smtpd_service - service one client */
5409 
5410 static void smtpd_service(VSTREAM *stream, char *service, char **argv)
5411 {
5412  SMTPD_STATE state;
5413 
5414  /*
5415  * Sanity check. This service takes no command-line arguments.
5416  */
5417  if (argv[0])
5418  msg_fatal("unexpected command-line argument: %s", argv[0]);
5419 
5420  /*
5421  * For sanity, require that at least one of INET or INET6 is enabled.
5422  * Otherwise, we can't look up interface information, and we can't
5423  * convert names or addresses.
5424  */
5425  if (SMTPD_STAND_ALONE_STREAM(stream) == 0
5426  && inet_proto_info()->ai_family_list[0] == 0)
5427  msg_fatal("all network protocols are disabled (%s = %s)",
5429 
5430  /*
5431  * This routine runs when a client has connected to our network port, or
5432  * when the smtp server is run in stand-alone mode (input from pipe).
5433  *
5434  * Look up and sanitize the peer name, then initialize some connection-
5435  * specific state. When the name service is hosed, hostname lookup will
5436  * take a while. This is why I always run a local name server on critical
5437  * machines.
5438  */
5439  smtpd_state_init(&state, stream, service);
5440  msg_info("connect from %s", state.namaddr);
5441 
5442  /*
5443  * Disable TLS when running in stand-alone mode via "sendmail -bs".
5444  */
5445  if (SMTPD_STAND_ALONE((&state))) {
5446  var_smtpd_use_tls = 0;
5449  }
5450 
5451  /*
5452  * XCLIENT must not override its own access control.
5453  */
5454  xclient_allowed = SMTPD_STAND_ALONE((&state)) == 0 &&
5455  namadr_list_match(xclient_hosts, state.name, state.addr);
5456 
5457  /*
5458  * Overriding XFORWARD access control makes no sense, either.
5459  */
5460  xforward_allowed = SMTPD_STAND_ALONE((&state)) == 0 &&
5461  namadr_list_match(xforward_hosts, state.name, state.addr);
5462 
5463  /*
5464  * See if we need to turn on verbose logging for this client.
5465  */
5466  debug_peer_check(state.name, state.addr);
5467 
5468  /*
5469  * Set up Milters, or disable Milters down-stream.
5470  */
5471  setup_milters(&state); /* duplicates xclient_cmd */
5472 
5473  /*
5474  * Provide the SMTP service.
5475  */
5476  if ((state.flags & SMTPD_FLAG_HANGUP) == 0)
5477  smtpd_proto(&state);
5478 
5479  /*
5480  * After the client has gone away, clean up whatever we have set up at
5481  * connection time.
5482  */
5483  msg_info("disconnect from %s%s", state.namaddr,
5484  smtpd_format_cmd_stats(state.buffer));
5485  teardown_milters(&state); /* duplicates xclient_cmd */
5486  smtpd_state_reset(&state);
5488 }
5489 
5490 /* pre_accept - see if tables have changed */
5491 
5492 static void pre_accept(char *unused_name, char **unused_argv)
5493 {
5494  const char *table;
5495 
5496  if ((table = dict_changed_name()) != 0) {
5497  msg_info("table %s has changed -- restarting", table);
5498  exit(0);
5499  }
5500 }
5501 
5502 /* pre_jail_init - pre-jail initialization */
5503 
5504 static void pre_jail_init(char *unused_name, char **unused_argv)
5505 {
5506 
5507  /*
5508  * Initialize blacklist/etc. patterns before entering the chroot jail, in
5509  * case they specify a filename pattern.
5510  */
5513  smtpd_forbid_cmds = string_list_init(VAR_SMTPD_FORBID_CMDS,
5525 
5526  /*
5527  * Open maps before dropping privileges so we can read passwords etc.
5528  *
5529  * XXX We should not do this in stand-alone (sendmail -bs) mode, but we
5530  * can't use SMTPD_STAND_ALONE(state) here. This means "sendmail -bs"
5531  * will try to connect to proxymap when invoked by root for mail
5532  * submission. To fix, we would have to pass stand-alone mode information
5533  * via different means. For now we have to tell people not to run mail
5534  * clients as root.
5535  */
5536  if (getuid() == 0 || getuid() == var_owner_uid)
5537  smtpd_check_init();
5539  debug_peer_init();
5540 
5542 #ifdef USE_SASL_AUTH
5544 
5546  sasl_exceptions_networks =
5550 #else
5551  msg_warn("%s is true, but SASL support is not compiled in",
5553 #endif
5554 
5555  if (*var_smtpd_cmd_filter)
5556  smtpd_cmd_filter = dict_open(var_smtpd_cmd_filter, O_RDONLY,
5558 
5559  /*
5560  * XXX Temporary fix to pretend that we consistently implement TLS
5561  * security levels. We implement only a subset for now. If we implement
5562  * more levels, wrappermode should override only weaker TLS security
5563  * levels.
5564  *
5565  * Note: tls_level_lookup() logs no warning.
5566  */
5569  default:
5570  msg_fatal("Invalid TLS level \"%s\"", var_smtpd_tls_level);
5571  /* NOTREACHED */
5572  break;
5573  case TLS_LEV_SECURE:
5574  case TLS_LEV_VERIFY:
5575  case TLS_LEV_FPRINT:
5576  msg_warn("%s: unsupported TLS level \"%s\", using \"encrypt\"",
5578  /* FALLTHROUGH */
5579  case TLS_LEV_ENCRYPT:
5581  break;
5582  case TLS_LEV_MAY:
5584  var_smtpd_use_tls = 1;
5585  break;
5586  case TLS_LEV_NONE:
5588  break;
5589  }
5590  }
5591 
5592  /*
5593  * With TLS wrapper mode, we run on a dedicated port and turn on TLS
5594  * before actually speaking the SMTP protocol. This implies TLS enforce
5595  * mode.
5596  *
5597  * With non-wrapper mode, TLS enforce mode implies that we don't advertise
5598  * AUTH before the client issues STARTTLS.
5599  */
5603 
5604  /*
5605  * Keys can only be loaded when running with suitable permissions. When
5606  * called from "sendmail -bs" this is not the case, so we must not
5607  * announce STARTTLS support.
5608  */
5609  if (getuid() == 0 || getuid() == var_owner_uid) {
5610  if (var_smtpd_use_tls) {
5611 #ifdef USE_TLS
5612 #ifndef USE_TLSPROXY
5613  TLS_SERVER_INIT_PROPS props;
5614  const char *cert_file;
5615  int have_server_cert;
5616  int no_server_cert_ok;
5617  int require_server_cert;
5618 
5619  /*
5620  * Can't use anonymous ciphers if we want client certificates.
5621  * Must use anonymous ciphers if we have no certificates.
5622  *
5623  * XXX: Ugh! Too many booleans!
5624  */
5625  ask_client_cert = require_server_cert =
5628  if (strcasecmp(var_smtpd_tls_cert_file, "none") == 0) {
5629  no_server_cert_ok = 1;
5630  cert_file = "";
5631  } else {
5632  no_server_cert_ok = 0;
5633  cert_file = var_smtpd_tls_cert_file;
5634  }
5635  have_server_cert =
5637 
5638  /* Some TLS configuration errors are not show stoppers. */
5639  if (!have_server_cert && require_server_cert)
5640  msg_warn("Need a server cert to request client certs");
5642  msg_warn("Can't require client certs unless TLS is required");
5643  /* After a show-stopper error, reply with 454 to STARTTLS. */
5644  if (have_server_cert || (no_server_cert_ok && !require_server_cert))
5645 
5646  /*
5647  * Large parameter lists are error-prone, so we emulate a
5648  * language feature that C does not have natively: named
5649  * parameter lists.
5650  */
5651  smtpd_tls_ctx =
5652  TLS_SERVER_INIT(&props,
5653  log_param = VAR_SMTPD_TLS_LOGLEVEL,
5654  log_level = var_smtpd_tls_loglevel,
5655  verifydepth = var_smtpd_tls_ccert_vd,
5656  cache_type = TLS_MGR_SCACHE_SMTPD,
5657  set_sessid = var_smtpd_tls_set_sessid,
5658  cert_file = cert_file,
5659  key_file = var_smtpd_tls_key_file,
5660  dcert_file = var_smtpd_tls_dcert_file,
5661  dkey_file = var_smtpd_tls_dkey_file,
5662  eccert_file = var_smtpd_tls_eccert_file,
5663  eckey_file = var_smtpd_tls_eckey_file,
5664  CAfile = var_smtpd_tls_CAfile,
5665  CApath = var_smtpd_tls_CApath,
5666  dh1024_param_file
5668  dh512_param_file
5670  eecdh_grade = var_smtpd_tls_eecdh,
5671  protocols = var_smtpd_enforce_tls ?
5674  ask_ccert = ask_client_cert,
5675  mdalg = var_smtpd_tls_fpt_dgst);
5676  else
5677  msg_warn("No server certs available. TLS won't be enabled");
5678 #endif /* USE_TLSPROXY */
5679 #else
5680  msg_warn("TLS has been selected, but TLS support is not compiled in");
5681 #endif
5682  }
5683  }
5684 
5685  /*
5686  * flush client.
5687  */
5688  flush_init();
5689 
5690  /*
5691  * EHLO keyword filter.
5692  */
5694  ehlo_discard_maps = maps_create(VAR_SMTPD_EHLO_DIS_MAPS,
5696  DICT_FLAG_LOCK);
5697 
5698  /*
5699  * Per-client Milter support.
5700  */
5701  if (*var_smtpd_milter_maps)
5702  smtpd_milter_maps = maps_create(VAR_SMTPD_MILTER_MAPS,
5704  DICT_FLAG_LOCK);
5705 
5706  /*
5707  * DNS reply filter.
5708  */
5712 }
5713 
5714 /* post_jail_init - post-jail initialization */
5715 
5716 static void post_jail_init(char *unused_name, char **unused_argv)
5717 {
5718 
5719  /*
5720  * Initialize the receive transparency options: do we want unknown
5721  * recipient checks, address mapping, header_body_checks?.
5722  */
5725 
5726  /*
5727  * Initialize before-queue filter options: do we want speed-matching
5728  * support so that the entire message is received before we contact a
5729  * before-queue content filter?
5730  */
5731  if (*var_smtpd_proxy_filt)
5734 
5735  /*
5736  * Sanity checks. The queue_minfree value should be at least as large as
5737  * (process_limit * message_size_limit) but that is unpractical, so we
5738  * arbitrarily pick a small multiple of the per-message size limit. This
5739  * helps to avoid many unneeded (re)transmissions.
5740  */
5741  if (var_queue_minfree > 0
5742  && var_message_limit > 0
5744  msg_warn("%s(%lu) should be at least 1.5*%s(%lu)",
5745  VAR_QUEUE_MINFREE, (unsigned long) var_queue_minfree,
5746  VAR_MESSAGE_LIMIT, (unsigned long) var_message_limit);
5747 
5748  /*
5749  * Connection rate management.
5750  */
5755 }
5756 
5758 
5759 /* main - the main program */
5760 
5761 int main(int argc, char **argv)
5762 {
5763  static const CONFIG_NINT_TABLE nint_table[] = {
5768  0,
5769  };
5770  static const CONFIG_INT_TABLE int_table[] = {
5802 #ifdef USE_TLS
5804 #endif
5807  0,
5808  };
5809  static const CONFIG_TIME_TABLE time_table[] = {
5817 #ifdef USE_TLS
5819 #endif
5826  0,
5827  };
5828  static const CONFIG_BOOL_TABLE bool_table[] = {
5844 #ifdef USE_TLS
5849 #endif
5853  0,
5854  };
5855  static const CONFIG_NBOOL_TABLE nbool_table[] = {
5857  0,
5858  };
5859  static const CONFIG_STR_TABLE str_table[] = {
5906 #ifdef USE_TLS
5928 #endif
5943  VAR_MILT_V, DEF_MILT_V, &var_milt_v, 1, 0,
5946  VAR_STRESS, DEF_STRESS, &var_stress, 0, 0,
5955 #ifdef USE_TLSPROXY
5957 #endif
5963  0,
5964  };
5965  static const CONFIG_RAW_TABLE raw_table[] = {
5969  0,
5970  };
5971 
5972  /*
5973  * Fingerprint executables and core dumps.
5974  */
5976 
5977  /*
5978  * Pass control to the single-threaded service skeleton.
5979  */
5980  single_server_main(argc, argv, smtpd_service,
5981  CA_MAIL_SERVER_NINT_TABLE(nint_table),
5982  CA_MAIL_SERVER_INT_TABLE(int_table),
5983  CA_MAIL_SERVER_STR_TABLE(str_table),
5984  CA_MAIL_SERVER_RAW_TABLE(raw_table),
5985  CA_MAIL_SERVER_BOOL_TABLE(bool_table),
5986  CA_MAIL_SERVER_NBOOL_TABLE(nbool_table),
5987  CA_MAIL_SERVER_TIME_TABLE(time_table),
5988  CA_MAIL_SERVER_PRE_INIT(pre_jail_init),
5989  CA_MAIL_SERVER_PRE_ACCEPT(pre_accept),
5990  CA_MAIL_SERVER_POST_INIT(post_jail_init),
5991  0);
5992 }
int mail_stream_finish(MAIL_STREAM *info, VSTRING *why)
Definition: mail_stream.c:398
#define DEF_SMTPD_ENFORCE_TLS
Definition: mail_params.h:1276
int msg_verbose
Definition: msg.c:177
#define DEF_UNK_ADDR_CODE
Definition: mail_params.h:2200
char * var_smtpd_tls_fpt_dgst
char * var_smtpd_proxy_filt
Definition: smtpd.c:1308
#define IS_SPACE_TAB(ch)
Definition: lex_822.h:17
#define REC_TYPE_FILT
Definition: rec_type.h:42
#define SMTPD_PROX_WANT_ANY
Definition: smtpd_proxy.h:48
MAIL_VERSION_STAMP_DECLARE
Definition: smtpd.c:5757
#define VAR_CLIENT_CHECKS
Definition: mail_params.h:2069
#define XFORWARD_NAME
Definition: mail_proto.h:252
char * var_mail_name
Definition: mail_params.c:230
#define MAIL_ATTR_ACT_CLIENT_AF
Definition: mail_proto.h:218
#define MAIL_ATTR_ACT_HELO_NAME
Definition: mail_proto.h:219
#define SMTPD_STAND_ALONE(state)
Definition: smtpd.h:309
#define MAIL_PROTO_ESMTP
Definition: mail_proto.h:31
char * var_verify_sender
#define REC_TYPE_DELAY
Definition: rec_type.h:54
#define SMTPD_MASK_MAIL_KEEP
Definition: smtpd.h:200
#define ATTR_FLAG_NONE
Definition: attr.h:98
#define MAIL_ATTR_DSN_NOTIFY
Definition: mail_proto.h:275
#define VAR_SMTPD_TLS_MAND_PROTO
Definition: mail_params.h:1331
const char * valid_mailhost_addr(const char *addr, int gripe)
#define XCLIENT_UNAVAILABLE
Definition: mail_proto.h:248
const CLEANUP_STAT_DETAIL * cleanup_stat_detail(unsigned status)
SMTPD_XFORWARD_ATTR xforward
Definition: smtpd.h:167
#define VAR_RELAY_RCPT_CODE
Definition: mail_params.h:2061
void myfree(void *ptr)
Definition: mymalloc.c:207
#define DEF_RBL_REPLY_MAPS
Definition: mail_params.h:2317
#define SMTPD_STATE_XFORWARD_PORT
Definition: smtpd.h:210
VSTRING * ehlo_buf
Definition: smtpd.h:190
#define MATCH_FLAG_RETURN
Definition: match_list.h:40
#define VERP_CMD
Definition: smtpd.c:1440
#define VAR_SMTPD_CNTLS_LIMIT
Definition: mail_params.h:3073
#define DEF_VERIFY_POLL_DELAY
Definition: mail_params.h:2835
#define VAR_SMTPD_POLICY_TRY_LIMIT
Definition: mail_params.h:3036
#define DEF_EOD_CHECKS
Definition: mail_params.h:2113
#define MAIL_ERROR_RESOURCE
Definition: mail_error.h:26
#define DEF_UNV_FROM_RCODE
Definition: mail_params.h:2222
char * id
Definition: mail_stream.h:37
#define VAR_MILT_UNK_MACROS
Definition: mail_params.h:3384
int var_smtpd_policy_req_limit
Definition: smtpd.c:1314
int rcpt_overshoot
Definition: smtpd.h:114
#define CA_MAIL_SERVER_BOOL_TABLE(v)
Definition: mail_server.h:58
#define VAR_UNK_ADDR_TF_ACT
Definition: mail_params.h:2203
#define VAR_SMTPD_TLS_MAND_EXCL
Definition: mail_params.h:1347
#define VAR_REJECT_CODE
Definition: mail_params.h:2131
void smtpd_sasl_initialize(void)
int match_parent_style(const char *name)
char * var_smtpd_proxy_ehlo
Definition: smtpd.c:1310
#define DEF_SMTPD_TLS_CERT_FILE
Definition: mail_params.h:1296
int debug_peer_check(const char *name, const char *addr)
Definition: debug_peer.c:109
#define VAR_SMTPD_CLIENT_PORT_LOG
Definition: mail_params.h:3447
#define DEF_MAP_DEFER_CODE
Definition: mail_params.h:2275
char * rfc_addr
Definition: smtpd.h:60
#define SMTPD_PEER_CODE_PERM
Definition: smtpd.h:333
#define MAIL_ERROR_DATA
Definition: mail_error.h:29
#define VAR_DEF_RBL_REPLY
Definition: mail_params.h:2320
char * var_smtpd_policy_def_action
Definition: smtpd.c:1317
#define DEF_SMTPD_HOGGERS
Definition: mail_params.h:3082
#define VAR_FILTER_XPORT
Definition: mail_params.h:2479
#define HAVE_FORWARDED_CLIENT_ATTR(s)
Definition: smtpd.h:348
#define CA_MAIL_SERVER_RAW_TABLE(v)
Definition: mail_server.h:60
#define DEF_UNV_FROM_WHY
Definition: mail_params.h:2246
char * var_smtpd_tls_dh1024_param_file
#define VAR_SMTPD_TLS_ECCERT_FILE
Definition: mail_params.h:1311
#define VAR_SMTPD_NOOP_CMDS
Definition: mail_params.h:1251
char * mystrdup(const char *str)
Definition: mymalloc.c:225
char * var_stress
Definition: smtpd.c:1400
#define CLEANUP_FLAG_SMTPUTF8
Definition: cleanup_user.h:26
#define VAR_UNV_FROM_DCODE
Definition: mail_params.h:2229
char * var_cleanup_service
Definition: mail_params.c:302
#define EHLO_MASK_XFORWARD
Definition: ehlo_mask.h:27
#define DEF_SMTPD_SOFT_ERLIM
Definition: mail_params.h:1228
bool var_smtpd_peername_lookup
Definition: smtpd.c:1378
#define EHLO_MASK_STARTTLS
Definition: ehlo_mask.h:24
#define DEF_VERIFY_SENDER_TTL
Definition: mail_params.h:2827
#define MAIL_ATTR_ENCODING
Definition: mail_proto.h:202
#define VAR_SMTPD_CMD_FILTER
Definition: mail_params.h:1259
int anvil_clnt_rcpt(ANVIL_CLNT *anvil_clnt, const char *service, const char *addr, int *rcpts)
Definition: anvil_clnt.c:280
#define TOK822_ADDR
Definition: tok822.h:46
#define DEF_MILT_MACRO_DEFLTS
Definition: mail_params.h:3429
#define DEF_XCLIENT_HOSTS
Definition: mail_params.h:2608
int smtputf8_autodetect(int class)
Definition: smtputf8.c:67
char * smtpd_check_mail(SMTPD_STATE *state, char *sender)
Definition: smtpd_check.c:4852
void watchdog_pat(void)
Definition: watchdog.c:278
#define VAR_SMTPD_HOGGERS
Definition: mail_params.h:3081
#define VAR_MILT_DAEMON_NAME
Definition: mail_params.h:3416
char * dest_port
Definition: smtpd.h:83
char * var_command_dir
Definition: mail_params.c:244
void mail_stream_cleanup(MAIL_STREAM *info)
Definition: mail_stream.c:151
#define VAR_CYRUS_CONF_PATH
Definition: mail_params.h:1631
#define VAR_SMTPD_SASL_AUTH_HDR
Definition: mail_params.h:1615
char * smtpd_check_eod(SMTPD_STATE *state)
Definition: smtpd_check.c:5400
#define SMTPD_AFTER_DOT
Definition: smtpd.h:226
#define SMTPD_IN_MAIL_TRANSACTION(state)
Definition: smtpd.h:322
#define EHLO_MASK_SMTPUTF8
Definition: ehlo_mask.h:30
char * var_smtpd_hoggers
Definition: smtpd.c:1332
VSTRING * buffer
Definition: smtpd.h:71
char * var_smtpd_tls_eccert_file
char * var_relay_checks
Definition: smtpd.c:1239
ARGV * argv_free(ARGV *argvp)
Definition: argv.c:136
#define DEF_FILTER_XPORT
Definition: mail_params.h:2480
#define VAR_MILT_MACRO_DEFLTS
Definition: mail_params.h:3428
const char * mail_date(time_t when)
Definition: mail_date.c:54
#define XCLIENT_LOGIN
Definition: mail_proto.h:244
#define CLEANUP_STAT_SIZE
Definition: cleanup_user.h:59
#define USE_SMTPD_PROXY(state)
Definition: smtpd.h:316
char * smtpd_check_etrn(SMTPD_STATE *state, char *domain)
Definition: smtpd_check.c:5019
int smtpd_sasl_auth_cmd(SMTPD_STATE *, int, SMTPD_TOKEN *)
bool var_smtpd_use_tls
Definition: smtpd.c:1338
int var_pid
Definition: mail_params.c:254
#define FORWARD_PORT(s)
Definition: smtpd.h:360
#define VALID_HOSTNAME_LEN
#define VAR_SMTPD_CAUTH_LIMIT
Definition: mail_params.h:3077
#define VAR_XCLIENT_HOSTS
Definition: mail_params.h:2607
#define NORETURN
Definition: sys_defs.h:1583
#define VAR_SMTPD_FORBID_CMDS
Definition: mail_params.h:1255
char * var_smtpd_tls_key_file
#define DEF_SHOW_UNK_RCPT_TABLE
Definition: mail_params.h:42
char * var_smtpd_tls_dkey_file
char * saved_redirect
Definition: smtpd.h:142
char * var_verp_delims
Definition: mail_params.c:289
int var_unv_rcpt_dcode
Definition: smtpd.c:1295
NORETURN msg_panic(const char *fmt,...)
Definition: msg.c:295
#define IS_AVAIL_CLIENT_ADDR(v)
Definition: smtpd.h:294
#define CA_MAIL_SERVER_STR_TABLE(v)
Definition: mail_server.h:57
void smtpd_expand_init(void)
Definition: smtpd_expand.c:89
#define MILTER_FLAG_NONE
Definition: milter.h:53
char * var_smtpd_tls_proto
#define VAR_INPUT_TRANSP
Definition: mail_params.h:3013
int junk_cmds
Definition: smtpd.h:113
off_t act_size
Definition: smtpd.h:112
char * var_rcpt_checks
Definition: smtpd.c:1240
#define DEF_MAPS_RBL_CODE
Definition: mail_params.h:2326
int input_transp_mask(const char *param_name, const char *pattern)
Definition: input_transp.c:70
#define vstring_str(vp)
Definition: vstring.h:71
struct timeval arrival_time
Definition: smtpd.h:74
const char * milter_other_event(MILTERS *milters)
Definition: milter.c:548
const char * vstream_peek_data(VSTREAM *vp)
Definition: vstream.c:1593
#define VAR_SMTPD_SOFT_ERLIM
Definition: mail_params.h:1227
#define XFORWARD_DOM_LOCAL
Definition: mail_proto.h:259
#define XCLIENT_HELO
Definition: mail_proto.h:243
#define VAR_SMTPD_MILTER_MAPS
Definition: mail_params.h:3346
#define VAR_SMTPD_TLS_EXCL_CIPH
Definition: mail_params.h:1343
char * name
Definition: dict.h:80
#define SMTPD_STATE_XFORWARD_NAME
Definition: smtpd.h:204
int var_unv_rcpt_rcode
Definition: smtpd.c:1293
#define DEF_MILT_DEF_ACTION
Definition: mail_params.h:3413
SMTPD_PROXY_REC_PUT_FN rec_put
Definition: smtpd_proxy.h:32
#define LEN(x)
Definition: smtpd.c:1423
void * myrealloc(void *ptr, ssize_t len)
Definition: mymalloc.c:175
char * var_milt_eoh_macros
Definition: smtpd.c:1395
#define inet_proto_info()
Definition: inet_proto.h:29
#define STRING_LIST
Definition: string_list.h:22
#define DEF_SMTPD_DNS_RE_FILTER
Definition: mail_params.h:4008
#define VAR_SMTPUTF8_ENABLE
Definition: mail_params.h:4036
#define VAR_MILT_PROTOCOL
Definition: mail_params.h:3408
#define XCLIENT_PROTO
Definition: mail_proto.h:242
#define DEF_SMTPD_TLS_CCERT_VD
Definition: mail_params.h:1292
#define DEF_LOCAL_RCPT_MAPS
Definition: mail_params.h:2357
#define DEF_RELAY_CHECKS
Definition: mail_params.h:2086
char * var_smtpd_tls_ciph
#define SMTP_ERR_TIME
Definition: smtp_stream.h:31
int valid_utf8_string(const char *, ssize_t)
VSTRING * escape(VSTRING *, const char *, ssize_t)
Definition: unescape.c:133
int var_verify_sender_ttl
char * queue_id
Definition: smtpd.h:96
#define DEF_SMTPD_RCPT_LIMIT
Definition: mail_params.h:1224
#define VAR_STRESS
Definition: mail_params.h:3532
#define DEF_SMTPD_UPROXY_TMOUT
Definition: mail_params.h:3952
#define DEF_NON_FQDN_CODE
Definition: mail_params.h:2189
#define SMTPD_CMD_STARTTLS
Definition: smtpd.h:234
char * name
Definition: smtpd.h:75
void smtpd_proxy_close(SMTPD_STATE *state)
Definition: smtpd_proxy.c:1078
bool var_smtpd_tls_req_ccert
int smtpd_proxy_create(SMTPD_STATE *state, int flags, const char *service, int timeout, const char *ehlo_name, const char *mail_from)
Definition: smtpd_proxy.c:1007
#define ISASCII(c)
Definition: sys_defs.h:1743
#define REC_TYPE_VERP
Definition: rec_type.h:68
#define VAR_SMTPD_TLS_CERT_FILE
Definition: mail_params.h:1295
#define VAR_MILT_HELO_MACROS
Definition: mail_params.h:3364
#define VAR_MAPS_RBL_DOMAINS
Definition: mail_params.h:2329
#define VAR_SMTPD_HIST_THRSH
Definition: mail_params.h:1247
#define SMTPD_CMD_ETRN
Definition: smtpd.h:243
const char * text
Definition: cleanup_user.h:87
off_t off_cvt_string(const char *str)
Definition: off_cvt.c:71
int var_map_defer_code
Definition: smtpd.c:1251
int smtpd_proxy_parse_opts(const char *param_name, const char *param_val)
Definition: smtpd_proxy.c:1148
bool var_smtpd_tls_received_header
int(* action)(SMTPD_STATE *, int, SMTPD_TOKEN *)
Definition: smtpd.c:4829
char * var_smtpd_sasl_tls_opts
char * saved_filter
Definition: smtpd.h:141
#define VAR_UNV_RCPT_TF_ACT
Definition: mail_params.h:2233
#define PRINT2_OR_NULL(cond, name, value)
char * var_unv_from_why
Definition: smtpd.c:1296
#define DEF_SMTPD_TLS_ECCERT_FILE
Definition: mail_params.h:1312
#define DEF_SMTPD_TLS_RCERT
Definition: mail_params.h:1288
#define DEF_STRICT_RFC821_ENV
Definition: mail_params.h:409
void smtpd_sasl_mail_reset(SMTPD_STATE *)
char * var_smtpd_ehlo_dis_maps
Definition: smtpd.c:1335
int var_smtpd_cconn_limit
Definition: smtpd.c:1327
#define SMTPD_CMD_XCLIENT
Definition: smtpd.h:245
Definition: tok822.h:27
int ehlo_discard_mask
Definition: smtpd.h:152
char * neuter(char *string, const char *bad, int replacement)
Definition: neuter.c:47
#define DEF_BROKEN_AUTH_CLNTS
Definition: mail_params.h:417
int var_virt_alias_code
Definition: smtpd.c:1301
int var_smtpd_err_sleep
Definition: smtpd.c:1257
#define vstream_longjmp(stream, val)
Definition: vstream.h:249
#define XCLIENT_ADDR
Definition: mail_proto.h:240
#define DEF_SMTPD_REJ_FOOTER
Definition: mail_params.h:3921
char * var_cyrus_conf_path
Definition: smtpd.c:1279
#define DEF_SMTPD_STARTTLS_TMOUT
Definition: mail_params.h:1220
#define VAR_SMTPD_CCONN_LIMIT
Definition: mail_params.h:3061
#define DEF_SMTPD_TLS_LOGLEVEL
Definition: mail_params.h:1372
#define VAR_SMTPD_BANNER
Definition: mail_params.h:1211
#define DEF_MILT_MSG_TIME
Definition: mail_params.h:3405
VSTREAM * cleanup
Definition: smtpd.h:97
#define MAIL_ERROR_BOUNCE
Definition: mail_error.h:24
#define tok822_parse(cp)
Definition: tok822.h:84
#define XFORWARD_PORT
Definition: mail_proto.h:254
#define DEF_BAD_NAME_CODE
Definition: mail_params.h:2171
#define VAR_SMTPD_NULL_KEY
Definition: mail_params.h:2339
int main(int argc, char **argv)
Definition: smtpd.c:5761
Definition: maps.h:22
#define CA_VSTREAM_CTL_DOUBLE
Definition: vstream.h:159
char ** argv
Definition: argv.h:20
int seqno
Definition: smtpd.h:151
char * var_smtpd_sasl_type
Definition: smtpd.c:1282
#define SMTPD_PROX_WANT_MORE
Definition: smtpd_proxy.h:50
#define MAIL_ATTR_RWR_CONTEXT
Definition: mail_proto.h:163
#define DEF_MILT_CONN_TIME
Definition: mail_params.h:3397
#define DEF_VERIFY_SENDER
Definition: mail_params.h:2823
char * uppercase(char *)
Definition: uppercase.c:34
#define EHLO_MASK_8BITMIME
Definition: ehlo_mask.h:17
#define VAR_SMTPD_CMAIL_LIMIT
Definition: mail_params.h:3065
#define VAR_XFORWARD_HOSTS
Definition: mail_params.h:2614
#define DEF_MILT_CMD_TIME
Definition: mail_params.h:3401
#define TLS_LEV_VERIFY
Definition: tls.h:50
#define DEF_MILT_MAIL_MACROS
Definition: mail_params.h:3370
#define ATTR_TYPE_END
Definition: attr.h:39
int anvil_clnt_newtls_stat(ANVIL_CLNT *anvil_clnt, const char *service, const char *addr, int *newtls)
Definition: anvil_clnt.c:328
#define DEF_SMTPD_NULL_KEY
Definition: mail_params.h:2340
#define CLEANUP_FLAG_DISCARD
Definition: cleanup_user.h:21
#define SMTPD_STATE_XFORWARD_ADDR
Definition: smtpd.h:205
#define MAIL_ATTR_RWR_LOCAL
Definition: mail_proto.h:166
#define CLEANUP_STAT_OK
Definition: cleanup_user.h:56
#define SMTP_ERR_QUIET
Definition: smtp_stream.h:32
#define MAIL_ATTR_ACT_CLIENT_ADDR
Definition: mail_proto.h:216
int var_smtpd_rcpt_limit
Definition: smtpd.c:1229
#define VAR_MAIL_CHECKS
Definition: mail_params.h:2081
#define SMTPD_CMD_DATA
Definition: smtpd.h:238
int smtp_get(VSTRING *vp, VSTREAM *stream, ssize_t bound, int flags)
Definition: smtp_stream.c:305
#define VAR_SMTPD_SASL_ENABLE
Definition: mail_params.h:1611
#define DEF_SMTPD_USE_TLS
Definition: mail_params.h:1272
#define SMTPD_CMD_NOOP
Definition: smtpd.h:241
#define EHLO_MASK_DSN
Definition: ehlo_mask.h:29
#define MAIL_ATTR_ACT_SERVER_ADDR
Definition: mail_proto.h:224
#define DEF_SMTPD_TLS_LEVEL
Definition: mail_params.h:1268
char * var_alias_maps
Definition: smtpd.c:1269
int anvil_clnt_auth(ANVIL_CLNT *anvil_clnt, const char *service, const char *addr, int *auths)
Definition: anvil_clnt.c:352
int var_milt_cmd_time
Definition: smtpd.c:1384
#define DEF_SMTPD_TLS_MAND_CIPH
Definition: mail_params.h:1340
#define TLS_LEV_NONE
Definition: tls.h:43
char * smtpd_check_helo(SMTPD_STATE *state, char *helohost)
Definition: smtpd_check.c:4798
DICT * dict_open(const char *, int, int)
Definition: dict_open.c:421
char * encoding
Definition: smtpd.h:104
char * var_error_rcpt
Definition: smtpd.c:1259
#define VAR_SMTPD_REJ_UNL_FROM
Definition: mail_params.h:2207
#define STREQ(x, y)
int var_smtputf8_enable
Definition: mail_params.c:343
#define VAR_SMTPD_MILTERS
Definition: mail_params.h:3342
#define VAR_SMTPD_CRCPT_LIMIT
Definition: mail_params.h:3069
#define DEF_SMTPD_TLS_AUTH_ONLY
Definition: mail_params.h:1280
#define MAIL_ATTR_SASL_METHOD
Definition: mail_proto.h:156
int var_smtpd_delay_reject
Definition: smtpd.c:1260
int var_smtpd_crcpt_limit
Definition: smtpd.c:1329
#define REC_TYPE_FROM
Definition: rec_type.h:43
#define CLIENT_IDENT_UNKNOWN
Definition: smtpd.h:282
#define MAIL_ATTR_RWR_REMOTE
Definition: mail_proto.h:167
#define FLUSH_STAT_BAD
Definition: flush_clnt.h:38
char * var_milt_v
Definition: smtpd.c:1389
char * var_milt_unk_macros
Definition: smtpd.c:1397
bool var_smtpd_sasl_enable
Definition: smtpd.c:1274
#define REC_TYPE_END
Definition: rec_type.h:77
#define DEF_MILT_PROTOCOL
Definition: mail_params.h:3409
void smtpd_chat_reset(SMTPD_STATE *state)
Definition: smtpd_chat.c:99
#define SMTPD_STATE_XFORWARD_HELO
Definition: smtpd.h:207
bool var_smtpd_rej_unl_rcpt
Definition: smtpd.c:1324
#define DEF_SMTPD_CAUTH_LIMIT
Definition: mail_params.h:3078
#define SMTPD_CMD_FLAG_LAST
Definition: smtpd.c:4837
int alldig(const char *string)
Definition: alldig.c:38
#define CLEANUP_STAT_HOPS
Definition: cleanup_user.h:61
#define VAR_SMTPD_ERR_SLEEP
Definition: mail_params.h:1235
#define vstream_setjmp(stream)
Definition: vstream.h:248
#define DEF_DATA_CHECKS
Definition: mail_params.h:2109
#define STR(x)
Definition: smtpd.c:1422
char * var_smtpd_tls_CApath
#define DEF_SMTPD_REJ_UNL_FROM
Definition: mail_params.h:2208
#define MAIL_ERROR_POLICY
Definition: mail_error.h:22
#define SLOPPY
#define SMTPD_BUILD_NAMADDRPORT(name, addr, port)
Definition: smtpd.h:339
ARGV * argv_alloc(ssize_t len)
Definition: argv.c:149
#define EHLO_MASK_XCLIENT
Definition: ehlo_mask.h:26
#define IS_SMTP_REJECT(s)
#define SMTPD_CMD_XFORWARD
Definition: smtpd.h:246
#define MAIL_ATTR_LOG_HELO_NAME
Definition: mail_proto.h:210
ssize_t milter_argc
Definition: smtpd.h:183
#define smtpd_sasl_is_active(s)
#define VAR_SEND_CANON_MAPS
Definition: mail_params.h:446
#define SMTPD_PROXY_FLAG_SPEED_ADJUST
Definition: smtpd_proxy.h:42
#define VSTRING_LEN(vp)
Definition: vstring.h:72
char * var_smtpd_null_key
Definition: smtpd.c:1288
#define VAR_SMTPD_SASL_PATH
Definition: mail_params.h:1623
char * var_milt_macro_deflts
Definition: smtpd.c:1398
#define DSN_NOTIFY_NEVER
Definition: dsn_mask.h:43
char * var_smtpd_tls_eecdh
const char * valid_verify_sender_addr(const char *their_addr)
#define VAR_SMTPD_TLS_CA_PATH
Definition: mail_params.h:1323
char * var_notify_classes
Definition: smtpd.c:1235
#define VAR_RELAY_CHECKS
Definition: mail_params.h:2085
#define VAR_SMTPD_POLICY_DEF_ACTION
Definition: mail_params.h:3044
#define SERVER_PORT_UNKNOWN
Definition: smtpd.h:289
#define VAR_UNV_RCPT_DCODE
Definition: mail_params.h:2225
#define VAR_SMTPD_TLS_512_FILE
Definition: mail_params.h:1355
#define DEF_SMTPD_EHLO_DIS_MAPS
Definition: mail_params.h:3126
#define VAR_SMTPD_SASL_TYPE
Definition: mail_params.h:1651
char * var_eod_checks
Definition: smtpd.c:1243
#define DEF_SMTPD_POLICY_TRY_DELAY
Definition: mail_params.h:3041
#define CLEANUP_FLAG_HOLD
Definition: cleanup_user.h:20
#define DICT_FLAG_FOLD_FIX
Definition: dict.h:124
#define DEF_SMTPD_SASL_TLS_OPTS
Definition: mail_params.h:1636
void flush_init(void)
Definition: flush_clnt.c:104
bool var_smtpd_tls_ask_ccert
#define DEF_VERIFY_POLL_COUNT
Definition: mail_params.h:2831
char * smtpd_check_data(SMTPD_STATE *state)
Definition: smtpd_check.c:5349
#define DEF_RCPT_CHECKS
Definition: mail_params.h:2101
#define MAIL_ATTR_LOG_PROTO_NAME
Definition: mail_proto.h:211
#define VAR_SMTPD_PEERNAME_LOOKUP
Definition: mail_params.h:2349
char * var_smtpd_acl_perm_log
Definition: smtpd.c:1344
char * dsn_envid
Definition: smtpd.h:153
#define VAR_HELO_CHECKS
Definition: mail_params.h:2077
#define MILTER_SKIP_FLAGS
#define DEF_MAPS_RBL_DOMAINS
Definition: mail_params.h:2330
char * var_milt_data_macros
Definition: smtpd.c:1394
#define DEF_DISABLE_VRFY_CMD
Definition: mail_params.h:424
int strncasecmp(const char *s1, const char *s2, size_t n)
Definition: strcasecmp.c:52
char * var_smtpd_uproxy_proto
Definition: smtpd.c:1416
#define DEF_RELAY_CODE
Definition: mail_params.h:2261
int anvil_clnt_connect(ANVIL_CLNT *anvil_clnt, const char *service, const char *addr, int *count, int *rate)
Definition: anvil_clnt.c:231
#define VAR_MAP_REJECT_CODE
Definition: mail_params.h:2270
bool var_smtpd_rej_unl_from
Definition: smtpd.c:1323
const char * smtpd_milter_eval(const char *name, void *ptr)
Definition: smtpd_milter.c:67
#define VAR_SMTPD_TLS_RCERT
Definition: mail_params.h:1287
char * var_milt_eod_macros
Definition: smtpd.c:1396
VSTRING * expand_buf
Definition: smtpd.h:148
#define DEF_SMTPD_TLS_CIPH
Definition: mail_params.h:1336
int var_milt_msg_time
Definition: smtpd.c:1385
MAIL_STREAM * mail_stream_command(const char *command)
Definition: mail_stream.c:462
char * protocol
Definition: smtpd.h:61
int var_unk_name_code
Definition: smtpd.c:1246
#define DEF_SMTPD_POLICY_TMOUT
Definition: mail_params.h:3021
#define VAR_VIRT_ALIAS_MAPS
Definition: mail_params.h:430
#define XFORWARD_PROTO
Definition: mail_proto.h:255
#define DEF_SMTPD_TLS_PROTO
Definition: mail_params.h:1328
const char * milter_helo_event(MILTERS *milters, const char *helo_name, int esmtp_flag)
Definition: milter.c:433
#define SERVER_ADDR_UNKNOWN
Definition: smtpd.h:288
char * var_filter_xport
Definition: smtpd.c:1283
#define SMTPD_CMD_AUTH
Definition: smtpd.h:235
#define FORWARD_NAME(s)
Definition: smtpd.h:356
SMTPD_PROXY_REC_FPRINTF_FN rec_fprintf
Definition: smtpd_proxy.h:31
#define DEF_SMTPD_SASL_EXCEPTIONS_NETWORKS
Definition: mail_params.h:1644
VSTRING * vstring_strcpy(VSTRING *vp, const char *src)
Definition: vstring.c:431
#define VAR_SMTPD_UPROXY_TMOUT
Definition: mail_params.h:3951
TOK822 * tok822_free_tree(TOK822 *)
Definition: tok822_tree.c:262
#define VAR_UNK_ADDR_CODE
Definition: mail_params.h:2199
char * helo_name
Definition: smtpd.h:95
#define DEF_REST_CLASSES
Definition: mail_params.h:2117
bool var_smtpd_sasl_auth_hdr
Definition: smtpd.c:1275
bool var_smtpd_rec_deadline
Definition: smtpd.c:1407
void smtpd_chat_notify(SMTPD_STATE *state)
Definition: smtpd_chat.c:239
#define EHLO_APPEND1(state, cmd, arg)
#define DEF_NOTIFY_CLASSES
Definition: mail_params.h:73
#define VSTRING_TERMINATE(vp)
Definition: vstring.h:74
#define VAR_UNK_NAME_CODE
Definition: mail_params.h:2176
#define DEF_MILT_CONN_MACROS
Definition: mail_params.h:3361
#define VAR_UNV_FROM_TF_ACT
Definition: mail_params.h:2237
#define string_list_init(o, f, p)
Definition: string_list.h:24
#define DEF_SMTPD_ACL_PERM_LOG
Definition: mail_params.h:3941
#define DEF_HELO_REQUIRED
Definition: mail_params.h:2074
char * proxy_mail
Definition: smtpd.h:162
long var_message_limit
Definition: mail_params.c:265
#define VAR_SMTPD_STARTTLS_TMOUT
Definition: mail_params.h:1219
#define VAR_SMTPD_HARD_ERLIM
Definition: mail_params.h:1231
#define INPUT_TRANSP_MILTER
Definition: input_transp.h:20
const char * str_ehlo_mask(int mask_bits)
Definition: ehlo_mask.c:100
#define TLS_LEV_SECURE
Definition: tls.h:51
#define DEF_SMTPD_TLS_ACERT
Definition: mail_params.h:1284
#define DEF_SMTPD_POLICY_DEF_ACTION
Definition: mail_params.h:3045
#define VAR_SMTPD_TLS_CCERT_VD
Definition: mail_params.h:1291
#define DEF_MILT_RCPT_MACROS
Definition: mail_params.h:3376
#define DEF_UNV_RCPT_WHY
Definition: mail_params.h:2242
#define VAR_VIRT_MAILBOX_MAPS
Definition: mail_params.h:2521
Definition: dict.h:78
char * var_smtpd_tls_mand_ciph
int addr_family
Definition: smtpd.h:81
#define DEF_SMTPD_MILTERS
Definition: mail_params.h:3343
int valid_hostname(const char *name, int gripe)
int var_milt_conn_time
Definition: smtpd.c:1383
#define MAIL_CLASS_PUBLIC
Definition: mail_proto.h:95
char * var_def_rbl_reply
Definition: smtpd.c:1291
#define CA_MAIL_SERVER_POST_INIT(v)
Definition: mail_server.h:65
#define CA_MAIL_SERVER_INT_TABLE(v)
Definition: mail_server.h:56
char * reason
Definition: smtpd.h:102
#define string_list_match
Definition: string_list.h:26
#define REC_TYPE_RDR
Definition: rec_type.h:52
#define MILTER_FLAG_WANT_RCPT_REJ
Definition: milter.h:54
char * var_reject_tmpf_act
Definition: smtpd.c:1402
#define is_header(str)
Definition: is_header.h:17
char * var_smtpd_dns_re_filter
Definition: smtpd.c:1345
VSTREAM * client
Definition: smtpd.h:70
VSTRING * addr_buf
Definition: smtpd.h:72
bool var_smtpd_delay_open
Definition: smtpd.c:1380
#define VAR_ALLOW_UNTRUST_ROUTE
Definition: mail_params.h:2120
const char * milter_unknown_event(MILTERS *milters, const char *command)
Definition: milter.c:526
#define SMTPD_STAND_ALONE_STREAM(stream)
Definition: smtpd.h:306
char * type
Definition: dict.h:79
#define VAR_SMTPD_SASL_TLS_OPTS
Definition: mail_params.h:1635
#define VAR_CANONICAL_MAPS
Definition: mail_params.h:442
char * var_smtpd_policy_context
Definition: smtpd.c:1318
#define VAR_LOCAL_RCPT_MAPS
Definition: mail_params.h:2356
void smtpd_sasl_auth_reset(SMTPD_STATE *)
#define VAR_ETRN_CHECKS
Definition: mail_params.h:2104
int milter_dummy(MILTERS *milters, VSTREAM *stream)
Definition: milter.c:751
#define SMTPD_CMD_EHLO
Definition: smtpd.h:233
#define DEF_SMTPD_PROXY_OPTS
Definition: mail_params.h:3005
char * var_smtpd_noop_cmds
Definition: smtpd.c:1287
char * var_rcpt_canon_maps
Definition: smtpd.c:1266
#define REASON_LOST_CONNECTION
Definition: smtpd.c:1491
#define VSTRING_ADDCH(vp, ch)
Definition: vstring.h:81
char * var_send_canon_maps
Definition: smtpd.c:1265
#define VAR_SMTPD_TLS_1024_FILE
Definition: mail_params.h:1359
MAIL_STREAM * dest
Definition: smtpd.h:98
VSTRING * vstring_sprintf_append(VSTRING *vp, const char *format,...)
Definition: vstring.c:624
#define DEF_SMTPD_POLICY_IDLE
Definition: mail_params.h:3029
int var_smtpd_policy_idle
Definition: smtpd.c:1319
#define attr_print
Definition: attr.h:109
#define VAR_SMTPD_REJ_FOOTER
Definition: mail_params.h:3920
bool var_allow_untrust_route
Definition: smtpd.c:1271
#define VAR_SMTPD_TLS_PROTO
Definition: mail_params.h:1327
#define VAR_SMTPD_TLS_LOGLEVEL
Definition: mail_params.h:1371
#define CLIENT_HELO_UNKNOWN
Definition: smtpd.h:280
char * domain
Definition: smtpd.h:64
#define MAIL_ATTR_ACT_CLIENT_PORT
Definition: mail_proto.h:217
#define MAIL_ATTR_LOG_ORIGIN
Definition: mail_proto.h:212
int var_smtpd_tmout
Definition: smtpd.c:1230
#define VAR_SMTPD_TLS_CA_FILE
Definition: mail_params.h:1319
#define EHLO_MASK_VERP
Definition: ehlo_mask.h:23
char * var_milt_rcpt_macros
Definition: smtpd.c:1393
#define DEF_RELAY_RCPT_CODE
Definition: mail_params.h:2062
#define VAR_UNV_RCPT_RCODE
Definition: mail_params.h:2216
char * var_smtpd_tls_mand_proto
const char * milter_mail_event(MILTERS *milters, const char **argv)
Definition: milter.c:456
int var_virt_mailbox_code
Definition: smtpd.c:1302
int var_smtpd_tls_ccert_vd
#define VAR_MILT_DATA_MACROS
Definition: mail_params.h:3380
#define MAIL_ATTR_DSN_ORCPT
Definition: mail_proto.h:276
char * var_tlsproxy_service
Definition: postscreen.c:509
#define DEF_SMTPD_SASL_PATH
Definition: mail_params.h:1624
#define DEF_CANONICAL_MAPS
Definition: mail_params.h:443
#define REASON_ERROR_LIMIT
Definition: smtpd.c:1492
char * var_smtpd_banner
Definition: smtpd.c:1234
#define DEF_SMTPD_EHLO_DIS_WORDS
Definition: mail_params.h:3122
bool var_smtpd_client_port_log
Definition: smtpd.c:1399
int var_verify_poll_delay
Definition: smtpd.c:1307
char * var_virt_mailbox_maps
Definition: smtpd.c:1268
#define VAR_MESSAGE_LIMIT
Definition: mail_params.h:1926
#define CLIENT_PROTO_UNKNOWN
Definition: smtpd.h:281
#define SMTPD_CMD_VRFY
Definition: smtpd.h:242
#define VAR_SMTPD_TLS_RECHEAD
Definition: mail_params.h:1375
#define SMTP_ERR_EOF
Definition: smtp_stream.h:30
#define VAR_MILT_CMD_TIME
Definition: mail_params.h:3400
#define VAR_ERROR_RCPT
Definition: mail_params.h:169
#define DEF_SMTPD_SASL_SERVICE
Definition: mail_params.h:1628
uid_t var_owner_uid
Definition: mail_params.c:234
char * var_smtpd_rej_footer
Definition: smtpd.c:1343
int valid_mailhost_literal(const char *addr, int gripe)
#define VAR_SMTPD_USE_TLS
Definition: mail_params.h:1271
SMTPD_PROXY_CMD_FN cmd
Definition: smtpd_proxy.h:30
#define DEF_SMTPD_SASL_ENABLE
Definition: mail_params.h:1612
char * var_milt_protocol
Definition: smtpd.c:1386
int var_smtpd_cntls_limit
Definition: smtpd.c:1330
#define DEF_SMTPD_TLS_EXCL_CIPH
Definition: mail_params.h:1344
#define NEUTER_CHARACTERS
Definition: smtpd.c:1485
#define VAR_SMTPD_TLS_AUTH_ONLY
Definition: mail_params.h:1279
#define dict_get(dp, key)
Definition: dict.h:236
#define REC_TYPE_CONT
Definition: rec_type.h:58
#define DEF_SMTPD_TLS_MAND_PROTO
Definition: mail_params.h:1332
#define CLEANUP_STAT_PROXY
Definition: cleanup_user.h:63
int anvil_clnt_disconnect(ANVIL_CLNT *anvil_clnt, const char *service, const char *addr)
Definition: anvil_clnt.c:376
char * var_local_rwr_clients
Definition: smtpd.c:1333
struct TOK822 * head
Definition: tok822.h:32
int type
Definition: tok822.h:28
#define DEF_ALIAS_MAPS
Definition: mail_params.h:527
#define VAR_MILT_CONN_MACROS
Definition: mail_params.h:3360
#define XCLIENT_DESTADDR
Definition: mail_proto.h:245
char * var_unv_rcpt_why
Definition: smtpd.c:1297
#define EHLO_MASK_SIZE
Definition: ehlo_mask.h:19
int dsn_notify_mask(const char *str)
Definition: dsn_mask.c:108
#define UPDATE_STR(s, v)
#define SMTPD_MILTERS_DISABLE
Definition: mail_params.h:3350
#define VERP_CMD_LEN
Definition: smtpd.c:1441
MAPS * maps_create(const char *title, const char *map_names, int dict_flags)
Definition: maps.c:112
char * var_local_rcpt_maps
Definition: smtpd.c:1270
#define VAR_SMTPD_TLS_FPT_DGST
Definition: mail_params.h:1351
const char * dict_changed_name(void)
Definition: dict.c:583
#define VAR_MILT_MAIL_MACROS
Definition: mail_params.h:3369
#define DEF_SMTPD_DELAY_OPEN
Definition: mail_params.h:1393
char * var_smtpd_snd_auth_maps
Definition: smtpd.c:1286
void smtpd_sasl_deactivate(SMTPD_STATE *)
const char * milter_reject_text
Definition: smtpd.h:184
#define VAR_EOD_CHECKS
Definition: mail_params.h:2112
#define SMTPD_CMD_FLAG_PRE_TLS
Definition: smtpd.c:4836
#define XCLIENT_TEMPORARY
Definition: mail_proto.h:249
#define VAR_SMTPD_TLS_EECDH
Definition: mail_params.h:1363
int vstream_fclose(VSTREAM *stream)
Definition: vstream.c:1268
#define VAR_SMTPD_SASL_REALM
Definition: mail_params.h:1639
#define REC_TYPE_TIME_FORMAT
Definition: rec_type.h:148
#define DEF_SMTPD_FORBID_CMDS
Definition: mail_params.h:1256
char * var_milt_helo_macros
Definition: smtpd.c:1391
char * access_denied
Definition: smtpd.h:100
int notify_mask
Definition: smtpd.h:94
#define REC_TYPE_RCPT
Definition: rec_type.h:45
bool var_smtpd_tls_set_sessid
#define EHLO_MASK_SILENT
Definition: ehlo_mask.h:31
#define DEF_SMTPD_TLS_WRAPPER
Definition: mail_params.h:1264
#define DEF_INPUT_TRANSP
Definition: mail_params.h:3014
int var_smtpd_starttls_tmout
#define DEF_SMTPD_NOOP_CMDS
Definition: mail_params.h:1252
void milter_abort(MILTERS *milters)
Definition: milter.c:593
#define DEF_DEFER_CODE
Definition: mail_params.h:2137
VSTRING * dsn_orcpt_buf
Definition: smtpd.h:156
#define DEF_VIRT_ALIAS_MAPS
Definition: mail_params.h:431
#define smtpd_sasl_auth_extern
struct SMTPD_CMD SMTPD_CMD
char * port
Definition: smtpd.h:78
char * var_smtpd_tls_dh512_param_file
#define DEF_RELAY_CCERTS
Definition: mail_params.h:2066
#define VAR_SMTPD_EHLO_DIS_MAPS
Definition: mail_params.h:3125
#define POP_STRING(old, curr)
int smtpd_check_addr(const char *sender, const char *addr, int smtputf8)
Definition: smtpd_check.c:4654
#define VSTRING_RESET(vp)
Definition: vstring.h:77
#define SMTPD_PROX_WANT_OK
Definition: smtpd_proxy.h:49
#define MAIL_ATTR_SASL_SENDER
Definition: mail_proto.h:158
#define VAR_SHOW_UNK_RCPT_TABLE
Definition: mail_params.h:41
#define VAR_MILT_MSG_TIME
Definition: mail_params.h:3404
#define DEF_SMTPD_SND_AUTH_MAPS
Definition: mail_params.h:1656
#define DEF_SMTPD_SASL_AUTH_HDR
Definition: mail_params.h:1616
int rec_fputs(VSTREAM *stream, int type, const char *str)
Definition: record.c:404
#define VAR_SMTPD_EHLO_DIS_WORDS
Definition: mail_params.h:3121
int var_smtpd_policy_try_limit
Definition: smtpd.c:1315
#define VAR_MILT_CONN_TIME
Definition: mail_params.h:3396
#define VAR_PERM_MX_NETWORKS
Definition: mail_params.h:2266
#define DICT_FLAG_LOCK
Definition: dict.h:116
char * var_unv_from_tf_act
Definition: smtpd.c:1406
#define REC_TYPE_MESG
Definition: rec_type.h:56
ARGV * saved_bcc
Definition: smtpd.h:143
#define VSTRING_STRDUP(s)
#define VSTREAM_PURGE_BOTH
Definition: vstream.h:90
int var_relay_rcpt_code
Definition: smtpd.c:1303
char * var_milt_daemon_name
Definition: smtpd.c:1388
#define DEF_QUEUE_MINFREE
Definition: mail_params.h:1931
char * var_milt_def_action
Definition: smtpd.c:1387
#define VAR_SMTPD_RCPT_LIMIT
Definition: mail_params.h:1223
#define VAR_SMTPD_RCPT_OVERLIM
Definition: mail_params.h:1243
char * var_smtpd_sasl_service
Definition: smtpd.c:1278
void msg_warn(const char *fmt,...)
Definition: msg.c:215
#define DEF_SMTPD_PEERNAME_LOOKUP
Definition: mail_params.h:2350
#define DEF_UNK_CLIENT_CODE
Definition: mail_params.h:2159
ANVIL_CLNT * anvil_clnt
Definition: smtpd.c:1461
#define MAIL_ATTR_ACT_CLIENT_NAME
Definition: mail_proto.h:215
#define DEF_LOC_RWR_CLIENTS
Definition: mail_params.h:3115
#define DEF_SMTPD_SASL_OPTS
Definition: mail_params.h:1620
#define MAIL_ERROR_SOFTWARE
Definition: mail_error.h:25
char * namaddr
Definition: smtpd.h:59
off_t msg_size
Definition: smtpd.h:111
void smtp_stream_setup(VSTREAM *stream, int maxtime, int enable_deadline)
Definition: smtp_stream.c:209
#define VAR_SMTPD_TLS_KEY_FILE
Definition: mail_params.h:1299
VSTRING * vstring_alloc(ssize_t len)
Definition: vstring.c:353
#define DEF_MILT_HELO_MACROS
Definition: mail_params.h:3365
#define XCLIENT_REVERSE_NAME
Definition: mail_proto.h:236
char * var_canonical_maps
Definition: smtpd.c:1264
#define DEF_SMTPD_TLS_CA_FILE
Definition: mail_params.h:1320
void milter_disc_event(MILTERS *milters)
Definition: milter.c:605
#define VAR_RBL_REPLY_MAPS
Definition: mail_params.h:2316
#define VAR_MILT_RCPT_MACROS
Definition: mail_params.h:3375
#define MAIL_ATTR_DSN_RET
Definition: mail_proto.h:274
void smtpd_proxy_free(SMTPD_STATE *state)
Definition: smtpd_proxy.c:1100
#define ANVIL_STAT_OK
Definition: anvil_clnt.h:48
#define SMTPD_FLAG_SMTPUTF8
Definition: smtpd.h:197
int var_defer_code
Definition: smtpd.c:1256
const char * username(void)
Definition: username.c:38
#define NAME_CODE_FLAG_NONE
Definition: name_code.h:22
#define CA_MAIL_SERVER_NBOOL_TABLE(v)
Definition: mail_server.h:62
int input_transp_cleanup(int cleanup_flags, int transp_mask)
Definition: input_transp.c:85
char * sender
Definition: smtpd.h:103
#define DEF_SMTPD_RCPT_OVERLIM
Definition: mail_params.h:1244
char * var_xclient_hosts
Definition: smtpd.c:1321
#define DEF_MILT_EOH_MACROS
Definition: mail_params.h:3389
#define DEF_SMTPD_TLS_512_FILE
Definition: mail_params.h:1356
#define DEF_MILT_DATA_MACROS
Definition: mail_params.h:3381
#define VAR_RELAY_CCERTS
Definition: mail_params.h:2065
#define DEF_SMTPD_REJ_UNL_RCPT
Definition: mail_params.h:2212
#define DEF_HELO_CHECKS
Definition: mail_params.h:2078
#define DEF_RCPT_CANON_MAPS
Definition: mail_params.h:451
#define XCLIENT_LOGIN_KLUDGE
#define PUSH_STRING(old, curr, new)
void debug_peer_init(void)
Definition: debug_peer.c:83
#define VAR_DATA_CHECKS
Definition: mail_params.h:2108
int success_count
Definition: smtpd.c:4831
#define MAIL_ATTR_ACT_REVERSE_CLIENT_NAME
Definition: mail_proto.h:221
const char * milter_rcpt_event(MILTERS *milters, int flags, const char **argv)
Definition: milter.c:478
#define VAR_MAP_DEFER_CODE
Definition: mail_params.h:2274
#define HAVE_FORWARDED_IDENT(s)
Definition: smtpd.h:365
#define MAIL_VERSION_STAMP_ALLOCATE
Definition: mail_version.h:67
char * var_smtpd_forbid_cmds
Definition: smtpd.c:1325
#define VAR_MILT_V
Definition: mail_params.h:3420
#define VAR_VERIFY_SENDER_TTL
Definition: mail_params.h:2826
#define SMTPD_STATE_XFORWARD_IDENT
Definition: smtpd.h:208
#define DEF_SMTPD_UPROXY_PROTO
Definition: mail_params.h:3948
#define FORWARD_IDENT(s)
Definition: smtpd.h:368
#define DEF_SMTPD_PROXY_FILT
Definition: mail_params.h:2993
void smtpd_chat_reply(SMTPD_STATE *state, const char *format,...)
Definition: smtpd_chat.c:148
#define VAR_SMTPD_TLS_DKEY_FILE
Definition: mail_params.h:1307
int var_local_rcpt_code
Definition: smtpd.c:1300
#define TLS_LEV_ENCRYPT
Definition: tls.h:45
#define VAR_INET_PROTOCOLS
Definition: mail_params.h:994
#define MAIL_PROTO_SMTP
Definition: mail_proto.h:30
void argv_truncate(ARGV *argvp, ssize_t len)
Definition: argv.c:253
#define VAR_MAPS_RBL_CODE
Definition: mail_params.h:2325
void debug_peer_restore(void)
Definition: debug_peer.c:127
char * var_smtpd_tls_eckey_file
#define FLUSH_STAT_DENY
Definition: flush_clnt.h:39
#define DEF_SMTPD_PROXY_EHLO
Definition: mail_params.h:2997
#define DEF_SMTPD_CLIENT_PORT_LOG
Definition: mail_params.h:3448
int var_unk_addr_code
Definition: smtpd.c:1247
char * ident
Definition: smtpd.h:63
#define VAR_SMTPD_JUNK_CMD
Definition: mail_params.h:1239
int error
Definition: dict.h:94
#define VAR_NON_FQDN_CODE
Definition: mail_params.h:2188
VSTRING * vstring_sprintf(VSTRING *vp, const char *format,...)
Definition: vstring.c:602
#define XFORWARD_CMD
Definition: mail_proto.h:251
#define DEF_SMTPD_CCONN_LIMIT
Definition: mail_params.h:3062
#define MAIL_ATTR_LOG_IDENT
Definition: mail_proto.h:162
#define VAR_UNV_FROM_RCODE
Definition: mail_params.h:2221
#define VAR_QUEUE_MINFREE
Definition: mail_params.h:1930
#define MAIL_ATTR_DSN_ENVID
Definition: mail_proto.h:273
#define DEF_UNV_RCPT_RCODE
Definition: mail_params.h:2217
#define MAIL_ATTR_LOG_CLIENT_ADDR
Definition: mail_proto.h:208
#define CA_MAIL_SERVER_TIME_TABLE(v)
Definition: mail_server.h:59
#define DEF_ALLOW_UNTRUST_ROUTE
Definition: mail_params.h:2121
VSTRING * tok822_internalize(VSTRING *, TOK822 *, int)
Definition: tok822_parse.c:199
char * lowercase(char *string)
Definition: lowercase.c:34
char * var_smtpd_cmd_filter
Definition: smtpd.c:1342
int var_strict_rfc821_env
Definition: smtpd.c:1262
#define SEND_ATTR_INT(name, val)
Definition: attr.h:63
#define XFORWARD_HELO
Definition: mail_proto.h:256
#define VAR_ALIAS_MAPS
Definition: mail_params.h:523
#define DEF_TLSPROXY_SERVICE
Definition: mail_params.h:3799
#define INET_PROTO_NAME_IPV6
Definition: mail_params.h:991
char * var_verp_clients
Definition: smtpd.c:1304
void milter_free(MILTERS *milters)
Definition: milter.c:733
#define FORWARD_DOMAIN(s)
Definition: smtpd.h:375
#define VAR_SMTPD_DELAY_REJECT
Definition: mail_params.h:2333
int rec_put(VSTREAM *stream, int type, const char *data, ssize_t len)
Definition: record.c:194
char * smtpd_check_size(SMTPD_STATE *state, off_t size)
Definition: smtpd_check.c:5281
#define allascii(s)
Definition: stringops.h:66
#define MAIL_ATTR_ACT_SERVER_PORT
Definition: mail_proto.h:225
int name_code(const NAME_CODE *table, int flags, const char *name)
Definition: name_code.c:65
#define VAR_UNK_NAME_TF_ACT
Definition: mail_params.h:2180
int var_line_limit
Definition: mail_params.c:263
#define VAR_RCPT_CANON_MAPS
Definition: mail_params.h:450
char * var_maps_rbl_domains
Definition: smtpd.c:1252
const char * verp_delims_verify(const char *delims)
Definition: verp_sender.c:104
int var_smtpd_junk_cmd_limit
Definition: smtpd.c:1272
bool var_disable_vrfy_cmd
Definition: smtpd.c:1263
int flags
Definition: smtpd.c:4830
#define DEF_REJECT_CODE
Definition: mail_params.h:2132
char * var_smtpd_milter_maps
Definition: smtpd.c:1382
#define VAR_UNV_FROM_WHY
Definition: mail_params.h:2245
NORETURN msg_fatal(const char *fmt,...)
Definition: msg.c:249
#define VAR_SMTPD_DNS_RE_FILTER
Definition: mail_params.h:4007
#define VAR_SMTPD_TMOUT
Definition: mail_params.h:1215
#define XFORWARD_DOM_REMOTE
Definition: mail_proto.h:260
#define VAR_SMTPD_PROXY_FILT
Definition: mail_params.h:2992
#define CLIENT_NAME_UNKNOWN
Definition: qmqpd.h:62
VSTREAM * stream
Definition: smtpd_proxy.h:27
int var_unv_from_dcode
Definition: smtpd.c:1294
void smtpd_chat_query(SMTPD_STATE *state)
Definition: smtpd_chat.c:126
#define DEF_SMTPD_HARD_ERLIM
Definition: mail_params.h:1232
char * var_unv_rcpt_tf_act
Definition: smtpd.c:1405
#define DEF_LOCAL_RCPT_CODE
Definition: mail_params.h:2361
int dsn_ret
Definition: smtpd.h:154
#define VAR_LOCAL_RCPT_CODE
Definition: mail_params.h:2360
char * var_smtpd_relay_ccerts
#define TLS_LEV_FPRINT
Definition: tls.h:46
MAIL_STREAM * mail_stream_service(const char *class, const char *name)
Definition: mail_stream.c:434
ARGV * prepend
Definition: smtpd.h:149
ssize_t peekfd(int)
Definition: peekfd.c:60
#define DEF_PLAINTEXT_CODE
Definition: mail_params.h:2151
char * smtpd_check_client(SMTPD_STATE *state)
Definition: smtpd_check.c:4762
#define VAR_VERIFY_POLL_COUNT
Definition: mail_params.h:2830
#define DEF_CYRUS_CONF_PATH
Definition: mail_params.h:1632
#define DEF_SMTPD_TLS_KEY_FILE
Definition: mail_params.h:1300
VSTREAM * stream
Definition: mail_stream.h:35
int smtpd_proxy_opts
Definition: smtpd.c:1409
#define DEF_UNV_RCPT_TF_ACT
Definition: mail_params.h:2234
int var_mul_rcpt_code
Definition: smtpd.c:1298
char * where
Definition: smtpd.h:109
int var_smtpd_soft_erlim
Definition: smtpd.c:1231
const char * milter_data_event(MILTERS *milters)
Definition: milter.c:504
#define VAR_SMTPD_REJ_UNL_RCPT
Definition: mail_params.h:2211
#define VAR_NOTIFY_CLASSES
Definition: mail_params.h:72
char * var_data_checks
Definition: smtpd.c:1242
char * var_smtpd_tls_loglevel
#define VAR_TLSPROXY_SERVICE
Definition: mail_params.h:3798
#define VAR_SMTPD_POLICY_TTL
Definition: mail_params.h:3032
int vstream_fflush(VSTREAM *stream)
Definition: vstream.c:1257
#define namadr_list_match
Definition: namadr_list.h:26
VSTRING * xtext_unquote(VSTRING *unquoted, const char *quoted)
Definition: xtext.c:139
char * var_etrn_checks
Definition: smtpd.c:1241
#define CLEANUP_STAT_CONT
Definition: cleanup_user.h:60
int error_mask
Definition: smtpd.h:93
#define CLEANUP_FLAG_MASK_EXTERNAL
Definition: cleanup_user.h:33
#define FORWARD_ADDR(s)
Definition: smtpd.h:355
#define CLEANUP_STAT_BAD
Definition: cleanup_user.h:57
#define DEF_SMTPD_TLS_ECKEY_FILE
Definition: mail_params.h:1316
#define SMTPD_STATE_XFORWARD_DOMAIN
Definition: smtpd.h:209
#define VAR_SMTPD_ACL_PERM_LOG
Definition: mail_params.h:3940
#define SMTPD_AFTER_DATA
Definition: smtpd.h:225
int var_helo_required
Definition: smtpd.c:1254
#define DEF_UNK_NAME_CODE
Definition: mail_params.h:2177
char * concatenate(const char *arg0,...)
Definition: concatenate.c:42
struct ANVIL_CLNT ANVIL_CLNT
Definition: anvil_clnt.h:54
int error
Definition: maps.h:25
void smtp_flush(VSTREAM *stream)
Definition: smtp_stream.c:228
char * var_smtpd_proxy_opts
Definition: smtpd.c:1311
char * mystrndup(const char *str, ssize_t len)
Definition: mymalloc.c:242
#define SMTPD_FLAG_ILL_PIPELINING
Definition: smtpd.h:195
int var_verify_poll_count
Definition: smtpd.c:1306
#define VAR_RELAY_CODE
Definition: mail_params.h:2260
int var_non_fqdn_code
Definition: smtpd.c:1258
int tls_level_lookup(const char *)
Definition: tls_level.c:85
char * reverse_name
Definition: smtpd.h:76
#define VAR_SMTPD_REC_DEADLINE
Definition: mail_params.h:3927
const char ** milter_argv
Definition: smtpd.h:182
#define VAR_STRICT_RFC821_ENV
Definition: mail_params.h:408
#define SMTPD_CMD_RSET
Definition: smtpd.h:240
int total_count
Definition: smtpd.c:4832
int name_status
Definition: smtpd.h:88
#define CA_MAIL_SERVER_NINT_TABLE(v)
Definition: mail_server.h:61
char * var_smtpd_tls_excl_ciph
char * helo_name
Definition: smtpd.h:62
ARGV * ehlo_argv
Definition: smtpd.h:191
#define vstream_peek(vp)
Definition: vstream.h:232
#define DEF_SMTPD_CRCPT_LIMIT
Definition: mail_params.h:3070
int dsn_ret_code(const char *str)
Definition: dsn_mask.c:90
int reverse_name_status
Definition: smtpd.h:89
char * var_input_transp
Definition: smtpd.c:1312
#define VAR_SMTPD_PROXY_EHLO
Definition: mail_params.h:2996
int var_bad_name_code
Definition: smtpd.c:1245
#define DEF_SMTPD_CRATE_LIMIT
Definition: mail_params.h:3058
char * var_unk_name_tf_act
Definition: smtpd.c:1403
#define VSTREAM_BST_OUT_PEND
Definition: vstream.h:230
int anvil_clnt_newtls(ANVIL_CLNT *anvil_clnt, const char *service, const char *addr, int *newtls)
Definition: anvil_clnt.c:304
struct SMTPD_PROXY * proxy
Definition: smtpd.h:161
#define DEF_MUL_RCPT_CODE
Definition: mail_params.h:2251
char * smtpd_check_rcpt(SMTPD_STATE *state, char *recipient)
Definition: smtpd_check.c:4907
#define MAIL_ATTR_SASL_USERNAME
Definition: mail_proto.h:157
#define VAR_SMTPD_SASL_EXCEPTIONS_NETWORKS
Definition: mail_params.h:1643
#define TOK822_STR_DEFL
Definition: tok822.h:91
#define DEF_SMTPD_ERR_SLEEP
Definition: mail_params.h:1236
#define DEF_ERROR_RCPT
Definition: mail_params.h:170
#define DEF_MAIL_CHECKS
Definition: mail_params.h:2082
int var_smtpd_uproxy_tmout
Definition: smtpd.c:1417
#define FORWARD_HELO(s)
Definition: smtpd.h:359
#define VAR_SMTPD_EXP_FILTER
Definition: mail_params.h:2343
#define VAR_SMTPD_POLICY_CONTEXT
Definition: mail_params.h:3048
#define XCLIENT_NAME
Definition: mail_proto.h:235
#define SMTPD_CMD_FLAG_LIMIT
Definition: smtpd.c:4835
char * var_smtpd_tls_mand_excl
char * var_rest_classes
Definition: smtpd.c:1261
int int
Definition: smtpd_proxy.h:21
#define VAR_MILT_EOD_MACROS
Definition: mail_params.h:3392
char * smtpd_check_queue(SMTPD_STATE *state)
Definition: smtpd_check.c:5306
void smtpd_xforward_reset(SMTPD_STATE *)
#define VAR_SMTPD_TLS_LEVEL
Definition: mail_params.h:1267
#define SMTPD_CMD_MAIL
Definition: smtpd.h:236
void smtpd_state_init(SMTPD_STATE *, VSTREAM *, const char *)
Definition: smtpd_state.c:78
bool var_smtpd_tls_wrappermode
Definition: smtpd.c:1340
#define DEF_SMTPD_DELAY_REJECT
Definition: mail_params.h:2334
#define REASON_TIMEOUT
Definition: smtpd.c:1490
#define quote_822_local(dst, src)
char * var_mail_checks
Definition: smtpd.c:1238
#define VAR_SMTPD_TLS_CIPH
Definition: mail_params.h:1335
#define vstream_feof(vp)
Definition: vstream.h:121
#define VAR_HELO_REQUIRED
Definition: mail_params.h:2073
char * dest_addr
Definition: smtpd.h:82
VSTRING * reply
Definition: smtpd_proxy.h:29
#define ISPRINT(c)
Definition: sys_defs.h:1751
#define DEF_SMTPD_REC_DEADLINE
Definition: mail_params.h:3928
#define DEF_SMTPD_CMD_FILTER
Definition: mail_params.h:1260
#define DEF_MILT_DAEMON_NAME
Definition: mail_params.h:3417
#define DEF_ETRN_CHECKS
Definition: mail_params.h:2105
#define VAR_SMTPD_POLICY_REQ_LIMIT
Definition: mail_params.h:3024
#define DEF_STRESS
Definition: mail_params.h:3533
#define SMTP_ERR_NONE
Definition: smtp_stream.h:33
int strcasecmp(const char *s1, const char *s2)
Definition: strcasecmp.c:41
#define DEF_SMTPD_MILTER_MAPS
Definition: mail_params.h:3347
#define VAR_SMTPD_SASL_SERVICE
Definition: mail_params.h:1627
#define XFORWARD_DOMAIN
Definition: mail_proto.h:258
int var_map_reject_code
Definition: smtpd.c:1250
#define VAR_SMTPD_TLS_ACERT
Definition: mail_params.h:1283
#define CLIENT_ADDR_UNKNOWN
Definition: qmqpd.h:63
#define SMTPD_CMD_QUIT
Definition: smtpd.h:244
char * var_perm_mx_networks
Definition: smtpd.c:1285
int var_reject_code
Definition: smtpd.c:1255
int anvil_clnt_mail(ANVIL_CLNT *anvil_clnt, const char *service, const char *addr, int *msgs)
Definition: anvil_clnt.c:256
char * addr
Definition: smtpd.h:77
int var_plaintext_code
Definition: smtpd.c:1379
#define DEF_PERM_MX_NETWORKS
Definition: mail_params.h:2267
#define DEF_SMTPD_POLICY_TRY_LIMIT
Definition: mail_params.h:3037
void smtpd_xforward_preset(SMTPD_STATE *)
#define DEF_UNV_FROM_DCODE
Definition: mail_params.h:2230
#define DEF_VIRT_MAILBOX_CODE
Definition: mail_params.h:2530
#define DEF_MILT_UNK_MACROS
Definition: mail_params.h:3385
#define VAR_DISABLE_VRFY_CMD
Definition: mail_params.h:423
char * var_smtpd_sasl_opts
Definition: smtpd.c:1276
int var_unv_from_rcode
Definition: smtpd.c:1292
#define VAR_VERIFY_SENDER
Definition: mail_params.h:2822
#define REC_TYPE_XTRA
Definition: rec_type.h:62
int var_smtpd_policy_try_delay
Definition: smtpd.c:1316
#define VAR_REJECT_TMPF_ACT
Definition: mail_params.h:2143
#define MAIL_ERROR_PROTOCOL
Definition: mail_error.h:23
#define DEF_MILT_EOD_MACROS
Definition: mail_params.h:3393
#define SMTP_ERR_DATA
Definition: smtp_stream.h:34
#define VAR_SMTPD_POLICY_TMOUT
Definition: mail_params.h:3020
#define MAIL_ATTR_LOG_CLIENT_NAME
Definition: mail_proto.h:207
VSTRING * vstring_free(VSTRING *vp)
Definition: vstring.c:380
int err
Definition: smtpd.h:69
int rcpt_count
Definition: smtpd.h:99
int var_unk_client_code
Definition: smtpd.c:1244
#define VAR_UNV_RCPT_WHY
Definition: mail_params.h:2241
#define DEF_SMTPD_HIST_THRSH
Definition: mail_params.h:1248
char * var_smtpd_tls_cert_file
#define DEF_SMTPD_CMAIL_LIMIT
Definition: mail_params.h:3066
#define DEF_SMTPD_BANNER
Definition: mail_params.h:1212
int var_smtpd_crate_limit
Definition: smtpd.c:1326
#define REJECT_EMPTY_ADDR
NORETURN single_server_main(int, char **, SINGLE_SERVER_FN,...)
int allprint(const char *string)
Definition: allprint.c:39
MILTERS * milters
Definition: smtpd.h:185
char * split_at(char *string, int delimiter)
Definition: split_at.c:53
#define DEF_SMTPD_JUNK_CMD
Definition: mail_params.h:1240
#define REC_TYPE_ATTR
Definition: rec_type.h:49
#define vstream_fileno(vp)
Definition: vstream.h:115
const char * milter_conn_event(MILTERS *milters, const char *client_name, const char *client_addr, const char *client_port, unsigned addr_family)
Definition: milter.c:399
#define FORWARD_PROTO(s)
Definition: smtpd.h:358
#define TLS_LEV_MAY
Definition: tls.h:44
int var_smtpd_cauth_limit
Definition: smtpd.c:1331
char * var_smtpd_milters
Definition: smtpd.c:1381
int discard
Definition: smtpd.h:140
#define SMTPD_STATE_XFORWARD_PROTO
Definition: smtpd.h:206
char * recipient
Definition: smtpd.h:106
char * var_inet_protocols
Definition: mail_params.c:260
char * var_smtpd_exp_filter
Definition: smtpd.c:1290
#define DEF_UNV_FROM_TF_ACT
Definition: mail_params.h:2238
int flags
Definition: smtpd.h:68
#define DEF_SMTPD_TLS_1024_FILE
Definition: mail_params.h:1360
#define NAMADR_LIST
Definition: namadr_list.h:22
#define VAR_PLAINTEXT_CODE
Definition: mail_params.h:2150
#define VAR_MILT_DEF_ACTION
Definition: mail_params.h:3412
#define CA_VSTREAM_CTL_END
Definition: vstream.h:155
#define DEF_SMTPD_TLS_DKEY_FILE
Definition: mail_params.h:1308
#define DEF_UNK_ADDR_TF_ACT
Definition: mail_params.h:2204
#define REC_TYPE_NORM
Definition: rec_type.h:59
#define DEF_SMTPD_PROXY_TMOUT
Definition: mail_params.h:3001
#define DEF_VIRT_ALIAS_CODE
Definition: mail_params.h:439
#define VAR_SMTPD_UPROXY_PROTO
Definition: mail_params.h:3947
#define EHLO_MASK_ENHANCEDSTATUSCODES
Definition: ehlo_mask.h:28
char * var_smtpd_ehlo_dis_words
Definition: smtpd.c:1334
int var_show_unk_rcpt_table
Definition: smtpd.c:1305
#define FLUSH_STAT_OK
Definition: flush_clnt.h:37
#define REC_TYPE_TIME
Definition: rec_type.h:38
#define VAR_SMTPD_POLICY_IDLE
Definition: mail_params.h:3028
#define DEF_SMTPD_TLS_SET_SESSID
Definition: mail_params.h:1389
#define CLEANUP_STAT_WRITE
Definition: cleanup_user.h:58
#define VAR_BAD_NAME_CODE
Definition: mail_params.h:2170
#define DEF_MILT_V
Definition: mail_params.h:3421
#define VAR_SMTPD_TLS_DCERT_FILE
Definition: mail_params.h:1303
ssize_t argc
Definition: argv.h:19
int var_strict_smtputf8
Definition: mail_params.c:344
#define DEF_VIRT_MAILBOX_MAPS
Definition: mail_params.h:2522
#define XFORWARD_ADDR
Definition: mail_proto.h:253
#define XFORWARD_IDENT
Definition: mail_proto.h:257
#define MAIL_ATTR_ACT_PROTO_NAME
Definition: mail_proto.h:220
VSTRING * dsn_buf
Definition: smtpd.h:155
int var_smtpd_hard_erlim
Definition: smtpd.c:1232
#define DEF_UNK_NAME_TF_ACT
Definition: mail_params.h:2181
#define DEF_SMTPD_SASL_TYPE
Definition: mail_params.h:1652
int var_smtpd_rcpt_overlim
Definition: smtpd.c:1273
int smtpd_token(char *cp, SMTPD_TOKEN **argvp)
Definition: smtpd_token.c:175
int conn_count
Definition: smtpd.h:90
char * var_smtpd_tls_level
Definition: smtpd.c:1337
int var_smtpd_policy_tmout
Definition: smtpd.c:1313
#define VAR_SMTPD_TLS_MAND_CIPH
Definition: mail_params.h:1339
#define VAR_SMTPD_TLS_SET_SESSID
Definition: mail_params.h:1388
#define CLEANUP_STAT_DEFER
Definition: cleanup_user.h:64
char * var_myhostname
Definition: mail_params.c:223
#define SMTPD_CMD_HELO
Definition: smtpd.h:232
#define SMTPD_CMD_RCPT
Definition: smtpd.h:237
#define CA_MAIL_SERVER_PRE_ACCEPT(v)
Definition: mail_server.h:68
#define VAR_RCPT_CHECKS
Definition: mail_params.h:2100
#define VAR_SMTPD_PROXY_OPTS
Definition: mail_params.h:3004
char * smtpd_check_rewrite(SMTPD_STATE *state)
Definition: smtpd_check.c:4690
char * printable(char *string, int replacement)
Definition: printable.c:49
#define EHLO_MASK_VRFY
Definition: ehlo_mask.h:20
#define XCLIENT_CMD
Definition: mail_proto.h:234
void vstream_control(VSTREAM *stream, int name,...)
Definition: vstream.c:1372
char * var_rbl_reply_maps
Definition: smtpd.c:1253
void smtpd_sasl_activate(SMTPD_STATE *, const char *, const char *)
bool var_smtpd_enforce_tls
Definition: smtpd.c:1339
int var_relay_code
Definition: smtpd.c:1248
ssize_t vstream_bufstat(VSTREAM *vp, int command)
Definition: vstream.c:1539
#define DEF_SMTPD_EXP_FILTER
Definition: mail_params.h:2344
#define SMTPD_PEER_CODE_TEMP
Definition: smtpd.h:332
#define VAR_SMTPD_SASL_OPTS
Definition: mail_params.h:1619
#define DEF_SMTPD_CNTLS_LIMIT
Definition: mail_params.h:3074
#define VAR_UNK_CLIENT_CODE
Definition: mail_params.h:2158
#define DEF_MAP_REJECT_CODE
Definition: mail_params.h:2271
void smtpd_check_init(void)
Definition: smtpd_check.c:721
#define XCLIENT_PORT
Definition: mail_proto.h:241
char * var_smtpd_sasl_exceptions_networks
Definition: smtpd.c:1281
char * var_smtpd_tls_CAfile
#define EHLO_MASK_AUTH
Definition: ehlo_mask.h:22
#define CLIENT_PORT_UNKNOWN
Definition: qmqpd.h:64
#define EHLO_MASK_ETRN
Definition: ehlo_mask.h:21
char * strval
Definition: smtpd_token.h:21
#define MAIL_ATTR_ENC_8BIT
Definition: mail_proto.h:203
#define VAR_SMTPD_TLS_WRAPPER
Definition: mail_params.h:1263
#define DEF_SMTPD_TLS_RECHEAD
Definition: mail_params.h:1376
#define VAR_SMTPD_SND_AUTH_MAPS
Definition: mail_params.h:1655
#define EHLO_APPEND(state, cmd)
void milter_macro_callback(MILTERS *milters, const char *(*mac_lookup)(const char *, void *), void *mac_context)
Definition: milter.c:363
#define XCLIENT_DESTPORT
Definition: mail_proto.h:246
char * rfc_addr
Definition: smtpd.h:80
char * protocol
Definition: smtpd.h:108
int vstream_fpurge(VSTREAM *stream, int direction)
Definition: vstream.c:1041
const char * maps_find(MAPS *maps, const char *name, int flags)
Definition: maps.c:162
#define vstream_ferror(vp)
Definition: vstream.h:120
#define VAR_SMTPD_ENFORCE_TLS
Definition: mail_params.h:1275
#define VAR_MUL_RCPT_CODE
Definition: mail_params.h:2250
#define DEF_SMTPD_POLICY_REQ_LIMIT
Definition: mail_params.h:3025
#define VAR_VERIFY_POLL_DELAY
Definition: mail_params.h:2834
#define DEF_XFORWARD_HOSTS
Definition: mail_params.h:2615
int warn_compat_break_smtputf8_enable
Definition: mail_params.c:364
#define DEF_SMTPD_TLS_CA_PATH
Definition: mail_params.h:1324
int error_count
Definition: smtpd.h:92
int rec_fprintf(VSTREAM *stream, int type, const char *format,...)
Definition: record.c:391
int var_queue_minfree
Definition: smtpd.c:1233
int saved_flags
Definition: smtpd.h:144
VSTRING * uxtext_unquote(VSTRING *unquoted, const char *quoted)
Definition: uxtext.c:219
int smtpd_input_transp_mask
Definition: smtpd.c:1467
#define VAR_SMTPD_PROXY_TMOUT
Definition: mail_params.h:3000
#define DEF_SMTPD_POLICY_CONTEXT
Definition: mail_params.h:3049
#define REC_TYPE_FLGS
Definition: rec_type.h:53
#define PERMIT_EMPTY_ADDR
#define DEF_SMTPD_SASL_REALM
Definition: mail_params.h:1640
#define CA_VSTREAM_CTL_SWAP_FD(v)
Definition: vstream.h:170
char * service
Definition: smtpd.h:73
#define DEF_SMTPD_TLS_FPT_DGST
Definition: mail_params.h:1352
#define VAR_SMTPD_POLICY_TRY_DELAY
Definition: mail_params.h:3040
char * var_smtpd_sasl_realm
Definition: smtpd.c:1280
char * var_milt_conn_macros
Definition: smtpd.c:1390
char * var_xforward_hosts
Definition: smtpd.c:1322
#define VAR_MILT_EOH_MACROS
Definition: mail_params.h:3388
char * var_relay_rcpt_maps
Definition: smtpd.c:1299
char * var_smtpd_sasl_path
Definition: smtpd.c:1277
char * smtpd_sasl_mail_opt(SMTPD_STATE *, const char *)
#define SMTPD_CMD_UNKNOWN
Definition: smtpd.h:247
#define MAIL_ATTR_FLAGS
Definition: mail_proto.h:128
char * name
Definition: smtpd.c:4828
char * var_virt_alias_maps
Definition: smtpd.c:1267
#define DEF_UNV_RCPT_DCODE
Definition: mail_params.h:2226
#define DEF_REJECT_TMPF_ACT
Definition: mail_params.h:2144
#define DEF_RELAY_RCPT_MAPS
Definition: mail_params.h:2058
#define VAR_LOC_RWR_CLIENTS
Definition: mail_params.h:3114
#define DEF_SMTPD_TLS_MAND_EXCL
Definition: mail_params.h:1348
#define VAR_BROKEN_AUTH_CLNTS
Definition: mail_params.h:416
int var_smtpd_cmail_limit
Definition: smtpd.c:1328
ANVIL_CLNT * anvil_clnt_create(void)
Definition: anvil_clnt.c:175
VSTRING * vstring_strcat(VSTRING *vp, const char *src)
Definition: vstring.c:459
bool var_broken_auth_clients
Definition: smtpd.c:1284
int var_smtpd_proxy_tmout
Definition: smtpd.c:1309
char * var_client_checks
Definition: smtpd.c:1236
VSTRING * vstrval
Definition: smtpd_token.h:22
struct TOK822 * next
Definition: tok822.h:31
#define DEF_VERP_CLIENTS
Definition: mail_params.h:2601
#define VAR_VERP_CLIENTS
Definition: mail_params.h:2600
int flush_send_site(const char *site)
Definition: flush_clnt.c:165
int var_smtpd_policy_ttl
Definition: smtpd.c:1320
#define MAIL_ATTR_LOG_CLIENT_PORT
Definition: mail_proto.h:209
#define VAR_SMTPD_DELAY_OPEN
Definition: mail_params.h:1392
#define FORWARD_NAMADDR(s)
Definition: smtpd.h:357
#define VAR_SMTPD_TLS_ECKEY_FILE
Definition: mail_params.h:1315
#define DEF_CLIENT_CHECKS
Definition: mail_params.h:2070
char * var_unk_addr_tf_act
Definition: smtpd.c:1404
#define DEF_DEF_RBL_REPLY
Definition: mail_params.h:2321
bool var_smtpd_tls_auth_only
Definition: smtpd.c:1341
#define DEF_SMTPD_TLS_EECDH
Definition: mail_params.h:1367
#define REC_TYPE_TIME_ARG(tv)
Definition: rec_type.h:149
int milter_send(MILTERS *milters, VSTREAM *stream)
Definition: milter.c:761
#define MAIL_ATTR_ENC_7BIT
Definition: mail_proto.h:204
int var_maps_rbl_code
Definition: smtpd.c:1249
char * namaddr
Definition: smtpd.h:79
#define VAR_RELAY_RCPT_MAPS
Definition: mail_params.h:2057
ARGV * history
Definition: smtpd.h:101
#define CLEANUP_FLAG_SMTP_REPLY
Definition: cleanup_user.h:25
void dns_rr_filter_compile(const char *, const char *)
Definition: dns_rr_filter.c:85
#define DEF_SEND_CANON_MAPS
Definition: mail_params.h:447
#define MAIL_SRC_MASK_SMTPD
Definition: mail_proto.h:78
int var_smtpd_hist_thrsh
Definition: smtpd.c:1289
#define SMTPD_PEER_CODE_OK
Definition: smtpd.h:331
#define DEF_SMTPD_TMOUT
Definition: mail_params.h:1216
const char * dsn
Definition: cleanup_user.h:86
#define EHLO_MASK_PIPELINING
Definition: ehlo_mask.h:18
char * verp_delims
Definition: smtpd.h:105
#define XFORWARD_UNAVAILABLE
Definition: mail_proto.h:262
#define VAR_SMTPD_CRATE_LIMIT
Definition: mail_params.h:3057
#define VAR_REST_CLASSES
Definition: mail_params.h:2116
#define CA_MAIL_SERVER_PRE_INIT(v)
Definition: mail_server.h:64
int ehlo_mask(const char *mask_str)
Definition: ehlo_mask.c:86
#define VAR_DEFER_CODE
Definition: mail_params.h:2136
char * var_helo_checks
Definition: smtpd.c:1237
char * var_verp_filter
Definition: mail_params.c:290
char * var_milt_mail_macros
Definition: smtpd.c:1392
#define SMTP_GET_FLAG_NONE
Definition: smtp_stream.h:50
void * mymalloc(ssize_t len)
Definition: mymalloc.c:150
#define SMTPD_TOK_ERROR
Definition: smtpd_token.h:27
#define DONT_GRIPE
Definition: haproxy_srvr.h:31
char * var_smtpd_tls_dcert_file
#define DEF_SMTPD_POLICY_TTL
Definition: mail_params.h:3033
#define DEF_SMTPD_TLS_DCERT_FILE
Definition: mail_params.h:1304
void msg_info(const char *fmt,...)
Definition: msg.c:199
#define SMTPD_FLAG_HANGUP
Definition: smtpd.h:194
VSTRING * instance
Definition: smtpd.h:150
void smtpd_state_reset(SMTPD_STATE *)
Definition: smtpd_state.c:190
#define VAR_VIRT_MAILBOX_CODE
Definition: mail_params.h:2529
#define namadr_list_init(o, f, p)
Definition: namadr_list.h:24
#define milter_create(milter_names, conn_timeout, cmd_timeout, msg_timeout, protocol, def_action, conn_macros, helo_macros, mail_macros, rcpt_macros, data_macros, eoh_macros, eod_macros, unk_macros, macro_deflts)
Definition: milter.h:122
#define VAR_VIRT_ALIAS_CODE
Definition: mail_params.h:438
int conn_rate
Definition: smtpd.h:91