Mercurial > hg > nginx-quic
comparison src/mail/ngx_mail_pop3_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_pop3_module.h> | |
11 | 12 |
12 | 13 |
13 static ngx_int_t ngx_mail_pop3_user(ngx_mail_session_t *s, ngx_connection_t *c); | 14 static ngx_int_t ngx_mail_pop3_user(ngx_mail_session_t *s, ngx_connection_t *c); |
14 static ngx_int_t ngx_mail_pop3_pass(ngx_mail_session_t *s, ngx_connection_t *c); | 15 static ngx_int_t ngx_mail_pop3_pass(ngx_mail_session_t *s, ngx_connection_t *c); |
15 static ngx_int_t ngx_mail_pop3_capa(ngx_mail_session_t *s, ngx_connection_t *c, | 16 static ngx_int_t ngx_mail_pop3_capa(ngx_mail_session_t *s, ngx_connection_t *c, |
30 void | 31 void |
31 ngx_mail_pop3_init_session(ngx_mail_session_t *s, ngx_connection_t *c) | 32 ngx_mail_pop3_init_session(ngx_mail_session_t *s, ngx_connection_t *c) |
32 { | 33 { |
33 u_char *p; | 34 u_char *p; |
34 ngx_mail_core_srv_conf_t *cscf; | 35 ngx_mail_core_srv_conf_t *cscf; |
35 | 36 ngx_mail_pop3_srv_conf_t *pscf; |
37 | |
38 pscf = ngx_mail_get_module_srv_conf(s, ngx_mail_pop3_module); | |
36 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); | 39 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); |
37 | 40 |
38 if (cscf->pop3_auth_methods | 41 if (pscf->auth_methods |
39 & (NGX_MAIL_AUTH_APOP_ENABLED|NGX_MAIL_AUTH_CRAM_MD5_ENABLED)) | 42 & (NGX_MAIL_AUTH_APOP_ENABLED|NGX_MAIL_AUTH_CRAM_MD5_ENABLED)) |
40 { | 43 { |
41 if (ngx_mail_salt(s, c, cscf) != NGX_OK) { | 44 if (ngx_mail_salt(s, c, cscf) != NGX_OK) { |
42 ngx_mail_session_internal_server_error(s); | 45 ngx_mail_session_internal_server_error(s); |
43 return; | 46 return; |
338 | 341 |
339 | 342 |
340 static ngx_int_t | 343 static ngx_int_t |
341 ngx_mail_pop3_capa(ngx_mail_session_t *s, ngx_connection_t *c, ngx_int_t stls) | 344 ngx_mail_pop3_capa(ngx_mail_session_t *s, ngx_connection_t *c, ngx_int_t stls) |
342 { | 345 { |
343 ngx_mail_core_srv_conf_t *cscf; | 346 ngx_mail_pop3_srv_conf_t *pscf; |
344 #if (NGX_MAIL_SSL) | 347 #if (NGX_MAIL_SSL) |
345 ngx_mail_ssl_conf_t *sslcf; | 348 ngx_mail_ssl_conf_t *sslcf; |
346 #endif | 349 #endif |
347 | 350 |
348 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); | 351 pscf = ngx_mail_get_module_srv_conf(s, ngx_mail_pop3_module); |
349 | 352 |
350 #if (NGX_MAIL_SSL) | 353 #if (NGX_MAIL_SSL) |
351 | 354 |
352 if (stls && c->ssl == NULL) { | 355 if (stls && c->ssl == NULL) { |
353 sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module); | 356 sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module); |
354 | 357 |
355 if (sslcf->starttls == NGX_MAIL_STARTTLS_ON) { | 358 if (sslcf->starttls == NGX_MAIL_STARTTLS_ON) { |
356 s->out = cscf->pop3_starttls_capability; | 359 s->out = pscf->starttls_capability; |
357 return NGX_OK; | 360 return NGX_OK; |
358 } | 361 } |
359 | 362 |
360 if (sslcf->starttls == NGX_MAIL_STARTTLS_ONLY) { | 363 if (sslcf->starttls == NGX_MAIL_STARTTLS_ONLY) { |
361 s->out = cscf->pop3_starttls_only_capability; | 364 s->out = pscf->starttls_only_capability; |
362 return NGX_OK; | 365 return NGX_OK; |
363 } | 366 } |
364 } | 367 } |
365 | 368 |
366 #endif | 369 #endif |
367 | 370 |
368 s->out = cscf->pop3_capability; | 371 s->out = pscf->capability; |
369 return NGX_OK; | 372 return NGX_OK; |
370 } | 373 } |
371 | 374 |
372 | 375 |
373 static ngx_int_t | 376 static ngx_int_t |
392 | 395 |
393 static ngx_int_t | 396 static ngx_int_t |
394 ngx_mail_pop3_apop(ngx_mail_session_t *s, ngx_connection_t *c) | 397 ngx_mail_pop3_apop(ngx_mail_session_t *s, ngx_connection_t *c) |
395 { | 398 { |
396 ngx_str_t *arg; | 399 ngx_str_t *arg; |
397 ngx_mail_core_srv_conf_t *cscf; | 400 ngx_mail_pop3_srv_conf_t *pscf; |
398 | 401 |
399 #if (NGX_MAIL_SSL) | 402 #if (NGX_MAIL_SSL) |
400 if (ngx_mail_starttls_only(s, c)) { | 403 if (ngx_mail_starttls_only(s, c)) { |
401 return NGX_MAIL_PARSE_INVALID_COMMAND; | 404 return NGX_MAIL_PARSE_INVALID_COMMAND; |
402 } | 405 } |
404 | 407 |
405 if (s->args.nelts != 2) { | 408 if (s->args.nelts != 2) { |
406 return NGX_MAIL_PARSE_INVALID_COMMAND; | 409 return NGX_MAIL_PARSE_INVALID_COMMAND; |
407 } | 410 } |
408 | 411 |
409 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); | 412 pscf = ngx_mail_get_module_srv_conf(s, ngx_mail_pop3_module); |
410 | 413 |
411 if (!(cscf->pop3_auth_methods & NGX_MAIL_AUTH_APOP_ENABLED)) { | 414 if (!(pscf->auth_methods & NGX_MAIL_AUTH_APOP_ENABLED)) { |
412 return NGX_MAIL_PARSE_INVALID_COMMAND; | 415 return NGX_MAIL_PARSE_INVALID_COMMAND; |
413 } | 416 } |
414 | 417 |
415 arg = s->args.elts; | 418 arg = s->args.elts; |
416 | 419 |
441 | 444 |
442 static ngx_int_t | 445 static ngx_int_t |
443 ngx_mail_pop3_auth(ngx_mail_session_t *s, ngx_connection_t *c) | 446 ngx_mail_pop3_auth(ngx_mail_session_t *s, ngx_connection_t *c) |
444 { | 447 { |
445 ngx_int_t rc; | 448 ngx_int_t rc; |
446 ngx_mail_core_srv_conf_t *cscf; | 449 ngx_mail_pop3_srv_conf_t *pscf; |
447 | 450 |
448 #if (NGX_MAIL_SSL) | 451 #if (NGX_MAIL_SSL) |
449 if (ngx_mail_starttls_only(s, c)) { | 452 if (ngx_mail_starttls_only(s, c)) { |
450 return NGX_MAIL_PARSE_INVALID_COMMAND; | 453 return NGX_MAIL_PARSE_INVALID_COMMAND; |
451 } | 454 } |
452 #endif | 455 #endif |
453 | 456 |
454 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); | 457 pscf = ngx_mail_get_module_srv_conf(s, ngx_mail_pop3_module); |
455 | 458 |
456 if (s->args.nelts == 0) { | 459 if (s->args.nelts == 0) { |
457 s->out = cscf->pop3_auth_capability; | 460 s->out = pscf->auth_capability; |
458 s->state = 0; | 461 s->state = 0; |
459 | 462 |
460 return NGX_OK; | 463 return NGX_OK; |
461 } | 464 } |
462 | 465 |
480 | 483 |
481 return NGX_OK; | 484 return NGX_OK; |
482 | 485 |
483 case NGX_MAIL_AUTH_CRAM_MD5: | 486 case NGX_MAIL_AUTH_CRAM_MD5: |
484 | 487 |
485 if (!(cscf->pop3_auth_methods & NGX_MAIL_AUTH_CRAM_MD5_ENABLED)) { | 488 if (!(pscf->auth_methods & NGX_MAIL_AUTH_CRAM_MD5_ENABLED)) { |
486 return NGX_MAIL_PARSE_INVALID_COMMAND; | 489 return NGX_MAIL_PARSE_INVALID_COMMAND; |
487 } | 490 } |
488 | 491 |
489 if (ngx_mail_auth_cram_md5_salt(s, c, "+ ", 2) == NGX_OK) { | 492 if (ngx_mail_auth_cram_md5_salt(s, c, "+ ", 2) == NGX_OK) { |
490 s->mail_state = ngx_pop3_auth_cram_md5; | 493 s->mail_state = ngx_pop3_auth_cram_md5; |