From: Stephan Bosch Date: Fri, 28 Sep 2018 22:21:05 +0000 (+0200) Subject: lib-smtp: server: RCPT command: Improve replacement of (forwarded) specific error... X-Git-Tag: 2.3.9~1266 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e255197476ed8b43f08b466b936be6f6622dc154;p=thirdparty%2Fdovecot%2Fcore.git lib-smtp: server: RCPT command: Improve replacement of (forwarded) specific error reply with generic state error. Predictable transaction state errors were not always replaced reliably when commands were pipelined, leading to a mix of proxy and remote errors. --- diff --git a/src/lib-smtp/smtp-server-cmd-rcpt.c b/src/lib-smtp/smtp-server-cmd-rcpt.c index cbeb5fbe50..2ce34fd67f 100644 --- a/src/lib-smtp/smtp-server-cmd-rcpt.c +++ b/src/lib-smtp/smtp-server-cmd-rcpt.c @@ -47,8 +47,12 @@ cmd_rcpt_completed(struct smtp_server_cmd_ctx *cmd, conn->state.pending_rcpt_cmds--; i_assert(smtp_server_command_is_replied(command)); - if (!smtp_server_command_replied_success(command)) + if (!smtp_server_command_replied_success(command)) { + /* failure; substitute our own error if predictable */ + if (smtp_server_command_reply_is_forwarded(command)) + (void)cmd_rcpt_check_state(cmd); return; + } /* success */ rcpt = smtp_server_transaction_add_rcpt(trans, data->path, @@ -62,20 +66,6 @@ cmd_rcpt_completed(struct smtp_server_cmd_ctx *cmd, } } -static void -cmd_rcpt_replied(struct smtp_server_cmd_ctx *cmd, - struct smtp_server_cmd_rcpt *data ATTR_UNUSED) -{ - struct smtp_server_command *command = cmd->cmd; - - i_assert(smtp_server_command_is_replied(command)); - if (!smtp_server_command_replied_success(command)) { - /* failure; substitute our own error if predictable */ - (void)cmd_rcpt_check_state(cmd); - return; - } -} - static void cmd_rcpt_recheck(struct smtp_server_cmd_ctx *cmd, struct smtp_server_cmd_rcpt *data ATTR_UNUSED) @@ -187,8 +177,6 @@ void smtp_server_cmd_rcpt(struct smtp_server_cmd_ctx *cmd, smtp_server_command_add_hook(command, SMTP_SERVER_COMMAND_HOOK_NEXT, cmd_rcpt_recheck, rcpt_data); - smtp_server_command_add_hook(command, SMTP_SERVER_COMMAND_HOOK_REPLIED, - cmd_rcpt_replied, rcpt_data); smtp_server_command_add_hook(command, SMTP_SERVER_COMMAND_HOOK_COMPLETED, cmd_rcpt_completed, rcpt_data);