Mercurial > hg > nginx-mail
comparison src/http/modules/ngx_http_userid_filter_module.c @ 260:0effe91f6083 NGINX_0_5_0
nginx 0.5.0
*) Change: the parameters in the "%name" form in the "log_format"
directive are not supported anymore.
*) Change: the "proxy_upstream_max_fails",
"proxy_upstream_fail_timeout", "fastcgi_upstream_max_fails",
"fastcgi_upstream_fail_timeout", "memcached_upstream_max_fails", and
"memcached_upstream_fail_timeout" directives are not supported
anymore.
*) Feature: the "server" directive in the "upstream" context supports
the "max_fails", "fail_timeout", and "down" parameters.
*) Feature: the "ip_hash" directive inside the "upstream" block.
*) Feature: the WAIT status in the "Auth-Status" header line of the
IMAP/POP3 proxy authentication server response.
*) Bugfix: nginx could not be built on 64-bit platforms; bug appeared
in 0.4.14.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 04 Dec 2006 00:00:00 +0300 |
parents | fbf2b2f66c9f |
children | 10cc350ed8a1 |
comparison
equal
deleted
inserted
replaced
259:c68f18041059 | 260:0effe91f6083 |
---|---|
43 | 43 |
44 static void ngx_http_userid_get_uid(ngx_http_request_t *r, | 44 static void ngx_http_userid_get_uid(ngx_http_request_t *r, |
45 ngx_http_userid_ctx_t *ctx, ngx_http_userid_conf_t *conf); | 45 ngx_http_userid_ctx_t *ctx, ngx_http_userid_conf_t *conf); |
46 static ngx_int_t ngx_http_userid_set_uid(ngx_http_request_t *r, | 46 static ngx_int_t ngx_http_userid_set_uid(ngx_http_request_t *r, |
47 ngx_http_userid_ctx_t *ctx, ngx_http_userid_conf_t *conf); | 47 ngx_http_userid_ctx_t *ctx, ngx_http_userid_conf_t *conf); |
48 | |
49 static size_t ngx_http_userid_log_uid_got_getlen(ngx_http_request_t *r, | |
50 uintptr_t data); | |
51 static u_char *ngx_http_userid_log_uid_got(ngx_http_request_t *r, u_char *buf, | |
52 ngx_http_log_op_t *op); | |
53 static size_t ngx_http_userid_log_uid_set_getlen(ngx_http_request_t *r, | |
54 uintptr_t data); | |
55 static u_char *ngx_http_userid_log_uid_set(ngx_http_request_t *r, u_char *buf, | |
56 ngx_http_log_op_t *op); | |
57 | 48 |
58 static ngx_int_t ngx_http_userid_add_variables(ngx_conf_t *cf); | 49 static ngx_int_t ngx_http_userid_add_variables(ngx_conf_t *cf); |
59 static ngx_int_t ngx_http_userid_variable(ngx_http_request_t *r, | 50 static ngx_int_t ngx_http_userid_variable(ngx_http_request_t *r, |
60 ngx_http_variable_value_t *v, uintptr_t data); | 51 ngx_http_variable_value_t *v, uintptr_t data); |
61 | 52 |
189 NULL, /* exit master */ | 180 NULL, /* exit master */ |
190 NGX_MODULE_V1_PADDING | 181 NGX_MODULE_V1_PADDING |
191 }; | 182 }; |
192 | 183 |
193 | 184 |
194 static ngx_http_log_op_name_t ngx_http_userid_log_fmt_ops[] = { | |
195 { ngx_string("uid_got"), 0, NULL, | |
196 ngx_http_userid_log_uid_got_getlen, | |
197 ngx_http_userid_log_uid_got }, | |
198 { ngx_string("uid_set"), 0, NULL, | |
199 ngx_http_userid_log_uid_set_getlen, | |
200 ngx_http_userid_log_uid_set }, | |
201 { ngx_null_string, 0, NULL, NULL, NULL } | |
202 }; | |
203 | |
204 | |
205 static ngx_str_t ngx_http_userid_got = ngx_string("uid_got"); | 185 static ngx_str_t ngx_http_userid_got = ngx_string("uid_got"); |
206 static ngx_str_t ngx_http_userid_set = ngx_string("uid_set"); | 186 static ngx_str_t ngx_http_userid_set = ngx_string("uid_set"); |
207 | 187 |
208 | 188 |
209 static ngx_int_t | 189 static ngx_int_t |
460 | 440 |
461 return NGX_OK; | 441 return NGX_OK; |
462 } | 442 } |
463 | 443 |
464 | 444 |
465 static size_t | |
466 ngx_http_userid_log_uid_got_getlen(ngx_http_request_t *r, uintptr_t data) | |
467 { | |
468 ngx_http_userid_ctx_t *ctx; | |
469 ngx_http_userid_conf_t *conf; | |
470 | |
471 ctx = ngx_http_get_module_ctx(r, ngx_http_userid_filter_module); | |
472 | |
473 if (ctx == NULL || ctx->uid_got[3] == 0) { | |
474 return 1; | |
475 } | |
476 | |
477 conf = ngx_http_get_module_loc_conf(r, ngx_http_userid_filter_module); | |
478 | |
479 return conf->name.len + 1 + 32; | |
480 } | |
481 | |
482 | |
483 static u_char * | |
484 ngx_http_userid_log_uid_got(ngx_http_request_t *r, u_char *buf, | |
485 ngx_http_log_op_t *op) | |
486 { | |
487 ngx_http_userid_ctx_t *ctx; | |
488 ngx_http_userid_conf_t *conf; | |
489 | |
490 ctx = ngx_http_get_module_ctx(r, ngx_http_userid_filter_module); | |
491 | |
492 if (ctx == NULL || ctx->uid_got[3] == 0) { | |
493 *buf = '-'; | |
494 return buf + 1; | |
495 } | |
496 | |
497 conf = ngx_http_get_module_loc_conf(r, ngx_http_userid_filter_module); | |
498 | |
499 buf = ngx_copy(buf, conf->name.data, conf->name.len); | |
500 | |
501 *buf++ = '='; | |
502 | |
503 return ngx_sprintf(buf, "%08XD%08XD%08XD%08XD", | |
504 ctx->uid_got[0], ctx->uid_got[1], | |
505 ctx->uid_got[2], ctx->uid_got[3]); | |
506 } | |
507 | |
508 | |
509 static size_t | |
510 ngx_http_userid_log_uid_set_getlen(ngx_http_request_t *r, uintptr_t data) | |
511 { | |
512 ngx_http_userid_ctx_t *ctx; | |
513 ngx_http_userid_conf_t *conf; | |
514 | |
515 ctx = ngx_http_get_module_ctx(r, ngx_http_userid_filter_module); | |
516 | |
517 if (ctx == NULL || ctx->uid_set[3] == 0) { | |
518 return 1; | |
519 } | |
520 | |
521 conf = ngx_http_get_module_loc_conf(r, ngx_http_userid_filter_module); | |
522 | |
523 return conf->name.len + 1 + 32; | |
524 } | |
525 | |
526 | |
527 static u_char * | |
528 ngx_http_userid_log_uid_set(ngx_http_request_t *r, u_char *buf, | |
529 ngx_http_log_op_t *op) | |
530 { | |
531 ngx_http_userid_ctx_t *ctx; | |
532 ngx_http_userid_conf_t *conf; | |
533 | |
534 ctx = ngx_http_get_module_ctx(r, ngx_http_userid_filter_module); | |
535 | |
536 if (ctx == NULL || ctx->uid_set[3] == 0) { | |
537 *buf = '-'; | |
538 return buf + 1; | |
539 } | |
540 | |
541 conf = ngx_http_get_module_loc_conf(r, ngx_http_userid_filter_module); | |
542 | |
543 buf = ngx_copy(buf, conf->name.data, conf->name.len); | |
544 | |
545 *buf++ = '='; | |
546 | |
547 return ngx_sprintf(buf, "%08XD%08XD%08XD%08XD", | |
548 ctx->uid_set[0], ctx->uid_set[1], | |
549 ctx->uid_set[2], ctx->uid_set[3]); | |
550 } | |
551 | |
552 | |
553 static ngx_int_t | 445 static ngx_int_t |
554 ngx_http_userid_add_variables(ngx_conf_t *cf) | 446 ngx_http_userid_add_variables(ngx_conf_t *cf) |
555 { | 447 { |
556 ngx_http_variable_t *var; | 448 ngx_http_variable_t *var; |
557 ngx_http_log_op_name_t *op; | |
558 | 449 |
559 var = ngx_http_add_variable(cf, &ngx_http_userid_got, NGX_HTTP_VAR_NOHASH); | 450 var = ngx_http_add_variable(cf, &ngx_http_userid_got, NGX_HTTP_VAR_NOHASH); |
560 if (var == NULL) { | 451 if (var == NULL) { |
561 return NGX_ERROR; | 452 return NGX_ERROR; |
562 } | 453 } |
569 return NGX_ERROR; | 460 return NGX_ERROR; |
570 } | 461 } |
571 | 462 |
572 var->get_handler = ngx_http_userid_variable; | 463 var->get_handler = ngx_http_userid_variable; |
573 var->data = offsetof(ngx_http_userid_ctx_t, uid_set); | 464 var->data = offsetof(ngx_http_userid_ctx_t, uid_set); |
574 | |
575 | |
576 for (op = ngx_http_userid_log_fmt_ops; op->name.len; op++) { /* void */ } | |
577 op->run = NULL; | |
578 | |
579 for (op = ngx_http_log_fmt_ops; op->run; op++) { | |
580 if (op->name.len == 0) { | |
581 op = (ngx_http_log_op_name_t *) op->run; | |
582 } | |
583 } | |
584 | |
585 op->run = (ngx_http_log_op_run_pt) ngx_http_userid_log_fmt_ops; | |
586 | 465 |
587 return NGX_OK; | 466 return NGX_OK; |
588 } | 467 } |
589 | 468 |
590 | 469 |