]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
submission-login: submission-proxy - Optionally send XCLIENT LOGIN to backend and...
authorStephan Bosch <stephan.bosch@open-xchange.com>
Sun, 4 Jul 2021 22:37:46 +0000 (00:37 +0200)
committerStephan Bosch <stephan.bosch@open-xchange.com>
Tue, 27 Jul 2021 23:49:41 +0000 (01:49 +0200)
This behavior is enabled by returning proxy_noauth from passdb.

src/submission-login/submission-proxy.c

index 53280c7844b6e841e65ec775536f25238b2b3d1d..778b8146375c0b63554861f5e7e2fabdf2f15fe9 100644 (file)
@@ -153,6 +153,19 @@ proxy_send_xclient(struct submission_client *client, struct ostream *output)
                }
                proxy_send_xclient_more(client, output, str, "PROTO", proto);
        }
+       if (client->common.proxy_noauth &&
+           str_array_icase_find(client->proxy_xclient, "LOGIN")) {
+               if (proxy_data.login != NULL) {
+                       proxy_send_xclient_more(client, output, str, "LOGIN",
+                                               proxy_data.login);
+               } else if (client->common.virtual_user != NULL) {
+                       proxy_send_xclient_more(client, output, str, "LOGIN",
+                                               client->common.virtual_user);
+               } else {
+                       proxy_send_xclient_more(client, output, str, "LOGIN",
+                                               "[UNAVAILABLE]");
+               }
+       }
        if (str_array_icase_find(client->proxy_xclient, "TTL")) {
                proxy_send_xclient_more(
                        client, output, str, "TTL",
@@ -247,6 +260,7 @@ static int
 proxy_handle_ehlo_reply(struct submission_client *client,
                        struct ostream *output)
 {
+       struct smtp_server_cmd_ctx *cmd = client->pending_auth;
        int ret;
 
        switch (client->proxy_state) {
@@ -276,6 +290,18 @@ proxy_handle_ehlo_reply(struct submission_client *client,
                i_unreached();
        }
 
+       if (client->common.proxy_noauth) {
+               smtp_server_connection_input_lock(cmd->conn);
+
+               smtp_server_command_add_hook(
+                       cmd->cmd, SMTP_SERVER_COMMAND_HOOK_DESTROY,
+                       submission_proxy_success_reply_sent, client);
+               client->pending_auth = NULL;
+
+               smtp_server_reply(cmd, 235, "2.7.0", "Logged in.");
+               return 1;
+       }
+
        return proxy_send_login(client, output);
 }