]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
login-common: Add and use client_destroy_iostream_error()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 3 Feb 2021 20:15:51 +0000 (22:15 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 11 Mar 2021 11:19:09 +0000 (11:19 +0000)
This standardizes the disconnection log message.

src/login-common/client-common-auth.c
src/login-common/client-common.c
src/login-common/client-common.h

index 00db836aa7901bc686c10c3117e941ea2b81fb04..e006b43e0966c8b3c1a1a475ba979ea805375625 100644 (file)
@@ -286,7 +286,7 @@ void client_proxy_finish_destroy_client(struct client *client)
                   In most places we don't have to check for this explicitly,
                   but login_proxy_detach() attempts to get and use the
                   istream's fd, which is now -1. */
-               client_destroy(client, "Disconnected");
+               client_destroy_iostream_error(client);
                return;
        }
 
@@ -654,7 +654,7 @@ int client_auth_read_line(struct client *client)
        size_t i, size, len;
 
        if (i_stream_read_more(client->input, &data, &size) == -1) {
-               client_destroy(client, "Disconnected");
+               client_destroy_iostream_error(client);
                return -1;
        }
 
index e3a9a614c743ccb82b9b80df9c8ca73a24c75604..b2615228ba3f3085552d0f1ddc848462a6b79676 100644 (file)
@@ -6,6 +6,7 @@
 #include "llist.h"
 #include "istream.h"
 #include "ostream.h"
+#include "iostream.h"
 #include "iostream-ssl.h"
 #include "iostream-proxy.h"
 #include "iostream-rawlog.h"
@@ -354,6 +355,13 @@ void client_destroy(struct client *client, const char *reason)
        login_refresh_proctitle();
 }
 
+void client_destroy_iostream_error(struct client *client)
+{
+       const char *reason =
+               io_stream_get_disconnect_reason(client->input, client->output);
+       client_destroy(client, reason);
+}
+
 void client_destroy_success(struct client *client, const char *reason)
 {
        client->login_success = TRUE;
@@ -565,7 +573,7 @@ static int client_output_starttls(struct client *client)
        int ret;
 
        if ((ret = o_stream_flush(client->output)) < 0) {
-               client_destroy(client, "Disconnected");
+               client_destroy_iostream_error(client);
                return 1;
        }
 
@@ -1111,7 +1119,7 @@ bool client_read(struct client *client)
                return FALSE;
        case -1:
                /* disconnected */
-               client_destroy(client, "Disconnected");
+               client_destroy_iostream_error(client);
                return FALSE;
        case 0:
                /* nothing new read */
index 9071b3d353bb2ad1fabeae3591bd281f6f79b0ca..dbcaee1cc0d75301c63bd9a16d388a6d6bbc7a38 100644 (file)
@@ -270,6 +270,7 @@ void client_init(struct client *client, void **other_sets);
 void client_disconnect(struct client *client, const char *reason,
                       bool add_disconnected_prefix);
 void client_destroy(struct client *client, const char *reason);
+void client_destroy_iostream_error(struct client *client);
 /* Destroy the client after a successful login. Either the client fd was
    sent to the post-login process, or the connection will be proxied. */
 void client_destroy_success(struct client *client, const char *reason);