From: Timo Sirainen Date: Wed, 3 Dec 2025 09:25:45 +0000 (+0200) Subject: login-common: If proxy fails, log the reason in the "Login aborted" log line X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7824fdef2274839005da428518ea0da2e3bcc0ae;p=thirdparty%2Fdovecot%2Fcore.git login-common: If proxy fails, log the reason in the "Login aborted" log line 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. --- diff --git a/src/login-common/client-common.c b/src/login-common/client-common.c index a7e8131e0f..f57e99e023 100644 --- a/src/login-common/client-common.c +++ b/src/login-common/client-common.c @@ -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; diff --git a/src/login-common/client-common.h b/src/login-common/client-common.h index f2333595da..1a3f58e250 100644 --- a/src/login-common/client-common.h +++ b/src/login-common/client-common.h @@ -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; diff --git a/src/login-common/login-proxy.c b/src/login-common/login-proxy.c index 01561fedcb..2df51eb402 100644 --- a/src/login-common/login-proxy.c +++ b/src/login-common/login-proxy.c @@ -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)