From: Stephan Bosch Date: Tue, 24 Mar 2020 11:23:32 +0000 (+0100) Subject: lib-smtp: smtp-server-command - Perform initial command execution in separate function. X-Git-Tag: 2.3.11.2~79 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8ab81b2dbd2e9d995e7ab0e4a5c8be127d77e953;p=thirdparty%2Fdovecot%2Fcore.git lib-smtp: smtp-server-command - Perform initial command execution in separate function. --- diff --git a/src/lib-smtp/smtp-server-command.c b/src/lib-smtp/smtp-server-command.c index c9b551b6ac..c250ac169d 100644 --- a/src/lib-smtp/smtp-server-command.c +++ b/src/lib-smtp/smtp-server-command.c @@ -184,7 +184,7 @@ smtp_server_command_new_invalid(struct smtp_server_connection *conn) struct smtp_server_command * smtp_server_command_new(struct smtp_server_connection *conn, - const char *name, const char *params) + const char *name) { struct smtp_server *server = conn->server; struct smtp_server_command *cmd; @@ -200,6 +200,14 @@ smtp_server_command_new(struct smtp_server_connection *conn, set_name("smtp_server_command_started"); e_debug(e->event(), "New command"); + return cmd; +} + +void smtp_server_command_execute(struct smtp_server_command *cmd, + const char *params) +{ + struct smtp_server_connection *conn = cmd->context.conn; + if (cmd->reg == NULL) { /* RFC 5321, Section 4.2.4: Reply Code 502 @@ -256,7 +264,6 @@ smtp_server_command_new(struct smtp_server_connection *conn, if (!smtp_server_command_unref(&tmp_cmd)) cmd = NULL; } - return cmd; } void smtp_server_command_ref(struct smtp_server_command *cmd) diff --git a/src/lib-smtp/smtp-server-connection.c b/src/lib-smtp/smtp-server-connection.c index 77380a0f72..ff8f04864a 100644 --- a/src/lib-smtp/smtp-server-connection.c +++ b/src/lib-smtp/smtp-server-connection.c @@ -295,7 +295,8 @@ smtp_server_connection_handle_command(struct smtp_server_connection *conn, struct smtp_server_command *cmd; smtp_server_connection_ref(tmp_conn); - cmd = smtp_server_command_new(tmp_conn, cmd_name, cmd_params); + cmd = smtp_server_command_new(tmp_conn, cmd_name); + smtp_server_command_execute(cmd, cmd_params); if (!smtp_server_connection_unref(&tmp_conn)) { /* the command start callback managed to get this connection destroyed */ diff --git a/src/lib-smtp/smtp-server-private.h b/src/lib-smtp/smtp-server-private.h index 640d6d6c05..ef593f9dd2 100644 --- a/src/lib-smtp/smtp-server-private.h +++ b/src/lib-smtp/smtp-server-private.h @@ -242,8 +242,11 @@ void smtp_server_command_debug(struct smtp_server_cmd_ctx *cmd, struct smtp_server_command * smtp_server_command_new_invalid(struct smtp_server_connection *conn); struct smtp_server_command * -smtp_server_command_new(struct smtp_server_connection *conn, - const char *name, const char *params); +smtp_server_command_new(struct smtp_server_connection *conn, const char *name); + +void smtp_server_command_execute(struct smtp_server_command *cmd, + const char *params); + void smtp_server_command_ref(struct smtp_server_command *cmd); bool smtp_server_command_unref(struct smtp_server_command **_cmd); void smtp_server_command_abort(struct smtp_server_command **_cmd);