From: Timo Sirainen Date: Wed, 3 Feb 2021 20:15:51 +0000 (+0200) Subject: login-common: Add and use client_destroy_iostream_error() X-Git-Tag: 2.3.15~270 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7bce44b6af0b83d6a5a0bfa318f6f641fc50f206;p=thirdparty%2Fdovecot%2Fcore.git login-common: Add and use client_destroy_iostream_error() This standardizes the disconnection log message. --- diff --git a/src/login-common/client-common-auth.c b/src/login-common/client-common-auth.c index 00db836aa7..e006b43e09 100644 --- a/src/login-common/client-common-auth.c +++ b/src/login-common/client-common-auth.c @@ -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; } diff --git a/src/login-common/client-common.c b/src/login-common/client-common.c index e3a9a614c7..b2615228ba 100644 --- a/src/login-common/client-common.c +++ b/src/login-common/client-common.c @@ -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 */ diff --git a/src/login-common/client-common.h b/src/login-common/client-common.h index 9071b3d353..dbcaee1cc0 100644 --- a/src/login-common/client-common.h +++ b/src/login-common/client-common.h @@ -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);