]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: client: Allow deferring sending the XCLIENT command until authentication...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Mon, 3 Dec 2018 17:45:42 +0000 (18:45 +0100)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Tue, 12 Feb 2019 13:42:07 +0000 (15:42 +0200)
This allows updating the proxy data until the XCLIENT command actually needs to
be sent. For submission, this means that later EHLO domain changes can still be
accounted for. This change makes the simplifications in subsequent changes
easier.

src/lib-smtp/smtp-client-command.c
src/lib-smtp/smtp-client-connection.c
src/lib-smtp/smtp-client.h

index 82208a0856a4698a18d0a4af6c6d8360742be293..185904dca4335a1982c0ca19a055afb26523127f 100644 (file)
@@ -981,6 +981,8 @@ smtp_client_command_mail_submit(
 {
        struct smtp_client_command *cmd;
 
+       smtp_client_connection_send_xclient(conn);
+
        cmd = smtp_client_command_new(conn,
                flags | SMTP_CLIENT_COMMAND_FLAG_PIPELINE,
                callback, context);
index c0f6c6d2d1e3c4a6f2bd11298d0576751c6b6a3e..0c2d217463dc63fbad756dfbb688625aa53a6ade 100644 (file)
@@ -747,6 +747,14 @@ smtp_client_connection_authenticate(struct smtp_client_connection *conn)
        string_t *sasl_output_base64;
        const char *init_resp, *error;
 
+       if (set->username == NULL && set->sasl_mech == NULL) {
+               if (!conn->initial_xclient_sent && !conn->set.xclient_defer) {
+                       conn->initial_xclient_sent = TRUE;
+                       smtp_client_connection_send_xclient(conn);
+               }
+               return (conn->xclient_replies_expected == 0);
+       }
+
        if (!conn->initial_xclient_sent) {
                conn->initial_xclient_sent = TRUE;
                smtp_client_connection_send_xclient(conn);
@@ -756,8 +764,6 @@ smtp_client_connection_authenticate(struct smtp_client_connection *conn)
 
        if (conn->authenticated)
                return TRUE;
-       if (set->username == NULL && set->sasl_mech == NULL)
-               return TRUE;
 
        if ((conn->caps.standard & SMTP_CAPABILITY_AUTH) == 0) {
                smtp_client_connection_fail(conn,
@@ -1878,6 +1884,7 @@ smtp_client_connection_do_create(struct smtp_client *client, const char *name,
 
                smtp_proxy_data_merge(conn->pool, &conn->set.proxy_data,
                                      &set->proxy_data);
+               conn->set.xclient_defer = set->xclient_defer;
                conn->set.peer_trusted = set->peer_trusted;
        }
 
index fe8fd55f2203f9e903ceb93b6a8936b3bc810ac1..bf16ec28ab3efec0276d4d5f76e216bc0eea8e2b 100644 (file)
@@ -93,6 +93,9 @@ struct smtp_client_settings {
        bool debug;
        /* peer is trusted, so e.g. attempt sending XCLIENT data */
        bool peer_trusted;
+       /* defer sending XCLIENT command until authentication or first mail
+          transaction. */
+       bool xclient_defer;
        /* don't clear password after first successful authentication */
        bool remember_password;
 };