comparison src/mail/ngx_mail_handler.c @ 410:cd9cb7a3ff9e

Merge with nginx 0.7.8.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 11 Aug 2008 22:07:06 +0400
parents 52b28d322d76 984bb0b1399b
children 03a69004d77d
comparison
equal deleted inserted replaced
409:52b28d322d76 410:cd9cb7a3ff9e
27 struct sockaddr_in sin; 27 struct sockaddr_in sin;
28 ngx_mail_log_ctx_t *ctx; 28 ngx_mail_log_ctx_t *ctx;
29 ngx_mail_in_port_t *imip; 29 ngx_mail_in_port_t *imip;
30 ngx_mail_in_addr_t *imia; 30 ngx_mail_in_addr_t *imia;
31 ngx_mail_session_t *s; 31 ngx_mail_session_t *s;
32 #if (NGX_MAIL_SSL)
33 ngx_mail_ssl_conf_t *sslcf;
34 #endif
35
36 32
37 /* find the server configuration for the address:port */ 33 /* find the server configuration for the address:port */
38 34
39 /* AF_INET only */ 35 /* AF_INET only */
40 36
114 c->log->action = "sending client greeting line"; 110 c->log->action = "sending client greeting line";
115 111
116 c->log_error = NGX_ERROR_INFO; 112 c->log_error = NGX_ERROR_INFO;
117 113
118 #if (NGX_MAIL_SSL) 114 #if (NGX_MAIL_SSL)
115 {
116 ngx_mail_ssl_conf_t *sslcf;
119 117
120 sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module); 118 sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module);
121 119
122 if (sslcf->enable) { 120 if (sslcf->enable) {
123 ngx_mail_ssl_init_connection(&sslcf->ssl, c); 121 ngx_mail_ssl_init_connection(&sslcf->ssl, c);
124 return; 122 return;
125 } 123 }
126 124 }
127 #endif 125 #endif
128 126
129 ngx_mail_init_session(c); 127 ngx_mail_init_session(c);
130 } 128 }
131 129
236 234
237 ngx_int_t 235 ngx_int_t
238 ngx_mail_salt(ngx_mail_session_t *s, ngx_connection_t *c, 236 ngx_mail_salt(ngx_mail_session_t *s, ngx_connection_t *c,
239 ngx_mail_core_srv_conf_t *cscf) 237 ngx_mail_core_srv_conf_t *cscf)
240 { 238 {
241 s->salt.data = ngx_palloc(c->pool, 239 s->salt.data = ngx_pnalloc(c->pool,
242 sizeof(" <18446744073709551616.@>" CRLF) - 1 240 sizeof(" <18446744073709551616.@>" CRLF) - 1
243 + NGX_TIME_T_LEN 241 + NGX_TIME_T_LEN
244 + cscf->server_name.len); 242 + cscf->server_name.len);
245 if (s->salt.data == NULL) { 243 if (s->salt.data == NULL) {
246 return NGX_ERROR; 244 return NGX_ERROR;
247 } 245 }
248 246
249 s->salt.len = ngx_sprintf(s->salt.data, "<%ul.%T@%V>" CRLF, 247 s->salt.len = ngx_sprintf(s->salt.data, "<%ul.%T@%V>" CRLF,
288 #if (NGX_DEBUG_MAIL_PASSWD) 286 #if (NGX_DEBUG_MAIL_PASSWD)
289 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, 287 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0,
290 "mail auth plain: \"%V\"", &arg[n]); 288 "mail auth plain: \"%V\"", &arg[n]);
291 #endif 289 #endif
292 290
293 plain.data = ngx_palloc(c->pool, ngx_base64_decoded_length(arg[n].len)); 291 plain.data = ngx_pnalloc(c->pool, ngx_base64_decoded_length(arg[n].len));
294 if (plain.data == NULL){ 292 if (plain.data == NULL){
295 return NGX_ERROR; 293 return NGX_ERROR;
296 } 294 }
297 295
298 if (ngx_decode_base64(&plain, &arg[n]) != NGX_OK) { 296 if (ngx_decode_base64(&plain, &arg[n]) != NGX_OK) {
344 arg = s->args.elts; 342 arg = s->args.elts;
345 343
346 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, 344 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0,
347 "mail auth login username: \"%V\"", &arg[0]); 345 "mail auth login username: \"%V\"", &arg[0]);
348 346
349 s->login.data = ngx_palloc(c->pool, ngx_base64_decoded_length(arg[0].len)); 347 s->login.data = ngx_pnalloc(c->pool, ngx_base64_decoded_length(arg[0].len));
350 if (s->login.data == NULL){ 348 if (s->login.data == NULL){
351 return NGX_ERROR; 349 return NGX_ERROR;
352 } 350 }
353 351
354 if (ngx_decode_base64(&s->login, &arg[0]) != NGX_OK) { 352 if (ngx_decode_base64(&s->login, &arg[0]) != NGX_OK) {
374 #if (NGX_DEBUG_MAIL_PASSWD) 372 #if (NGX_DEBUG_MAIL_PASSWD)
375 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, 373 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0,
376 "mail auth login password: \"%V\"", &arg[0]); 374 "mail auth login password: \"%V\"", &arg[0]);
377 #endif 375 #endif
378 376
379 s->passwd.data = ngx_palloc(c->pool, ngx_base64_decoded_length(arg[0].len)); 377 s->passwd.data = ngx_pnalloc(c->pool,
378 ngx_base64_decoded_length(arg[0].len));
380 if (s->passwd.data == NULL){ 379 if (s->passwd.data == NULL){
381 return NGX_ERROR; 380 return NGX_ERROR;
382 } 381 }
383 382
384 if (ngx_decode_base64(&s->passwd, &arg[0]) != NGX_OK) { 383 if (ngx_decode_base64(&s->passwd, &arg[0]) != NGX_OK) {
402 { 401 {
403 u_char *p; 402 u_char *p;
404 ngx_str_t salt; 403 ngx_str_t salt;
405 ngx_uint_t n; 404 ngx_uint_t n;
406 405
407 p = ngx_palloc(c->pool, len + ngx_base64_encoded_length(s->salt.len) + 2); 406 p = ngx_pnalloc(c->pool, len + ngx_base64_encoded_length(s->salt.len) + 2);
408 if (p == NULL) { 407 if (p == NULL) {
409 return NGX_ERROR; 408 return NGX_ERROR;
410 } 409 }
411 410
412 salt.data = ngx_cpymem(p, prefix, len); 411 salt.data = ngx_cpymem(p, prefix, len);
434 arg = s->args.elts; 433 arg = s->args.elts;
435 434
436 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, 435 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0,
437 "mail auth cram-md5: \"%V\"", &arg[0]); 436 "mail auth cram-md5: \"%V\"", &arg[0]);
438 437
439 s->login.data = ngx_palloc(c->pool, ngx_base64_decoded_length(arg[0].len)); 438 s->login.data = ngx_pnalloc(c->pool, ngx_base64_decoded_length(arg[0].len));
440 if (s->login.data == NULL){ 439 if (s->login.data == NULL){
441 return NGX_ERROR; 440 return NGX_ERROR;
442 } 441 }
443 442
444 if (ngx_decode_base64(&s->login, &arg[0]) != NGX_OK) { 443 if (ngx_decode_base64(&s->login, &arg[0]) != NGX_OK) {