summaryrefslogtreecommitdiff
path: root/src/mail
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2009-02-10 16:51:14 +0000
committerJonathan Kolb <jon@b0g.us>2009-02-10 16:51:14 +0000
commit21b3e284e6ede9abda0d2e6bf92ac5f98cd8cfe2 (patch)
treef41434d0197cba1f9f9ad5649430f5d8c4dd779d /src/mail
parent0e7e73291ae306f7ce6e8621ef8ed9fd24d94859 (diff)
downloadnginx-21b3e284e6ede9abda0d2e6bf92ac5f98cd8cfe2.tar.gz
Changes with nginx 0.7.34 10 Feb 2009v0.7.34
*) Feature: the "off" parameter of the "if_modified_since" directive. *) Feature: now nginx sends an HELO/EHLO command after a XCLIENT command. Thanks to Maxim Dounin. *) Feature: Microsoft specific "AUTH LOGIN with User Name" mode support in mail proxy server. Thanks to Maxim Dounin. *) Bugfix: in a redirect rewrite directive original arguments were concatenated with new arguments by an "?" rather than an "&"; the bug had appeared in 0.1.18. Thanks to Maxim Dounin. *) Bugfix: nginx could not be built on AIX.
Diffstat (limited to 'src/mail')
-rw-r--r--src/mail/ngx_mail.h14
-rw-r--r--src/mail/ngx_mail_handler.c9
-rw-r--r--src/mail/ngx_mail_imap_handler.c10
-rw-r--r--src/mail/ngx_mail_parse.c4
-rw-r--r--src/mail/ngx_mail_pop3_handler.c10
-rw-r--r--src/mail/ngx_mail_proxy_module.c41
-rw-r--r--src/mail/ngx_mail_smtp_handler.c10
7 files changed, 79 insertions, 19 deletions
diff --git a/src/mail/ngx_mail.h b/src/mail/ngx_mail.h
index 4052efea7..81969c9e0 100644
--- a/src/mail/ngx_mail.h
+++ b/src/mail/ngx_mail.h
@@ -140,6 +140,7 @@ typedef enum {
ngx_smtp_helo_from,
ngx_smtp_xclient,
ngx_smtp_xclient_from,
+ ngx_smtp_xclient_helo,
ngx_smtp_from,
ngx_smtp_to
} ngx_smtp_state_e;
@@ -258,11 +259,12 @@ typedef struct {
#define NGX_SMTP_STARTTLS 13
-#define NGX_MAIL_AUTH_PLAIN 0
-#define NGX_MAIL_AUTH_LOGIN 1
-#define NGX_MAIL_AUTH_APOP 2
-#define NGX_MAIL_AUTH_CRAM_MD5 3
-#define NGX_MAIL_AUTH_NONE 4
+#define NGX_MAIL_AUTH_PLAIN 0
+#define NGX_MAIL_AUTH_LOGIN 1
+#define NGX_MAIL_AUTH_LOGIN_USERNAME 2
+#define NGX_MAIL_AUTH_APOP 3
+#define NGX_MAIL_AUTH_CRAM_MD5 4
+#define NGX_MAIL_AUTH_NONE 5
#define NGX_MAIL_AUTH_PLAIN_ENABLED 0x0002
@@ -346,7 +348,7 @@ ngx_int_t ngx_mail_salt(ngx_mail_session_t *s, ngx_connection_t *c,
ngx_int_t ngx_mail_auth_plain(ngx_mail_session_t *s, ngx_connection_t *c,
ngx_uint_t n);
ngx_int_t ngx_mail_auth_login_username(ngx_mail_session_t *s,
- ngx_connection_t *c);
+ ngx_connection_t *c, ngx_uint_t n);
ngx_int_t ngx_mail_auth_login_password(ngx_mail_session_t *s,
ngx_connection_t *c);
ngx_int_t ngx_mail_auth_cram_md5_salt(ngx_mail_session_t *s,
diff --git a/src/mail/ngx_mail_handler.c b/src/mail/ngx_mail_handler.c
index e86877f1a..0863d6dfe 100644
--- a/src/mail/ngx_mail_handler.c
+++ b/src/mail/ngx_mail_handler.c
@@ -356,21 +356,22 @@ ngx_mail_auth_plain(ngx_mail_session_t *s, ngx_connection_t *c, ngx_uint_t n)
ngx_int_t
-ngx_mail_auth_login_username(ngx_mail_session_t *s, ngx_connection_t *c)
+ngx_mail_auth_login_username(ngx_mail_session_t *s, ngx_connection_t *c,
+ ngx_uint_t n)
{
ngx_str_t *arg;
arg = s->args.elts;
ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0,
- "mail auth login username: \"%V\"", &arg[0]);
+ "mail auth login username: \"%V\"", &arg[n]);
- s->login.data = ngx_pnalloc(c->pool, ngx_base64_decoded_length(arg[0].len));
+ s->login.data = ngx_pnalloc(c->pool, ngx_base64_decoded_length(arg[n].len));
if (s->login.data == NULL){
return NGX_ERROR;
}
- if (ngx_decode_base64(&s->login, &arg[0]) != NGX_OK) {
+ if (ngx_decode_base64(&s->login, &arg[n]) != NGX_OK) {
ngx_log_error(NGX_LOG_INFO, c->log, 0,
"client sent invalid base64 encoding in AUTH LOGIN command");
return NGX_MAIL_PARSE_INVALID_COMMAND;
diff --git a/src/mail/ngx_mail_imap_handler.c b/src/mail/ngx_mail_imap_handler.c
index 780c38fbb..a2e032eff 100644
--- a/src/mail/ngx_mail_imap_handler.c
+++ b/src/mail/ngx_mail_imap_handler.c
@@ -205,7 +205,7 @@ ngx_mail_imap_auth_state(ngx_event_t *rev)
break;
case ngx_imap_auth_login_username:
- rc = ngx_mail_auth_login_username(s, c);
+ rc = ngx_mail_auth_login_username(s, c, 0);
tag = 0;
s->out.len = sizeof(imap_password) - 1;
@@ -370,6 +370,14 @@ ngx_mail_imap_authenticate(ngx_mail_session_t *s, ngx_connection_t *c)
return NGX_OK;
+ case NGX_MAIL_AUTH_LOGIN_USERNAME:
+
+ s->out.len = sizeof(imap_password) - 1;
+ s->out.data = imap_password;
+ s->mail_state = ngx_imap_auth_login_password;
+
+ return ngx_mail_auth_login_username(s, c, 1);
+
case NGX_MAIL_AUTH_PLAIN:
s->out.len = sizeof(imap_plain_next) - 1;
diff --git a/src/mail/ngx_mail_parse.c b/src/mail/ngx_mail_parse.c
index a2d3f48ad..67f4d5edf 100644
--- a/src/mail/ngx_mail_parse.c
+++ b/src/mail/ngx_mail_parse.c
@@ -848,6 +848,10 @@ ngx_mail_auth_parse(ngx_mail_session_t *s, ngx_connection_t *c)
return NGX_MAIL_AUTH_LOGIN;
}
+ if (s->args.nelts == 2) {
+ return NGX_MAIL_AUTH_LOGIN_USERNAME;
+ }
+
return NGX_MAIL_PARSE_INVALID_COMMAND;
}
diff --git a/src/mail/ngx_mail_pop3_handler.c b/src/mail/ngx_mail_pop3_handler.c
index c763f04ff..aed662919 100644
--- a/src/mail/ngx_mail_pop3_handler.c
+++ b/src/mail/ngx_mail_pop3_handler.c
@@ -226,7 +226,7 @@ ngx_mail_pop3_auth_state(ngx_event_t *rev)
break;
case ngx_pop3_auth_login_username:
- rc = ngx_mail_auth_login_username(s, c);
+ rc = ngx_mail_auth_login_username(s, c, 0);
s->out.len = sizeof(pop3_password) - 1;
s->out.data = pop3_password;
@@ -474,6 +474,14 @@ ngx_mail_pop3_auth(ngx_mail_session_t *s, ngx_connection_t *c)
return NGX_OK;
+ case NGX_MAIL_AUTH_LOGIN_USERNAME:
+
+ s->out.len = sizeof(pop3_password) - 1;
+ s->out.data = pop3_password;
+ s->mail_state = ngx_pop3_auth_login_password;
+
+ return ngx_mail_auth_login_username(s, c, 1);
+
case NGX_MAIL_AUTH_PLAIN:
s->out.len = sizeof(pop3_next) - 1;
diff --git a/src/mail/ngx_mail_proxy_module.c b/src/mail/ngx_mail_proxy_module.c
index a11101e91..193df8ada 100644
--- a/src/mail/ngx_mail_proxy_module.c
+++ b/src/mail/ngx_mail_proxy_module.c
@@ -539,9 +539,8 @@ ngx_mail_proxy_smtp_handler(ngx_event_t *rev)
s->connection->log->action = "sending XCLIENT to upstream";
- line.len = sizeof("XCLIENT PROTO=SMTP HELO= ADDR= LOGIN= NAME="
+ line.len = sizeof("XCLIENT ADDR= LOGIN= NAME="
CRLF) - 1
- + s->esmtp + s->smtp_helo.len
+ s->connection->addr_text.len + s->login.len + s->host.len;
line.data = ngx_pnalloc(c->pool, line.len);
@@ -551,15 +550,44 @@ ngx_mail_proxy_smtp_handler(ngx_event_t *rev)
}
line.len = ngx_sprintf(line.data,
- "XCLIENT PROTO=%sSMTP%s%V ADDR=%V%s%V NAME=%V" CRLF,
- (s->esmtp ? "E" : ""),
- (s->smtp_helo.len ? " HELO=" : ""), &s->smtp_helo,
+ "XCLIENT ADDR=%V%s%V NAME=%V" CRLF,
&s->connection->addr_text,
(s->login.len ? " LOGIN=" : ""), &s->login, &s->host)
- line.data;
+ if (s->smtp_helo.len) {
+ s->mail_state = ngx_smtp_xclient_helo;
+
+ } else if (s->auth_method == NGX_MAIL_AUTH_NONE) {
+ s->mail_state = ngx_smtp_xclient_from;
+
+ } else {
+ s->mail_state = ngx_smtp_xclient;
+ }
+
+ break;
+
+ case ngx_smtp_xclient_helo:
+ ngx_log_debug0(NGX_LOG_DEBUG_MAIL, rev->log, 0,
+ "mail proxy send client ehlo");
+
+ s->connection->log->action = "sending client HELO/EHLO to upstream";
+
+ line.len = sizeof("HELO " CRLF) - 1 + s->smtp_helo.len;
+
+ line.data = ngx_pnalloc(c->pool, line.len);
+ if (line.data == NULL) {
+ ngx_mail_proxy_internal_server_error(s);
+ return;
+ }
+
+ line.len = ngx_sprintf(line.data,
+ ((s->esmtp) ? "EHLO %V" CRLF : "HELO %V" CRLF),
+ &s->smtp_helo)
+ - line.data;
+
s->mail_state = (s->auth_method == NGX_MAIL_AUTH_NONE) ?
- ngx_smtp_xclient_from : ngx_smtp_xclient;
+ ngx_smtp_helo_from : ngx_smtp_helo;
break;
@@ -772,6 +800,7 @@ ngx_mail_proxy_read_response(ngx_mail_session_t *s, ngx_uint_t state)
case ngx_smtp_xclient:
case ngx_smtp_xclient_from:
+ case ngx_smtp_xclient_helo:
if (p[0] == '2' && (p[1] == '2' || p[1] == '5') && p[2] == '0') {
return NGX_OK;
}
diff --git a/src/mail/ngx_mail_smtp_handler.c b/src/mail/ngx_mail_smtp_handler.c
index a88a82cd4..a0ad37f17 100644
--- a/src/mail/ngx_mail_smtp_handler.c
+++ b/src/mail/ngx_mail_smtp_handler.c
@@ -462,7 +462,7 @@ ngx_mail_smtp_auth_state(ngx_event_t *rev)
break;
case ngx_smtp_auth_login_username:
- rc = ngx_mail_auth_login_username(s, c);
+ rc = ngx_mail_auth_login_username(s, c, 0);
s->out.len = sizeof(smtp_password) - 1;
s->out.data = smtp_password;
@@ -611,6 +611,14 @@ ngx_mail_smtp_auth(ngx_mail_session_t *s, ngx_connection_t *c)
return NGX_OK;
+ case NGX_MAIL_AUTH_LOGIN_USERNAME:
+
+ s->out.len = sizeof(smtp_password) - 1;
+ s->out.data = smtp_password;
+ s->mail_state = ngx_smtp_auth_login_password;
+
+ return ngx_mail_auth_login_username(s, c, 1);
+
case NGX_MAIL_AUTH_PLAIN:
s->out.len = sizeof(smtp_next) - 1;