changeset 386:1878e9c00f22 NGINX_0_6_37

nginx 0.6.37 *) Feature: Microsoft specific "AUTH LOGIN with User Name" mode support in mail proxy server. Thanks to Maxim Dounin. *) Bugfix: nginx could not be built on platforms different from i386, amd64, sparc, and ppc; the bug had appeared in 0.6.36.
author Igor Sysoev <http://sysoev.ru>
date Mon, 18 May 2009 00:00:00 +0400
parents 842321c9fc84
children 837f381d298f
files CHANGES CHANGES.ru auto/options configure src/core/nginx.c src/core/nginx.h src/core/ngx_cpuinfo.c src/core/ngx_log.c src/core/ngx_log.h src/http/modules/ngx_http_proxy_module.c src/http/modules/perl/nginx.pm src/http/ngx_http_core_module.c src/http/ngx_http_postpone_filter_module.c src/mail/ngx_mail.h src/mail/ngx_mail_auth_http_module.c src/mail/ngx_mail_handler.c src/mail/ngx_mail_imap_handler.c src/mail/ngx_mail_parse.c src/mail/ngx_mail_pop3_handler.c src/mail/ngx_mail_smtp_handler.c
diffstat 20 files changed, 102 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES	Thu Apr 02 00:00:00 2009 +0400
+++ b/CHANGES	Mon May 18 00:00:00 2009 +0400
@@ -1,4 +1,14 @@
 
+Changes with nginx 0.6.37                                        18 May 2009
+
+    *) Feature: Microsoft specific "AUTH LOGIN with User Name" mode support 
+       in mail proxy server.
+       Thanks to Maxim Dounin.
+
+    *) Bugfix: nginx could not be built on platforms different from i386, 
+       amd64, sparc, and ppc; the bug had appeared in 0.6.36.
+
+
 Changes with nginx 0.6.36                                        02 Apr 2009
 
     *) Change: now the "Invalid argument" error returned by 
--- a/CHANGES.ru	Thu Apr 02 00:00:00 2009 +0400
+++ b/CHANGES.ru	Mon May 18 00:00:00 2009 +0400
@@ -1,4 +1,14 @@
 
+Изменения в nginx 0.6.37                                          18.05.2009
+
+    *) Добавление: поддержка Microsoft-специфичного режима 
+       "AUTH LOGIN with User Name" в почтовом прокси-сервере.
+       Спасибо Максиму Дунину.
+
+    *) Исправление: nginx не собирался на платформах, отличных от i386, 
+       amd64, sparc и ppc; ошибка появилась в 0.6.36.
+
+
 Изменения в nginx 0.6.36                                          02.04.2009
 
     *) Изменение: ошибка "Invalid argument", возвращаемая 
--- a/auto/options	Thu Apr 02 00:00:00 2009 +0400
+++ b/auto/options	Mon May 18 00:00:00 2009 +0400
@@ -119,9 +119,12 @@
 
 NGX_CPU_CACHE_LINE=
 
+opt=
 
 for option
 do
+    opt="$opt `echo $option | sed -e \"s/\(--[^=]*=\)\(.* .*\)/\1'\2'/\"`"
+
     case "$option" in
         -*=*) value=`echo "$option" | sed -e 's/[-_a-zA-Z0-9]*=//'` ;;
            *) value="" ;;
@@ -248,6 +251,9 @@
 done
 
 
+NGX_CONFIGURE="$opt"
+
+
 if [ $help = yes ]; then
 
 cat << END
--- a/configure	Thu Apr 02 00:00:00 2009 +0400
+++ b/configure	Mon May 18 00:00:00 2009 +0400
@@ -3,8 +3,6 @@
 # Copyright (C) Igor Sysoev
 
 
-NGX_CONFIGURE=`echo $@ | sed 's/"/\\\\"/g'`
-
 . auto/options
 . auto/init
 . auto/sources
--- a/src/core/nginx.c	Thu Apr 02 00:00:00 2009 +0400
+++ b/src/core/nginx.c	Mon May 18 00:00:00 2009 +0400
@@ -261,8 +261,8 @@
             }
 #endif
 
-            p = "configure arguments: " NGX_CONFIGURE CRLF;
-            n = sizeof("configure arguments :" NGX_CONFIGURE CRLF) - 1;
+            p = "configure arguments:" NGX_CONFIGURE CRLF;
+            n = sizeof("configure arguments:" NGX_CONFIGURE CRLF) - 1;
 
             if (ngx_write_fd(ngx_stderr_fileno, p, n) != n) {
                 return 1;
--- a/src/core/nginx.h	Thu Apr 02 00:00:00 2009 +0400
+++ b/src/core/nginx.h	Mon May 18 00:00:00 2009 +0400
@@ -8,8 +8,8 @@
 #define _NGINX_H_INCLUDED_
 
 
-#define nginx_version       006036
-#define NGINX_VERSION      "0.6.36"
+#define nginx_version       006037
+#define NGINX_VERSION      "0.6.37"
 #define NGINX_VER          "nginx/" NGINX_VERSION
 
 #define NGINX_VAR          "NGINX"
--- a/src/core/ngx_cpuinfo.c	Thu Apr 02 00:00:00 2009 +0400
+++ b/src/core/ngx_cpuinfo.c	Mon May 18 00:00:00 2009 +0400
@@ -72,7 +72,7 @@
 ngx_cpuinfo(void)
 {
     u_char    *vendor;
-    uint32_t   vbuf[5], cpu[4];
+    uint32_t   vbuf[5], cpu[4], model;
 
     vbuf[0] = 0;
     vbuf[1] = 0;
@@ -103,8 +103,10 @@
         case 6:
             ngx_cacheline_size = 32;
 
-            if ((cpu[0] & 0xf0) >= 0xd0) {
-                /* Intel Core */
+            model = ((cpu[0] & 0xf0000) >> 8) | (cpu[0] & 0xf0);
+
+            if (model >= 0xd0) {
+                /* Intel Core, Core 2, Atom */
                 ngx_cacheline_size = 64;
             }
 
--- a/src/core/ngx_log.c	Thu Apr 02 00:00:00 2009 +0400
+++ b/src/core/ngx_log.c	Mon May 18 00:00:00 2009 +0400
@@ -184,9 +184,9 @@
 
 
 void
-ngx_log_abort(ngx_err_t err, const char *text)
+ngx_log_abort(ngx_err_t err, const char *text, void *param)
 {
-    ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, err, text);
+    ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, err, text, param);
 }
 
 
--- a/src/core/ngx_log.h	Thu Apr 02 00:00:00 2009 +0400
+++ b/src/core/ngx_log.h	Mon May 18 00:00:00 2009 +0400
@@ -198,7 +198,7 @@
 ngx_log_t *ngx_log_init(void);
 ngx_log_t *ngx_log_create_errlog(ngx_cycle_t *cycle, ngx_array_t *args);
 char *ngx_set_error_log_levels(ngx_conf_t *cf, ngx_log_t *log);
-void ngx_log_abort(ngx_err_t err, const char *text);
+void ngx_log_abort(ngx_err_t err, const char *text, void *param);
 
 
 extern ngx_module_t  ngx_errlog_module;
--- a/src/http/modules/ngx_http_proxy_module.c	Thu Apr 02 00:00:00 2009 +0400
+++ b/src/http/modules/ngx_http_proxy_module.c	Mon May 18 00:00:00 2009 +0400
@@ -1899,6 +1899,12 @@
         conf->proxy_values = prev->proxy_values;
     }
 
+#if (NGX_HTTP_SSL)
+    if (conf->upstream.ssl == NULL) {
+        conf->upstream.ssl = prev->upstream.ssl;
+    }
+#endif
+
     ngx_conf_merge_uint_value(conf->headers_hash_max_size,
                               prev->headers_hash_max_size, 512);
 
--- a/src/http/modules/perl/nginx.pm	Thu Apr 02 00:00:00 2009 +0400
+++ b/src/http/modules/perl/nginx.pm	Mon May 18 00:00:00 2009 +0400
@@ -47,7 +47,7 @@
     HTTP_INSUFFICIENT_STORAGE
 );
 
-our $VERSION = '0.6.36';
+our $VERSION = '0.6.37';
 
 require XSLoader;
 XSLoader::load('nginx', $VERSION);
--- a/src/http/ngx_http_core_module.c	Thu Apr 02 00:00:00 2009 +0400
+++ b/src/http/ngx_http_core_module.c	Mon May 18 00:00:00 2009 +0400
@@ -1557,16 +1557,24 @@
 ngx_int_t
 ngx_http_output_filter(ngx_http_request_t *r, ngx_chain_t *in)
 {
-    ngx_int_t  rc;
-
-    ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+    ngx_int_t          rc;
+    ngx_connection_t  *c;
+
+    c = r->connection;
+
+    ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
                    "http output filter \"%V?%V\"", &r->uri, &r->args);
 
     rc = ngx_http_top_body_filter(r, in);
 
     if (rc == NGX_ERROR) {
+
+        if (c->destroyed) {
+            return NGX_DONE;
+        }
+
         /* NGX_ERROR may be returned by any filter */
-        r->connection->error = 1;
+        c->error = 1;
     }
 
     return rc;
--- a/src/http/ngx_http_postpone_filter_module.c	Thu Apr 02 00:00:00 2009 +0400
+++ b/src/http/ngx_http_postpone_filter_module.c	Mon May 18 00:00:00 2009 +0400
@@ -216,7 +216,7 @@
         r->postponed = r->postponed->next;
     }
 
-    if (r->out) {
+    if (r != r->main && r->out) {
         ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                        "http postpone filter out again \"%V?%V\"",
                        &r->uri, &r->args);
--- a/src/mail/ngx_mail.h	Thu Apr 02 00:00:00 2009 +0400
+++ b/src/mail/ngx_mail.h	Mon May 18 00:00:00 2009 +0400
@@ -164,7 +164,7 @@
     unsigned                no_sync_literal:1;
     unsigned                starttls:1;
     unsigned                esmtp:1;
-    unsigned                auth_method:2;
+    unsigned                auth_method:3;
     unsigned                auth_wait:1;
 
     ngx_str_t               login;
@@ -243,10 +243,11 @@
 #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_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_PLAIN_ENABLED     0x0002
@@ -329,7 +330,7 @@
 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,
--- a/src/mail/ngx_mail_auth_http_module.c	Thu Apr 02 00:00:00 2009 +0400
+++ b/src/mail/ngx_mail_auth_http_module.c	Mon May 18 00:00:00 2009 +0400
@@ -140,6 +140,7 @@
 static ngx_str_t   ngx_mail_auth_http_method[] = {
     ngx_string("plain"),
     ngx_string("plain"),
+    ngx_string("plain"),
     ngx_string("apop"),
     ngx_string("cram-md5")
 };
--- a/src/mail/ngx_mail_handler.c	Thu Apr 02 00:00:00 2009 +0400
+++ b/src/mail/ngx_mail_handler.c	Mon May 18 00:00:00 2009 +0400
@@ -335,21 +335,22 @@
 
 
 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_palloc(c->pool, ngx_base64_decoded_length(arg[0].len));
+    s->login.data = ngx_palloc(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;
--- a/src/mail/ngx_mail_imap_handler.c	Thu Apr 02 00:00:00 2009 +0400
+++ b/src/mail/ngx_mail_imap_handler.c	Mon May 18 00:00:00 2009 +0400
@@ -205,7 +205,7 @@
             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 @@
 
         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;
--- a/src/mail/ngx_mail_parse.c	Thu Apr 02 00:00:00 2009 +0400
+++ b/src/mail/ngx_mail_parse.c	Mon May 18 00:00:00 2009 +0400
@@ -848,6 +848,10 @@
                 return NGX_MAIL_AUTH_LOGIN;
             }
 
+            if (s->args.nelts == 2) {
+                return NGX_MAIL_AUTH_LOGIN_USERNAME;
+            }
+
             return NGX_MAIL_PARSE_INVALID_COMMAND;
         }
 
--- a/src/mail/ngx_mail_pop3_handler.c	Thu Apr 02 00:00:00 2009 +0400
+++ b/src/mail/ngx_mail_pop3_handler.c	Mon May 18 00:00:00 2009 +0400
@@ -226,7 +226,7 @@
             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 @@
 
         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;
--- a/src/mail/ngx_mail_smtp_handler.c	Thu Apr 02 00:00:00 2009 +0400
+++ b/src/mail/ngx_mail_smtp_handler.c	Mon May 18 00:00:00 2009 +0400
@@ -452,7 +452,7 @@
             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;
@@ -596,6 +596,14 @@
 
         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;