[PATCH 2 of 2] Mail: fixed "upstream: ..." in logs with "smtp_auth none"
Maxim Dounin
mdounin at mdounin.ru
Thu Aug 14 21:01:02 UTC 2025
# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1755187434 -10800
# Thu Aug 14 19:03:54 2025 +0300
# Node ID 31ecd4a1b346b117e84128988bd7bf056e7aa3b9
# Parent 13ee0b2ffee6d852bc5aa4e10fcf217a982c8e79
Mail: fixed "upstream: ..." in logs with "smtp_auth none".
Previously, it was not added to the log line due to no s->login, which
caused early return from the function. Fix is to restructure the log handler
to use "if (...)" blocks instead, similarly to ngx_http_log_error_handler().
diff --git a/src/mail/ngx_mail_handler.c b/src/mail/ngx_mail_handler.c
--- a/src/mail/ngx_mail_handler.c
+++ b/src/mail/ngx_mail_handler.c
@@ -1486,19 +1486,15 @@ ngx_mail_log_error(ngx_log_t *log, u_cha
len -= p - buf;
buf = p;
- if (s->login.len == 0) {
- return p;
+ if (s->login.len) {
+ p = ngx_snprintf(buf, len, ", login: \"%V\"", &s->login);
+ len -= p - buf;
+ buf = p;
}
- p = ngx_snprintf(buf, len, ", login: \"%V\"", &s->login);
- len -= p - buf;
- buf = p;
-
- if (s->proxy == NULL) {
- return p;
+ if (s->proxy) {
+ p = ngx_snprintf(buf, len, ", upstream: %V", s->proxy->upstream.name);
}
- p = ngx_snprintf(buf, len, ", upstream: %V", s->proxy->upstream.name);
-
return p;
}
More information about the nginx-devel
mailing list