comparison src/imap/ngx_imap_auth_http_module.c @ 116:e38f51cd0905 NGINX_0_3_5

nginx 0.3.5 *) Bugfix: the segmentation fault may occurred if the IMAP/POP3 login was changed by authorization server; bug appeared in 0.2.2. *) Bugfix: the accept mutex did not work and all connections were handled by one process; bug appeared in 0.3.3. *) Bugfix: the timeout did not work if the "rtsig" method and the "timer_resolution" directive were used.
author Igor Sysoev <http://sysoev.ru>
date Fri, 21 Oct 2005 00:00:00 +0400
parents cf3d6edb3ad6
children d25a1d6034f1
comparison
equal deleted inserted replaced
115:45a230988aa5 116:e38f51cd0905
42 u_char *header_end; 42 u_char *header_end;
43 43
44 ngx_str_t addr; 44 ngx_str_t addr;
45 ngx_str_t port; 45 ngx_str_t port;
46 ngx_str_t err; 46 ngx_str_t err;
47 ngx_str_t errmsg;
47 48
48 time_t sleep; 49 time_t sleep;
49 50
50 ngx_pool_t *pool; 51 ngx_pool_t *pool;
51 }; 52 };
457 && ctx->header_start[1] == 'K') 458 && ctx->header_start[1] == 'K')
458 { 459 {
459 continue; 460 continue;
460 } 461 }
461 462
463 ctx->errmsg.len = len;
464 ctx->errmsg.data = ctx->header_start;
465
462 if (s->protocol == NGX_IMAP_POP3_PROTOCOL) { 466 if (s->protocol == NGX_IMAP_POP3_PROTOCOL) {
463 size = sizeof("-ERR") - 1 + len + sizeof(CRLF) - 1; 467 size = sizeof("-ERR") - 1 + len + sizeof(CRLF) - 1;
464 468
465 } else { 469 } else {
466 size = s->tag.len + sizeof("NO") - 1 + len 470 size = s->tag.len + sizeof("NO") - 1 + len
484 p = ngx_cpymem(p, s->tag.data, s->tag.len); 488 p = ngx_cpymem(p, s->tag.data, s->tag.len);
485 *p++ = 'N'; *p++ = 'O'; 489 *p++ = 'N'; *p++ = 'O';
486 } 490 }
487 491
488 *p++ = ' '; 492 *p++ = ' ';
493
489 p = ngx_cpymem(p, ctx->header_start, len); 494 p = ngx_cpymem(p, ctx->header_start, len);
490 *p++ = CR; *p++ = LF; 495 *p++ = CR; *p++ = LF;
491 496
492 ctx->err.len = p - ctx->err.data; 497 ctx->err.len = p - ctx->err.data;
493 498
517 if (len == sizeof("Auth-User") - 1 522 if (len == sizeof("Auth-User") - 1
518 && ngx_strncasecmp(ctx->header_name_start, "Auth-User", 523 && ngx_strncasecmp(ctx->header_name_start, "Auth-User",
519 sizeof("Auth-User") - 1) == 0) 524 sizeof("Auth-User") - 1) == 0)
520 { 525 {
521 s->login.len = ctx->header_end - ctx->header_start; 526 s->login.len = ctx->header_end - ctx->header_start;
522 s->login.data = ctx->header_start; 527
528 s->login.data = ngx_palloc(s->connection->pool, s->login.len);
529 if (s->login.data == NULL) {
530 ngx_close_connection(ctx->peer.connection);
531 ngx_destroy_pool(ctx->pool);
532 ngx_imap_session_internal_server_error(s);
533 return;
534 }
535
536 ngx_memcpy(s->login.data, ctx->header_start, s->login.len);
523 537
524 continue; 538 continue;
525 } 539 }
526 540
527 if (len == sizeof("Auth-Wait") - 1 541 if (len == sizeof("Auth-Wait") - 1
548 "auth http header done"); 562 "auth http header done");
549 563
550 ngx_close_connection(ctx->peer.connection); 564 ngx_close_connection(ctx->peer.connection);
551 565
552 if (ctx->err.len) { 566 if (ctx->err.len) {
567 ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
568 "client login failed: \"%V\"", &ctx->errmsg);
569
553 s->out = ctx->err; 570 s->out = ctx->err;
554 timer = ctx->sleep; 571 timer = ctx->sleep;
555 572
556 ngx_destroy_pool(ctx->pool); 573 ngx_destroy_pool(ctx->pool);
557
558 ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
559 "client login failed");
560 574
561 if (timer == 0) { 575 if (timer == 0) {
562 s->quit = 1; 576 s->quit = 1;
563 ngx_imap_send(s->connection->write); 577 ngx_imap_send(s->connection->write);
564 return; 578 return;