]> git.kaiwu.me - nginx.git/commitdiff
Merge of r4813, r4814, r4818, r4819, r4820, r4823: mail fixes.
authorMaxim Dounin <mdounin@mdounin.ru>
Mon, 24 Sep 2012 18:58:13 +0000 (18:58 +0000)
committerMaxim Dounin <mdounin@mdounin.ru>
Mon, 24 Sep 2012 18:58:13 +0000 (18:58 +0000)
*) Corrected the directive name in the ngx_mail_auth_http_module
   error message.

*) Don't let the well-known port in the "listen" directive to
   override the already set "protocol".

*) Fixed sorting of listen addresses (ticket #187).  For http module
   this problem was already fixed in r4756.

*) Removed a stale "AF_INET only" comment.  IPv6 client connections
   in mail modules have been supported since r2856.

*) Fixed handling of AF_UNIX addresses in "listen".  This makes AF_UNIX
   addresses in mail officially supported.

*) Whitespace fix.

src/mail/ngx_mail.c
src/mail/ngx_mail_auth_http_module.c
src/mail/ngx_mail_core_module.c
src/mail/ngx_mail_handler.c

index 49ec2e05b4ddef76415b3e60f511338105493840..3812e15179e35d52f30c2ba360ba62508a79cfce 100644 (file)
@@ -263,6 +263,12 @@ ngx_mail_add_ports(ngx_conf_t *cf, ngx_array_t *ports,
         break;
 #endif
 
+#if (NGX_HAVE_UNIX_DOMAIN)
+    case AF_UNIX:
+        p = 0;
+        break;
+#endif
+
     default: /* AF_INET */
         sin = (struct sockaddr_in *) sa;
         p = sin->sin_port;
@@ -539,6 +545,11 @@ ngx_mail_cmp_conf_addrs(const void *one, const void *two)
         return 1;
     }
 
+    if (second->wildcard) {
+        /* a wildcard must be the last resort, shift it to the end */
+        return -1;
+    }
+
     if (first->bind && !second->bind) {
         /* shift explicit bind()ed addresses to the start */
         return -1;
index c23c4bad73d87c75999fb03fc7ca11fe507daf4c..d2bd4ad61a8a481b821287eed904adaaed212f64 100644 (file)
@@ -1332,7 +1332,7 @@ ngx_mail_auth_http_merge_conf(ngx_conf_t *cf, void *parent, void *child)
 
         if (conf->peer == NULL) {
             ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
-                          "no \"http_auth\" is defined for server in %s:%ui",
+                          "no \"auth_http\" is defined for server in %s:%ui",
                           conf->file, conf->line);
 
             return NGX_CONF_ERROR;
index f79913b0a461bd1899477d25ddef4ff87529d056..6509b989b1cdddb69174d5bf35b67ceb9f3ba493 100644 (file)
@@ -340,6 +340,14 @@ ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
             break;
 #endif
 
+#if (NGX_HAVE_UNIX_DOMAIN)
+        case AF_UNIX:
+            off = offsetof(struct sockaddr_un, sun_path);
+            len = sizeof(((struct sockaddr_un *) sa)->sun_path);
+            port = 0;
+            break;
+#endif
+
         default: /* AF_INET */
             off = offsetof(struct sockaddr_in, sin_addr);
             len = 4;
@@ -374,21 +382,23 @@ ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
     ls->wildcard = u.wildcard;
     ls->ctx = cf->ctx;
 
-    for (m = 0; ngx_modules[m]; m++) {
-        if (ngx_modules[m]->type != NGX_MAIL_MODULE) {
-            continue;
-        }
+    if (cscf->protocol == NULL) {
+        for (m = 0; ngx_modules[m]; m++) {
+            if (ngx_modules[m]->type != NGX_MAIL_MODULE) {
+                continue;
+            }
 
-        module = ngx_modules[m]->ctx;
+            module = ngx_modules[m]->ctx;
 
-        if (module->protocol == NULL) {
-            continue;
-        }
+            if (module->protocol == NULL) {
+                continue;
+            }
 
-        for (i = 0; module->protocol->port[i]; i++) {
-            if (module->protocol->port[i] == u.port) {
-                cscf->protocol = module->protocol;
-                break;
+            for (i = 0; module->protocol->port[i]; i++) {
+                if (module->protocol->port[i] == u.port) {
+                    cscf->protocol = module->protocol;
+                    break;
+                }
             }
         }
     }
index a1c4464f7e56cb537efc5a9f9d4ed00036d5b3bd..ae955f9c6aea04cf64a72d4ea306af2ceb2b81d4 100644 (file)
@@ -38,8 +38,6 @@ ngx_mail_init_connection(ngx_connection_t *c)
 
     /* find the server configuration for the address:port */
 
-    /* AF_INET only */
-
     port = c->listening->servers;
 
     if (port->naddrs > 1) {