From: Stephan Bosch Date: Sun, 27 May 2018 09:30:06 +0000 (+0200) Subject: lib-smtp: client: Do not start authentication before initial XCLIENT gets reply. X-Git-Tag: 2.3.9~1777 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3912d6be16b765ac6972583114faf6ddb223e8d0;p=thirdparty%2Fdovecot%2Fcore.git lib-smtp: client: Do not start authentication before initial XCLIENT gets reply. --- diff --git a/src/lib-smtp/smtp-client-connection.c b/src/lib-smtp/smtp-client-connection.c index c8cea9bc3e..88cfe9ce95 100644 --- a/src/lib-smtp/smtp-client-connection.c +++ b/src/lib-smtp/smtp-client-connection.c @@ -618,19 +618,20 @@ smtp_client_connection_xclient_cb(const struct smtp_reply *reply, smtp_client_connection_handshake(conn); } -void -smtp_client_connection_send_xclient(struct smtp_client_connection *conn, - struct smtp_proxy_data *xclient) +bool smtp_client_connection_send_xclient(struct smtp_client_connection *conn, + struct smtp_proxy_data *xclient) { const char **xclient_args = conn->cap_xclient_args; + struct smtp_client_command *cmd; + enum smtp_client_command_flags flags; unsigned int empty_len; string_t *str; if (!conn->set.peer_trusted) - return; + return TRUE; if ((conn->capabilities & SMTP_CAPABILITY_XCLIENT) == 0 || conn->cap_xclient_args == NULL) - return; + return TRUE; str = t_str_new(64); str_append(str, "XCLIENT"); @@ -685,21 +686,20 @@ smtp_client_connection_send_xclient(struct smtp_client_connection *conn, str_array_icase_find(xclient_args, "TIMEOUT")) str_printfa(str, " TIMEOUT=%u", xclient->timeout_secs); - if (str_len(str) > empty_len) { - struct smtp_client_command *cmd; - enum smtp_client_command_flags flags; + if (str_len(str) <= empty_len) + return TRUE; - smtp_client_connection_debug(conn, - "Sending XCLIENT handshake"); + smtp_client_connection_debug(conn, + "Sending XCLIENT handshake"); - flags = SMTP_CLIENT_COMMAND_FLAG_PRELOGIN | - SMTP_CLIENT_COMMAND_FLAG_PRIORITY; + flags = SMTP_CLIENT_COMMAND_FLAG_PRELOGIN | + SMTP_CLIENT_COMMAND_FLAG_PRIORITY; - cmd = smtp_client_command_new(conn, flags, - smtp_client_connection_xclient_cb, conn); - smtp_client_command_write(cmd, str_c(str)); - smtp_client_command_submit(cmd); - } + cmd = smtp_client_command_new(conn, flags, + smtp_client_connection_xclient_cb, conn); + smtp_client_command_write(cmd, str_c(str)); + smtp_client_command_submit(cmd); + return FALSE; } static bool @@ -707,8 +707,9 @@ smtp_client_connection_init_xclient(struct smtp_client_connection *conn) { if (!conn->initial_xclient_sent) { conn->initial_xclient_sent = TRUE; - smtp_client_connection_send_xclient(conn, - &conn->set.proxy_data); + if (!smtp_client_connection_send_xclient(conn, + &conn->set.proxy_data)) + return FALSE; } return smtp_client_connection_authenticate(conn); diff --git a/src/lib-smtp/smtp-client-connection.h b/src/lib-smtp/smtp-client-connection.h index 31ebfdb1e9..33d2e9256f 100644 --- a/src/lib-smtp/smtp-client-connection.h +++ b/src/lib-smtp/smtp-client-connection.h @@ -56,8 +56,8 @@ void smtp_client_connection_uncork(struct smtp_client_connection *conn); void smtp_client_connection_connect(struct smtp_client_connection *conn, smtp_client_command_callback_t login_callback, void *login_context); void smtp_client_connection_disconnect(struct smtp_client_connection *conn); -void smtp_client_connection_send_xclient(struct smtp_client_connection *conn, - struct smtp_proxy_data *xclient); +bool smtp_client_connection_send_xclient(struct smtp_client_connection *conn, + struct smtp_proxy_data *xclient); void smtp_client_connection_switch_ioloop(struct smtp_client_connection *conn);