annotate src/http/modules/ngx_http_userid_filter.c @ 417:0526206251f6

nginx-0.0.10-2004-09-07-19:29:22 import
author Igor Sysoev <igor@sysoev.ru>
date Tue, 07 Sep 2004 15:29:22 +0000
parents b9bd635011de
children da8c5707af39
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
2 #include <ngx_config.h>
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
3 #include <ngx_core.h>
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
4 #include <ngx_http.h>
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
5
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
6
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
7 #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
8 #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
9 #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
10 #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
11
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
12 /* 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
13 #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
14
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
15
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
16 typedef struct {
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
17 ngx_flag_t enable;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
18
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
19 ngx_int_t service;
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 ngx_str_t name;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
22 ngx_str_t domain;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
23 ngx_str_t path;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
24 time_t expires;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
25
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
26 ngx_int_t p3p;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
27 ngx_str_t p3p_string;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
28 } 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
29
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
30
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
31 typedef struct {
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
32 uint32_t uid_got[4];
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
33 uint32_t uid_set[4];
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
34 } 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
35
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 static ngx_int_t ngx_http_userid_get_uid(ngx_http_request_t *r,
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
38 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
39 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
40 static ngx_int_t ngx_http_userid_set_uid(ngx_http_request_t *r,
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
41 ngx_http_userid_ctx_t *ctx,
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
42 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
43
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
44 static u_char *ngx_http_userid_log_uid_got(ngx_http_request_t *r, u_char *buf,
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
45 uintptr_t data);
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
46 static u_char *ngx_http_userid_log_uid_set(ngx_http_request_t *r, u_char *buf,
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
47 uintptr_t data);
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
48
410
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
49 static ngx_int_t ngx_http_userid_init(ngx_cycle_t *cycle);
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
50 static ngx_int_t ngx_http_userid_pre_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
51 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
52 static char *ngx_http_userid_merge_conf(ngx_conf_t *cf, void *parent,
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
53 void *child);
412
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
54 char *ngx_conf_check_domain(ngx_conf_t *cf, void *post, void *data);
410
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
55 char *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
56
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
57
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
58 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
59 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
60
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
61
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
62 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
63
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
64
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
65 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
66
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
67
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
68 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
69 { 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
70 { 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
71 { 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
72 { 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
73 { ngx_null_string, 0 }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
74 };
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
75
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
76
412
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
77 static ngx_conf_post_handler_pt ngx_conf_check_domain_p =
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
78 ngx_conf_check_domain;
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
79
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
80
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
81 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
82
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
83 { 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
84 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
85 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
86 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
87 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
88 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
89
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
90 { ngx_string("userid_service"),
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
91 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
92 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
93 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
94 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
95 NULL },
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
96
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
97 { ngx_string("userid_name"),
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
98 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
99 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
100 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
101 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
102 NULL },
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
103
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
104 { ngx_string("userid_domain"),
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
105 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
106 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
107 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
108 offsetof(ngx_http_userid_conf_t, domain),
412
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
109 &ngx_conf_check_domain_p },
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
110
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
111 { ngx_string("userid_path"),
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
112 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
113 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
114 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
115 offsetof(ngx_http_userid_conf_t, path),
412
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
116 NULL },
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
117
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
118 { 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
119 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
120 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
121 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
122 0,
412
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
123 NULL },
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
124
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
125 ngx_null_command
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
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
128
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
129 ngx_http_module_t ngx_http_userid_filter_module_ctx = {
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
130 ngx_http_userid_pre_conf, /* pre conf */
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
131
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
132 NULL, /* create main configuration */
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
133 NULL, /* init main configuration */
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
134
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
135 NULL, /* create server configuration */
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
136 NULL, /* merge server configuration */
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
137
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
138 ngx_http_userid_create_conf, /* create location configration */
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
139 ngx_http_userid_merge_conf /* merge location configration */
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
140 };
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
141
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
142
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
143 ngx_module_t ngx_http_userid_filter_module = {
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
144 NGX_MODULE,
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
145 &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
146 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
147 NGX_HTTP_MODULE, /* module type */
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
148 ngx_http_userid_init, /* init module */
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
149 NULL /* init process */
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
150 };
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
151
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
152
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
153 static ngx_http_log_op_name_t ngx_http_userid_log_fmt_ops[] = {
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
154 { ngx_string("uid_got"), 0, ngx_http_userid_log_uid_got },
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
155 { ngx_string("uid_set"), 0, ngx_http_userid_log_uid_set },
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
156 { ngx_null_string, 0, NULL }
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
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
159
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
160 static ngx_int_t 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
161 {
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
162 ngx_int_t rc;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
163 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
164 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
165
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
166 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
167
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
168 if (conf->enable == NGX_HTTP_USERID_OFF) {
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
169 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
170 }
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
171
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
172 ngx_http_create_ctx(r, ctx, ngx_http_userid_filter_module,
412
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
173 sizeof(ngx_http_userid_ctx_t), NGX_ERROR);
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
174
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
175 rc = ngx_http_userid_get_uid(r, ctx, conf);
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
176
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
177 if (rc != NGX_OK) {
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
178 return rc;
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
179 }
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
180
412
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
181 if (conf->enable == NGX_HTTP_USERID_LOG || ctx->uid_got[3] != 0) {
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
182 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
183 }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
184
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
185 rc = ngx_http_userid_set_uid(r, ctx, conf);
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
186
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
187 if (rc != NGX_OK) {
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
188 return rc;
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
189 }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
190
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
191 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
192 }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
193
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
194
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
195 static ngx_int_t ngx_http_userid_get_uid(ngx_http_request_t *r,
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
196 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
197 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
198 {
415
3c56e834be46 nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents: 412
diff changeset
199 u_char *start, *last, *end;
3c56e834be46 nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents: 412
diff changeset
200 ngx_uint_t i;
3c56e834be46 nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents: 412
diff changeset
201 ngx_str_t src, dst;
3c56e834be46 nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents: 412
diff changeset
202 ngx_table_elt_t **cookies;
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
203
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
204 cookies = r->headers_in.cookies.elts;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
205
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
206 for (i = 0; i < r->headers_in.cookies.nelts; i++) {
415
3c56e834be46 nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents: 412
diff changeset
207 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
3c56e834be46 nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents: 412
diff changeset
208 "cookie: \"%s\"", cookies[i]->value.data);
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
209
415
3c56e834be46 nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents: 412
diff changeset
210 end = cookies[i]->value.data + cookies[i]->value.len;
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
211
415
3c56e834be46 nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents: 412
diff changeset
212 for (start = cookies[i]->value.data; start < end; /* void */) {
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
213
415
3c56e834be46 nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents: 412
diff changeset
214 if (conf->name.len >= cookies[i]->value.len
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
215 || ngx_strncmp(start, conf->name.data, conf->name.len) != 0)
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
216 {
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
217 start += conf->name.len;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
218 while (start < end && *start++ != ';') { /* void */ }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
219
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
220 for (/* void */; start < end && *start == ' '; start++) { /**/ }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
221
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
222 continue;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
223 }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
224
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
225 for (start += conf->name.len; start < end && *start == ' '; start++)
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
226 {
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
227 /* void */
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
228 }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
229
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
230 if (*start != '=') {
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
231 break;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
232 }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
233
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
234 for (start++; start < end && *start == ' '; start++) { /* void */ }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
235
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
236 for (last = start; last < end && *last != ';'; last++) { /**/ }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
237
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
238 if (last - start < 22) {
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
239 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
240 "client sent too short userid cookie \"%s\"",
415
3c56e834be46 nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents: 412
diff changeset
241 cookies[i]->value.data);
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
242 break;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
243 }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
244
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
245 /*
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
246 * we have to limit encoded string to 22 characters
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
247 * because there are already the millions cookies with a garbage
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
248 * instead of the correct base64 trail "=="
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
249 */
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
250
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
251 src.len = 22;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
252 src.data = start;
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
253 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
254
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
255 if (ngx_decode_base64(&src, &dst) == NGX_ERROR) {
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
256 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
257 "client sent invalid userid cookie \"%s\"",
415
3c56e834be46 nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents: 412
diff changeset
258 cookies[i]->value.data);
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
259 break;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
260 }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
261
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
262 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
263 "uid: %08X%08X%08X%08X",
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
264 ctx->uid_got[0], ctx->uid_got[1],
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
265 ctx->uid_got[2], ctx->uid_got[3]);
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
266
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
267 return NGX_OK;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
268 }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
269 }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
270
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
271 return NGX_OK;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
272 }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
273
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
274
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
275 static ngx_int_t ngx_http_userid_set_uid(ngx_http_request_t *r,
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
276 ngx_http_userid_ctx_t *ctx,
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
277 ngx_http_userid_conf_t *conf)
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
278
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
279 {
412
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
280 u_char *cookie, *p;
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
281 size_t len;
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
282 socklen_t slen;
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
283 struct sockaddr_in addr_in;
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
284 ngx_str_t src, dst;
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
285 ngx_table_elt_t *set_cookie;
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
286
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
287 /* TODO: mutex for sequencers */
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
288
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
289 if (conf->enable == NGX_HTTP_USERID_V1) {
410
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
290 if (conf->service == NGX_CONF_UNSET) {
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
291 ctx->uid_set[0] = 0;
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
292 } else {
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
293 ctx->uid_set[0] = htonl(conf->service);
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
294 }
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
295
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
296 ctx->uid_set[1] = ngx_time();
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
297 ctx->uid_set[2] = ngx_pid;
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
298 ctx->uid_set[3] = sequencer_v1;
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
299 sequencer_v1 += 0x100;
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
300
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
301 } else {
410
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
302 if (conf->service == NGX_CONF_UNSET) {
412
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
303 if (r->in_addr == 0) {
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
304 slen = sizeof(struct sockaddr_in);
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
305 if (getsockname(r->connection->fd,
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
306 (struct sockaddr *) &addr_in, &slen) == -1)
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
307 {
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
308 ngx_log_error(NGX_LOG_CRIT, r->connection->log,
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
309 ngx_socket_errno,
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
310 "getsockname() failed");
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
311 }
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
312
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
313 r->in_addr = addr_in.sin_addr.s_addr;
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
314 }
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
315
410
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
316 ctx->uid_set[0] = htonl(r->in_addr);
412
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
317
410
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
318 } else {
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
319 ctx->uid_set[0] = htonl(conf->service);
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
320 }
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
321
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
322 ctx->uid_set[1] = htonl(ngx_time());
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
323 ctx->uid_set[2] = htonl(ngx_pid);
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
324 ctx->uid_set[3] = htonl(sequencer_v2);
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
325 sequencer_v2 += 0x100;
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
326 if (sequencer_v2 < 0x03030302) {
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
327 sequencer_v2 = 0x03030302;
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
328 }
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
329 }
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
330
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
331 len = conf->name.len + 1 + ngx_base64_encoded_length(16) + 1;
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
332
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
333 if (conf->expires) {
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
334 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
335 }
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
336
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
337 if (conf->domain.len > 1) {
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
338 len += sizeof("; domain=") - 1 + conf->domain.len;
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
339 }
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
340
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
341 if (conf->path.len) {
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
342 len += sizeof("; path=") - 1 + conf->path.len;
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
343 }
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
344
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
345 if (!(cookie = ngx_palloc(r->pool, len))) {
412
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
346 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
347 }
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
348
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
349 p = ngx_cpymem(cookie, conf->name.data, conf->name.len);
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
350 *p++ = '=';
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
351
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
352 src.len = 16;
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
353 src.data = (u_char *) ctx->uid_set;
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
354 dst.data = p;
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
355
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
356 ngx_encode_base64(&src, &dst);
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
357
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
358 p += dst.len;
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
359
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
360 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
361 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
362
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
363 } 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
364 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
365 p += ngx_http_cookie_time(p, ngx_time() + conf->expires);
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
366 }
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
367
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
368 if (conf->domain.len > 1) {
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
369 p = ngx_cpymem(p, "; domain=", sizeof("; domain=") - 1);
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
370 p = ngx_cpymem(p, conf->domain.data, conf->domain.len);
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
371 }
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
372
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
373 if (conf->path.len) {
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
374 p = ngx_cpymem(p, "; path=", sizeof("; path=") - 1);
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
375 p = ngx_cpymem(p, conf->path.data, conf->path.len);
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
376 }
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 *p = '\0';
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
379
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
380 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
381 "uid cookie: \"%s\"", cookie);
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
382
416
b9bd635011de nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 415
diff changeset
383 if (!(set_cookie = ngx_list_push(&r->headers_out.headers))) {
412
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
384 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
385 }
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
386
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
387 set_cookie->key.len = sizeof("Set-Cookie") - 1;
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
388 set_cookie->key.data = (u_char *) "Set-Cookie";
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
389 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
390 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
391
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
392 return NGX_OK;
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
393 }
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
394
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
395
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
396 static u_char *ngx_http_userid_log_uid_got(ngx_http_request_t *r, u_char *buf,
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
397 uintptr_t data)
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
398 {
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
399 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
400 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
401
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
402 ctx = ngx_http_get_module_ctx(r, ngx_http_userid_filter_module);
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
403
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
404 if (ctx == NULL || ctx->uid_got[3] == 0) {
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
405 if (buf == NULL) {
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
406 return (u_char *) 1;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
407 }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
409 *buf = '-';
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
410 return buf + 1;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
411 }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
412
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
413 conf = ngx_http_get_module_loc_conf(r, ngx_http_userid_filter_module);
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
414
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
415 if (buf == NULL) {
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
416 return (u_char *) (conf->name.len + 1 + 32);
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
417 }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
418
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
419 buf = ngx_cpymem(buf, conf->name.data, conf->name.len);
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
420
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
421 *buf++ = '=';
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
422
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
423 return buf + ngx_snprintf((char *) buf, 33, "%08X%08X%08X%08X",
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
424 ctx->uid_got[0], ctx->uid_got[1],
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
425 ctx->uid_got[2], ctx->uid_got[3]);
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
426 }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
427
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
428
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
429 static u_char *ngx_http_userid_log_uid_set(ngx_http_request_t *r, u_char *buf,
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
430 uintptr_t data)
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
431 {
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
432 ngx_http_userid_ctx_t *ctx;
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
433 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
434
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
435 ctx = ngx_http_get_module_ctx(r, ngx_http_userid_filter_module);
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
436
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
437 if (ctx == NULL || ctx->uid_set[3] == 0) {
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
438 if (buf == NULL) {
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
439 return (u_char *) 1;
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
440 }
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
441
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
442 *buf = '-';
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
443 return buf + 1;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
444 }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
445
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
446 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
447
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
448 if (buf == NULL) {
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
449 return (u_char *) (conf->name.len + 1 + 32);
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
450 }
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
451
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
452 buf = ngx_cpymem(buf, conf->name.data, conf->name.len);
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 *buf++ = '=';
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
455
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
456 return buf + ngx_snprintf((char *) buf, 33, "%08X%08X%08X%08X",
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
457 ctx->uid_set[0], ctx->uid_set[1],
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
458 ctx->uid_set[2], ctx->uid_set[3]);
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
459 }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
460
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
461
410
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
462 static ngx_int_t ngx_http_userid_init(ngx_cycle_t *cycle)
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
463 {
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
464 ngx_http_next_header_filter = ngx_http_top_header_filter;
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
465 ngx_http_top_header_filter = ngx_http_userid_filter;
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
466
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
467 return NGX_OK;
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
468 }
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
469
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
470
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
471 static ngx_int_t ngx_http_userid_pre_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
472 {
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
473 ngx_http_log_op_name_t *op;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
474
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
475 for (op = ngx_http_userid_log_fmt_ops; op->name.len; op++) { /* void */ }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
476 op->op = NULL;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
477
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
478 op = ngx_http_log_fmt_ops;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
479
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
480 for (op = ngx_http_log_fmt_ops; op->op; op++) {
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
481 if (op->name.len == 0) {
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
482 op = (ngx_http_log_op_name_t *) op->op;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
483 }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
484 }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
485
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
486 op->op = (ngx_http_log_op_pt) ngx_http_userid_log_fmt_ops;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
487
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
488 return NGX_OK;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
489 }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
490
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
491
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
492 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
493 {
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
494 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
495
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
496 if (!(conf = ngx_pcalloc(cf->pool, sizeof(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
497 return NGX_CONF_ERROR;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
498 }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
499
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
500 /* set by ngx_pcalloc():
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
501
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
502 conf->name.len = 0;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
503 conf->name.date = NULL;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
504 conf->domain.len = 0;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
505 conf->domain.date = NULL;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
506 conf->path.len = 0;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
507 conf->path.date = NULL;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
508
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
509 */
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
510
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
511 conf->enable = NGX_CONF_UNSET;
410
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
512 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
513 conf->expires = NGX_CONF_UNSET;
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
514
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
515 return conf;
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
516 }
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
517
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
518
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
519 static char *ngx_http_userid_merge_conf(ngx_conf_t *cf, void *parent,
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
520 void *child)
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
521 {
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
522 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
523 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
524
409
8ac40cae79f0 nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents: 408
diff changeset
525 ngx_conf_merge_value(conf->enable, prev->enable, 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
526
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
527 ngx_conf_merge_str_value(conf->name, prev->name, "uid");
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
528 ngx_conf_merge_str_value(conf->domain, prev->domain, ".");
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
529 ngx_conf_merge_str_value(conf->path, prev->path, "/");
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
530
410
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
531 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
532 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
533
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
534 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
535 }
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
536
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
537
412
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
538 char *ngx_conf_check_domain(ngx_conf_t *cf, void *post, void *data)
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
539 {
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
540 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
541
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
542 if (domain->len == 4 && ngx_strcmp(domain->data, "none") == 0) {
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
543 domain->len = 1;
417
0526206251f6 nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents: 416
diff changeset
544 domain->data = (u_char *) ".";
412
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
545 }
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
546
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
547 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
548 }
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
549
199cd29f35a3 nginx-0.0.10-2004-08-31-19:32:52 import
Igor Sysoev <igor@sysoev.ru>
parents: 411
diff changeset
550
410
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
551 char *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
552 {
410
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
553 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
554
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
555 ngx_str_t *value;
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
556
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
557 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
558 return "is duplicate";
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
559 }
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
560
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
561 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
562
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
563 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
564 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
565 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
566 }
408
d6e2b445c1b8 nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
567
410
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
568 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
569 ucf->expires = 0;
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
570 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
571 }
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
572
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
573 ucf->expires = ngx_parse_time(&value[1], 1);
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
574 if (ucf->expires == NGX_ERROR) {
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
575 return "invalid value";
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
576 }
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
577
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
578 if (ucf->expires == NGX_PARSE_LARGE_TIME) {
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
579 return "value must be less than 68 years";
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
580 }
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
581
48b9ad5ca1fc nginx-0.0.10-2004-08-30-19:42:44 import
Igor Sysoev <igor@sysoev.ru>
parents: 409
diff changeset
582 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
583 }