Mercurial > hg > nginx
comparison src/mail/ngx_mail_imap_handler.c @ 1487:f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sat, 15 Sep 2007 16:51:16 +0000 |
parents | 0e7074ef7303 |
children | e584e946e198 |
comparison
equal
deleted
inserted
replaced
1486:0e7074ef7303 | 1487:f69493e8faab |
---|---|
6 | 6 |
7 #include <ngx_config.h> | 7 #include <ngx_config.h> |
8 #include <ngx_core.h> | 8 #include <ngx_core.h> |
9 #include <ngx_event.h> | 9 #include <ngx_event.h> |
10 #include <ngx_mail.h> | 10 #include <ngx_mail.h> |
11 #include <ngx_mail_imap_module.h> | |
11 | 12 |
12 | 13 |
13 static ngx_int_t ngx_mail_imap_login(ngx_mail_session_t *s, | 14 static ngx_int_t ngx_mail_imap_login(ngx_mail_session_t *s, |
14 ngx_connection_t *c); | 15 ngx_connection_t *c); |
15 static ngx_int_t ngx_mail_imap_authenticate(ngx_mail_session_t *s, | 16 static ngx_int_t ngx_mail_imap_authenticate(ngx_mail_session_t *s, |
56 void | 57 void |
57 ngx_mail_imap_init_protocol(ngx_event_t *rev) | 58 ngx_mail_imap_init_protocol(ngx_event_t *rev) |
58 { | 59 { |
59 ngx_connection_t *c; | 60 ngx_connection_t *c; |
60 ngx_mail_session_t *s; | 61 ngx_mail_session_t *s; |
61 ngx_mail_core_srv_conf_t *cscf; | 62 ngx_mail_imap_srv_conf_t *iscf; |
62 | 63 |
63 c = rev->data; | 64 c = rev->data; |
64 | 65 |
65 c->log->action = "in auth state"; | 66 c->log->action = "in auth state"; |
66 | 67 |
79 { | 80 { |
80 ngx_mail_session_internal_server_error(s); | 81 ngx_mail_session_internal_server_error(s); |
81 return; | 82 return; |
82 } | 83 } |
83 | 84 |
84 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); | 85 iscf = ngx_mail_get_module_srv_conf(s, ngx_mail_imap_module); |
85 | 86 |
86 s->buffer = ngx_create_temp_buf(c->pool, cscf->imap_client_buffer_size); | 87 s->buffer = ngx_create_temp_buf(c->pool, iscf->client_buffer_size); |
87 if (s->buffer == NULL) { | 88 if (s->buffer == NULL) { |
88 ngx_mail_session_internal_server_error(s); | 89 ngx_mail_session_internal_server_error(s); |
89 return; | 90 return; |
90 } | 91 } |
91 } | 92 } |
347 static ngx_int_t | 348 static ngx_int_t |
348 ngx_mail_imap_authenticate(ngx_mail_session_t *s, ngx_connection_t *c) | 349 ngx_mail_imap_authenticate(ngx_mail_session_t *s, ngx_connection_t *c) |
349 { | 350 { |
350 ngx_int_t rc; | 351 ngx_int_t rc; |
351 ngx_mail_core_srv_conf_t *cscf; | 352 ngx_mail_core_srv_conf_t *cscf; |
353 ngx_mail_imap_srv_conf_t *iscf; | |
352 | 354 |
353 #if (NGX_MAIL_SSL) | 355 #if (NGX_MAIL_SSL) |
354 if (ngx_mail_starttls_only(s, c)) { | 356 if (ngx_mail_starttls_only(s, c)) { |
355 return NGX_MAIL_PARSE_INVALID_COMMAND; | 357 return NGX_MAIL_PARSE_INVALID_COMMAND; |
356 } | 358 } |
376 | 378 |
377 return NGX_OK; | 379 return NGX_OK; |
378 | 380 |
379 case NGX_MAIL_AUTH_CRAM_MD5: | 381 case NGX_MAIL_AUTH_CRAM_MD5: |
380 | 382 |
381 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); | 383 iscf = ngx_mail_get_module_srv_conf(s, ngx_mail_imap_module); |
382 | 384 |
383 if (!(cscf->imap_auth_methods & NGX_MAIL_AUTH_CRAM_MD5_ENABLED)) { | 385 if (!(iscf->auth_methods & NGX_MAIL_AUTH_CRAM_MD5_ENABLED)) { |
384 return NGX_MAIL_PARSE_INVALID_COMMAND; | 386 return NGX_MAIL_PARSE_INVALID_COMMAND; |
385 } | 387 } |
386 | 388 |
387 if (s->salt.data == NULL) { | 389 if (s->salt.data == NULL) { |
390 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); | |
391 | |
388 if (ngx_mail_salt(s, c, cscf) != NGX_OK) { | 392 if (ngx_mail_salt(s, c, cscf) != NGX_OK) { |
389 return NGX_ERROR; | 393 return NGX_ERROR; |
390 } | 394 } |
391 } | 395 } |
392 | 396 |
403 | 407 |
404 | 408 |
405 static ngx_int_t | 409 static ngx_int_t |
406 ngx_mail_imap_capability(ngx_mail_session_t *s, ngx_connection_t *c) | 410 ngx_mail_imap_capability(ngx_mail_session_t *s, ngx_connection_t *c) |
407 { | 411 { |
408 ngx_mail_core_srv_conf_t *cscf; | 412 ngx_mail_imap_srv_conf_t *iscf; |
409 #if (NGX_MAIL_SSL) | 413 #if (NGX_MAIL_SSL) |
410 ngx_mail_ssl_conf_t *sslcf; | 414 ngx_mail_ssl_conf_t *sslcf; |
411 #endif | 415 #endif |
412 | 416 |
413 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); | 417 iscf = ngx_mail_get_module_srv_conf(s, ngx_mail_imap_module); |
414 | 418 |
415 #if (NGX_MAIL_SSL) | 419 #if (NGX_MAIL_SSL) |
416 | 420 |
417 if (c->ssl == NULL) { | 421 if (c->ssl == NULL) { |
418 sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module); | 422 sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module); |
419 | 423 |
420 if (sslcf->starttls == NGX_MAIL_STARTTLS_ON) { | 424 if (sslcf->starttls == NGX_MAIL_STARTTLS_ON) { |
421 s->text = cscf->imap_starttls_capability; | 425 s->text = iscf->starttls_capability; |
422 return NGX_OK; | 426 return NGX_OK; |
423 } | 427 } |
424 | 428 |
425 if (sslcf->starttls == NGX_MAIL_STARTTLS_ONLY) { | 429 if (sslcf->starttls == NGX_MAIL_STARTTLS_ONLY) { |
426 s->text = cscf->imap_starttls_only_capability; | 430 s->text = iscf->starttls_only_capability; |
427 return NGX_OK; | 431 return NGX_OK; |
428 } | 432 } |
429 } | 433 } |
430 #endif | 434 #endif |
431 | 435 |
432 s->text = cscf->imap_capability; | 436 s->text = iscf->capability; |
433 | 437 |
434 return NGX_OK; | 438 return NGX_OK; |
435 } | 439 } |
436 | 440 |
437 | 441 |