diff src/mail/ngx_mail_imap_handler.c @ 1485:b3488fc2675a

create salt just before it will be used
author Igor Sysoev <igor@sysoev.ru>
date Fri, 14 Sep 2007 15:00:19 +0000
parents 4606dce4f416
children 0e7074ef7303
line wrap: on
line diff
--- a/src/mail/ngx_mail_imap_handler.c
+++ b/src/mail/ngx_mail_imap_handler.c
@@ -38,13 +38,6 @@ ngx_mail_imap_init_session(ngx_mail_sess
 
     cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module);
 
-    if (cscf->imap_auth_methods & NGX_MAIL_AUTH_CRAM_MD5_ENABLED) {
-        if (ngx_mail_salt(s, c, cscf) != NGX_OK) {
-            ngx_mail_session_internal_server_error(s);
-            return;
-        }
-    }
-
     s->out.len = sizeof(imap_greeting) - 1;
     s->out.data = imap_greeting;
 
@@ -391,6 +384,12 @@ ngx_mail_imap_authenticate(ngx_mail_sess
             return NGX_MAIL_PARSE_INVALID_COMMAND;
         }
 
+        if (s->salt.data == NULL) {
+            if (ngx_mail_salt(s, c, cscf) != NGX_OK) {
+                return NGX_ERROR;
+            }
+        }
+
         if (ngx_mail_auth_cram_md5_salt(s, c, "+ ", 2) == NGX_OK) {
             s->mail_state = ngx_imap_auth_cram_md5;
             return NGX_OK;