]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
submission: Move client_command_handle_proxy_reply() to submission-backend-relay.c.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sun, 15 Jul 2018 17:10:36 +0000 (19:10 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 9 Oct 2018 06:41:17 +0000 (06:41 +0000)
src/submission/Makefile.am
src/submission/submission-backend-relay.c [new file with mode: 0644]
src/submission/submission-commands.c

index 7fd81ac8d6de1096deb2b41dc780bc10e5ed981b..69ce63ebed6875330095e6525db0cc2f379ed66a 100644 (file)
@@ -46,6 +46,7 @@ cmds = \
 submission_SOURCES = \
        $(cmds) \
        main.c \
+       submission-backend-relay.c \
        submission-client.c \
        submission-commands.c \
        submission-settings.c
diff --git a/src/submission/submission-backend-relay.c b/src/submission/submission-backend-relay.c
new file mode 100644 (file)
index 0000000..71f8dc3
--- /dev/null
@@ -0,0 +1,68 @@
+/* Copyright (c) 2018 Dovecot authors, see the included COPYING file */
+
+#include "submission-common.h"
+#include "smtp-client.h"
+#include "smtp-client-connection.h"
+#include "smtp-client-command.h"
+
+#include "submission-commands.h"
+
+/*
+ * Common
+ */
+
+/* The command handling of the submission proxy service aims to follow the
+   following rules:
+
+   - Attempt to keep pipelined commands pipelined when proxying them to the
+     actual relay service.
+   - Don't forward commands if they're known to fail at the relay server. Errors
+     can still occur if pipelined commands fail. Abort subsequent pending
+     commands if such failures affect those commands.
+   - Keep predictable errors consistent as much as possible; send our own reply
+     if the error condition is clear (e.g. missing MAIL, RCPT).
+*/
+
+bool client_command_handle_proxy_reply(struct client *client,
+       const struct smtp_reply *reply, struct smtp_reply *reply_r)
+{
+       *reply_r = *reply;
+
+       switch (reply->status) {
+       case SMTP_CLIENT_COMMAND_ERROR_ABORTED:
+               return FALSE;
+       case SMTP_CLIENT_COMMAND_ERROR_HOST_LOOKUP_FAILED:
+       case SMTP_CLIENT_COMMAND_ERROR_CONNECT_FAILED:
+       case SMTP_CLIENT_COMMAND_ERROR_AUTH_FAILED:
+               i_unreached();
+               return FALSE;
+       case SMTP_CLIENT_COMMAND_ERROR_CONNECTION_CLOSED:
+       case SMTP_CLIENT_COMMAND_ERROR_CONNECTION_LOST:
+       case SMTP_CLIENT_COMMAND_ERROR_BAD_REPLY:
+       case SMTP_CLIENT_COMMAND_ERROR_TIMED_OUT:
+               client_destroy(client,
+                       "4.4.0", "Lost connection to relay server");
+               return FALSE;
+       /* RFC 4954, Section 6: 530 5.7.0 Authentication required
+
+          This response SHOULD be returned by any command other than AUTH,
+          EHLO, HELO, NOOP, RSET, or QUIT when server policy requires
+          authentication in order to perform the requested action and
+          authentication is not currently in force. */
+       case 530:
+               i_error("Relay server requires authentication: %s",
+                       smtp_reply_log(reply));
+               client_destroy(client, "4.3.5",
+                       "Internal error occurred. "
+                       "Refer to server log for more information.");
+               return FALSE;
+       default:
+               break;
+       }
+
+       if (!smtp_reply_has_enhanced_code(reply)) {
+               reply_r->enhanced_code =
+                       SMTP_REPLY_ENH_CODE(reply->status / 100, 0, 0);
+       }
+       return TRUE;
+}
index 8f2cbf37df4f27b6c48003794a439624c147d762..62015e6643d5ec83a9f7e308e7cab2963cdde854 100644 (file)
@@ -1,71 +1,6 @@
 /* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
 
 #include "submission-common.h"
-#include "ioloop.h"
-#include "array.h"
-#include "str.h"
-#include "llist.h"
-#include "istream.h"
-#include "ostream.h"
-#include "mail-storage.h"
-#include "smtp-reply.h"
-#include "smtp-client.h"
-#include "smtp-client-connection.h"
 
 #include "submission-commands.h"
 
-/* The command handling of the submission proxy service aims to follow the
-   following rules:
-
-   - Attempt to keep pipelined commands pipelined when proxying them to the
-     actual relay service.
-   - Don't forward commands if they're known to fail at the relay server. Errors
-     can still occur if pipelined commands fail. Abort subsequent pending
-     commands if such failures affect those commands.
-   - Keep predictable errors consistent as much as possible; send our own reply
-     if the error condition is clear (e.g. missing MAIL, RCPT).
-*/
-
-bool client_command_handle_proxy_reply(struct client *client,
-       const struct smtp_reply *reply, struct smtp_reply *reply_r)
-{
-       *reply_r = *reply;
-
-       switch (reply->status) {
-       case SMTP_CLIENT_COMMAND_ERROR_ABORTED:
-               return FALSE;
-       case SMTP_CLIENT_COMMAND_ERROR_HOST_LOOKUP_FAILED:
-       case SMTP_CLIENT_COMMAND_ERROR_CONNECT_FAILED:
-       case SMTP_CLIENT_COMMAND_ERROR_AUTH_FAILED:
-               i_unreached();
-               return FALSE;
-       case SMTP_CLIENT_COMMAND_ERROR_CONNECTION_CLOSED:
-       case SMTP_CLIENT_COMMAND_ERROR_CONNECTION_LOST:
-       case SMTP_CLIENT_COMMAND_ERROR_BAD_REPLY:
-       case SMTP_CLIENT_COMMAND_ERROR_TIMED_OUT:
-               client_destroy(client,
-                       "4.4.0", "Lost connection to relay server");
-               return FALSE;
-       /* RFC 4954, Section 6: 530 5.7.0 Authentication required
-
-          This response SHOULD be returned by any command other than AUTH,
-          EHLO, HELO, NOOP, RSET, or QUIT when server policy requires
-          authentication in order to perform the requested action and
-          authentication is not currently in force. */
-       case 530:
-               i_error("Relay server requires authentication: %s",
-                       smtp_reply_log(reply));
-               client_destroy(client, "4.3.5",
-                       "Internal error occurred. "
-                       "Refer to server log for more information.");
-               return FALSE;
-       default:
-               break;
-       }
-
-       if (!smtp_reply_has_enhanced_code(reply)) {
-               reply_r->enhanced_code =
-                       SMTP_REPLY_ENH_CODE(reply->status / 100, 0, 0);
-       }
-       return TRUE;
-}