Skip to content

Commit

Permalink
lib-smtp: server: Change conn_start_tls() connection callback to retu…
Browse files Browse the repository at this point in the history
…rn a success status.
  • Loading branch information
stephanbosch authored and sirainen committed Dec 22, 2017
1 parent d0d92f4 commit b1de005
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/lib-smtp/smtp-server-cmd-starttls.c
Expand Up @@ -22,11 +22,12 @@ static int cmd_starttls_start(struct smtp_server_connection *conn)
struct smtp_server_connection *tmp_conn = conn;
struct istream *input = conn->conn.input;
struct ostream *output = conn->conn.output;
int ret;

smtp_server_connection_ref(tmp_conn);
callbacks->conn_start_tls(tmp_conn->context,
ret = callbacks->conn_start_tls(tmp_conn->context,
&input, &output);
if (!smtp_server_connection_unref(&tmp_conn))
if (!smtp_server_connection_unref(&tmp_conn) || ret < 0)
return -1;

smtp_server_connection_set_streams(conn, input, output);
Expand Down
4 changes: 2 additions & 2 deletions src/lib-smtp/smtp-server.h
Expand Up @@ -147,8 +147,6 @@ struct smtp_server_callbacks {
/* STARTTLS */
int (*conn_cmd_starttls)(void *conn_ctx,
struct smtp_server_cmd_ctx *cmd);
void (*conn_start_tls)(void *conn_ctx,
struct istream **input, struct ostream **output);
/* AUTH */
int (*conn_cmd_auth)(void *conn_ctx,
struct smtp_server_cmd_ctx *cmd,
Expand Down Expand Up @@ -210,6 +208,8 @@ struct smtp_server_callbacks {
const struct smtp_proxy_data *data);

/* Connection */
int (*conn_start_tls)(void *conn_ctx,
struct istream **input, struct ostream **output);
void (*conn_disconnect)(void *context, const char *reason);
void (*conn_destroy)(void *context);

Expand Down
5 changes: 3 additions & 2 deletions src/submission-login/client.c
Expand Up @@ -26,7 +26,7 @@ static const struct smtp_server_callbacks smtp_callbacks;

static struct smtp_server *smtp_server = NULL;

static void submission_login_start_tls(void *conn_ctx,
static int submission_login_start_tls(void *conn_ctx,
struct istream **input, struct ostream **output)
{
struct submission_client *subm_client = conn_ctx;
Expand All @@ -39,12 +39,13 @@ static void submission_login_start_tls(void *conn_ctx,
"TLS initialization failed.");
client_destroy(client,
"Disconnected: TLS initialization failed.");
return;
return -1;
}
login_refresh_proctitle();

*input = client->input;
*output = client->output;
return 0;
}

static struct client *submission_client_alloc(pool_t pool)
Expand Down

0 comments on commit b1de005

Please sign in to comment.