]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
login-common: If proxy fails, log the reason in the "Login aborted" log line
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 3 Dec 2025 09:25:45 +0000 (11:25 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 27 Nov 2025 07:53:37 +0000 (07:53 +0000)
It was already logged separately in proxy's "Login failed" line, but having
the reason in the "Login aborted" line as well avoids having to match log
lines to find the reason.

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

index a7e8131e0feae51a82a43bc657fba78451a0638e..f57e99e02350be0e95be8e9ebbb74d15e36d7014 100644 (file)
@@ -639,6 +639,7 @@ bool client_unref(struct client **_client)
        i_free(client->virtual_user_orig);
        i_free(client->virtual_auth_user);
        i_free(client->auth_mech_name);
+       i_free(client->last_proxy_auth_failure_reason);
        i_free(client->master_data_prefix);
        pool_unref(&client->pool);
 
@@ -1501,6 +1502,10 @@ bool client_get_extra_disconnect_reason(struct client *client,
        }
 
        str_printfa(str, "in %u secs", auth_secs);
+       if (client->last_proxy_auth_failure_reason != NULL) {
+               str_printfa(str, ", last failure: %s",
+                           str_sanitize(client->last_proxy_auth_failure_reason, 160));
+       }
        *human_reason_r = str_c(str);
        i_assert(*event_reason_r != NULL);
        return TRUE;
index f2333595da7b1e06faa7d0c8a219269365bdb4da..1a3f58e25052f7b41028808612e337b7d211c325 100644 (file)
@@ -249,6 +249,7 @@ struct client {
 
        unsigned int bad_counter;
        unsigned int auth_attempts, auth_successes;
+       char *last_proxy_auth_failure_reason;
        enum client_auth_fail_code last_auth_fail;
        enum login_proxy_failure_type proxy_last_failure;
        pid_t mail_pid;
index 01561fedcb9b239fda45d33340d8795eedc90f9e..2df51eb4026bc8d99b00ab0fa05c151fa3caa189 100644 (file)
@@ -883,6 +883,10 @@ bool login_proxy_failed(struct login_proxy *proxy, struct event *event,
                return TRUE;
        }
 
+       i_free(proxy->client->last_proxy_auth_failure_reason);
+       proxy->client->last_proxy_auth_failure_reason =
+               i_strdup_printf("%s%s", log_prefix, reason);
+
        if (type != LOGIN_PROXY_FAILURE_TYPE_AUTH_REPLIED &&
            type != LOGIN_PROXY_FAILURE_TYPE_AUTH_NOT_REPLIED &&
            type != LOGIN_PROXY_FAILURE_TYPE_AUTH_TEMPFAIL)