Skip to content

Commit

Permalink
lib-smtp: server: Use the HELO domain provided to smtp_server_connect…
Browse files Browse the repository at this point in the history
…ion_login() immediately.

Before, it was only used when no new HELO/EHLO command was issued before MAIL.
  • Loading branch information
stephanbosch authored and villesavolainen committed Feb 12, 2019
1 parent da2b4d7 commit be6f409
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
9 changes: 0 additions & 9 deletions src/lib-smtp/smtp-server-cmd-mail.c
Expand Up @@ -128,15 +128,6 @@ void smtp_server_cmd_mail(struct smtp_server_cmd_ctx *cmd,
return;
}

if (conn->pending_helo == NULL && conn->helo.domain == NULL &&
conn->helo_login != NULL && *conn->helo_login != '\0') {
/* no EHLO executed post-login, use pre-login value instead */
conn->helo_domain = conn->helo_login;
conn->helo.domain = conn->helo_domain;
conn->helo.domain_valid = TRUE;
conn->helo_login = NULL;
}

mail_data = p_new(cmd->pool, struct smtp_server_cmd_mail, 1);

if (conn->set.protocol == SMTP_PROTOCOL_LMTP)
Expand Down
9 changes: 6 additions & 3 deletions src/lib-smtp/smtp-server-connection.c
Expand Up @@ -1178,7 +1178,6 @@ bool smtp_server_connection_unref(struct smtp_server_connection **_conn)
connection_deinit(&conn->conn);

i_free(conn->helo_domain);
i_free(conn->helo_login);
i_free(conn->username);
i_free(conn->disconnect_reason);
pool_unref(&conn->pool);
Expand Down Expand Up @@ -1268,10 +1267,15 @@ void smtp_server_connection_login(struct smtp_server_connection *conn,
{
i_assert(!conn->started);
i_assert(conn->username == NULL);
i_assert(conn->helo_domain == NULL);

conn->set.capabilities &= ~SMTP_CAPABILITY_STARTTLS;
conn->username = i_strdup(username);
conn->helo_login = i_strdup(helo);
if (helo != NULL && *helo != '\0') {
conn->helo_domain = i_strdup(helo);
conn->helo.domain = conn->helo_domain;
conn->helo.domain_valid = TRUE;
}
conn->authenticated = TRUE;
conn->ssl_secured = ssl_secured;

Expand Down Expand Up @@ -1422,7 +1426,6 @@ void smtp_server_connection_clear(struct smtp_server_connection *conn)
smtp_server_connection_debug(conn, "Connection clear");

i_free(conn->helo_domain);
i_free(conn->helo_login);
i_zero(&conn->helo);
smtp_server_connection_reset_state(conn);
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib-smtp/smtp-server-private.h
Expand Up @@ -161,7 +161,7 @@ struct smtp_server_connection {
unsigned int proxy_timeout_secs;

struct smtp_server_helo_data helo, *pending_helo;
char *helo_domain, *helo_login, *username;
char *helo_domain, *username;
unsigned int id;

struct timeout *to_idle;
Expand Down

0 comments on commit be6f409

Please sign in to comment.