]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
*-login: Add "Disconnected: " prefix to most disconnection log lines
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 3 Feb 2021 19:58:15 +0000 (21:58 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 11 Mar 2021 11:19:09 +0000 (11:19 +0000)
All except "Disconnected by proxy" disconnections.

src/imap-login/imap-login-client.c
src/login-common/client-common.c
src/login-common/client-common.h
src/login-common/login-proxy.c
src/login-common/main.c
src/submission-login/client.c

index b2c8af9cbf0df74cdfd6e0301583bd47d8238f02..b426a0c2a5bb9b5e9a21f63421b1578980a09f4c 100644 (file)
@@ -60,8 +60,7 @@ bool client_handle_parser_error(struct imap_client *client,
        case IMAP_PARSE_ERROR_LITERAL_TOO_BIG:
                client_send_reply(&client->common,
                                  IMAP_CMD_REPLY_BYE, msg);
-               client_destroy(&client->common,
-                              t_strconcat("Disconnected: ", msg, NULL));
+               client_destroy(&client->common, msg);
                return FALSE;
        default:
                break;
@@ -201,8 +200,7 @@ static bool client_invalid_command(struct imap_client *client)
        if (++client->common.bad_counter >= CLIENT_MAX_BAD_COMMANDS) {
                client_send_reply(&client->common, IMAP_CMD_REPLY_BYE,
                                  "Too many invalid IMAP commands.");
-               client_destroy(&client->common,
-                              "Disconnected: Too many invalid commands");
+               client_destroy(&client->common, "Too many invalid commands");
                return FALSE;
        }
        client_send_reply(&client->common, IMAP_CMD_REPLY_BAD,
index cb0f9fbaac74c432a5489c97b1d42b08191aee99..e3a9a614c743ccb82b9b80df9c8ca73a24c75604 100644 (file)
@@ -101,8 +101,7 @@ static void client_idle_disconnect_timeout(struct client *client)
        } else if (client->auth_request != NULL) {
                user_reason =
                        "Disconnected for inactivity during authentication.";
-               destroy_reason =
-                       "Disconnected: Inactivity during authentication";
+               destroy_reason = "Inactivity during authentication";
        } else if (client->login_proxy != NULL) {
                secs = ioloop_time - client->created;
                user_reason = "Timeout while finishing login.";
@@ -114,7 +113,7 @@ static void client_idle_disconnect_timeout(struct client *client)
                        "%s", destroy_reason);
        } else {
                user_reason = "Disconnected for inactivity.";
-               destroy_reason = "Disconnected: Inactivity";
+               destroy_reason = "Inactivity";
        }
        client_notify_disconnect(client, CLIENT_DISCONNECT_TIMEOUT, user_reason);
        client_destroy(client, destroy_reason);
@@ -250,7 +249,8 @@ void client_init(struct client *client, void **other_sets)
        login_refresh_proctitle();
 }
 
-void client_disconnect(struct client *client, const char *reason)
+void client_disconnect(struct client *client, const char *reason,
+                      bool add_disconnected_prefix)
 {
        if (client->disconnected)
                return;
@@ -267,7 +267,10 @@ void client_disconnect(struct client *client, const char *reason)
                struct event *event = client->login_proxy == NULL ?
                        client->event :
                        login_proxy_get_event(client->login_proxy);
-               e_info(event, "%s", reason);
+               if (add_disconnected_prefix)
+                       e_info(event, "Disconnected: %s", reason);
+               else
+                       e_info(event, "%s", reason);
        }
 
        if (client->output != NULL)
@@ -305,7 +308,7 @@ void client_destroy(struct client *client, const char *reason)
           client_fd_proxies. */
        DLLIST_REMOVE(&clients, client);
 
-       client_disconnect(client, reason);
+       client_disconnect(client, reason, !client->login_success);
 
        pool_unref(&client->preproxy_pool);
 
@@ -441,7 +444,7 @@ void client_destroy_oldest(void)
 
        client_notify_disconnect(client, CLIENT_DISCONNECT_RESOURCE_CONSTRAINT,
                                 "Connection queue full");
-       client_destroy(client, "Disconnected: Connection queue full");
+       client_destroy(client, "Connection queue full");
 }
 
 void clients_destroy_all_reason(const char *reason)
@@ -458,7 +461,7 @@ void clients_destroy_all_reason(const char *reason)
 
 void clients_destroy_all(void)
 {
-       clients_destroy_all_reason("Disconnected: Shutting down");
+       clients_destroy_all_reason("Shutting down");
 }
 
 static int client_sni_callback(const char *name, const char **error_r,
@@ -549,8 +552,7 @@ static void client_start_tls(struct client *client)
                client_notify_disconnect(client,
                        CLIENT_DISCONNECT_INTERNAL_ERROR,
                        "TLS initialization failed.");
-               client_destroy(client,
-                       "Disconnected: TLS initialization failed.");
+               client_destroy(client, "TLS initialization failed.");
                return;
        }
        login_refresh_proctitle();
@@ -1105,7 +1107,7 @@ bool client_read(struct client *client)
                client_notify_disconnect(client,
                        CLIENT_DISCONNECT_RESOURCE_CONSTRAINT,
                        "Input buffer full, aborting");
-               client_destroy(client, "Disconnected: Input buffer full");
+               client_destroy(client, "Input buffer full");
                return FALSE;
        case -1:
                /* disconnected */
index 98bebf154ffb9014fcf805f618668f1b4f0b9920..90232f47f675c8c8faafcfb5d4131afdd6feebdb 100644 (file)
@@ -263,7 +263,8 @@ client_alloc(int fd, pool_t pool,
             const struct login_settings *set,
             const struct master_service_ssl_settings *ssl_set);
 void client_init(struct client *client, void **other_sets);
-void client_disconnect(struct client *client, const char *reason);
+void client_disconnect(struct client *client, const char *reason,
+                      bool add_disconnected_prefix);
 void client_destroy(struct client *client, const char *reason);
 /* Destroy the client after a successful login. Either the client fd was
    sent to the post-login process, or the connection will be proxied. */
index bb23b90d011aad566d42fdf8603cf9da9339fc24..5e3b59c3a887482141d13e2ca15264d8fe993afe 100644 (file)
@@ -883,7 +883,8 @@ login_proxy_cmd_kick_full(struct ipc_cmd *cmd, const char *const *args,
                next = proxy->next;
 
                if (want_kick(proxy, args, key_idx)) {
-                       client_destroy(proxy->client, KILLED_BY_ADMIN_REASON);
+                       client_disconnect(proxy->client, KILLED_BY_ADMIN_REASON, FALSE);
+                       client_destroy(proxy->client, NULL);
                        count++;
                }
        } T_END;
@@ -983,7 +984,8 @@ login_proxy_cmd_kick_director_hash(struct ipc_cmd *cmd, const char *const *args)
                if (director_username_hash(proxy->client, &proxy_hash) &&
                    proxy_hash == hash &&
                    !net_ip_compare(&proxy->ip, &except_ip)) {
-                       client_destroy(proxy->client, KILLED_BY_DIRECTOR_REASON);
+                       client_disconnect(proxy->client, KILLED_BY_DIRECTOR_REASON, FALSE);
+                       client_destroy(proxy->client, NULL);
                        count++;
                }
        }
index a4e559738566c82aad6cac0fcde68333f2fc4ce7..cee6d43d149df060a45853eb7934924a8ec021dc 100644 (file)
@@ -293,7 +293,7 @@ static void auth_connect_notify(struct auth_client *client ATTR_UNUSED,
                /* auth disconnected without having ever succeeded, so the
                   auth process is probably misconfigured. no point in
                   keeping the client connections hanging. */
-               clients_destroy_all_reason("Disconnected: Auth process broken");
+               clients_destroy_all_reason("Auth process broken");
        }
 }
 
index 479eb0d806c4cae33c2698141295d4b2312c750e..122ace3d1a5bb0f22740442d991b91ff846cc86b 100644 (file)
@@ -213,7 +213,8 @@ static void client_connection_disconnect(void *context, const char *reason)
        struct submission_client *client = context;
 
        client->pending_auth = NULL;
-       client_disconnect(&client->common, reason);
+       client_disconnect(&client->common, reason,
+                         !client->common.login_success);
 }
 
 static void client_connection_free(void *context)