[nginx] Mail: fixed "upstream: ..." in logs with "smtp_auth none".
Maxim Dounin
mdounin at mdounin.ru
Thu Aug 21 17:08:51 UTC 2025
details: http://freenginx.org/hg/nginx/rev/983ba8e0d396
branches:
changeset: 9413:983ba8e0d396
user: Maxim Dounin <mdounin at mdounin.ru>
date: Thu Aug 21 06:02:08 2025 +0300
description:
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().
diffstat:
src/mail/ngx_mail_handler.c | 16 ++++++----------
1 files changed, 6 insertions(+), 10 deletions(-)
diffs (29 lines):
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