Mercurial > hg > nginx-quic
annotate src/http/modules/ngx_http_userid_filter_module.c @ 5503:d049b0ea00a3
SSL: ssl_session_tickets directive.
This adds support so it's possible to explicitly disable SSL Session
Tickets. In order to have good Forward Secrecy support either the
session ticket key has to be reloaded by using nginx' binary upgrade
process or using an external key file and reloading the configuration.
This directive adds another possibility to have good support by
disabling session tickets altogether.
If session tickets are enabled and the process lives for a long a time,
an attacker can grab the session ticket from the process and use that to
decrypt any traffic that occured during the entire lifetime of the
process.
author | Dirkjan Bussink <d.bussink@gmail.com> |
---|---|
date | Fri, 10 Jan 2014 16:12:40 +0100 |
parents | 778ef9c3fd2d |
children | b3682580c1bd |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
417
diff
changeset
|
6 |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_core.h> |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 #include <ngx_http.h> |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
13 #define NGX_HTTP_USERID_OFF 0 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
14 #define NGX_HTTP_USERID_LOG 1 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
15 #define NGX_HTTP_USERID_V1 2 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
16 #define NGX_HTTP_USERID_ON 3 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
17 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
18 /* 31 Dec 2037 23:55:55 GMT */ |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
19 #define NGX_HTTP_USERID_MAX_EXPIRES 2145916555 |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
20 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
21 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
22 typedef struct { |
509 | 23 ngx_uint_t enable; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
24 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
25 ngx_int_t service; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
26 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
27 ngx_str_t name; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
28 ngx_str_t domain; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
29 ngx_str_t path; |
539 | 30 ngx_str_t p3p; |
31 | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
32 time_t expires; |
539 | 33 |
34 u_char mark; | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
35 } ngx_http_userid_conf_t; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
36 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
37 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
38 typedef struct { |
461 | 39 uint32_t uid_got[4]; |
40 uint32_t uid_set[4]; | |
539 | 41 ngx_str_t cookie; |
3943 | 42 ngx_uint_t reset; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
43 } ngx_http_userid_ctx_t; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
44 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
45 |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
46 static ngx_http_userid_ctx_t *ngx_http_userid_get_uid(ngx_http_request_t *r, |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
47 ngx_http_userid_conf_t *conf); |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
48 static ngx_int_t ngx_http_userid_variable(ngx_http_request_t *r, |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
49 ngx_http_variable_value_t *v, ngx_str_t *name, uint32_t *uid); |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
50 static ngx_int_t ngx_http_userid_set_uid(ngx_http_request_t *r, |
499 | 51 ngx_http_userid_ctx_t *ctx, ngx_http_userid_conf_t *conf); |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
52 static ngx_int_t ngx_http_userid_create_uid(ngx_http_request_t *r, |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
53 ngx_http_userid_ctx_t *ctx, ngx_http_userid_conf_t *conf); |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
54 |
573 | 55 static ngx_int_t ngx_http_userid_add_variables(ngx_conf_t *cf); |
681 | 56 static ngx_int_t ngx_http_userid_init(ngx_conf_t *cf); |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
57 static void *ngx_http_userid_create_conf(ngx_conf_t *cf); |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
58 static char *ngx_http_userid_merge_conf(ngx_conf_t *cf, void *parent, |
499 | 59 void *child); |
60 static char *ngx_http_userid_domain(ngx_conf_t *cf, void *post, void *data); | |
61 static char *ngx_http_userid_path(ngx_conf_t *cf, void *post, void *data); | |
62 static char *ngx_http_userid_expires(ngx_conf_t *cf, ngx_command_t *cmd, | |
63 void *conf); | |
64 static char *ngx_http_userid_p3p(ngx_conf_t *cf, void *post, void *data); | |
539 | 65 static char *ngx_http_userid_mark(ngx_conf_t *cf, ngx_command_t *cmd, |
66 void *conf); | |
1651
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
67 static ngx_int_t ngx_http_userid_init_worker(ngx_cycle_t *cycle); |
539 | 68 |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
69 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
70 |
1651
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
71 static uint32_t start_value; |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
72 static uint32_t sequencer_v1 = 1; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
73 static uint32_t sequencer_v2 = 0x03030302; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
74 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
75 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
76 static u_char expires[] = "; expires=Thu, 31-Dec-37 23:55:55 GMT"; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
77 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
78 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
79 static ngx_http_output_header_filter_pt ngx_http_next_header_filter; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
80 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
81 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
82 static ngx_conf_enum_t ngx_http_userid_state[] = { |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
83 { ngx_string("off"), NGX_HTTP_USERID_OFF }, |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
84 { ngx_string("log"), NGX_HTTP_USERID_LOG }, |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
85 { ngx_string("v1"), NGX_HTTP_USERID_V1 }, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
86 { ngx_string("on"), NGX_HTTP_USERID_ON }, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
87 { ngx_null_string, 0 } |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
88 }; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
89 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
90 |
461 | 91 static ngx_conf_post_handler_pt ngx_http_userid_domain_p = |
509 | 92 ngx_http_userid_domain; |
461 | 93 static ngx_conf_post_handler_pt ngx_http_userid_path_p = ngx_http_userid_path; |
94 static ngx_conf_post_handler_pt ngx_http_userid_p3p_p = ngx_http_userid_p3p; | |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
95 |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
96 |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
97 static ngx_command_t ngx_http_userid_commands[] = { |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
98 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
99 { ngx_string("userid"), |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
100 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
101 ngx_conf_set_enum_slot, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
102 NGX_HTTP_LOC_CONF_OFFSET, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
103 offsetof(ngx_http_userid_conf_t, enable), |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
104 ngx_http_userid_state }, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
105 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
106 { ngx_string("userid_service"), |
539 | 107 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
108 ngx_conf_set_num_slot, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
109 NGX_HTTP_LOC_CONF_OFFSET, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
110 offsetof(ngx_http_userid_conf_t, service), |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
111 NULL }, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
112 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
113 { ngx_string("userid_name"), |
539 | 114 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
115 ngx_conf_set_str_slot, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
116 NGX_HTTP_LOC_CONF_OFFSET, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
117 offsetof(ngx_http_userid_conf_t, name), |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
118 NULL }, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
119 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
120 { ngx_string("userid_domain"), |
539 | 121 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
122 ngx_conf_set_str_slot, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
123 NGX_HTTP_LOC_CONF_OFFSET, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
124 offsetof(ngx_http_userid_conf_t, domain), |
461 | 125 &ngx_http_userid_domain_p }, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
126 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
127 { ngx_string("userid_path"), |
539 | 128 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
129 ngx_conf_set_str_slot, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
130 NGX_HTTP_LOC_CONF_OFFSET, |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
131 offsetof(ngx_http_userid_conf_t, path), |
461 | 132 &ngx_http_userid_path_p }, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
133 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
134 { ngx_string("userid_expires"), |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
135 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
136 ngx_http_userid_expires, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
137 NGX_HTTP_LOC_CONF_OFFSET, |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
138 0, |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
139 NULL }, |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
140 |
461 | 141 { ngx_string("userid_p3p"), |
142 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
143 ngx_conf_set_str_slot, | |
144 NGX_HTTP_LOC_CONF_OFFSET, | |
145 offsetof(ngx_http_userid_conf_t, p3p), | |
146 &ngx_http_userid_p3p_p }, | |
147 | |
539 | 148 { ngx_string("userid_mark"), |
149 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
150 ngx_http_userid_mark, | |
151 NGX_HTTP_LOC_CONF_OFFSET, | |
152 0, | |
153 NULL }, | |
154 | |
499 | 155 ngx_null_command |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
156 }; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
157 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
158 |
667 | 159 static ngx_http_module_t ngx_http_userid_filter_module_ctx = { |
573 | 160 ngx_http_userid_add_variables, /* preconfiguration */ |
681 | 161 ngx_http_userid_init, /* postconfiguration */ |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
162 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
163 NULL, /* create main configuration */ |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
164 NULL, /* init main configuration */ |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
165 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
166 NULL, /* create server configuration */ |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
167 NULL, /* merge server configuration */ |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
168 |
4499
778ef9c3fd2d
Fixed spelling in single-line comments.
Ruslan Ermilov <ru@nginx.com>
parents:
4474
diff
changeset
|
169 ngx_http_userid_create_conf, /* create location configuration */ |
778ef9c3fd2d
Fixed spelling in single-line comments.
Ruslan Ermilov <ru@nginx.com>
parents:
4474
diff
changeset
|
170 ngx_http_userid_merge_conf /* merge location configuration */ |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
171 }; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
172 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
173 |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
174 ngx_module_t ngx_http_userid_filter_module = { |
509 | 175 NGX_MODULE_V1, |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
176 &ngx_http_userid_filter_module_ctx, /* module context */ |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
177 ngx_http_userid_commands, /* module directives */ |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
178 NGX_HTTP_MODULE, /* module type */ |
541 | 179 NULL, /* init master */ |
681 | 180 NULL, /* init module */ |
1651
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
181 ngx_http_userid_init_worker, /* init process */ |
541 | 182 NULL, /* init thread */ |
183 NULL, /* exit thread */ | |
184 NULL, /* exit process */ | |
185 NULL, /* exit master */ | |
186 NGX_MODULE_V1_PADDING | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
187 }; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
188 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
189 |
3943 | 190 static ngx_str_t ngx_http_userid_got = ngx_string("uid_got"); |
191 static ngx_str_t ngx_http_userid_set = ngx_string("uid_set"); | |
192 static ngx_str_t ngx_http_userid_reset = ngx_string("uid_reset"); | |
193 static ngx_uint_t ngx_http_userid_reset_index; | |
573 | 194 |
195 | |
499 | 196 static ngx_int_t |
197 ngx_http_userid_filter(ngx_http_request_t *r) | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
198 { |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
199 ngx_http_userid_ctx_t *ctx; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
200 ngx_http_userid_conf_t *conf; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
201 |
597 | 202 if (r != r->main) { |
509 | 203 return ngx_http_next_header_filter(r); |
204 } | |
205 | |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
206 conf = ngx_http_get_module_loc_conf(r, ngx_http_userid_filter_module); |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
207 |
3647 | 208 if (conf->enable < NGX_HTTP_USERID_V1) { |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
209 return ngx_http_next_header_filter(r); |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
210 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
211 |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
212 ctx = ngx_http_userid_get_uid(r, conf); |
499 | 213 |
214 if (ctx == NULL) { | |
215 return NGX_ERROR; | |
216 } | |
217 | |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
218 if (ngx_http_userid_set_uid(r, ctx, conf) == NGX_OK) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
219 return ngx_http_next_header_filter(r); |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
220 } |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
221 |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
222 return NGX_ERROR; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
223 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
224 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
225 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
226 static ngx_int_t |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
227 ngx_http_userid_got_variable(ngx_http_request_t *r, |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
228 ngx_http_variable_value_t *v, uintptr_t data) |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
229 { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
230 ngx_http_userid_ctx_t *ctx; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
231 ngx_http_userid_conf_t *conf; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
232 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
233 conf = ngx_http_get_module_loc_conf(r->main, ngx_http_userid_filter_module); |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
234 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
235 if (conf->enable == NGX_HTTP_USERID_OFF) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
236 v->not_found = 1; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
237 return NGX_OK; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
238 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
239 |
3659
7e69af2dd93c
set uid values for main request only
Igor Sysoev <igor@sysoev.ru>
parents:
3649
diff
changeset
|
240 ctx = ngx_http_userid_get_uid(r->main, conf); |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
241 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
242 if (ctx == NULL) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
243 return NGX_ERROR; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
244 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
245 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
246 if (ctx->uid_got[3] != 0) { |
3659
7e69af2dd93c
set uid values for main request only
Igor Sysoev <igor@sysoev.ru>
parents:
3649
diff
changeset
|
247 return ngx_http_userid_variable(r->main, v, &conf->name, ctx->uid_got); |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
248 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
249 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
250 v->not_found = 1; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
251 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
252 return NGX_OK; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
253 } |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
254 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
255 |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
256 static ngx_int_t |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
257 ngx_http_userid_set_variable(ngx_http_request_t *r, |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
258 ngx_http_variable_value_t *v, uintptr_t data) |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
259 { |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
260 ngx_http_userid_ctx_t *ctx; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
261 ngx_http_userid_conf_t *conf; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
262 |
3659
7e69af2dd93c
set uid values for main request only
Igor Sysoev <igor@sysoev.ru>
parents:
3649
diff
changeset
|
263 conf = ngx_http_get_module_loc_conf(r->main, ngx_http_userid_filter_module); |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
264 |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
265 if (conf->enable < NGX_HTTP_USERID_V1) { |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
266 v->not_found = 1; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
267 return NGX_OK; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
268 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
269 |
3659
7e69af2dd93c
set uid values for main request only
Igor Sysoev <igor@sysoev.ru>
parents:
3649
diff
changeset
|
270 ctx = ngx_http_userid_get_uid(r->main, conf); |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
271 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
272 if (ctx == NULL) { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
273 return NGX_ERROR; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
274 } |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
275 |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
276 if (ngx_http_userid_create_uid(r->main, ctx, conf) != NGX_OK) { |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
277 return NGX_ERROR; |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
278 } |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
279 |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
280 if (ctx->uid_set[3] == 0) { |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
281 v->not_found = 1; |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
282 return NGX_OK; |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
283 } |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
284 |
3659
7e69af2dd93c
set uid values for main request only
Igor Sysoev <igor@sysoev.ru>
parents:
3649
diff
changeset
|
285 return ngx_http_userid_variable(r->main, v, &conf->name, ctx->uid_set); |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
286 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
287 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
288 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
289 static ngx_http_userid_ctx_t * |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
290 ngx_http_userid_get_uid(ngx_http_request_t *r, ngx_http_userid_conf_t *conf) |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
291 { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
292 ngx_int_t n; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
293 ngx_str_t src, dst; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
294 ngx_table_elt_t **cookies; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
295 ngx_http_userid_ctx_t *ctx; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
296 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
297 ctx = ngx_http_get_module_ctx(r, ngx_http_userid_filter_module); |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
298 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
299 if (ctx) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
300 return ctx; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
301 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
302 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
303 if (ctx == NULL) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
304 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_userid_ctx_t)); |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
305 if (ctx == NULL) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
306 return NULL; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
307 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
308 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
309 ngx_http_set_ctx(r, ctx, ngx_http_userid_filter_module); |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
310 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
311 |
509 | 312 n = ngx_http_parse_multi_header_lines(&r->headers_in.cookies, &conf->name, |
539 | 313 &ctx->cookie); |
509 | 314 if (n == NGX_DECLINED) { |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
315 return ctx; |
509 | 316 } |
461 | 317 |
539 | 318 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
319 "uid cookie: \"%V\"", &ctx->cookie); | |
320 | |
321 if (ctx->cookie.len < 22) { | |
509 | 322 cookies = r->headers_in.cookies.elts; |
323 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
324 "client sent too short userid cookie \"%V\"", | |
325 &cookies[n]->value); | |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
326 return ctx; |
509 | 327 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
328 |
539 | 329 src = ctx->cookie; |
330 | |
509 | 331 /* |
539 | 332 * we have to limit the encoded string to 22 characters because |
333 * 1) cookie may be marked by "userid_mark", | |
334 * 2) and there are already the millions cookies with a garbage | |
335 * instead of the correct base64 trail "==" | |
509 | 336 */ |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
337 |
509 | 338 src.len = 22; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
339 |
509 | 340 dst.data = (u_char *) ctx->uid_got; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
341 |
509 | 342 if (ngx_decode_base64(&dst, &src) == NGX_ERROR) { |
343 cookies = r->headers_in.cookies.elts; | |
344 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
345 "client sent invalid userid cookie \"%V\"", | |
346 &cookies[n]->value); | |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
347 return ctx; |
509 | 348 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
349 |
509 | 350 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
351 "uid: %08XD%08XD%08XD%08XD", | |
352 ctx->uid_got[0], ctx->uid_got[1], | |
353 ctx->uid_got[2], ctx->uid_got[3]); | |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
354 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
355 return ctx; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
356 } |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
357 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
358 |
499 | 359 static ngx_int_t |
360 ngx_http_userid_set_uid(ngx_http_request_t *r, ngx_http_userid_ctx_t *ctx, | |
361 ngx_http_userid_conf_t *conf) | |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
362 { |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
363 u_char *cookie, *p; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
364 size_t len; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
365 ngx_str_t src, dst; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
366 ngx_table_elt_t *set_cookie, *p3p; |
2528 | 367 |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
368 if (ngx_http_userid_create_uid(r, ctx, conf) != NGX_OK) { |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
369 return NGX_ERROR; |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
370 } |
539 | 371 |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
372 if (ctx->uid_set[3] == 0) { |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
373 return NGX_OK; |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
374 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
375 |
461 | 376 len = conf->name.len + 1 + ngx_base64_encoded_length(16) + conf->path.len; |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
377 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
378 if (conf->expires) { |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
379 len += sizeof(expires) - 1 + 2; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
380 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
381 |
479 | 382 if (conf->domain.len) { |
461 | 383 len += conf->domain.len; |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
384 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
385 |
2049 | 386 cookie = ngx_pnalloc(r->pool, len); |
499 | 387 if (cookie == NULL) { |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
388 return NGX_ERROR; |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
389 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
390 |
573 | 391 p = ngx_copy(cookie, conf->name.data, conf->name.len); |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
392 *p++ = '='; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
393 |
3943 | 394 if (ctx->uid_got[3] == 0 || ctx->reset) { |
539 | 395 src.len = 16; |
396 src.data = (u_char *) ctx->uid_set; | |
397 dst.data = p; | |
398 | |
399 ngx_encode_base64(&dst, &src); | |
400 | |
401 p += dst.len; | |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
402 |
539 | 403 if (conf->mark) { |
404 *(p - 2) = conf->mark; | |
405 } | |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
406 |
539 | 407 } else { |
408 p = ngx_cpymem(p, ctx->cookie.data, 22); | |
409 *p++ = conf->mark; | |
410 *p++ = '='; | |
411 } | |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
412 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
413 if (conf->expires == NGX_HTTP_USERID_MAX_EXPIRES) { |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
414 p = ngx_cpymem(p, expires, sizeof(expires) - 1); |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
415 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
416 } else if (conf->expires) { |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
417 p = ngx_cpymem(p, expires, sizeof("; expires=") - 1); |
455 | 418 p = ngx_http_cookie_time(p, ngx_time() + conf->expires); |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
419 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
420 |
573 | 421 p = ngx_copy(p, conf->domain.data, conf->domain.len); |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
422 |
573 | 423 p = ngx_copy(p, conf->path.data, conf->path.len); |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
424 |
499 | 425 set_cookie = ngx_list_push(&r->headers_out.headers); |
426 if (set_cookie == NULL) { | |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
427 return NGX_ERROR; |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
428 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
429 |
509 | 430 set_cookie->hash = 1; |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
431 ngx_str_set(&set_cookie->key, "Set-Cookie"); |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
432 set_cookie->value.len = p - cookie; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
433 set_cookie->value.data = cookie; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
434 |
461 | 435 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
436 "uid cookie: \"%V\"", &set_cookie->value); | |
437 | |
479 | 438 if (conf->p3p.len == 0) { |
461 | 439 return NGX_OK; |
440 } | |
441 | |
499 | 442 p3p = ngx_list_push(&r->headers_out.headers); |
443 if (p3p == NULL) { | |
461 | 444 return NGX_ERROR; |
445 } | |
446 | |
509 | 447 p3p->hash = 1; |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
448 ngx_str_set(&p3p->key, "P3P"); |
461 | 449 p3p->value = conf->p3p; |
450 | |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
451 return NGX_OK; |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
452 } |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
453 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
454 |
499 | 455 static ngx_int_t |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
456 ngx_http_userid_create_uid(ngx_http_request_t *r, ngx_http_userid_ctx_t *ctx, |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
457 ngx_http_userid_conf_t *conf) |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
458 { |
3943 | 459 ngx_connection_t *c; |
460 struct sockaddr_in *sin; | |
461 ngx_http_variable_value_t *vv; | |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
462 #if (NGX_HAVE_INET6) |
3943 | 463 u_char *p; |
464 struct sockaddr_in6 *sin6; | |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
465 #endif |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
466 |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
467 if (ctx->uid_set[3] != 0) { |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
468 return NGX_OK; |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
469 } |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
470 |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
471 if (ctx->uid_got[3] != 0) { |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
472 |
3943 | 473 vv = ngx_http_get_indexed_variable(r, ngx_http_userid_reset_index); |
474 | |
475 if (vv->len == 0 || (vv->len == 1 && vv->data[0] == '0')) { | |
476 | |
477 if (conf->mark == '\0' | |
478 || (ctx->cookie.len > 23 | |
479 && ctx->cookie.data[22] == conf->mark | |
480 && ctx->cookie.data[23] == '=')) | |
481 { | |
482 return NGX_OK; | |
483 } | |
484 | |
485 ctx->uid_set[0] = ctx->uid_got[0]; | |
486 ctx->uid_set[1] = ctx->uid_got[1]; | |
487 ctx->uid_set[2] = ctx->uid_got[2]; | |
488 ctx->uid_set[3] = ctx->uid_got[3]; | |
489 | |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
490 return NGX_OK; |
3943 | 491 |
492 } else { | |
493 ctx->reset = 1; | |
494 | |
495 if (vv->len == 3 && ngx_strncmp(vv->data, "log", 3) == 0) { | |
496 ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0, | |
497 "userid cookie \"%V=%08XD%08XD%08XD%08XD\" was reset", | |
498 &conf->name, ctx->uid_got[0], ctx->uid_got[1], | |
499 ctx->uid_got[2], ctx->uid_got[3]); | |
500 } | |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
501 } |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
502 } |
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
503 |
3648
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
504 /* |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
505 * TODO: in the threaded mode the sequencers should be in TLS and their |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
506 * ranges should be divided between threads |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
507 */ |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
508 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
509 if (conf->enable == NGX_HTTP_USERID_V1) { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
510 if (conf->service == NGX_CONF_UNSET) { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
511 ctx->uid_set[0] = 0; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
512 } else { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
513 ctx->uid_set[0] = conf->service; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
514 } |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
515 ctx->uid_set[1] = (uint32_t) ngx_time(); |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
516 ctx->uid_set[2] = start_value; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
517 ctx->uid_set[3] = sequencer_v1; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
518 sequencer_v1 += 0x100; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
519 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
520 } else { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
521 if (conf->service == NGX_CONF_UNSET) { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
522 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
523 c = r->connection; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
524 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
525 if (ngx_connection_local_sockaddr(c, NULL, 0) != NGX_OK) { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
526 return NGX_ERROR; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
527 } |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
528 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
529 switch (c->local_sockaddr->sa_family) { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
530 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
531 #if (NGX_HAVE_INET6) |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
532 case AF_INET6: |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
533 sin6 = (struct sockaddr_in6 *) c->local_sockaddr; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
534 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
535 p = (u_char *) &ctx->uid_set[0]; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
536 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
537 *p++ = sin6->sin6_addr.s6_addr[12]; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
538 *p++ = sin6->sin6_addr.s6_addr[13]; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
539 *p++ = sin6->sin6_addr.s6_addr[14]; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
540 *p = sin6->sin6_addr.s6_addr[15]; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
541 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
542 break; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
543 #endif |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
544 default: /* AF_INET */ |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
545 sin = (struct sockaddr_in *) c->local_sockaddr; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
546 ctx->uid_set[0] = sin->sin_addr.s_addr; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
547 break; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
548 } |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
549 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
550 } else { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
551 ctx->uid_set[0] = htonl(conf->service); |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
552 } |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
553 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
554 ctx->uid_set[1] = htonl((uint32_t) ngx_time()); |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
555 ctx->uid_set[2] = htonl(start_value); |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
556 ctx->uid_set[3] = htonl(sequencer_v2); |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
557 sequencer_v2 += 0x100; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
558 if (sequencer_v2 < 0x03030302) { |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
559 sequencer_v2 = 0x03030302; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
560 } |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
561 } |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
562 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
563 return NGX_OK; |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
564 } |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
565 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
566 |
67dc5dbbcca3
Now $uid_set may be used at any time, r2013 states the same is wrong.
Igor Sysoev <igor@sysoev.ru>
parents:
3647
diff
changeset
|
567 static ngx_int_t |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
568 ngx_http_userid_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v, |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
569 ngx_str_t *name, uint32_t *uid) |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
570 { |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
571 v->len = name->len + sizeof("=00001111222233334444555566667777") - 1; |
2049 | 572 v->data = ngx_pnalloc(r->pool, v->len); |
573 | 573 if (v->data == NULL) { |
574 return NGX_ERROR; | |
575 } | |
576 | |
657 | 577 v->valid = 1; |
1565 | 578 v->no_cacheable = 0; |
657 | 579 v->not_found = 0; |
580 | |
573 | 581 ngx_sprintf(v->data, "%V=%08XD%08XD%08XD%08XD", |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
582 name, uid[0], uid[1], uid[2], uid[3]); |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
583 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
584 return NGX_OK; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
585 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
586 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
587 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
588 static ngx_int_t |
3943 | 589 ngx_http_userid_reset_variable(ngx_http_request_t *r, |
590 ngx_http_variable_value_t *v, uintptr_t data) | |
591 { | |
592 *v = ngx_http_variable_null_value; | |
593 | |
594 return NGX_OK; | |
595 } | |
596 | |
597 | |
598 static ngx_int_t | |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
599 ngx_http_userid_add_variables(ngx_conf_t *cf) |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
600 { |
3943 | 601 ngx_int_t n; |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
602 ngx_http_variable_t *var; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
603 |
3522
d24f030507cd
allow to use $uid_got in SSI and perl module
Igor Sysoev <igor@sysoev.ru>
parents:
3516
diff
changeset
|
604 var = ngx_http_add_variable(cf, &ngx_http_userid_got, 0); |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
605 if (var == NULL) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
606 return NGX_ERROR; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
607 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
608 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
609 var->get_handler = ngx_http_userid_got_variable; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
610 |
3661
8649a0c0f09d
change logic introduced in r3649:
Igor Sysoev <igor@sysoev.ru>
parents:
3659
diff
changeset
|
611 var = ngx_http_add_variable(cf, &ngx_http_userid_set, 0); |
2012
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
612 if (var == NULL) { |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
613 return NGX_ERROR; |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
614 } |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
615 |
220f5e8603d0
$uid_got and $uid_set may used at any time
Igor Sysoev <igor@sysoev.ru>
parents:
1805
diff
changeset
|
616 var->get_handler = ngx_http_userid_set_variable; |
573 | 617 |
3943 | 618 var = ngx_http_add_variable(cf, &ngx_http_userid_reset, |
619 NGX_HTTP_VAR_CHANGEABLE); | |
620 if (var == NULL) { | |
621 return NGX_ERROR; | |
622 } | |
623 | |
624 var->get_handler = ngx_http_userid_reset_variable; | |
625 | |
626 n = ngx_http_get_variable_index(cf, &ngx_http_userid_reset); | |
627 if (n == NGX_ERROR) { | |
628 return NGX_ERROR; | |
629 } | |
630 | |
631 ngx_http_userid_reset_index = n; | |
632 | |
573 | 633 return NGX_OK; |
634 } | |
635 | |
636 | |
499 | 637 static void * |
638 ngx_http_userid_create_conf(ngx_conf_t *cf) | |
577 | 639 { |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
640 ngx_http_userid_conf_t *conf; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
641 |
499 | 642 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_userid_conf_t)); |
643 if (conf == NULL) { | |
2912
c7d57b539248
return NULL instead of NGX_CONF_ERROR on a create conf failure
Igor Sysoev <igor@sysoev.ru>
parents:
2857
diff
changeset
|
644 return NULL; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
645 } |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
646 |
479 | 647 /* |
648 * set by ngx_pcalloc(): | |
649 * | |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
650 * conf->name = { 0, NULL }; |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
651 * conf->domain = { 0, NULL }; |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
652 * conf->path = { 0, NULL }; |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
653 * conf->p3p = { 0, NULL }; |
479 | 654 */ |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
655 |
509 | 656 conf->enable = NGX_CONF_UNSET_UINT; |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
657 conf->service = NGX_CONF_UNSET; |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
658 conf->expires = NGX_CONF_UNSET; |
539 | 659 conf->mark = (u_char) '\xFF'; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
660 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
661 return conf; |
577 | 662 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
663 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
664 |
499 | 665 static char * |
666 ngx_http_userid_merge_conf(ngx_conf_t *cf, void *parent, void *child) | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
667 { |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
668 ngx_http_userid_conf_t *prev = parent; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
669 ngx_http_userid_conf_t *conf = child; |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
670 |
663 | 671 ngx_conf_merge_uint_value(conf->enable, prev->enable, |
672 NGX_HTTP_USERID_OFF); | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
673 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
674 ngx_conf_merge_str_value(conf->name, prev->name, "uid"); |
479 | 675 ngx_conf_merge_str_value(conf->domain, prev->domain, ""); |
461 | 676 ngx_conf_merge_str_value(conf->path, prev->path, "; path=/"); |
479 | 677 ngx_conf_merge_str_value(conf->p3p, prev->p3p, ""); |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
678 |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
679 ngx_conf_merge_value(conf->service, prev->service, NGX_CONF_UNSET); |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
680 ngx_conf_merge_sec_value(conf->expires, prev->expires, 0); |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
681 |
539 | 682 if (conf->mark == (u_char) '\xFF') { |
683 if (prev->mark == (u_char) '\xFF') { | |
684 conf->mark = '\0'; | |
685 } else { | |
686 conf->mark = prev->mark; | |
687 } | |
688 } | |
689 | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
690 return NGX_CONF_OK; |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
691 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
692 |
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
693 |
681 | 694 static ngx_int_t |
695 ngx_http_userid_init(ngx_conf_t *cf) | |
696 { | |
697 ngx_http_next_header_filter = ngx_http_top_header_filter; | |
698 ngx_http_top_header_filter = ngx_http_userid_filter; | |
699 | |
700 return NGX_OK; | |
701 } | |
702 | |
703 | |
499 | 704 static char * |
705 ngx_http_userid_domain(ngx_conf_t *cf, void *post, void *data) | |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
706 { |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
707 ngx_str_t *domain = data; |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
708 |
461 | 709 u_char *p, *new; |
710 | |
503 | 711 if (ngx_strcmp(domain->data, "none") == 0) { |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
712 ngx_str_set(domain, ""); |
461 | 713 return NGX_CONF_OK; |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
714 } |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
715 |
2049 | 716 new = ngx_pnalloc(cf->pool, sizeof("; domain=") - 1 + domain->len); |
499 | 717 if (new == NULL) { |
461 | 718 return NGX_CONF_ERROR; |
719 } | |
720 | |
721 p = ngx_cpymem(new, "; domain=", sizeof("; domain=") - 1); | |
501 | 722 ngx_memcpy(p, domain->data, domain->len); |
461 | 723 |
724 domain->len += sizeof("; domain=") - 1; | |
725 domain->data = new; | |
726 | |
727 return NGX_CONF_OK; | |
728 } | |
729 | |
730 | |
499 | 731 static char * |
732 ngx_http_userid_path(ngx_conf_t *cf, void *post, void *data) | |
461 | 733 { |
734 ngx_str_t *path = data; | |
735 | |
736 u_char *p, *new; | |
737 | |
2049 | 738 new = ngx_pnalloc(cf->pool, sizeof("; path=") - 1 + path->len); |
499 | 739 if (new == NULL) { |
461 | 740 return NGX_CONF_ERROR; |
741 } | |
742 | |
743 p = ngx_cpymem(new, "; path=", sizeof("; path=") - 1); | |
501 | 744 ngx_memcpy(p, path->data, path->len); |
461 | 745 |
746 path->len += sizeof("; path=") - 1; | |
747 path->data = new; | |
748 | |
412
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
749 return NGX_CONF_OK; |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
750 } |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
751 |
199cd29f35a3
nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
411
diff
changeset
|
752 |
499 | 753 static char * |
754 ngx_http_userid_expires(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
755 { |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
756 ngx_http_userid_conf_t *ucf = conf; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
757 |
539 | 758 ngx_str_t *value; |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
759 |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
760 if (ucf->expires != NGX_CONF_UNSET) { |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
761 return "is duplicate"; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
762 } |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
763 |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
764 value = cf->args->elts; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
765 |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
766 if (ngx_strcmp(value[1].data, "max") == 0) { |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
767 ucf->expires = NGX_HTTP_USERID_MAX_EXPIRES; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
768 return NGX_CONF_OK; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
769 } |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
770 |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
771 if (ngx_strcmp(value[1].data, "off") == 0) { |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
772 ucf->expires = 0; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
773 return NGX_CONF_OK; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
774 } |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
775 |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
776 ucf->expires = ngx_parse_time(&value[1], 1); |
4474 | 777 if (ucf->expires == (time_t) NGX_ERROR) { |
410
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
778 return "invalid value"; |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
779 } |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
780 |
48b9ad5ca1fc
nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
781 return NGX_CONF_OK; |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
782 } |
461 | 783 |
784 | |
499 | 785 static char * |
786 ngx_http_userid_p3p(ngx_conf_t *cf, void *post, void *data) | |
461 | 787 { |
788 ngx_str_t *p3p = data; | |
789 | |
503 | 790 if (ngx_strcmp(p3p->data, "none") == 0) { |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3509
diff
changeset
|
791 ngx_str_set(p3p, ""); |
461 | 792 } |
793 | |
794 return NGX_CONF_OK; | |
795 } | |
539 | 796 |
797 | |
798 static char * | |
799 ngx_http_userid_mark(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
800 { | |
801 ngx_http_userid_conf_t *ucf = conf; | |
802 | |
803 ngx_str_t *value; | |
804 | |
805 if (ucf->mark != (u_char) '\xFF') { | |
806 return "is duplicate"; | |
807 } | |
808 | |
809 value = cf->args->elts; | |
810 | |
811 if (ngx_strcmp(value[1].data, "off") == 0) { | |
812 ucf->mark = '\0'; | |
813 return NGX_CONF_OK; | |
814 } | |
815 | |
816 if (value[1].len != 1 | |
817 || !((value[1].data[0] >= '0' && value[1].data[0] <= '9') | |
818 || (value[1].data[0] >= 'A' && value[1].data[0] <= 'Z') | |
819 || (value[1].data[0] >= 'a' && value[1].data[0] <= 'z') | |
820 || value[1].data[0] == '=')) | |
821 { | |
822 return "value must be \"off\" or a single letter, digit or \"=\""; | |
823 } | |
824 | |
825 ucf->mark = value[1].data[0]; | |
826 | |
827 return NGX_CONF_OK; | |
828 } | |
1651
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
829 |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
830 |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
831 static ngx_int_t |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
832 ngx_http_userid_init_worker(ngx_cycle_t *cycle) |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
833 { |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
834 struct timeval tp; |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
835 |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
836 ngx_gettimeofday(&tp); |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
837 |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
838 /* use the most significant usec part that fits to 16 bits */ |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
839 start_value = ((tp.tv_usec / 20) << 16) | ngx_pid; |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
840 |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
841 return NGX_OK; |
555ee689cecc
use usec and pid as start value
Igor Sysoev <igor@sysoev.ru>
parents:
1640
diff
changeset
|
842 } |