~ubuntu-branches/ubuntu/maverick/postfix/maverick-security

« back to all changes in this revision

Viewing changes to src/smtpd/smtpd.c

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones, Wietse Venema, LaMont Jones
  • Date: 2009-06-03 14:17:08 UTC
  • mfrom: (1.1.22 upstream)
  • Revision ID: james.westby@ubuntu.com-20090603141708-o9u59xlor7nmd2x1
[Wietse Venema]

* New upstream release: 2.6.2~rc1

[LaMont Jones]

* move postfix-add-{filter,policy} manpages to section 8, and deliver
* provide: default-mta on ubuntu

Show diffs side-by-side

added added

removed removed

Lines of Context:
119
119
/*      Force the Postfix SMTP server to issue a TLS session id, even
120
120
/*      when TLS session caching is turned off (smtpd_tls_session_cache_database
121
121
/*      is empty).
 
122
/* .PP
 
123
/*      Available in Postfix version 2.6 and later:
 
124
/* .IP "\fBtcp_windowsize (0)\fR"
 
125
/*      An optional workaround for routers that break TCP window scaling.
122
126
/* ADDRESS REWRITING CONTROLS
123
127
/* .ad
124
128
/* .fi
172
176
/* .IP "\fBsmtpd_milters (empty)\fR"
173
177
/*      A list of Milter (mail filter) applications for new mail that
174
178
/*      arrives via the Postfix \fBsmtpd\fR(8) server.
175
 
/* .IP "\fBmilter_protocol (2)\fR"
 
179
/* .IP "\fBmilter_protocol (6)\fR"
176
180
/*      The mail filter protocol version and optional protocol extensions
177
 
/*      for communication with a Milter (mail filter) application.
 
181
/*      for communication with a Milter application; prior to Postfix 2.6
 
182
/*      the default protocol is 2.
178
183
/* .IP "\fBmilter_default_action (tempfail)\fR"
179
184
/*      The default action when a Milter (mail filter) application is
180
185
/*      unavailable or mis-configured.
191
196
/* .IP "\fBmilter_content_timeout (300s)\fR"
192
197
/*      The time limit for sending message content to a Milter (mail
193
198
/*      filter) application, and for receiving the response.
194
 
/* .IP "\fBmilter_connect_macros (see postconf -n output)\fR"
 
199
/* .IP "\fBmilter_connect_macros (see 'postconf -d' output)\fR"
195
200
/*      The macros that are sent to Milter (mail filter) applications
196
201
/*      after completion of an SMTP connection.
197
 
/* .IP "\fBmilter_helo_macros (see postconf -n output)\fR"
 
202
/* .IP "\fBmilter_helo_macros (see 'postconf -d' output)\fR"
198
203
/*      The macros that are sent to Milter (mail filter) applications
199
204
/*      after the SMTP HELO or EHLO command.
200
 
/* .IP "\fBmilter_mail_macros (see postconf -n output)\fR"
 
205
/* .IP "\fBmilter_mail_macros (see 'postconf -d' output)\fR"
201
206
/*      The macros that are sent to Milter (mail filter) applications
202
207
/*      after the SMTP MAIL FROM command.
203
 
/* .IP "\fBmilter_rcpt_macros (see postconf -n output)\fR"
 
208
/* .IP "\fBmilter_rcpt_macros (see 'postconf -d' output)\fR"
204
209
/*      The macros that are sent to Milter (mail filter) applications
205
210
/*      after the SMTP RCPT TO command.
206
 
/* .IP "\fBmilter_data_macros (see postconf -n output)\fR"
 
211
/* .IP "\fBmilter_data_macros (see 'postconf -d' output)\fR"
207
212
/*      The macros that are sent to version 4 or higher Milter (mail
208
213
/*      filter) applications after the SMTP DATA command.
209
 
/* .IP "\fBmilter_unknown_command_macros (see postconf -n output)\fR"
 
214
/* .IP "\fBmilter_unknown_command_macros (see 'postconf -d' output)\fR"
210
215
/*      The macros that are sent to version 3 or higher Milter (mail
211
216
/*      filter) applications after an unknown SMTP command.
212
 
/* .IP "\fBmilter_end_of_header_macros (see postconf -n output)\fR"
 
217
/* .IP "\fBmilter_end_of_header_macros (see 'postconf -d' output)\fR"
213
218
/*      The macros that are sent to Milter (mail filter) applications
214
219
/*      after the end of the message header.
215
 
/* .IP "\fBmilter_end_of_data_macros (see postconf -n output)\fR"
 
220
/* .IP "\fBmilter_end_of_data_macros (see 'postconf -d' output)\fR"
216
221
/*      The macros that are sent to Milter (mail filter) applications
217
222
/*      after the message end-of-data.
218
223
/* GENERAL CONTENT INSPECTION CONTROLS
301
306
/*      The time limit for Postfix SMTP server write and read operations
302
307
/*      during TLS startup and shutdown handshake procedures.
303
308
/* .IP "\fBsmtpd_tls_CAfile (empty)\fR"
304
 
/*      The file with the certificate of the certification authority
305
 
/*      (CA) that issued the Postfix SMTP server certificate.
306
 
/* .IP "\fBsmtpd_tls_CAfile (empty)\fR"
307
 
/*      The file with the certificate of the certification authority
308
 
/*      (CA) that issued the Postfix SMTP server certificate.
 
309
/*      A file containing (PEM format) CA certificates of root CAs trusted
 
310
/*      to sign either remote SMTP client certificates or intermediate CA
 
311
/*      certificates.
 
312
/* .IP "\fBsmtpd_tls_CApath (empty)\fR"
 
313
/*      A directory containing (PEM format) CA certificates of root CAs
 
314
/*      trusted to sign either remote SMTP client certificates or intermediate CA
 
315
/*      certificates.
309
316
/* .IP "\fBsmtpd_tls_always_issue_session_ids (yes)\fR"
310
317
/*      Force the Postfix SMTP server to issue a TLS session id, even
311
318
/*      when TLS session caching is turned off (smtpd_tls_session_cache_database
338
345
/* .IP "\fBsmtpd_tls_loglevel (0)\fR"
339
346
/*      Enable additional Postfix SMTP server logging of TLS activity.
340
347
/* .IP "\fBsmtpd_tls_mandatory_ciphers (medium)\fR"
341
 
/*      The minimum TLS cipher grade that the Postfix SMTP server will
342
 
/*      use with mandatory
343
 
/*      TLS encryption.
 
348
/*      The minimum TLS cipher grade that the Postfix SMTP server
 
349
/*      will use with mandatory TLS encryption.
344
350
/* .IP "\fBsmtpd_tls_mandatory_exclude_ciphers (empty)\fR"
345
351
/*      Additional list of ciphers or cipher types to exclude from the
346
352
/*      SMTP server cipher list at mandatory TLS security levels.
385
391
/*      The message digest algorithm used to construct client-certificate
386
392
/*      fingerprints for \fBcheck_ccert_access\fR and
387
393
/*      \fBpermit_tls_clientcerts\fR.
 
394
/* .PP
 
395
/*      Available in Postfix version 2.6 and later:
 
396
/* .IP "\fBsmtpd_tls_protocols (empty)\fR"
 
397
/*      List of TLS protocols that the Postfix SMTP server will exclude
 
398
/*      or include with opportunistic TLS encryption.
 
399
/* .IP "\fBsmtpd_tls_ciphers (export)\fR"
 
400
/*      The minimum TLS cipher grade that the Postfix SMTP server
 
401
/*      will use with opportunistic TLS encryption.
 
402
/* .IP "\fBsmtpd_tls_eccert_file (empty)\fR"
 
403
/*      File with the Postfix SMTP server ECDSA certificate in PEM format.
 
404
/* .IP "\fBsmtpd_tls_eckey_file ($smtpd_tls_eccert_file)\fR"
 
405
/*      File with the Postfix SMTP server ECDSA private key in PEM format.
 
406
/* .IP "\fBsmtpd_tls_eecdh_grade (see 'postconf -d' output)\fR"
 
407
/*      The Postfix SMTP server security grade for ephemeral elliptic-curve
 
408
/*      Diffie-Hellman (EECDH) key exchange.
 
409
/* .IP "\fBtls_eecdh_strong_curve (prime256v1)\fR"
 
410
/*      The elliptic curve used by the SMTP server for sensibly strong
 
411
/*      ephemeral ECDH key exchange.
 
412
/* .IP "\fBtls_eecdh_ultra_curve (secp384r1)\fR"
 
413
/*      The elliptic curve used by the SMTP server for maximally strong
 
414
/*      ephemeral ECDH key exchange.
388
415
/* OBSOLETE STARTTLS CONTROLS
389
416
/* .ad
390
417
/* .fi
549
576
/* .IP "\fBsmtpd_recipient_limit (1000)\fR"
550
577
/*      The maximal number of recipients that the Postfix SMTP server
551
578
/*      accepts per message delivery request.
552
 
/* .IP "\fBsmtpd_timeout (300s)\fR"
 
579
/* .IP "\fBsmtpd_timeout (normal: 300s, stress: 10s)\fR"
553
580
/*      The time limit for sending a Postfix SMTP server response and for
554
581
/*      receiving a remote SMTP client request.
555
582
/* .IP "\fBsmtpd_history_flush_threshold (100)\fR"
603
630
/*      The number of errors a remote SMTP client is allowed to make without
604
631
/*      delivering mail before the Postfix SMTP server slows down all its
605
632
/*      responses.
606
 
/* .IP "\fBsmtpd_hard_error_limit (20)\fR"
 
633
/* .IP "\fBsmtpd_hard_error_limit (normal: 20, stress: 1)\fR"
607
634
/*      The maximal number of errors a remote SMTP client is allowed to
608
635
/*      make without delivering mail.
609
 
/* .IP "\fBsmtpd_junk_command_limit (100)\fR"
 
636
/* .IP "\fBsmtpd_junk_command_limit (normal: 100, stress: 1)\fR"
610
637
/*      The number of junk commands (NOOP, VRFY, ETRN or RSET) that a remote
611
638
/*      SMTP client can send before the Postfix SMTP server starts to
612
639
/*      increment the error counter with each junk command.
719
746
/*      The sender address to use in address verification probes; prior
720
747
/*      to Postfix 2.5 the default was "postmaster".
721
748
/* .IP "\fBunverified_sender_reject_code (450)\fR"
722
 
/*      The numerical Postfix SMTP server response code when a sender
 
749
/*      The numerical Postfix SMTP server response code when a recipient
723
750
/*      address is rejected by the reject_unverified_sender restriction.
724
751
/* .IP "\fBunverified_recipient_reject_code (450)\fR"
725
752
/*      The numerical Postfix SMTP server response when a recipient address
726
753
/*      is rejected by the reject_unverified_recipient restriction.
 
754
/* .PP
 
755
/*      Available in Postfix version 2.6 and later:
 
756
/* .IP "\fBunverified_sender_defer_code (450)\fR"
 
757
/*      The numerical Postfix SMTP server response code when a sender address
 
758
/*      probe fails due to a temporary error condition.
 
759
/* .IP "\fBunverified_recipient_defer_code (450)\fR"
 
760
/*      The numerical Postfix SMTP server response when a recipient address
 
761
/*      probe fails due to a temporary error condition.
 
762
/* .IP "\fBunverified_sender_reject_reason (empty)\fR"
 
763
/*      The Postfix SMTP server's reply when rejecting mail with
 
764
/*      reject_unverified_sender.
 
765
/* .IP "\fBunverified_recipient_reject_reason (empty)\fR"
 
766
/*      The Postfix SMTP server's reply when rejecting mail with
 
767
/*      reject_unverified_recipient.
 
768
/* .IP "\fBunverified_sender_tempfail_action ($reject_tempfail_action)\fR"
 
769
/*      The Postfix SMTP server's action when reject_unverified_sender
 
770
/*      fails due to a temporary error condition.
 
771
/* .IP "\fBunverified_recipient_tempfail_action ($reject_tempfail_action)\fR"
 
772
/*      The Postfix SMTP server's action when reject_unverified_recipient
 
773
/*      fails due to a temporary error condition.
727
774
/* ACCESS CONTROL RESPONSES
728
775
/* .ad
729
776
/* .fi
730
777
/*      The following parameters control numerical SMTP reply codes
731
778
/*      and/or text responses.
732
779
/* .IP "\fBaccess_map_reject_code (554)\fR"
733
 
/*      The numerical Postfix SMTP server response code when a client
734
 
/*      is rejected by an \fBaccess\fR(5) map restriction.
 
780
/*      The numerical Postfix SMTP server response code for
 
781
/*      an \fBaccess\fR(5) map "reject" action.
735
782
/* .IP "\fBdefer_code (450)\fR"
736
783
/*      The numerical Postfix SMTP server response code when a remote SMTP
737
784
/*      client request is rejected by the "defer" restriction.
780
827
/*      restriction.
781
828
/* .IP "\fBrbl_reply_maps (empty)\fR"
782
829
/*      Optional lookup tables with RBL response templates.
 
830
/* .PP
 
831
/*      Available in Postfix version 2.6 and later:
 
832
/* .IP "\fBaccess_map_defer_code (450)\fR"
 
833
/*      The numerical Postfix SMTP server response code for
 
834
/*      an \fBaccess\fR(5) map "defer" action, including "defer_if_permit"
 
835
/*      or "defer_if_reject".
 
836
/* .IP "\fBreject_tempfail_action (defer_if_permit)\fR"
 
837
/*      The Postfix SMTP server's action when a reject-type restriction
 
838
/*      fails due to a temporary error condition.
 
839
/* .IP "\fBunknown_helo_hostname_tempfail_action ($reject_tempfail_action)\fR"
 
840
/*      The Postfix SMTP server's action when reject_unknown_helo_hostname
 
841
/*      fails due to an temporary error condition.
 
842
/* .IP "\fBunknown_address_tempfail_action ($reject_tempfail_action)\fR"
 
843
/*      The Postfix SMTP server's action when reject_unknown_sender_domain
 
844
/*      or reject_unknown_recipient_domain fail due to a temporary error
 
845
/*      condition.
783
846
/* MISCELLANEOUS CONTROLS
784
847
/* .ad
785
848
/* .fi
830
893
/*      banner.
831
894
/* .IP "\fBsyslog_facility (mail)\fR"
832
895
/*      The syslog facility of Postfix logging.
833
 
/* .IP "\fBsyslog_name (postfix)\fR"
 
896
/* .IP "\fBsyslog_name (see 'postconf -d' output)\fR"
834
897
/*      The mail system name that is prepended to the process name in syslog
835
898
/*      records, so that "smtpd" becomes, for example, "postfix/smtpd".
836
899
/* .PP
1017
1080
int     var_unk_addr_code;
1018
1081
int     var_relay_code;
1019
1082
int     var_maps_rbl_code;
1020
 
int     var_access_map_code;
 
1083
int     var_map_reject_code;
 
1084
int     var_map_defer_code;
1021
1085
char   *var_maps_rbl_domains;
1022
1086
char   *var_rbl_reply_maps;
1023
1087
int     var_helo_required;
1056
1120
int     var_smtpd_hist_thrsh;
1057
1121
char   *var_smtpd_exp_filter;
1058
1122
char   *var_def_rbl_reply;
1059
 
int     var_unv_from_code;
1060
 
int     var_unv_rcpt_code;
 
1123
int     var_unv_from_rcode;
 
1124
int     var_unv_rcpt_rcode;
 
1125
int     var_unv_from_dcode;
 
1126
int     var_unv_rcpt_dcode;
 
1127
char   *var_unv_from_why;
 
1128
char   *var_unv_rcpt_why;
1061
1129
int     var_mul_rcpt_code;
1062
1130
char   *var_relay_rcpt_maps;
1063
1131
char   *var_verify_sender;
1095
1163
bool    var_smtpd_use_tls;
1096
1164
bool    var_smtpd_enforce_tls;
1097
1165
bool    var_smtpd_tls_wrappermode;
 
1166
bool    var_smtpd_tls_auth_only;
1098
1167
 
1099
1168
#ifdef USE_TLS
1100
1169
char   *var_smtpd_relay_ccerts;
1103
1172
char   *var_smtpd_tls_CAfile;
1104
1173
char   *var_smtpd_tls_CApath;
1105
1174
bool    var_smtpd_tls_ask_ccert;
1106
 
bool    var_smtpd_tls_auth_only;
1107
1175
int     var_smtpd_tls_ccert_vd;
1108
1176
char   *var_smtpd_tls_cert_file;
1109
1177
char   *var_smtpd_tls_mand_ciph;
1121
1189
int     var_smtpd_tls_scache_timeout;
1122
1190
bool    var_smtpd_tls_set_sessid;
1123
1191
char   *var_smtpd_tls_fpt_dgst;
 
1192
char   *var_smtpd_tls_ciph;
 
1193
char   *var_smtpd_tls_proto;
 
1194
char   *var_smtpd_tls_eecdh;
 
1195
char   *var_smtpd_tls_eccert_file;
 
1196
char   *var_smtpd_tls_eckey_file;
1124
1197
 
1125
1198
#endif
1126
1199
 
1146
1219
bool    var_smtpd_client_port_log;
1147
1220
char   *var_stress;
1148
1221
 
 
1222
char   *var_reject_tmpf_act;
 
1223
char   *var_unk_name_tf_act;
 
1224
char   *var_unk_addr_tf_act;
 
1225
char   *var_unv_rcpt_tf_act;
 
1226
char   *var_unv_from_tf_act;
 
1227
 
1149
1228
 /*
1150
1229
  * Silly little macros.
1151
1230
  */
1221
1300
  * TLS initialization status.
1222
1301
  */
1223
1302
static TLS_APPL_STATE *smtpd_tls_ctx;
1224
 
static int wantcert;
 
1303
static int ask_client_cert;
1225
1304
 
1226
1305
#endif
1227
1306
 
1535
1614
#endif
1536
1615
#ifdef USE_SASL_AUTH
1537
1616
    if ((discard_mask & EHLO_MASK_AUTH) == 0) {
1538
 
        if (var_smtpd_sasl_enable && !sasl_client_exception(state)
1539
 
#ifdef USE_TLS
1540
 
            && (!state->tls_auth_only || state->tls_context)
1541
 
#endif
1542
 
            ) {
 
1617
        if (smtpd_sasl_is_active(state) && !sasl_client_exception(state)) {
1543
1618
            ENQUEUE_FMT_REPLY(state, reply_buf, "AUTH %s",
1544
1619
                              state->sasl_mechanism_list);
1545
1620
            if (var_broken_auth_clients)
1689
1764
            rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
1690
1765
                        MAIL_ATTR_RWR_CONTEXT, FORWARD_DOMAIN(state));
1691
1766
#ifdef USE_SASL_AUTH
1692
 
            if (var_smtpd_sasl_enable) {
 
1767
            if (smtpd_sasl_is_active(state)) {
1693
1768
                if (state->sasl_method)
1694
1769
                    rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
1695
1770
                                MAIL_ATTR_SASL_METHOD, state->sasl_method);
1739
1814
 
1740
1815
            /*
1741
1816
             * Attributes for logging, also used for XFORWARD.
 
1817
             * 
 
1818
             * We store all client attributes, including ones with unknown
 
1819
             * values. Otherwise, an unknown client hostname would be treated
 
1820
             * as a non-existent hostname (i.e. local submission).
1742
1821
             */
1743
 
            if (IS_AVAIL_CLIENT_NAME(FORWARD_NAME(state)))
1744
 
                rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
1745
 
                            MAIL_ATTR_LOG_CLIENT_NAME, FORWARD_NAME(state));
1746
 
            if (IS_AVAIL_CLIENT_ADDR(FORWARD_ADDR(state)))
1747
 
                rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
1748
 
                            MAIL_ATTR_LOG_CLIENT_ADDR, FORWARD_ADDR(state));
1749
 
            if (IS_AVAIL_CLIENT_PORT(FORWARD_PORT(state)))
1750
 
                rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
1751
 
                            MAIL_ATTR_LOG_CLIENT_PORT, FORWARD_PORT(state));
1752
 
            if (IS_AVAIL_CLIENT_NAMADDR(FORWARD_NAMADDR(state)))
1753
 
                rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
1754
 
                            MAIL_ATTR_LOG_ORIGIN, FORWARD_NAMADDR(state));
1755
 
            if (IS_AVAIL_CLIENT_HELO(FORWARD_HELO(state)))
 
1822
            rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
 
1823
                        MAIL_ATTR_LOG_CLIENT_NAME, FORWARD_NAME(state));
 
1824
            /* XXX Note: state->rfc_addr, not state->addr. */
 
1825
            rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
 
1826
                        MAIL_ATTR_LOG_CLIENT_ADDR, FORWARD_ADDR(state));
 
1827
            rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
 
1828
                        MAIL_ATTR_LOG_CLIENT_PORT, FORWARD_PORT(state));
 
1829
            rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
 
1830
                        MAIL_ATTR_LOG_ORIGIN, FORWARD_NAMADDR(state));
 
1831
            if (FORWARD_HELO(state))
1756
1832
                rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
1757
1833
                            MAIL_ATTR_LOG_HELO_NAME, FORWARD_HELO(state));
1758
 
            if (IS_AVAIL_CLIENT_PROTO(FORWARD_PROTO(state)))
1759
 
                rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
1760
 
                            MAIL_ATTR_LOG_PROTO_NAME, FORWARD_PROTO(state));
 
1834
            rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
 
1835
                        MAIL_ATTR_LOG_PROTO_NAME, FORWARD_PROTO(state));
1761
1836
 
1762
1837
            /*
1763
1838
             * Attributes with actual client information. These are used by
1764
 
             * Milters in case mail is re-injected with "postsuper -R".
 
1839
             * the smtpd Milter client for policy decisions. Mail that is
 
1840
             * requeued with "postsuper -r" is not subject to processing by
 
1841
             * the cleanup Milter client, because a) it has already been
 
1842
             * filtered, and b) we don't have sufficient information to
 
1843
             * reproduce the exact same SMTP events and Sendmail macros that
 
1844
             * the smtpd Milter client received when the message originally
 
1845
             * arrived in Postfix.
1765
1846
             */
1766
1847
            rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
1767
1848
                        MAIL_ATTR_ACT_CLIENT_NAME, state->name);
1768
1849
            rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
1769
1850
                    MAIL_ATTR_ACT_REVERSE_CLIENT_NAME, state->reverse_name);
 
1851
            /* XXX Note: state->addr, not state->rfc_addr. */
1770
1852
            rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
1771
1853
                        MAIL_ATTR_ACT_CLIENT_ADDR, state->addr);
1772
1854
            rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
1774
1856
            if (state->helo_name)
1775
1857
                rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
1776
1858
                            MAIL_ATTR_ACT_HELO_NAME, state->helo_name);
 
1859
            rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
 
1860
                        MAIL_ATTR_ACT_PROTO_NAME, state->protocol);
1777
1861
            rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%u",
1778
1862
                        MAIL_ATTR_ACT_CLIENT_AF, state->addr_family);
1779
1863
 
1790
1874
     * Log the queue ID with the message origin.
1791
1875
     */
1792
1876
#ifdef USE_SASL_AUTH
1793
 
    if (var_smtpd_sasl_enable)
 
1877
    if (smtpd_sasl_is_active(state))
1794
1878
        smtpd_sasl_mail_log(state);
1795
1879
    else
1796
1880
#endif
2032
2116
                return (-1);
2033
2117
            }
2034
2118
#ifdef USE_SASL_AUTH
2035
 
        } else if (var_smtpd_sasl_enable && strncasecmp(arg, "AUTH=", 5) == 0) {
 
2119
        } else if (smtpd_sasl_is_active(state)
 
2120
                   && strncasecmp(arg, "AUTH=", 5) == 0) {
2036
2121
            if ((err = smtpd_sasl_mail_opt(state, arg + 5)) != 0) {
2037
2122
                smtpd_chat_reply(state, "%s", err);
2038
2123
                return (-1);
2166
2251
{
2167
2252
    state->msg_size = 0;
2168
2253
    state->act_size = 0;
 
2254
    state->flags &= SMTPD_MASK_MAIL_KEEP;
2169
2255
 
2170
2256
    /*
2171
2257
     * Unceremoniously close the pipe to the cleanup service. The cleanup
2213
2299
    state->saved_delay = 0;
2214
2300
#endif
2215
2301
#ifdef USE_SASL_AUTH
2216
 
    if (var_smtpd_sasl_enable)
 
2302
    if (smtpd_sasl_is_active(state))
2217
2303
        smtpd_sasl_mail_reset(state);
2218
2304
#endif
2219
2305
    state->discard = 0;
2256
2342
    const char *dsn_orcpt_type = 0;
2257
2343
    int     dsn_notify = 0;
2258
2344
    const char *coded_addr;
 
2345
    const char *milter_err;
2259
2346
 
2260
2347
    /*
2261
2348
     * Sanity checks.
2356
2443
        return (-1);
2357
2444
    }
2358
2445
    if (SMTPD_STAND_ALONE(state) == 0) {
2359
 
        if ((err = smtpd_check_rcpt(state, STR(state->addr_buf))) != 0) {
2360
 
            smtpd_chat_reply(state, "%s", err);
2361
 
            return (-1);
2362
 
        }
 
2446
        err = smtpd_check_rcpt(state, STR(state->addr_buf));
2363
2447
        if (smtpd_milters != 0
2364
2448
            && (state->saved_flags & MILTER_SKIP_FLAGS) == 0) {
2365
2449
            PUSH_STRING(saved_rcpt, state->recipient, STR(state->addr_buf));
2366
 
            err = milter_rcpt_event(smtpd_milters,
 
2450
            state->milter_reject_text = err;
 
2451
            milter_err = milter_rcpt_event(smtpd_milters,
 
2452
                                           err == 0 ? MILTER_FLAG_NONE :
 
2453
                                           MILTER_FLAG_WANT_RCPT_REJ,
2367
2454
                                    milter_argv(state, argc - 2, argv + 2));
2368
 
            if (err != 0) {
 
2455
            if (err == 0 && milter_err != 0) {
2369
2456
                /* Log reject etc. with correct recipient information. */
2370
 
                err = check_milter_reply(state, err);
 
2457
                err = check_milter_reply(state, milter_err);
2371
2458
            }
2372
2459
            POP_STRING(saved_rcpt, state->recipient);
2373
 
            if (err != 0) {
2374
 
                smtpd_chat_reply(state, "%s", err);
2375
 
                return (-1);
2376
 
            }
 
2460
        }
 
2461
        if (err != 0) {
 
2462
            smtpd_chat_reply(state, "%s", err);
 
2463
            return (-1);
2377
2464
        }
2378
2465
    }
2379
2466
 
2476
2563
    state->rcpt_overshoot = 0;
2477
2564
}
2478
2565
 
 
2566
#if 0
 
2567
 
 
2568
/* rfc2047_comment_encode - encode comment string */
 
2569
 
 
2570
static VSTRING *rfc2047_comment_encode(const char *str, const char *charset)
 
2571
{
 
2572
    VSTRING *buf = vstring_alloc(30);
 
2573
    const unsigned char *cp;
 
2574
    int     ch;
 
2575
 
 
2576
    /*
 
2577
     * XXX This is problematic code.
 
2578
     * 
 
2579
     * XXX Most of the RFC 2047 "especials" are not special in RFC*822 comments,
 
2580
     * but we encode them anyway to avoid complaints.
 
2581
     * 
 
2582
     * XXX In Received: header comments we enclose peer and issuer common names
 
2583
     * with "" quotes (inherited from the Lutz Jaenicke patch). This is the
 
2584
     * cause of several quirks.
 
2585
     * 
 
2586
     * 1) We encode text that contains the " character, even though that
 
2587
     * character is not special for RFC*822 comments.
 
2588
     * 
 
2589
     * 2) We ignore the recommended limit of 75 characters per encoded word,
 
2590
     * because long comments look ugly when folded in-between quotes.
 
2591
     * 
 
2592
     * 3) We encode the enclosing quotes, to avoid producing invalid encoded
 
2593
     * words. Microsoft abuses RFC 2047 encoding with attachment names, but
 
2594
     * we have no information on what decoders do with malformed encoding in
 
2595
     * comments. This means the comments are Jaenicke-compatible only after
 
2596
     * decoding.
 
2597
     */
 
2598
#define ESPECIALS "()<>@,;:\"/[]?.="            /* Special in RFC 2047 */
 
2599
#define QSPECIALS "_" ESPECIALS                 /* Special in RFC 2047 'Q' */
 
2600
#define CSPECIALS "\\\"()"                      /* Special in our comments */
 
2601
 
 
2602
    /* Don't encode if not needed. */
 
2603
    for (cp = (unsigned char *) str; /* see below */ ; ++cp) {
 
2604
        if ((ch = *cp) == 0) {
 
2605
            vstring_sprintf(buf, "\"%s\"", str);
 
2606
            return (buf);
 
2607
        }
 
2608
        if (!ISPRINT(ch) || strchr(CSPECIALS, ch))
 
2609
            break;
 
2610
    }
 
2611
 
 
2612
    /*
 
2613
     * Use quoted-printable (like) encoding with spaces mapped to underscore.
 
2614
     */
 
2615
    vstring_sprintf(buf, "=?%s?Q?=%02X", charset, '"');
 
2616
    for (cp = (unsigned char *) str; (ch = *cp) != 0; ++cp) {
 
2617
        if (!ISPRINT(ch) || strchr(QSPECIALS CSPECIALS, ch)) {
 
2618
            vstring_sprintf_append(buf, "=%02X", ch);
 
2619
        } else if (ch == ' ') {
 
2620
            VSTRING_ADDCH(buf, '_');
 
2621
        } else {
 
2622
            VSTRING_ADDCH(buf, ch);
 
2623
        }
 
2624
    }
 
2625
    vstring_sprintf_append(buf, "=%02X?=", '"');
 
2626
    return (buf);
 
2627
}
 
2628
 
 
2629
#endif
 
2630
 
2479
2631
/* comment_sanitize - clean up comment string */
2480
2632
 
2481
2633
static void comment_sanitize(VSTRING *comment_string)
2671
2823
#endif
2672
2824
            rfc3848_sess = "";
2673
2825
#ifdef USE_SASL_AUTH
2674
 
        if (var_smtpd_sasl_enable && var_smtpd_sasl_auth_hdr && state->sasl_username) {
 
2826
        if (smtpd_sasl_is_active(state) && var_smtpd_sasl_auth_hdr
 
2827
            && state->sasl_username) {
2675
2828
            username = VSTRING_STRDUP(state->sasl_username);
2676
2829
            comment_sanitize(username);
2677
2830
            out_fprintf(out_stream, REC_TYPE_NORM,
2679
2832
            vstring_free(username);
2680
2833
        }
2681
2834
        /* RFC 3848 is defined for ESMTP only. */
2682
 
        if (var_smtpd_sasl_enable && state->sasl_username
 
2835
        if (smtpd_sasl_is_active(state) && state->sasl_username
2683
2836
            && strcmp(state->protocol, MAIL_PROTO_ESMTP) == 0)
2684
2837
            rfc3848_auth = "A";
2685
2838
        else
2713
2866
#endif
2714
2867
    }
2715
2868
    smtpd_chat_reply(state, "354 End data with <CR><LF>.<CR><LF>");
 
2869
    state->where = SMTPD_AFTER_DATA;
2716
2870
 
2717
2871
    /*
2718
2872
     * Copy the message content. If the cleanup process has a problem, keep
3155
3309
 
3156
3310
static int quit_cmd(SMTPD_STATE *state, int unused_argc, SMTPD_TOKEN *unused_argv)
3157
3311
{
 
3312
    int     out_pending = vstream_bufstat(state->client, VSTREAM_BST_OUT_PEND);
3158
3313
 
3159
3314
    /*
3160
3315
     * Don't bother checking the syntax.
3169
3324
     * XXX When this was added in Postfix 2.1 we used vstream_fflush(). As of
3170
3325
     * Postfix 2.3 we use smtp_flush() for better error reporting.
3171
3326
     */
3172
 
    smtp_flush(state->client);
 
3327
    if (out_pending > 0)
 
3328
        smtp_flush(state->client);
3173
3329
    return (0);
3174
3330
}
3175
3331
 
3436
3592
        state->protocol = mystrdup(MAIL_PROTO_SMTP);
3437
3593
    }
3438
3594
#ifdef USE_SASL_AUTH
3439
 
    if (var_smtpd_sasl_enable)
 
3595
    if (smtpd_sasl_is_active(state))
3440
3596
        smtpd_sasl_auth_reset(state);
3441
3597
#endif
3442
3598
    chat_reset(state, 0);
3735
3891
 
3736
3892
    if (cipher_grade == 0) {
3737
3893
        cipher_grade =
3738
 
            enforce_tls ? var_smtpd_tls_mand_ciph : "export";
 
3894
            enforce_tls ? var_smtpd_tls_mand_ciph : var_smtpd_tls_ciph;
3739
3895
        cipher_exclusions = vstring_alloc(10);
3740
3896
        ADD_EXCLUDE(cipher_exclusions, var_smtpd_tls_excl_ciph);
3741
3897
        if (enforce_tls)
3742
3898
            ADD_EXCLUDE(cipher_exclusions, var_smtpd_tls_mand_excl);
3743
 
        if (wantcert)
 
3899
        if (ask_client_cert)
3744
3900
            ADD_EXCLUDE(cipher_exclusions, "aNULL");
3745
3901
    }
3746
3902
 
3831
3987
     * offered within a plain-text session.
3832
3988
     */
3833
3989
#ifdef USE_SASL_AUTH
3834
 
    if (var_smtpd_sasl_enable
3835
 
        && strcmp(var_smtpd_sasl_tls_opts, var_smtpd_sasl_opts) != 0) {
3836
 
        smtpd_sasl_auth_reset(state);
3837
 
        smtpd_sasl_disconnect(state);
3838
 
        smtpd_sasl_connect(state, VAR_SMTPD_SASL_TLS_OPTS,
3839
 
                           var_smtpd_sasl_tls_opts);
 
3990
    if (var_smtpd_sasl_enable) {
 
3991
        /* Non-wrappermode, presumably. */
 
3992
        if (smtpd_sasl_is_active(state)
 
3993
            && strcmp(var_smtpd_sasl_opts, var_smtpd_sasl_tls_opts) != 0) {
 
3994
            smtpd_sasl_auth_reset(state);
 
3995
            smtpd_sasl_deactivate(state);
 
3996
        }
 
3997
        /* Wrappermode and non-wrappermode. */
 
3998
        if (smtpd_sasl_is_active(state) == 0)
 
3999
            smtpd_sasl_activate(state, VAR_SMTPD_SASL_TLS_OPTS,
 
4000
                                var_smtpd_sasl_tls_opts);
3840
4001
    }
3841
4002
#endif
3842
4003
}
3964
4125
 
3965
4126
#define SMTPD_CMD_FLAG_LIMIT    (1<<0)  /* limit usage */
3966
4127
#define SMTPD_CMD_FLAG_PRE_TLS  (1<<1)  /* allow before STARTTLS */
 
4128
#define SMTPD_CMD_FLAG_LAST     (1<<2)  /* last in PIPELINING command group */
3967
4129
 
3968
4130
static SMTPD_CMD smtpd_cmd_table[] = {
3969
4131
    SMTPD_CMD_HELO, helo_cmd, SMTPD_CMD_FLAG_LIMIT | SMTPD_CMD_FLAG_PRE_TLS,
3976
4138
#endif
3977
4139
    SMTPD_CMD_MAIL, mail_cmd, 0,
3978
4140
    SMTPD_CMD_RCPT, rcpt_cmd, 0,
3979
 
    SMTPD_CMD_DATA, data_cmd, 0,
 
4141
    SMTPD_CMD_DATA, data_cmd, SMTPD_CMD_FLAG_LAST,
3980
4142
    SMTPD_CMD_RSET, rset_cmd, SMTPD_CMD_FLAG_LIMIT,
3981
4143
    SMTPD_CMD_NOOP, noop_cmd, SMTPD_CMD_FLAG_LIMIT | SMTPD_CMD_FLAG_PRE_TLS,
3982
4144
    SMTPD_CMD_VRFY, vrfy_cmd, SMTPD_CMD_FLAG_LIMIT,
3983
4145
    SMTPD_CMD_ETRN, etrn_cmd, SMTPD_CMD_FLAG_LIMIT,
3984
4146
    SMTPD_CMD_QUIT, quit_cmd, SMTPD_CMD_FLAG_PRE_TLS,
3985
 
    SMTPD_CMD_XCLIENT, xclient_cmd, SMTPD_CMD_FLAG_LIMIT,
3986
 
    SMTPD_CMD_XFORWARD, xforward_cmd, SMTPD_CMD_FLAG_LIMIT,
 
4147
    SMTPD_CMD_XCLIENT, xclient_cmd, 0,
 
4148
    SMTPD_CMD_XFORWARD, xforward_cmd, 0,
3987
4149
    0,
3988
4150
};
3989
4151
 
4166
4328
                smtpd_chat_reply(state, "421 %s Service unavailable - try again later",
4167
4329
                                 var_myhostname);
4168
4330
                /* Not: state->error_count++; */
 
4331
#ifdef notdef
 
4332
            } else if (strcmp(state->name, "unknown") == 0) {
 
4333
                static char *greet_chunks[] = {
 
4334
                    "220 ", 0, " ESMTP ", 0, 0,
 
4335
                };
 
4336
                char  **cpp;
 
4337
                char   *cp;
 
4338
 
 
4339
                greet_chunks[1] = var_myhostname;
 
4340
                greet_chunks[3] = var_mail_name;
 
4341
                for (cpp = greet_chunks; *cpp; cpp++) {
 
4342
                    for (cp = *cpp; *cp; cp++)
 
4343
                        smtp_fputc(*(unsigned char *) cp, state->client);
 
4344
                    smtp_flush(state->client);
 
4345
                    if (read_wait(vstream_fileno(state->client), 2) == 0) {
 
4346
                        smtpd_chat_query(state);
 
4347
                        msg_info("PREGREET from %s: %s",
 
4348
                                 state->namaddr, vstring_str(state->buffer));
 
4349
                        state->error_mask |= MAIL_ERROR_POLICY;
 
4350
                        smtpd_chat_reply(state,
 
4351
                                   "521 %s ESMTP not accepting connections",
 
4352
                                         var_myhostname);
 
4353
                        /* Not: state->error_count++; */
 
4354
                        break;
 
4355
                    }
 
4356
                }
 
4357
                smtp_fputs("", 0, state->client);
 
4358
                smtp_flush(state->client);
 
4359
#endif
4169
4360
            } else {
 
4361
#ifdef PREGREET
 
4362
                if (*var_stress == 0 && strcmp(state->name, "unknown") == 0) {
 
4363
                    smtpd_chat_reply(state, "220-%s", var_smtpd_banner);
 
4364
                    smtp_flush(state->client);
 
4365
                    if (read_wait(vstream_fileno(state->client), 1) == 0) {
 
4366
                        int     n = peekfd(vstream_fileno(state->client));
 
4367
 
 
4368
                        smtpd_chat_query(state);
 
4369
                        msg_info("PREGREET %d from %s: %s",
 
4370
                             n, state->namaddr, vstring_str(state->buffer));
 
4371
                        state->error_mask |= MAIL_ERROR_POLICY;
 
4372
                        smtpd_chat_reply(state,
 
4373
                                   "521 %s ESMTP not accepting connections",
 
4374
                                         var_myhostname);
 
4375
                        /* Not: state->error_count++; */
 
4376
                        break;
 
4377
                    }
 
4378
                }
 
4379
#endif
4170
4380
                smtpd_chat_reply(state, "220 %s", var_smtpd_banner);
4171
4381
            }
4172
4382
        }
4180
4390
            ehlo_words = var_smtpd_ehlo_dis_words;
4181
4391
        state->ehlo_discard_mask = ehlo_mask(ehlo_words);
4182
4392
 
 
4393
        /*
 
4394
         * SASL initialization for plaintext mode.
 
4395
         * 
 
4396
         * XXX Backwards compatibility: allow AUTH commands when the AUTH
 
4397
         * announcement is suppressed via smtpd_sasl_exceptions_networks.
 
4398
         * 
 
4399
         * XXX Safety: don't enable SASL with "smtpd_tls_auth_only = yes" and
 
4400
         * non-TLS build.
 
4401
         */
 
4402
#ifdef USE_SASL_AUTH
 
4403
        if (var_smtpd_sasl_enable && smtpd_sasl_is_active(state) == 0
 
4404
#ifdef USE_TLS
 
4405
            && state->tls_context == 0 && !state->tls_auth_only
 
4406
#else
 
4407
            && var_smtpd_tls_auth_only == 0
 
4408
#endif
 
4409
            )
 
4410
            smtpd_sasl_activate(state, VAR_SMTPD_SASL_OPTS,
 
4411
                                var_smtpd_sasl_opts);
 
4412
#endif
 
4413
 
4183
4414
        for (;;) {
4184
4415
            if (state->flags & SMTPD_FLAG_HANGUP)
4185
4416
                break;
4251
4482
            }
4252
4483
#endif
4253
4484
            state->where = cmdp->name;
 
4485
            if (SMTPD_STAND_ALONE(state) == 0
 
4486
                && (strcasecmp(state->protocol, MAIL_PROTO_ESMTP) != 0
 
4487
                    || (cmdp->flags & SMTPD_CMD_FLAG_LAST))
 
4488
                && (state->flags & SMTPD_FLAG_ILL_PIPELINING) == 0
 
4489
                && (vstream_peek(state->client) > 0
 
4490
                    || peekfd(vstream_fileno(state->client)) > 0)) {
 
4491
                msg_info("improper command pipelining after %s from %s",
 
4492
                         cmdp->name, state->namaddr);
 
4493
                state->flags |= SMTPD_FLAG_ILL_PIPELINING;
 
4494
            }
4254
4495
            if (cmdp->action(state, argc, argv) != 0)
4255
4496
                state->error_count++;
4256
4497
            if ((cmdp->flags & SMTPD_CMD_FLAG_LIMIT)
4287
4528
     * troubles.
4288
4529
     */
4289
4530
    if (state->reason && state->where) {
4290
 
        if (strcmp(state->where, SMTPD_CMD_DATA) == 0) {
4291
 
            msg_info("%s after %s (%lu bytes) from %s",
4292
 
                     state->reason, state->where, (long) state->act_size,
 
4531
        if (strcmp(state->where, SMTPD_AFTER_DATA) == 0) {
 
4532
            msg_info("%s after %s (%lu bytes) from %s", /* 2.5 compat */
 
4533
                     state->reason, SMTPD_CMD_DATA,     /* 2.5 compat */
 
4534
                     (long) (state->act_size + vstream_peek(state->client)),
4293
4535
                     state->namaddr);
4294
4536
        } else if (strcmp(state->where, SMTPD_AFTER_DOT)
4295
4537
                   || strcmp(state->reason, REASON_LOST_CONNECTION)) {
4309
4551
#endif
4310
4552
    helo_reset(state);
4311
4553
#ifdef USE_SASL_AUTH
4312
 
    if (var_smtpd_sasl_enable)
 
4554
    if (smtpd_sasl_is_active(state)) {
4313
4555
        smtpd_sasl_auth_reset(state);
 
4556
        smtpd_sasl_deactivate(state);
 
4557
    }
4314
4558
#endif
4315
4559
    chat_reset(state, 0);
4316
4560
    mail_reset(state);
4497
4741
#ifdef USE_TLS
4498
4742
            TLS_SERVER_INIT_PROPS props;
4499
4743
            const char *cert_file;
4500
 
            int     havecert;
4501
 
            int     oknocert;
 
4744
            int     have_server_cert;
 
4745
            int     no_server_cert_ok;
 
4746
            int     require_server_cert;
4502
4747
 
4503
4748
            /*
4504
4749
             * Can't use anonymous ciphers if we want client certificates.
4506
4751
             * 
4507
4752
             * XXX: Ugh! Too many booleans!
4508
4753
             */
4509
 
            wantcert = (var_smtpd_tls_ask_ccert
4510
 
                        || (enforce_tls && var_smtpd_tls_req_ccert));
 
4754
            ask_client_cert = require_server_cert =
 
4755
                (var_smtpd_tls_ask_ccert
 
4756
                 || (enforce_tls && var_smtpd_tls_req_ccert));
4511
4757
            if (strcasecmp(var_smtpd_tls_cert_file, "none") == 0) {
4512
 
                oknocert = 1;
 
4758
                no_server_cert_ok = 1;
4513
4759
                cert_file = "";
4514
4760
            } else {
4515
 
                oknocert = 0;
 
4761
                no_server_cert_ok = 0;
4516
4762
                cert_file = var_smtpd_tls_cert_file;
4517
4763
            }
4518
 
            havecert =
4519
 
                (*cert_file || *var_smtpd_tls_dcert_file);
 
4764
            have_server_cert =
 
4765
                (*cert_file || *var_smtpd_tls_dcert_file || *var_smtpd_tls_eccert_file);
4520
4766
 
4521
4767
            /* Some TLS configuration errors are not show stoppers. */
4522
 
            if (!havecert && wantcert)
 
4768
            if (!have_server_cert && require_server_cert)
4523
4769
                msg_warn("Need a server cert to request client certs");
4524
4770
            if (!enforce_tls && var_smtpd_tls_req_ccert)
4525
4771
                msg_warn("Can't require client certs unless TLS is required");
4526
4772
            /* After a show-stopper error, reply with 454 to STARTTLS. */
4527
 
            if (havecert || (oknocert && !wantcert))
 
4773
            if (have_server_cert || (no_server_cert_ok && !require_server_cert))
4528
4774
 
4529
4775
                /*
4530
4776
                 * Large parameter lists are error-prone, so we emulate a
4543
4789
                                    key_file = var_smtpd_tls_key_file,
4544
4790
                                    dcert_file = var_smtpd_tls_dcert_file,
4545
4791
                                    dkey_file = var_smtpd_tls_dkey_file,
 
4792
                                    eccert_file = var_smtpd_tls_eccert_file,
 
4793
                                    eckey_file = var_smtpd_tls_eckey_file,
4546
4794
                                    CAfile = var_smtpd_tls_CAfile,
4547
4795
                                    CApath = var_smtpd_tls_CApath,
4548
4796
                                    dh1024_param_file
4549
4797
                                    = var_smtpd_tls_dh1024_param_file,
4550
4798
                                    dh512_param_file
4551
4799
                                    = var_smtpd_tls_dh512_param_file,
 
4800
                                    eecdh_grade = var_smtpd_tls_eecdh,
4552
4801
                                    protocols = enforce_tls ?
4553
 
                                    var_smtpd_tls_mand_proto : "",
4554
 
                                    ask_ccert = var_smtpd_tls_ask_ccert,
 
4802
                                    var_smtpd_tls_mand_proto :
 
4803
                                    var_smtpd_tls_proto,
 
4804
                                    ask_ccert = ask_client_cert,
4555
4805
                                    fpt_dgst = var_smtpd_tls_fpt_dgst);
4556
4806
            else
4557
4807
                msg_warn("No server certs available. TLS won't be enabled");
4643
4893
 
4644
4894
int     main(int argc, char **argv)
4645
4895
{
 
4896
    static const CONFIG_NINT_TABLE nint_table[] = {
 
4897
        VAR_SMTPD_SOFT_ERLIM, DEF_SMTPD_SOFT_ERLIM, &var_smtpd_soft_erlim, 1, 0,
 
4898
        VAR_SMTPD_HARD_ERLIM, DEF_SMTPD_HARD_ERLIM, &var_smtpd_hard_erlim, 1, 0,
 
4899
        VAR_SMTPD_JUNK_CMD, DEF_SMTPD_JUNK_CMD, &var_smtpd_junk_cmd_limit, 1, 0,
 
4900
        0,
 
4901
    };
4646
4902
    static const CONFIG_INT_TABLE int_table[] = {
4647
4903
        VAR_SMTPD_RCPT_LIMIT, DEF_SMTPD_RCPT_LIMIT, &var_smtpd_rcpt_limit, 1, 0,
4648
 
        VAR_SMTPD_SOFT_ERLIM, DEF_SMTPD_SOFT_ERLIM, &var_smtpd_soft_erlim, 1, 0,
4649
 
        VAR_SMTPD_HARD_ERLIM, DEF_SMTPD_HARD_ERLIM, &var_smtpd_hard_erlim, 1, 0,
4650
4904
        VAR_QUEUE_MINFREE, DEF_QUEUE_MINFREE, &var_queue_minfree, 0, 0,
4651
4905
        VAR_UNK_CLIENT_CODE, DEF_UNK_CLIENT_CODE, &var_unk_client_code, 0, 0,
4652
4906
        VAR_BAD_NAME_CODE, DEF_BAD_NAME_CODE, &var_bad_name_code, 0, 0,
4654
4908
        VAR_UNK_ADDR_CODE, DEF_UNK_ADDR_CODE, &var_unk_addr_code, 0, 0,
4655
4909
        VAR_RELAY_CODE, DEF_RELAY_CODE, &var_relay_code, 0, 0,
4656
4910
        VAR_MAPS_RBL_CODE, DEF_MAPS_RBL_CODE, &var_maps_rbl_code, 0, 0,
4657
 
        VAR_ACCESS_MAP_CODE, DEF_ACCESS_MAP_CODE, &var_access_map_code, 0, 0,
 
4911
        VAR_MAP_REJECT_CODE, DEF_MAP_REJECT_CODE, &var_map_reject_code, 0, 0,
 
4912
        VAR_MAP_DEFER_CODE, DEF_MAP_DEFER_CODE, &var_map_defer_code, 0, 0,
4658
4913
        VAR_REJECT_CODE, DEF_REJECT_CODE, &var_reject_code, 0, 0,
4659
4914
        VAR_DEFER_CODE, DEF_DEFER_CODE, &var_defer_code, 0, 0,
4660
4915
        VAR_NON_FQDN_CODE, DEF_NON_FQDN_CODE, &var_non_fqdn_code, 0, 0,
4661
 
        VAR_SMTPD_JUNK_CMD, DEF_SMTPD_JUNK_CMD, &var_smtpd_junk_cmd_limit, 1, 0,
4662
4916
        VAR_SMTPD_RCPT_OVERLIM, DEF_SMTPD_RCPT_OVERLIM, &var_smtpd_rcpt_overlim, 1, 0,
4663
4917
        VAR_SMTPD_HIST_THRSH, DEF_SMTPD_HIST_THRSH, &var_smtpd_hist_thrsh, 1, 0,
4664
 
        VAR_UNV_FROM_CODE, DEF_UNV_FROM_CODE, &var_unv_from_code, 0, 0,
4665
 
        VAR_UNV_RCPT_CODE, DEF_UNV_RCPT_CODE, &var_unv_rcpt_code, 0, 0,
 
4918
        VAR_UNV_FROM_RCODE, DEF_UNV_FROM_RCODE, &var_unv_from_rcode, 200, 599,
 
4919
        VAR_UNV_RCPT_RCODE, DEF_UNV_RCPT_RCODE, &var_unv_rcpt_rcode, 200, 599,
 
4920
        VAR_UNV_FROM_DCODE, DEF_UNV_FROM_DCODE, &var_unv_from_dcode, 200, 499,
 
4921
        VAR_UNV_RCPT_DCODE, DEF_UNV_RCPT_DCODE, &var_unv_rcpt_dcode, 200, 499,
4666
4922
        VAR_MUL_RCPT_CODE, DEF_MUL_RCPT_CODE, &var_mul_rcpt_code, 0, 0,
4667
4923
        VAR_LOCAL_RCPT_CODE, DEF_LOCAL_RCPT_CODE, &var_local_rcpt_code, 0, 0,
4668
4924
        VAR_VIRT_ALIAS_CODE, DEF_VIRT_ALIAS_CODE, &var_virt_alias_code, 0, 0,
4713
4969
        VAR_SMTPD_USE_TLS, DEF_SMTPD_USE_TLS, &var_smtpd_use_tls,
4714
4970
        VAR_SMTPD_ENFORCE_TLS, DEF_SMTPD_ENFORCE_TLS, &var_smtpd_enforce_tls,
4715
4971
        VAR_SMTPD_TLS_WRAPPER, DEF_SMTPD_TLS_WRAPPER, &var_smtpd_tls_wrappermode,
4716
 
#ifdef USE_TLS
4717
4972
        VAR_SMTPD_TLS_AUTH_ONLY, DEF_SMTPD_TLS_AUTH_ONLY, &var_smtpd_tls_auth_only,
 
4973
#ifdef USE_TLS
4718
4974
        VAR_SMTPD_TLS_ACERT, DEF_SMTPD_TLS_ACERT, &var_smtpd_tls_ask_ccert,
4719
4975
        VAR_SMTPD_TLS_RCERT, DEF_SMTPD_TLS_RCERT, &var_smtpd_tls_req_ccert,
4720
4976
        VAR_SMTPD_TLS_RECHEAD, DEF_SMTPD_TLS_RECHEAD, &var_smtpd_tls_received_header,
4775
5031
        VAR_SMTPD_TLS_KEY_FILE, DEF_SMTPD_TLS_KEY_FILE, &var_smtpd_tls_key_file, 0, 0,
4776
5032
        VAR_SMTPD_TLS_DCERT_FILE, DEF_SMTPD_TLS_DCERT_FILE, &var_smtpd_tls_dcert_file, 0, 0,
4777
5033
        VAR_SMTPD_TLS_DKEY_FILE, DEF_SMTPD_TLS_DKEY_FILE, &var_smtpd_tls_dkey_file, 0, 0,
 
5034
        VAR_SMTPD_TLS_ECCERT_FILE, DEF_SMTPD_TLS_ECCERT_FILE, &var_smtpd_tls_eccert_file, 0, 0,
 
5035
        VAR_SMTPD_TLS_ECKEY_FILE, DEF_SMTPD_TLS_ECKEY_FILE, &var_smtpd_tls_eckey_file, 0, 0,
4778
5036
        VAR_SMTPD_TLS_CA_FILE, DEF_SMTPD_TLS_CA_FILE, &var_smtpd_tls_CAfile, 0, 0,
4779
5037
        VAR_SMTPD_TLS_CA_PATH, DEF_SMTPD_TLS_CA_PATH, &var_smtpd_tls_CApath, 0, 0,
 
5038
        VAR_SMTPD_TLS_CIPH, DEF_SMTPD_TLS_CIPH, &var_smtpd_tls_ciph, 1, 0,
4780
5039
        VAR_SMTPD_TLS_MAND_CIPH, DEF_SMTPD_TLS_MAND_CIPH, &var_smtpd_tls_mand_ciph, 1, 0,
4781
5040
        VAR_SMTPD_TLS_EXCL_CIPH, DEF_SMTPD_TLS_EXCL_CIPH, &var_smtpd_tls_excl_ciph, 0, 0,
4782
5041
        VAR_SMTPD_TLS_MAND_EXCL, DEF_SMTPD_TLS_MAND_EXCL, &var_smtpd_tls_mand_excl, 0, 0,
 
5042
        VAR_SMTPD_TLS_PROTO, DEF_SMTPD_TLS_PROTO, &var_smtpd_tls_proto, 0, 0,
4783
5043
        VAR_SMTPD_TLS_MAND_PROTO, DEF_SMTPD_TLS_MAND_PROTO, &var_smtpd_tls_mand_proto, 0, 0,
4784
5044
        VAR_SMTPD_TLS_512_FILE, DEF_SMTPD_TLS_512_FILE, &var_smtpd_tls_dh512_param_file, 0, 0,
4785
5045
        VAR_SMTPD_TLS_1024_FILE, DEF_SMTPD_TLS_1024_FILE, &var_smtpd_tls_dh1024_param_file, 0, 0,
 
5046
        VAR_SMTPD_TLS_EECDH, DEF_SMTPD_TLS_EECDH, &var_smtpd_tls_eecdh, 1, 0,
4786
5047
        VAR_SMTPD_TLS_FPT_DGST, DEF_SMTPD_TLS_FPT_DGST, &var_smtpd_tls_fpt_dgst, 1, 0,
4787
5048
#endif
4788
5049
        VAR_SMTPD_TLS_LEVEL, DEF_SMTPD_TLS_LEVEL, &var_smtpd_tls_level, 0, 0,
4801
5062
        VAR_MILT_DAEMON_NAME, DEF_MILT_DAEMON_NAME, &var_milt_daemon_name, 1, 0,
4802
5063
        VAR_MILT_V, DEF_MILT_V, &var_milt_v, 1, 0,
4803
5064
        VAR_STRESS, DEF_STRESS, &var_stress, 0, 0,
 
5065
        VAR_UNV_FROM_WHY, DEF_UNV_FROM_WHY, &var_unv_from_why, 0, 0,
 
5066
        VAR_UNV_RCPT_WHY, DEF_UNV_RCPT_WHY, &var_unv_rcpt_why, 0, 0,
 
5067
        VAR_REJECT_TMPF_ACT, DEF_REJECT_TMPF_ACT, &var_reject_tmpf_act, 1, 0,
 
5068
        VAR_UNK_NAME_TF_ACT, DEF_UNK_NAME_TF_ACT, &var_unk_name_tf_act, 1, 0,
 
5069
        VAR_UNK_ADDR_TF_ACT, DEF_UNK_ADDR_TF_ACT, &var_unk_addr_tf_act, 1, 0,
 
5070
        VAR_UNV_RCPT_TF_ACT, DEF_UNV_RCPT_TF_ACT, &var_unv_rcpt_tf_act, 1, 0,
 
5071
        VAR_UNV_FROM_TF_ACT, DEF_UNV_FROM_TF_ACT, &var_unv_from_tf_act, 1, 0,
4804
5072
        0,
4805
5073
    };
4806
5074
    static const CONFIG_RAW_TABLE raw_table[] = {
4818
5086
     * Pass control to the single-threaded service skeleton.
4819
5087
     */
4820
5088
    single_server_main(argc, argv, smtpd_service,
 
5089
                       MAIL_SERVER_NINT_TABLE, nint_table,
4821
5090
                       MAIL_SERVER_INT_TABLE, int_table,
4822
5091
                       MAIL_SERVER_STR_TABLE, str_table,
4823
5092
                       MAIL_SERVER_RAW_TABLE, raw_table,