]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: server: RCPT command: Improve replacement of (forwarded) specific error...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Fri, 28 Sep 2018 22:21:05 +0000 (00:21 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Tue, 12 Feb 2019 13:40:48 +0000 (15:40 +0200)
Predictable transaction state errors were not always replaced reliably when
commands were pipelined, leading to a mix of proxy and remote errors.

src/lib-smtp/smtp-server-cmd-rcpt.c

index cbeb5fbe508dfc7a561e04c8c50ba59adac67ea8..2ce34fd67f4c388e389d6eb992591cc02599306d 100644 (file)
@@ -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);