annotate src/mail/ngx_mail_auth_http_module.c @ 6593:b3b7e33083ac

Introduced ngx_inet_get_port() and ngx_inet_set_port() functions.
author Roman Arutyunyan <arut@nginx.com>
date Mon, 20 Jun 2016 11:50:39 +0300
parents f01ab2dbcfdc
children 0a820872dd4c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
2 /*
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
3 * Copyright (C) Igor Sysoev
4412
d620f497c50f Copyright updated.
Maxim Konovalov <maxim@nginx.com>
parents: 4227
diff changeset
4 * Copyright (C) Nginx, Inc.
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
5 */
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
6
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
7
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
8 #include <ngx_config.h>
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
9 #include <ngx_core.h>
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
10 #include <ngx_event.h>
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
11 #include <ngx_event_connect.h>
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
12 #include <ngx_mail.h>
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
13
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
14
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
15 typedef struct {
3269
f0d596e84634 rename ngx_peer_addr_t to ngx_addr_t
Igor Sysoev <igor@sysoev.ru>
parents: 3267
diff changeset
16 ngx_addr_t *peer;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
17
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
18 ngx_msec_t timeout;
5989
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
19 ngx_flag_t pass_client_cert;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
20
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
21 ngx_str_t host_header;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
22 ngx_str_t uri;
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
23 ngx_str_t header;
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
24
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
25 ngx_array_t *headers;
1392
86acec04b8b0 test http_auth absence
Igor Sysoev <igor@sysoev.ru>
parents: 1391
diff changeset
26
86acec04b8b0 test http_auth absence
Igor Sysoev <igor@sysoev.ru>
parents: 1391
diff changeset
27 u_char *file;
86acec04b8b0 test http_auth absence
Igor Sysoev <igor@sysoev.ru>
parents: 1391
diff changeset
28 ngx_uint_t line;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
29 } ngx_mail_auth_http_conf_t;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
30
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
31
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
32 typedef struct ngx_mail_auth_http_ctx_s ngx_mail_auth_http_ctx_t;
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
33
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
34 typedef void (*ngx_mail_auth_http_handler_pt)(ngx_mail_session_t *s,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
35 ngx_mail_auth_http_ctx_t *ctx);
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
36
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
37 struct ngx_mail_auth_http_ctx_s {
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
38 ngx_buf_t *request;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
39 ngx_buf_t *response;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
40 ngx_peer_connection_t peer;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
41
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
42 ngx_mail_auth_http_handler_pt handler;
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
43
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
44 ngx_uint_t state;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
45
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
46 u_char *header_name_start;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
47 u_char *header_name_end;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
48 u_char *header_start;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
49 u_char *header_end;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
50
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
51 ngx_str_t addr;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
52 ngx_str_t port;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
53 ngx_str_t err;
567
1af2fcb3be8a nginx-0.3.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
54 ngx_str_t errmsg;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
55 ngx_str_t errcode;
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
56
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
57 time_t sleep;
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
58
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
59 ngx_pool_t *pool;
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
60 };
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
61
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
62
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
63 static void ngx_mail_auth_http_write_handler(ngx_event_t *wev);
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
64 static void ngx_mail_auth_http_read_handler(ngx_event_t *rev);
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
65 static void ngx_mail_auth_http_ignore_status_line(ngx_mail_session_t *s,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
66 ngx_mail_auth_http_ctx_t *ctx);
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
67 static void ngx_mail_auth_http_process_headers(ngx_mail_session_t *s,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
68 ngx_mail_auth_http_ctx_t *ctx);
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
69 static void ngx_mail_auth_sleep_handler(ngx_event_t *rev);
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
70 static ngx_int_t ngx_mail_auth_http_parse_header_line(ngx_mail_session_t *s,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
71 ngx_mail_auth_http_ctx_t *ctx);
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
72 static void ngx_mail_auth_http_block_read(ngx_event_t *rev);
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
73 static void ngx_mail_auth_http_dummy_handler(ngx_event_t *ev);
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
74 static ngx_buf_t *ngx_mail_auth_http_create_request(ngx_mail_session_t *s,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
75 ngx_pool_t *pool, ngx_mail_auth_http_conf_t *ahcf);
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
76 static ngx_int_t ngx_mail_auth_http_escape(ngx_pool_t *pool, ngx_str_t *text,
633
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
77 ngx_str_t *escaped);
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
78
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
79 static void *ngx_mail_auth_http_create_conf(ngx_conf_t *cf);
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
80 static char *ngx_mail_auth_http_merge_conf(ngx_conf_t *cf, void *parent,
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
81 void *child);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
82 static char *ngx_mail_auth_http(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
83 static char *ngx_mail_auth_http_header(ngx_conf_t *cf, ngx_command_t *cmd,
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
84 void *conf);
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
85
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
86
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
87 static ngx_command_t ngx_mail_auth_http_commands[] = {
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
88
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
89 { ngx_string("auth_http"),
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
90 NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
91 ngx_mail_auth_http,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
92 NGX_MAIL_SRV_CONF_OFFSET,
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
93 0,
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
94 NULL },
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
95
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
96 { ngx_string("auth_http_timeout"),
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
97 NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1,
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
98 ngx_conf_set_msec_slot,
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
99 NGX_MAIL_SRV_CONF_OFFSET,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
100 offsetof(ngx_mail_auth_http_conf_t, timeout),
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
101 NULL },
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
102
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
103 { ngx_string("auth_http_header"),
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
104 NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE2,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
105 ngx_mail_auth_http_header,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
106 NGX_MAIL_SRV_CONF_OFFSET,
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
107 0,
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
108 NULL },
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
109
5989
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
110 { ngx_string("auth_http_pass_client_cert"),
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
111 NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_FLAG,
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
112 ngx_conf_set_flag_slot,
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
113 NGX_MAIL_SRV_CONF_OFFSET,
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
114 offsetof(ngx_mail_auth_http_conf_t, pass_client_cert),
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
115 NULL },
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
116
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
117 ngx_null_command
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
118 };
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
119
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
120
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
121 static ngx_mail_module_t ngx_mail_auth_http_module_ctx = {
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1478
diff changeset
122 NULL, /* protocol */
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1478
diff changeset
123
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
124 NULL, /* create main configuration */
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
125 NULL, /* init main configuration */
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
126
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
127 ngx_mail_auth_http_create_conf, /* create server configuration */
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
128 ngx_mail_auth_http_merge_conf /* merge server configuration */
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
129 };
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
130
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
131
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
132 ngx_module_t ngx_mail_auth_http_module = {
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
133 NGX_MODULE_V1,
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
134 &ngx_mail_auth_http_module_ctx, /* module context */
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
135 ngx_mail_auth_http_commands, /* module directives */
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
136 NGX_MAIL_MODULE, /* module type */
541
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
137 NULL, /* init master */
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
138 NULL, /* init module */
541
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
139 NULL, /* init process */
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
140 NULL, /* init thread */
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
141 NULL, /* exit thread */
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
142 NULL, /* exit process */
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
143 NULL, /* exit master */
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
144 NGX_MODULE_V1_PADDING
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
145 };
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
146
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
147
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
148 static ngx_str_t ngx_mail_auth_http_method[] = {
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
149 ngx_string("plain"),
809
da9c1521319d AUTH PLAIN LOGIN CRAM-MD5
Igor Sysoev <igor@sysoev.ru>
parents: 805
diff changeset
150 ngx_string("plain"),
2748
2477b28eaccb fix Auth-Method, the bug has been introduced in r2496
Igor Sysoev <igor@sysoev.ru>
parents: 2388
diff changeset
151 ngx_string("plain"),
809
da9c1521319d AUTH PLAIN LOGIN CRAM-MD5
Igor Sysoev <igor@sysoev.ru>
parents: 805
diff changeset
152 ngx_string("apop"),
2309
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
153 ngx_string("cram-md5"),
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
154 ngx_string("none")
800
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
155 };
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
156
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
157 static ngx_str_t ngx_mail_smtp_errcode = ngx_string("535 5.7.0");
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
158
1477
59e1caf2be94 style fix and optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1405
diff changeset
159
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
160 void
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
161 ngx_mail_auth_http_init(ngx_mail_session_t *s)
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
162 {
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
163 ngx_int_t rc;
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
164 ngx_pool_t *pool;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
165 ngx_mail_auth_http_ctx_t *ctx;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
166 ngx_mail_auth_http_conf_t *ahcf;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
167
541
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
168 s->connection->log->action = "in http auth state";
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
169
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
170 pool = ngx_create_pool(2048, s->connection->log);
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
171 if (pool == NULL) {
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
172 ngx_mail_session_internal_server_error(s);
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
173 return;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
174 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
175
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
176 ctx = ngx_pcalloc(pool, sizeof(ngx_mail_auth_http_ctx_t));
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
177 if (ctx == NULL) {
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
178 ngx_destroy_pool(pool);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
179 ngx_mail_session_internal_server_error(s);
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
180 return;
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
181 }
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
182
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
183 ctx->pool = pool;
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
184
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
185 ahcf = ngx_mail_get_module_srv_conf(s, ngx_mail_auth_http_module);
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
186
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
187 ctx->request = ngx_mail_auth_http_create_request(s, pool, ahcf);
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
188 if (ctx->request == NULL) {
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
189 ngx_destroy_pool(ctx->pool);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
190 ngx_mail_session_internal_server_error(s);
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
191 return;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
192 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
193
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
194 ngx_mail_set_ctx(s, ctx, ngx_mail_auth_http_module);
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
195
884
4d68c486fcb0 upstream choice modules
Igor Sysoev <igor@sysoev.ru>
parents: 883
diff changeset
196 ctx->peer.sockaddr = ahcf->peer->sockaddr;
4d68c486fcb0 upstream choice modules
Igor Sysoev <igor@sysoev.ru>
parents: 883
diff changeset
197 ctx->peer.socklen = ahcf->peer->socklen;
4d68c486fcb0 upstream choice modules
Igor Sysoev <igor@sysoev.ru>
parents: 883
diff changeset
198 ctx->peer.name = &ahcf->peer->name;
4d68c486fcb0 upstream choice modules
Igor Sysoev <igor@sysoev.ru>
parents: 883
diff changeset
199 ctx->peer.get = ngx_event_get_peer;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
200 ctx->peer.log = s->connection->log;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
201 ctx->peer.log_error = NGX_ERROR_ERR;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
202
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
203 rc = ngx_event_connect_peer(&ctx->peer);
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
204
543
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 541
diff changeset
205 if (rc == NGX_ERROR || rc == NGX_BUSY || rc == NGX_DECLINED) {
862
6044cea025fa fix segfault when connect() failed
Igor Sysoev <igor@sysoev.ru>
parents: 856
diff changeset
206 if (ctx->peer.connection) {
6044cea025fa fix segfault when connect() failed
Igor Sysoev <igor@sysoev.ru>
parents: 856
diff changeset
207 ngx_close_connection(ctx->peer.connection);
6044cea025fa fix segfault when connect() failed
Igor Sysoev <igor@sysoev.ru>
parents: 856
diff changeset
208 }
6044cea025fa fix segfault when connect() failed
Igor Sysoev <igor@sysoev.ru>
parents: 856
diff changeset
209
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
210 ngx_destroy_pool(ctx->pool);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
211 ngx_mail_session_internal_server_error(s);
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
212 return;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
213 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
214
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
215 ctx->peer.connection->data = s;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
216 ctx->peer.connection->pool = s->connection->pool;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
217
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
218 s->connection->read->handler = ngx_mail_auth_http_block_read;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
219 ctx->peer.connection->read->handler = ngx_mail_auth_http_read_handler;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
220 ctx->peer.connection->write->handler = ngx_mail_auth_http_write_handler;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
221
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
222 ctx->handler = ngx_mail_auth_http_ignore_status_line;
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
223
541
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
224 ngx_add_timer(ctx->peer.connection->read, ahcf->timeout);
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
225 ngx_add_timer(ctx->peer.connection->write, ahcf->timeout);
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
226
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
227 if (rc == NGX_OK) {
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
228 ngx_mail_auth_http_write_handler(ctx->peer.connection->write);
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
229 return;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
230 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
231 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
232
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
233
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
234 static void
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
235 ngx_mail_auth_http_write_handler(ngx_event_t *wev)
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
236 {
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
237 ssize_t n, size;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
238 ngx_connection_t *c;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
239 ngx_mail_session_t *s;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
240 ngx_mail_auth_http_ctx_t *ctx;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
241 ngx_mail_auth_http_conf_t *ahcf;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
242
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
243 c = wev->data;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
244 s = c->data;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
245
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
246 ctx = ngx_mail_get_module_ctx(s, ngx_mail_auth_http_module);
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
247
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
248 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, wev->log, 0,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
249 "mail auth http write handler");
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
250
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
251 if (wev->timedout) {
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
252 ngx_log_error(NGX_LOG_ERR, wev->log, NGX_ETIMEDOUT,
884
4d68c486fcb0 upstream choice modules
Igor Sysoev <igor@sysoev.ru>
parents: 883
diff changeset
253 "auth http server %V timed out", ctx->peer.name);
1478
d0cce8369848 small optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
254 ngx_close_connection(c);
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
255 ngx_destroy_pool(ctx->pool);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
256 ngx_mail_session_internal_server_error(s);
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
257 return;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
258 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
259
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
260 size = ctx->request->last - ctx->request->pos;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
261
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
262 n = ngx_send(c, ctx->request->pos, size);
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
263
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
264 if (n == NGX_ERROR) {
1478
d0cce8369848 small optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
265 ngx_close_connection(c);
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
266 ngx_destroy_pool(ctx->pool);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
267 ngx_mail_session_internal_server_error(s);
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
268 return;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
269 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
270
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
271 if (n > 0) {
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
272 ctx->request->pos += n;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
273
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
274 if (n == size) {
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
275 wev->handler = ngx_mail_auth_http_dummy_handler;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
276
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
277 if (wev->timer_set) {
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
278 ngx_del_timer(wev);
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
279 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
280
2388
722b5aff05ae use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents: 2310
diff changeset
281 if (ngx_handle_write_event(wev, 0) != NGX_OK) {
1478
d0cce8369848 small optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
282 ngx_close_connection(c);
799
9737d6fb1ac6 disable write level event while waiting auth server response
Igor Sysoev <igor@sysoev.ru>
parents: 633
diff changeset
283 ngx_destroy_pool(ctx->pool);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
284 ngx_mail_session_internal_server_error(s);
799
9737d6fb1ac6 disable write level event while waiting auth server response
Igor Sysoev <igor@sysoev.ru>
parents: 633
diff changeset
285 }
9737d6fb1ac6 disable write level event while waiting auth server response
Igor Sysoev <igor@sysoev.ru>
parents: 633
diff changeset
286
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
287 return;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
288 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
289 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
290
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
291 if (!wev->timer_set) {
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
292 ahcf = ngx_mail_get_module_srv_conf(s, ngx_mail_auth_http_module);
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
293 ngx_add_timer(wev, ahcf->timeout);
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
294 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
295 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
296
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
297
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
298 static void
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
299 ngx_mail_auth_http_read_handler(ngx_event_t *rev)
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
300 {
525
09b42134ac0c nginx-0.1.37-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
301 ssize_t n, size;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
302 ngx_connection_t *c;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
303 ngx_mail_session_t *s;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
304 ngx_mail_auth_http_ctx_t *ctx;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
305
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
306 c = rev->data;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
307 s = c->data;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
308
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
309 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, rev->log, 0,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
310 "mail auth http read handler");
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
311
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
312 ctx = ngx_mail_get_module_ctx(s, ngx_mail_auth_http_module);
525
09b42134ac0c nginx-0.1.37-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
313
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
314 if (rev->timedout) {
525
09b42134ac0c nginx-0.1.37-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
315 ngx_log_error(NGX_LOG_ERR, rev->log, NGX_ETIMEDOUT,
884
4d68c486fcb0 upstream choice modules
Igor Sysoev <igor@sysoev.ru>
parents: 883
diff changeset
316 "auth http server %V timed out", ctx->peer.name);
1478
d0cce8369848 small optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
317 ngx_close_connection(c);
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
318 ngx_destroy_pool(ctx->pool);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
319 ngx_mail_session_internal_server_error(s);
525
09b42134ac0c nginx-0.1.37-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
320 return;
09b42134ac0c nginx-0.1.37-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
321 }
09b42134ac0c nginx-0.1.37-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
322
09b42134ac0c nginx-0.1.37-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
323 if (ctx->response == NULL) {
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
324 ctx->response = ngx_create_temp_buf(ctx->pool, 1024);
525
09b42134ac0c nginx-0.1.37-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
325 if (ctx->response == NULL) {
1478
d0cce8369848 small optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
326 ngx_close_connection(c);
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
327 ngx_destroy_pool(ctx->pool);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
328 ngx_mail_session_internal_server_error(s);
525
09b42134ac0c nginx-0.1.37-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
329 return;
09b42134ac0c nginx-0.1.37-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
330 }
09b42134ac0c nginx-0.1.37-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
331 }
09b42134ac0c nginx-0.1.37-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
332
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
333 size = ctx->response->end - ctx->response->last;
525
09b42134ac0c nginx-0.1.37-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
334
09b42134ac0c nginx-0.1.37-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
335 n = ngx_recv(c, ctx->response->pos, size);
09b42134ac0c nginx-0.1.37-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
336
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
337 if (n > 0) {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
338 ctx->response->last += n;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
339
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
340 ctx->handler(s, ctx);
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
341 return;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
342 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
343
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
344 if (n == NGX_AGAIN) {
525
09b42134ac0c nginx-0.1.37-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
345 return;
09b42134ac0c nginx-0.1.37-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
346 }
09b42134ac0c nginx-0.1.37-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
347
1478
d0cce8369848 small optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1477
diff changeset
348 ngx_close_connection(c);
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
349 ngx_destroy_pool(ctx->pool);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
350 ngx_mail_session_internal_server_error(s);
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
351 }
525
09b42134ac0c nginx-0.1.37-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
352
09b42134ac0c nginx-0.1.37-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
353
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
354 static void
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
355 ngx_mail_auth_http_ignore_status_line(ngx_mail_session_t *s,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
356 ngx_mail_auth_http_ctx_t *ctx)
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
357 {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
358 u_char *p, ch;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
359 enum {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
360 sw_start = 0,
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
361 sw_H,
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
362 sw_HT,
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
363 sw_HTT,
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
364 sw_HTTP,
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
365 sw_skip,
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
366 sw_almost_done
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
367 } state;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
368
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
369 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, s->connection->log, 0,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
370 "mail auth http process status line");
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
371
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
372 state = ctx->state;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
373
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
374 for (p = ctx->response->pos; p < ctx->response->last; p++) {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
375 ch = *p;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
376
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
377 switch (state) {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
378
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
379 /* "HTTP/" */
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
380 case sw_start:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
381 if (ch == 'H') {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
382 state = sw_H;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
383 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
384 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
385 goto next;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
386
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
387 case sw_H:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
388 if (ch == 'T') {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
389 state = sw_HT;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
390 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
391 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
392 goto next;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
393
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
394 case sw_HT:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
395 if (ch == 'T') {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
396 state = sw_HTT;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
397 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
398 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
399 goto next;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
400
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
401 case sw_HTT:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
402 if (ch == 'P') {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
403 state = sw_HTTP;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
404 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
405 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
406 goto next;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
407
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
408 case sw_HTTP:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
409 if (ch == '/') {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
410 state = sw_skip;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
411 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
412 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
413 goto next;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
414
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
415 /* any text until end of line */
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
416 case sw_skip:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
417 switch (ch) {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
418 case CR:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
419 state = sw_almost_done;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
420
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
421 break;
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
422 case LF:
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
423 goto done;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
424 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
425 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
426
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
427 /* end of status line */
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
428 case sw_almost_done:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
429 if (ch == LF) {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
430 goto done;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
431 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
432
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
433 ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
6480
f01ab2dbcfdc Fixed logging.
Sergey Kandaurov <pluknet@nginx.com>
parents: 6001
diff changeset
434 "auth http server %V sent invalid response",
884
4d68c486fcb0 upstream choice modules
Igor Sysoev <igor@sysoev.ru>
parents: 883
diff changeset
435 ctx->peer.name);
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
436 ngx_close_connection(ctx->peer.connection);
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
437 ngx_destroy_pool(ctx->pool);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
438 ngx_mail_session_internal_server_error(s);
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
439 return;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
440 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
441 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
442
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
443 ctx->response->pos = p;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
444 ctx->state = state;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
445
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
446 return;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
447
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
448 next:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
449
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
450 p = ctx->response->start - 1;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
451
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
452 done:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
453
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
454 ctx->response->pos = p + 1;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
455 ctx->state = 0;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
456 ctx->handler = ngx_mail_auth_http_process_headers;
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
457 ctx->handler(s, ctx);
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
458 }
525
09b42134ac0c nginx-0.1.37-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
459
09b42134ac0c nginx-0.1.37-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
460
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
461 static void
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
462 ngx_mail_auth_http_process_headers(ngx_mail_session_t *s,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
463 ngx_mail_auth_http_ctx_t *ctx)
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
464 {
6593
b3b7e33083ac Introduced ngx_inet_get_port() and ngx_inet_set_port() functions.
Roman Arutyunyan <arut@nginx.com>
parents: 6480
diff changeset
465 u_char *p;
b3b7e33083ac Introduced ngx_inet_get_port() and ngx_inet_set_port() functions.
Roman Arutyunyan <arut@nginx.com>
parents: 6480
diff changeset
466 time_t timer;
b3b7e33083ac Introduced ngx_inet_get_port() and ngx_inet_set_port() functions.
Roman Arutyunyan <arut@nginx.com>
parents: 6480
diff changeset
467 size_t len, size;
b3b7e33083ac Introduced ngx_inet_get_port() and ngx_inet_set_port() functions.
Roman Arutyunyan <arut@nginx.com>
parents: 6480
diff changeset
468 ngx_int_t rc, port, n;
b3b7e33083ac Introduced ngx_inet_get_port() and ngx_inet_set_port() functions.
Roman Arutyunyan <arut@nginx.com>
parents: 6480
diff changeset
469 ngx_addr_t *peer;
525
09b42134ac0c nginx-0.1.37-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
470
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
471 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, s->connection->log, 0,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
472 "mail auth http process headers");
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
473
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
474 for ( ;; ) {
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
475 rc = ngx_mail_auth_http_parse_header_line(s, ctx);
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
476
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
477 if (rc == NGX_OK) {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
478
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
479 #if (NGX_DEBUG)
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
480 {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
481 ngx_str_t key, value;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
482
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
483 key.len = ctx->header_name_end - ctx->header_name_start;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
484 key.data = ctx->header_name_start;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
485 value.len = ctx->header_end - ctx->header_start;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
486 value.data = ctx->header_start;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
487
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
488 ngx_log_debug2(NGX_LOG_DEBUG_MAIL, s->connection->log, 0,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
489 "mail auth http header: \"%V: %V\"",
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
490 &key, &value);
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
491 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
492 #endif
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
493
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
494 len = ctx->header_name_end - ctx->header_name_start;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
495
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
496 if (len == sizeof("Auth-Status") - 1
1107
db7c468c447d ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents: 906
diff changeset
497 && ngx_strncasecmp(ctx->header_name_start,
db7c468c447d ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents: 906
diff changeset
498 (u_char *) "Auth-Status",
db7c468c447d ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents: 906
diff changeset
499 sizeof("Auth-Status") - 1)
db7c468c447d ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents: 906
diff changeset
500 == 0)
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
501 {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
502 len = ctx->header_end - ctx->header_start;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
503
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
504 if (len == 2
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
505 && ctx->header_start[0] == 'O'
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
506 && ctx->header_start[1] == 'K')
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
507 {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
508 continue;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
509 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
510
883
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
511 if (len == 4
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
512 && ctx->header_start[0] == 'W'
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
513 && ctx->header_start[1] == 'A'
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
514 && ctx->header_start[2] == 'I'
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
515 && ctx->header_start[3] == 'T')
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
516 {
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
517 s->auth_wait = 1;
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
518 continue;
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
519 }
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
520
567
1af2fcb3be8a nginx-0.3.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
521 ctx->errmsg.len = len;
1af2fcb3be8a nginx-0.3.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
522 ctx->errmsg.data = ctx->header_start;
1af2fcb3be8a nginx-0.3.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
523
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
524 switch (s->protocol) {
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
525
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
526 case NGX_MAIL_POP3_PROTOCOL:
854
1673f197bc62 fix segfault when many auth failures occurred
Igor Sysoev <igor@sysoev.ru>
parents: 809
diff changeset
527 size = sizeof("-ERR ") - 1 + len + sizeof(CRLF) - 1;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
528 break;
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
529
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
530 case NGX_MAIL_IMAP_PROTOCOL:
854
1673f197bc62 fix segfault when many auth failures occurred
Igor Sysoev <igor@sysoev.ru>
parents: 809
diff changeset
531 size = s->tag.len + sizeof("NO ") - 1 + len
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
532 + sizeof(CRLF) - 1;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
533 break;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
534
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
535 default: /* NGX_MAIL_SMTP_PROTOCOL */
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
536 ctx->err = ctx->errmsg;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
537 continue;
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
538 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
539
2061
b0a1c84725cf change useless ngx_pcalloc() to ngx_pnalloc()
Igor Sysoev <igor@sysoev.ru>
parents: 2049
diff changeset
540 p = ngx_pnalloc(s->connection->pool, size);
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
541 if (p == NULL) {
543
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 541
diff changeset
542 ngx_close_connection(ctx->peer.connection);
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
543 ngx_destroy_pool(ctx->pool);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
544 ngx_mail_session_internal_server_error(s);
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
545 return;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
546 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
547
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
548 ctx->err.data = p;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
549
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
550 switch (s->protocol) {
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
551
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
552 case NGX_MAIL_POP3_PROTOCOL:
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
553 *p++ = '-'; *p++ = 'E'; *p++ = 'R'; *p++ = 'R'; *p++ = ' ';
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
554 break;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
555
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
556 case NGX_MAIL_IMAP_PROTOCOL:
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
557 p = ngx_cpymem(p, s->tag.data, s->tag.len);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
558 *p++ = 'N'; *p++ = 'O'; *p++ = ' ';
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
559 break;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
560
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
561 default: /* NGX_MAIL_SMTP_PROTOCOL */
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
562 break;
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
563 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
564
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
565 p = ngx_cpymem(p, ctx->header_start, len);
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
566 *p++ = CR; *p++ = LF;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
567
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
568 ctx->err.len = p - ctx->err.data;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
569
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
570 continue;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
571 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
572
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
573 if (len == sizeof("Auth-Server") - 1
1107
db7c468c447d ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents: 906
diff changeset
574 && ngx_strncasecmp(ctx->header_name_start,
db7c468c447d ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents: 906
diff changeset
575 (u_char *) "Auth-Server",
db7c468c447d ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents: 906
diff changeset
576 sizeof("Auth-Server") - 1)
db7c468c447d ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents: 906
diff changeset
577 == 0)
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
578 {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
579 ctx->addr.len = ctx->header_end - ctx->header_start;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
580 ctx->addr.data = ctx->header_start;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
581
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
582 continue;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
583 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
584
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
585 if (len == sizeof("Auth-Port") - 1
1107
db7c468c447d ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents: 906
diff changeset
586 && ngx_strncasecmp(ctx->header_name_start,
db7c468c447d ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents: 906
diff changeset
587 (u_char *) "Auth-Port",
db7c468c447d ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents: 906
diff changeset
588 sizeof("Auth-Port") - 1)
db7c468c447d ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents: 906
diff changeset
589 == 0)
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
590 {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
591 ctx->port.len = ctx->header_end - ctx->header_start;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
592 ctx->port.data = ctx->header_start;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
593
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
594 continue;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
595 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
596
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
597 if (len == sizeof("Auth-User") - 1
1107
db7c468c447d ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents: 906
diff changeset
598 && ngx_strncasecmp(ctx->header_name_start,
db7c468c447d ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents: 906
diff changeset
599 (u_char *) "Auth-User",
db7c468c447d ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents: 906
diff changeset
600 sizeof("Auth-User") - 1)
db7c468c447d ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents: 906
diff changeset
601 == 0)
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
602 {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
603 s->login.len = ctx->header_end - ctx->header_start;
567
1af2fcb3be8a nginx-0.3.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
604
2049
2a92804f4109 *) back out r2040
Igor Sysoev <igor@sysoev.ru>
parents: 1640
diff changeset
605 s->login.data = ngx_pnalloc(s->connection->pool, s->login.len);
567
1af2fcb3be8a nginx-0.3.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
606 if (s->login.data == NULL) {
1af2fcb3be8a nginx-0.3.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
607 ngx_close_connection(ctx->peer.connection);
1af2fcb3be8a nginx-0.3.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
608 ngx_destroy_pool(ctx->pool);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
609 ngx_mail_session_internal_server_error(s);
567
1af2fcb3be8a nginx-0.3.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
610 return;
1af2fcb3be8a nginx-0.3.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
611 }
1af2fcb3be8a nginx-0.3.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
612
1af2fcb3be8a nginx-0.3.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
613 ngx_memcpy(s->login.data, ctx->header_start, s->login.len);
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
614
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
615 continue;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
616 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
617
800
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
618 if (len == sizeof("Auth-Pass") - 1
1107
db7c468c447d ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents: 906
diff changeset
619 && ngx_strncasecmp(ctx->header_name_start,
db7c468c447d ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents: 906
diff changeset
620 (u_char *) "Auth-Pass",
db7c468c447d ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents: 906
diff changeset
621 sizeof("Auth-Pass") - 1)
db7c468c447d ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents: 906
diff changeset
622 == 0)
800
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
623 {
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
624 s->passwd.len = ctx->header_end - ctx->header_start;
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
625
2049
2a92804f4109 *) back out r2040
Igor Sysoev <igor@sysoev.ru>
parents: 1640
diff changeset
626 s->passwd.data = ngx_pnalloc(s->connection->pool,
2a92804f4109 *) back out r2040
Igor Sysoev <igor@sysoev.ru>
parents: 1640
diff changeset
627 s->passwd.len);
800
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
628 if (s->passwd.data == NULL) {
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
629 ngx_close_connection(ctx->peer.connection);
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
630 ngx_destroy_pool(ctx->pool);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
631 ngx_mail_session_internal_server_error(s);
800
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
632 return;
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
633 }
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
634
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
635 ngx_memcpy(s->passwd.data, ctx->header_start, s->passwd.len);
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
636
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
637 continue;
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
638 }
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
639
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
640 if (len == sizeof("Auth-Wait") - 1
1107
db7c468c447d ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents: 906
diff changeset
641 && ngx_strncasecmp(ctx->header_name_start,
db7c468c447d ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents: 906
diff changeset
642 (u_char *) "Auth-Wait",
db7c468c447d ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents: 906
diff changeset
643 sizeof("Auth-Wait") - 1)
db7c468c447d ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents: 906
diff changeset
644 == 0)
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
645 {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
646 n = ngx_atoi(ctx->header_start,
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
647 ctx->header_end - ctx->header_start);
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
648
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
649 if (n != NGX_ERROR) {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
650 ctx->sleep = n;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
651 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
652
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
653 continue;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
654 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
655
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
656 if (len == sizeof("Auth-Error-Code") - 1
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
657 && ngx_strncasecmp(ctx->header_name_start,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
658 (u_char *) "Auth-Error-Code",
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
659 sizeof("Auth-Error-Code") - 1)
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
660 == 0)
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
661 {
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
662 ctx->errcode.len = ctx->header_end - ctx->header_start;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
663
2049
2a92804f4109 *) back out r2040
Igor Sysoev <igor@sysoev.ru>
parents: 1640
diff changeset
664 ctx->errcode.data = ngx_pnalloc(s->connection->pool,
2a92804f4109 *) back out r2040
Igor Sysoev <igor@sysoev.ru>
parents: 1640
diff changeset
665 ctx->errcode.len);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
666 if (ctx->errcode.data == NULL) {
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
667 ngx_close_connection(ctx->peer.connection);
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
668 ngx_destroy_pool(ctx->pool);
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
669 ngx_mail_session_internal_server_error(s);
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
670 return;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
671 }
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
672
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
673 ngx_memcpy(ctx->errcode.data, ctx->header_start,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
674 ctx->errcode.len);
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
675
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
676 continue;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
677 }
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
678
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
679 /* ignore other headers */
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
680
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
681 continue;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
682 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
683
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
684 if (rc == NGX_DONE) {
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
685 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, s->connection->log, 0,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
686 "mail auth http header done");
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
687
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
688 ngx_close_connection(ctx->peer.connection);
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
689
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
690 if (ctx->err.len) {
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
691
567
1af2fcb3be8a nginx-0.3.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
692 ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
1af2fcb3be8a nginx-0.3.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
693 "client login failed: \"%V\"", &ctx->errmsg);
1af2fcb3be8a nginx-0.3.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
694
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
695 if (s->protocol == NGX_MAIL_SMTP_PROTOCOL) {
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
696
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
697 if (ctx->errcode.len == 0) {
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
698 ctx->errcode = ngx_mail_smtp_errcode;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
699 }
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
700
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
701 ctx->err.len = ctx->errcode.len + ctx->errmsg.len
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
702 + sizeof(" " CRLF) - 1;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
703
2049
2a92804f4109 *) back out r2040
Igor Sysoev <igor@sysoev.ru>
parents: 1640
diff changeset
704 p = ngx_pnalloc(s->connection->pool, ctx->err.len);
1166
bde5e4134759 style fix: remove tabs
Igor Sysoev <igor@sysoev.ru>
parents: 1136
diff changeset
705 if (p == NULL) {
bde5e4134759 style fix: remove tabs
Igor Sysoev <igor@sysoev.ru>
parents: 1136
diff changeset
706 ngx_destroy_pool(ctx->pool);
bde5e4134759 style fix: remove tabs
Igor Sysoev <igor@sysoev.ru>
parents: 1136
diff changeset
707 ngx_mail_session_internal_server_error(s);
bde5e4134759 style fix: remove tabs
Igor Sysoev <igor@sysoev.ru>
parents: 1136
diff changeset
708 return;
bde5e4134759 style fix: remove tabs
Igor Sysoev <igor@sysoev.ru>
parents: 1136
diff changeset
709 }
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
710
1166
bde5e4134759 style fix: remove tabs
Igor Sysoev <igor@sysoev.ru>
parents: 1136
diff changeset
711 ctx->err.data = p;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
712
1166
bde5e4134759 style fix: remove tabs
Igor Sysoev <igor@sysoev.ru>
parents: 1136
diff changeset
713 p = ngx_cpymem(p, ctx->errcode.data, ctx->errcode.len);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
714 *p++ = ' ';
1166
bde5e4134759 style fix: remove tabs
Igor Sysoev <igor@sysoev.ru>
parents: 1136
diff changeset
715 p = ngx_cpymem(p, ctx->errmsg.data, ctx->errmsg.len);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
716 *p++ = CR; *p = LF;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
717 }
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
718
539
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 527
diff changeset
719 s->out = ctx->err;
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
720 timer = ctx->sleep;
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
721
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
722 ngx_destroy_pool(ctx->pool);
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
723
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
724 if (timer == 0) {
539
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 527
diff changeset
725 s->quit = 1;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
726 ngx_mail_send(s->connection->write);
541
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
727 return;
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
728 }
539
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 527
diff changeset
729
1640
02a22cd5282a 64-bit time_t compatibility
Igor Sysoev <igor@sysoev.ru>
parents: 1559
diff changeset
730 ngx_add_timer(s->connection->read, (ngx_msec_t) (timer * 1000));
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
731
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
732 s->connection->read->handler = ngx_mail_auth_sleep_handler;
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
733
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
734 return;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
735 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
736
883
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
737 if (s->auth_wait) {
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
738 timer = ctx->sleep;
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
739
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
740 ngx_destroy_pool(ctx->pool);
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
741
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
742 if (timer == 0) {
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
743 ngx_mail_auth_http_init(s);
883
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
744 return;
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
745 }
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
746
1640
02a22cd5282a 64-bit time_t compatibility
Igor Sysoev <igor@sysoev.ru>
parents: 1559
diff changeset
747 ngx_add_timer(s->connection->read, (ngx_msec_t) (timer * 1000));
883
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
748
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
749 s->connection->read->handler = ngx_mail_auth_sleep_handler;
883
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
750
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
751 return;
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
752 }
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
753
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
754 if (ctx->addr.len == 0 || ctx->port.len == 0) {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
755 ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
541
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
756 "auth http server %V did not send server or port",
884
4d68c486fcb0 upstream choice modules
Igor Sysoev <igor@sysoev.ru>
parents: 883
diff changeset
757 ctx->peer.name);
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
758 ngx_destroy_pool(ctx->pool);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
759 ngx_mail_session_internal_server_error(s);
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
760 return;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
761 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
762
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1478
diff changeset
763 if (s->passwd.data == NULL
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1478
diff changeset
764 && s->protocol != NGX_MAIL_SMTP_PROTOCOL)
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
765 {
800
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
766 ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
767 "auth http server %V did not send password",
884
4d68c486fcb0 upstream choice modules
Igor Sysoev <igor@sysoev.ru>
parents: 883
diff changeset
768 ctx->peer.name);
800
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
769 ngx_destroy_pool(ctx->pool);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
770 ngx_mail_session_internal_server_error(s);
800
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
771 return;
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
772 }
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
773
3269
f0d596e84634 rename ngx_peer_addr_t to ngx_addr_t
Igor Sysoev <igor@sysoev.ru>
parents: 3267
diff changeset
774 peer = ngx_pcalloc(s->connection->pool, sizeof(ngx_addr_t));
884
4d68c486fcb0 upstream choice modules
Igor Sysoev <igor@sysoev.ru>
parents: 883
diff changeset
775 if (peer == NULL) {
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
776 ngx_destroy_pool(ctx->pool);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
777 ngx_mail_session_internal_server_error(s);
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
778 return;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
779 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
780
5134
c788e54090de Mail: IPv6 backends (ticket #323).
Ruslan Ermilov <ru@nginx.com>
parents: 4971
diff changeset
781 rc = ngx_parse_addr(s->connection->pool, peer,
c788e54090de Mail: IPv6 backends (ticket #323).
Ruslan Ermilov <ru@nginx.com>
parents: 4971
diff changeset
782 ctx->addr.data, ctx->addr.len);
c788e54090de Mail: IPv6 backends (ticket #323).
Ruslan Ermilov <ru@nginx.com>
parents: 4971
diff changeset
783
c788e54090de Mail: IPv6 backends (ticket #323).
Ruslan Ermilov <ru@nginx.com>
parents: 4971
diff changeset
784 switch (rc) {
c788e54090de Mail: IPv6 backends (ticket #323).
Ruslan Ermilov <ru@nginx.com>
parents: 4971
diff changeset
785 case NGX_OK:
c788e54090de Mail: IPv6 backends (ticket #323).
Ruslan Ermilov <ru@nginx.com>
parents: 4971
diff changeset
786 break;
2855
a96a8c916b0c mail proxy listen IPv6 support
Igor Sysoev <igor@sysoev.ru>
parents: 2748
diff changeset
787
5134
c788e54090de Mail: IPv6 backends (ticket #323).
Ruslan Ermilov <ru@nginx.com>
parents: 4971
diff changeset
788 case NGX_DECLINED:
c788e54090de Mail: IPv6 backends (ticket #323).
Ruslan Ermilov <ru@nginx.com>
parents: 4971
diff changeset
789 ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
c788e54090de Mail: IPv6 backends (ticket #323).
Ruslan Ermilov <ru@nginx.com>
parents: 4971
diff changeset
790 "auth http server %V sent invalid server "
c788e54090de Mail: IPv6 backends (ticket #323).
Ruslan Ermilov <ru@nginx.com>
parents: 4971
diff changeset
791 "address:\"%V\"",
c788e54090de Mail: IPv6 backends (ticket #323).
Ruslan Ermilov <ru@nginx.com>
parents: 4971
diff changeset
792 ctx->peer.name, &ctx->addr);
c788e54090de Mail: IPv6 backends (ticket #323).
Ruslan Ermilov <ru@nginx.com>
parents: 4971
diff changeset
793 /* fall through */
c788e54090de Mail: IPv6 backends (ticket #323).
Ruslan Ermilov <ru@nginx.com>
parents: 4971
diff changeset
794
c788e54090de Mail: IPv6 backends (ticket #323).
Ruslan Ermilov <ru@nginx.com>
parents: 4971
diff changeset
795 default:
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
796 ngx_destroy_pool(ctx->pool);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
797 ngx_mail_session_internal_server_error(s);
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
798 return;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
799 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
800
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
801 port = ngx_atoi(ctx->port.data, ctx->port.len);
4227
4af8ea9c3a86 Fixed port range checking.
Ruslan Ermilov <ru@nginx.com>
parents: 3516
diff changeset
802 if (port == NGX_ERROR || port < 1 || port > 65535) {
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
803 ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
541
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
804 "auth http server %V sent invalid server "
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
805 "port:\"%V\"",
884
4d68c486fcb0 upstream choice modules
Igor Sysoev <igor@sysoev.ru>
parents: 883
diff changeset
806 ctx->peer.name, &ctx->port);
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
807 ngx_destroy_pool(ctx->pool);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
808 ngx_mail_session_internal_server_error(s);
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
809 return;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
810 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
811
6593
b3b7e33083ac Introduced ngx_inet_get_port() and ngx_inet_set_port() functions.
Roman Arutyunyan <arut@nginx.com>
parents: 6480
diff changeset
812 ngx_inet_set_port(peer->sockaddr, port);
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
813
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
814 len = ctx->addr.len + 1 + ctx->port.len;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
815
884
4d68c486fcb0 upstream choice modules
Igor Sysoev <igor@sysoev.ru>
parents: 883
diff changeset
816 peer->name.len = len;
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
817
2049
2a92804f4109 *) back out r2040
Igor Sysoev <igor@sysoev.ru>
parents: 1640
diff changeset
818 peer->name.data = ngx_pnalloc(s->connection->pool, len);
884
4d68c486fcb0 upstream choice modules
Igor Sysoev <igor@sysoev.ru>
parents: 883
diff changeset
819 if (peer->name.data == NULL) {
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
820 ngx_destroy_pool(ctx->pool);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
821 ngx_mail_session_internal_server_error(s);
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
822 return;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
823 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
824
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
825 len = ctx->addr.len;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
826
884
4d68c486fcb0 upstream choice modules
Igor Sysoev <igor@sysoev.ru>
parents: 883
diff changeset
827 ngx_memcpy(peer->name.data, ctx->addr.data, len);
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
828
884
4d68c486fcb0 upstream choice modules
Igor Sysoev <igor@sysoev.ru>
parents: 883
diff changeset
829 peer->name.data[len++] = ':';
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
830
884
4d68c486fcb0 upstream choice modules
Igor Sysoev <igor@sysoev.ru>
parents: 883
diff changeset
831 ngx_memcpy(peer->name.data + len, ctx->port.data, ctx->port.len);
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
832
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
833 ngx_destroy_pool(ctx->pool);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
834 ngx_mail_proxy_init(s, peer);
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
835
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
836 return;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
837 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
838
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
839 if (rc == NGX_AGAIN ) {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
840 return;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
841 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
842
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
843 /* rc == NGX_ERROR */
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
844
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
845 ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
541
b09ee85d0ac8 nginx-0.1.45-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
846 "auth http server %V sent invalid header in response",
884
4d68c486fcb0 upstream choice modules
Igor Sysoev <igor@sysoev.ru>
parents: 883
diff changeset
847 ctx->peer.name);
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
848 ngx_close_connection(ctx->peer.connection);
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
849 ngx_destroy_pool(ctx->pool);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
850 ngx_mail_session_internal_server_error(s);
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
851
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
852 return;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
853 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
854 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
855
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
856
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
857 static void
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
858 ngx_mail_auth_sleep_handler(ngx_event_t *rev)
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
859 {
543
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 541
diff changeset
860 ngx_connection_t *c;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
861 ngx_mail_session_t *s;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
862 ngx_mail_core_srv_conf_t *cscf;
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
863
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
864 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, rev->log, 0, "mail auth sleep handler");
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
865
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
866 c = rev->data;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
867 s = c->data;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
868
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
869 if (rev->timedout) {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
870
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
871 rev->timedout = 0;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
872
883
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
873 if (s->auth_wait) {
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
874 s->auth_wait = 0;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
875 ngx_mail_auth_http_init(s);
883
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
876 return;
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
877 }
eac23634d614 Auth-Status: WAIT
Igor Sysoev <igor@sysoev.ru>
parents: 862
diff changeset
878
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1478
diff changeset
879 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module);
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
880
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1478
diff changeset
881 rev->handler = cscf->protocol->auth_state;
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1478
diff changeset
882
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1478
diff changeset
883 s->mail_state = 0;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
884 s->auth_method = NGX_MAIL_AUTH_PLAIN;
800
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
885
543
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 541
diff changeset
886 c->log->action = "in auth state";
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 541
diff changeset
887
1477
59e1caf2be94 style fix and optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1405
diff changeset
888 ngx_mail_send(c->write);
543
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 541
diff changeset
889
583
4e296b7d25bf nginx-0.3.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 577
diff changeset
890 if (c->destroyed) {
543
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 541
diff changeset
891 return;
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 541
diff changeset
892 }
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 541
diff changeset
893
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 541
diff changeset
894 ngx_add_timer(rev, cscf->timeout);
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 541
diff changeset
895
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
896 if (rev->ready) {
1477
59e1caf2be94 style fix and optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1405
diff changeset
897 rev->handler(rev);
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
898 return;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
899 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
900
2388
722b5aff05ae use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents: 2310
diff changeset
901 if (ngx_handle_read_event(rev, 0) != NGX_OK) {
1477
59e1caf2be94 style fix and optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1405
diff changeset
902 ngx_mail_close_connection(c);
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
903 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
904
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
905 return;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
906 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
907
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
908 if (rev->active) {
2388
722b5aff05ae use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents: 2310
diff changeset
909 if (ngx_handle_read_event(rev, 0) != NGX_OK) {
1477
59e1caf2be94 style fix and optimizations
Igor Sysoev <igor@sysoev.ru>
parents: 1405
diff changeset
910 ngx_mail_close_connection(c);
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
911 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
912 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
913 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
914
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
915
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
916 static ngx_int_t
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
917 ngx_mail_auth_http_parse_header_line(ngx_mail_session_t *s,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
918 ngx_mail_auth_http_ctx_t *ctx)
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
919 {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
920 u_char c, ch, *p;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
921 enum {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
922 sw_start = 0,
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
923 sw_name,
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
924 sw_space_before_value,
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
925 sw_value,
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
926 sw_space_after_value,
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
927 sw_almost_done,
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
928 sw_header_almost_done
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
929 } state;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
930
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
931 state = ctx->state;
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
932
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
933 for (p = ctx->response->pos; p < ctx->response->last; p++) {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
934 ch = *p;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
935
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
936 switch (state) {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
937
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
938 /* first char */
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
939 case sw_start:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
940
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
941 switch (ch) {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
942 case CR:
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
943 ctx->header_end = p;
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
944 state = sw_header_almost_done;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
945 break;
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
946 case LF:
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
947 ctx->header_end = p;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
948 goto header_done;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
949 default:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
950 state = sw_name;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
951 ctx->header_name_start = p;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
952
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
953 c = (u_char) (ch | 0x20);
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
954 if (c >= 'a' && c <= 'z') {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
955 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
956 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
957
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
958 if (ch >= '0' && ch <= '9') {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
959 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
960 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
961
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
962 return NGX_ERROR;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
963 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
964 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
965
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
966 /* header name */
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
967 case sw_name:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
968 c = (u_char) (ch | 0x20);
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
969 if (c >= 'a' && c <= 'z') {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
970 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
971 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
972
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
973 if (ch == ':') {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
974 ctx->header_name_end = p;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
975 state = sw_space_before_value;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
976 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
977 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
978
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
979 if (ch == '-') {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
980 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
981 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
982
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
983 if (ch >= '0' && ch <= '9') {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
984 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
985 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
986
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
987 if (ch == CR) {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
988 ctx->header_name_end = p;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
989 ctx->header_start = p;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
990 ctx->header_end = p;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
991 state = sw_almost_done;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
992 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
993 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
994
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
995 if (ch == LF) {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
996 ctx->header_name_end = p;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
997 ctx->header_start = p;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
998 ctx->header_end = p;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
999 goto done;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1000 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1001
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1002 return NGX_ERROR;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1003
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1004 /* space* before header value */
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1005 case sw_space_before_value:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1006 switch (ch) {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1007 case ' ':
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1008 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1009 case CR:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1010 ctx->header_start = p;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1011 ctx->header_end = p;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1012 state = sw_almost_done;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1013 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1014 case LF:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1015 ctx->header_start = p;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1016 ctx->header_end = p;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1017 goto done;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1018 default:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1019 ctx->header_start = p;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1020 state = sw_value;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1021 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1022 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1023 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1024
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1025 /* header value */
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1026 case sw_value:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1027 switch (ch) {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1028 case ' ':
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1029 ctx->header_end = p;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1030 state = sw_space_after_value;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1031 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1032 case CR:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1033 ctx->header_end = p;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1034 state = sw_almost_done;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1035 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1036 case LF:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1037 ctx->header_end = p;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1038 goto done;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1039 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1040 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1041
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1042 /* space* before end of header line */
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1043 case sw_space_after_value:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1044 switch (ch) {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1045 case ' ':
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1046 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1047 case CR:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1048 state = sw_almost_done;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1049 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1050 case LF:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1051 goto done;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1052 default:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1053 state = sw_value;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1054 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1055 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1056 break;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1057
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1058 /* end of header line */
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1059 case sw_almost_done:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1060 switch (ch) {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1061 case LF:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1062 goto done;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1063 default:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1064 return NGX_ERROR;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1065 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1066
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1067 /* end of header */
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1068 case sw_header_almost_done:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1069 switch (ch) {
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1070 case LF:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1071 goto header_done;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1072 default:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1073 return NGX_ERROR;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1074 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1075 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1076 }
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1077
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1078 ctx->response->pos = p;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1079 ctx->state = state;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1080
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1081 return NGX_AGAIN;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1082
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1083 done:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1084
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1085 ctx->response->pos = p + 1;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1086 ctx->state = sw_start;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1087
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1088 return NGX_OK;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1089
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1090 header_done:
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1091
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1092 ctx->response->pos = p + 1;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1093 ctx->state = sw_start;
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1094
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1095 return NGX_DONE;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1096 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1097
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1098
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1099 static void
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1100 ngx_mail_auth_http_block_read(ngx_event_t *rev)
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1101 {
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1102 ngx_connection_t *c;
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1103 ngx_mail_session_t *s;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1104 ngx_mail_auth_http_ctx_t *ctx;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1105
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1106 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, rev->log, 0,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1107 "mail auth http block read");
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1108
2388
722b5aff05ae use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents: 2310
diff changeset
1109 if (ngx_handle_read_event(rev, 0) != NGX_OK) {
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1110 c = rev->data;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1111 s = c->data;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1112
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1113 ctx = ngx_mail_get_module_ctx(s, ngx_mail_auth_http_module);
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1114
525
09b42134ac0c nginx-0.1.37-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
1115 ngx_close_connection(ctx->peer.connection);
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
1116 ngx_destroy_pool(ctx->pool);
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1117 ngx_mail_session_internal_server_error(s);
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1118 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1119 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1120
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1121
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1122 static void
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1123 ngx_mail_auth_http_dummy_handler(ngx_event_t *ev)
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1124 {
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1125 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, ev->log, 0,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1126 "mail auth http dummy handler");
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1127 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1128
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1129
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1130 static ngx_buf_t *
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1131 ngx_mail_auth_http_create_request(ngx_mail_session_t *s, ngx_pool_t *pool,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1132 ngx_mail_auth_http_conf_t *ahcf)
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1133 {
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1478
diff changeset
1134 size_t len;
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1478
diff changeset
1135 ngx_buf_t *b;
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1478
diff changeset
1136 ngx_str_t login, passwd;
5989
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1137 #if (NGX_MAIL_SSL)
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1138 ngx_str_t verify, subject, issuer, serial, fingerprint,
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1139 raw_cert, cert;
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1140 ngx_connection_t *c;
5990
6a7c6973d6fc Mail: don't emit Auth-SSL-Verify with disabled ssl_verify_client.
Sergey Kandaurov <pluknet@nginx.com>
parents: 5989
diff changeset
1141 ngx_mail_ssl_conf_t *sslcf;
5989
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1142 #endif
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1478
diff changeset
1143 ngx_mail_core_srv_conf_t *cscf;
633
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1144
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1145 if (ngx_mail_auth_http_escape(pool, &s->login, &login) != NGX_OK) {
633
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1146 return NULL;
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1147 }
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1148
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1149 if (ngx_mail_auth_http_escape(pool, &s->passwd, &passwd) != NGX_OK) {
633
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1150 return NULL;
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1151 }
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1152
5989
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1153 #if (NGX_MAIL_SSL)
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1154
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1155 c = s->connection;
5990
6a7c6973d6fc Mail: don't emit Auth-SSL-Verify with disabled ssl_verify_client.
Sergey Kandaurov <pluknet@nginx.com>
parents: 5989
diff changeset
1156 sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module);
5989
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1157
5990
6a7c6973d6fc Mail: don't emit Auth-SSL-Verify with disabled ssl_verify_client.
Sergey Kandaurov <pluknet@nginx.com>
parents: 5989
diff changeset
1158 if (c->ssl && sslcf->verify) {
5989
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1159
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1160 /* certificate details */
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1161
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1162 if (ngx_ssl_get_client_verify(c, pool, &verify) != NGX_OK) {
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1163 return NULL;
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1164 }
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1165
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1166 if (ngx_ssl_get_subject_dn(c, pool, &subject) != NGX_OK) {
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1167 return NULL;
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1168 }
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1169
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1170 if (ngx_ssl_get_issuer_dn(c, pool, &issuer) != NGX_OK) {
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1171 return NULL;
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1172 }
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1173
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1174 if (ngx_ssl_get_serial_number(c, pool, &serial) != NGX_OK) {
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1175 return NULL;
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1176 }
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1177
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1178 if (ngx_ssl_get_fingerprint(c, pool, &fingerprint) != NGX_OK) {
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1179 return NULL;
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1180 }
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1181
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1182 if (ahcf->pass_client_cert) {
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1183
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1184 /* certificate itself, if configured */
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1185
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1186 if (ngx_ssl_get_raw_certificate(c, pool, &raw_cert) != NGX_OK) {
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1187 return NULL;
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1188 }
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1189
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1190 if (ngx_mail_auth_http_escape(pool, &raw_cert, &cert) != NGX_OK) {
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1191 return NULL;
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1192 }
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1193
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1194 } else {
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1195 ngx_str_null(&cert);
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1196 }
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1197
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1198 } else {
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1199 ngx_str_null(&verify);
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1200 ngx_str_null(&subject);
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1201 ngx_str_null(&issuer);
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1202 ngx_str_null(&serial);
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1203 ngx_str_null(&fingerprint);
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1204 ngx_str_null(&cert);
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1205 }
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1206
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1207 #endif
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1208
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1478
diff changeset
1209 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module);
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1478
diff changeset
1210
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1211 len = sizeof("GET ") - 1 + ahcf->uri.len + sizeof(" HTTP/1.0" CRLF) - 1
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1212 + sizeof("Host: ") - 1 + ahcf->host_header.len + sizeof(CRLF) - 1
856
0197d6aae54e use correct auth method length
Igor Sysoev <igor@sysoev.ru>
parents: 854
diff changeset
1213 + sizeof("Auth-Method: ") - 1
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1214 + ngx_mail_auth_http_method[s->auth_method].len
856
0197d6aae54e use correct auth method length
Igor Sysoev <igor@sysoev.ru>
parents: 854
diff changeset
1215 + sizeof(CRLF) - 1
633
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1216 + sizeof("Auth-User: ") - 1 + login.len + sizeof(CRLF) - 1
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1217 + sizeof("Auth-Pass: ") - 1 + passwd.len + sizeof(CRLF) - 1
800
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
1218 + sizeof("Auth-Salt: ") - 1 + s->salt.len
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1478
diff changeset
1219 + sizeof("Auth-Protocol: ") - 1 + cscf->protocol->name.len
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1478
diff changeset
1220 + sizeof(CRLF) - 1
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1221 + sizeof("Auth-Login-Attempt: ") - 1 + NGX_INT_T_LEN
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1222 + sizeof(CRLF) - 1
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1223 + sizeof("Client-IP: ") - 1 + s->connection->addr_text.len
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1224 + sizeof(CRLF) - 1
2309
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1225 + sizeof("Client-Host: ") - 1 + s->host.len + sizeof(CRLF) - 1
5987
62c098eb4509 Mail: fixed buffer allocation for CRLF after Auth-SMTP-* headers.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5685
diff changeset
1226 + sizeof("Auth-SMTP-Helo: ") - 1 + s->smtp_helo.len + sizeof(CRLF) - 1
62c098eb4509 Mail: fixed buffer allocation for CRLF after Auth-SMTP-* headers.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5685
diff changeset
1227 + sizeof("Auth-SMTP-From: ") - 1 + s->smtp_from.len + sizeof(CRLF) - 1
62c098eb4509 Mail: fixed buffer allocation for CRLF after Auth-SMTP-* headers.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5685
diff changeset
1228 + sizeof("Auth-SMTP-To: ") - 1 + s->smtp_to.len + sizeof(CRLF) - 1
5988
3b3f789655dc Mail: added Auth-SSL header to indicate SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5987
diff changeset
1229 #if (NGX_MAIL_SSL)
3b3f789655dc Mail: added Auth-SSL header to indicate SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5987
diff changeset
1230 + sizeof("Auth-SSL: on" CRLF) - 1
5989
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1231 + sizeof("Auth-SSL-Verify: ") - 1 + verify.len + sizeof(CRLF) - 1
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1232 + sizeof("Auth-SSL-Subject: ") - 1 + subject.len + sizeof(CRLF) - 1
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1233 + sizeof("Auth-SSL-Issuer: ") - 1 + issuer.len + sizeof(CRLF) - 1
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1234 + sizeof("Auth-SSL-Serial: ") - 1 + serial.len + sizeof(CRLF) - 1
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1235 + sizeof("Auth-SSL-Fingerprint: ") - 1 + fingerprint.len
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1236 + sizeof(CRLF) - 1
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1237 + sizeof("Auth-SSL-Cert: ") - 1 + cert.len + sizeof(CRLF) - 1
5988
3b3f789655dc Mail: added Auth-SSL header to indicate SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5987
diff changeset
1238 #endif
1285
0c10dc6a8e74 fix memory allocation for auth_http_header
Igor Sysoev <igor@sysoev.ru>
parents: 1166
diff changeset
1239 + ahcf->header.len
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1240 + sizeof(CRLF) - 1;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1241
547
818fbd4750b9 nginx-0.2.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
1242 b = ngx_create_temp_buf(pool, len);
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1243 if (b == NULL) {
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1244 return NULL;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1245 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1246
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1247 b->last = ngx_cpymem(b->last, "GET ", sizeof("GET ") - 1);
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1248 b->last = ngx_copy(b->last, ahcf->uri.data, ahcf->uri.len);
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1249 b->last = ngx_cpymem(b->last, " HTTP/1.0" CRLF,
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1250 sizeof(" HTTP/1.0" CRLF) - 1);
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1251
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1252 b->last = ngx_cpymem(b->last, "Host: ", sizeof("Host: ") - 1);
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1253 b->last = ngx_copy(b->last, ahcf->host_header.data,
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1254 ahcf->host_header.len);
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1255 *b->last++ = CR; *b->last++ = LF;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1256
800
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
1257 b->last = ngx_cpymem(b->last, "Auth-Method: ",
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
1258 sizeof("Auth-Method: ") - 1);
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
1259 b->last = ngx_cpymem(b->last,
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1260 ngx_mail_auth_http_method[s->auth_method].data,
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1261 ngx_mail_auth_http_method[s->auth_method].len);
800
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
1262 *b->last++ = CR; *b->last++ = LF;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1263
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1264 b->last = ngx_cpymem(b->last, "Auth-User: ", sizeof("Auth-User: ") - 1);
633
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1265 b->last = ngx_copy(b->last, login.data, login.len);
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1266 *b->last++ = CR; *b->last++ = LF;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1267
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1268 b->last = ngx_cpymem(b->last, "Auth-Pass: ", sizeof("Auth-Pass: ") - 1);
633
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1269 b->last = ngx_copy(b->last, passwd.data, passwd.len);
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1270 *b->last++ = CR; *b->last++ = LF;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1271
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1272 if (s->auth_method != NGX_MAIL_AUTH_PLAIN && s->salt.len) {
800
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
1273 b->last = ngx_cpymem(b->last, "Auth-Salt: ", sizeof("Auth-Salt: ") - 1);
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
1274 b->last = ngx_copy(b->last, s->salt.data, s->salt.len);
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
1275
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
1276 s->passwd.data = NULL;
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
1277 }
Igor Sysoev <igor@sysoev.ru>
parents: 799
diff changeset
1278
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1279 b->last = ngx_cpymem(b->last, "Auth-Protocol: ",
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1280 sizeof("Auth-Protocol: ") - 1);
1487
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1478
diff changeset
1281 b->last = ngx_cpymem(b->last, cscf->protocol->name.data,
f69493e8faab ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents: 1478
diff changeset
1282 cscf->protocol->name.len);
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1283 *b->last++ = CR; *b->last++ = LF;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1284
527
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1285 b->last = ngx_sprintf(b->last, "Auth-Login-Attempt: %ui" CRLF,
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1286 s->login_attempt);
7fa11e5c6e96 nginx-0.1.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 525
diff changeset
1287
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1288 b->last = ngx_cpymem(b->last, "Client-IP: ", sizeof("Client-IP: ") - 1);
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1289 b->last = ngx_copy(b->last, s->connection->addr_text.data,
2309
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1290 s->connection->addr_text.len);
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1291 *b->last++ = CR; *b->last++ = LF;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1292
2309
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1293 if (s->host.len) {
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1294 b->last = ngx_cpymem(b->last, "Client-Host: ",
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1295 sizeof("Client-Host: ") - 1);
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1296 b->last = ngx_copy(b->last, s->host.data, s->host.len);
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1297 *b->last++ = CR; *b->last++ = LF;
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1298 }
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1299
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1300 if (s->auth_method == NGX_MAIL_AUTH_NONE) {
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1301
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1302 /* HELO, MAIL FROM, and RCPT TO can't contain CRLF, no need to escape */
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1303
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1304 b->last = ngx_cpymem(b->last, "Auth-SMTP-Helo: ",
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1305 sizeof("Auth-SMTP-Helo: ") - 1);
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1306 b->last = ngx_copy(b->last, s->smtp_helo.data, s->smtp_helo.len);
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1307 *b->last++ = CR; *b->last++ = LF;
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1308
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1309 b->last = ngx_cpymem(b->last, "Auth-SMTP-From: ",
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1310 sizeof("Auth-SMTP-From: ") - 1);
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1311 b->last = ngx_copy(b->last, s->smtp_from.data, s->smtp_from.len);
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1312 *b->last++ = CR; *b->last++ = LF;
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1313
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1314 b->last = ngx_cpymem(b->last, "Auth-SMTP-To: ",
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1315 sizeof("Auth-SMTP-To: ") - 1);
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1316 b->last = ngx_copy(b->last, s->smtp_to.data, s->smtp_to.len);
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1317 *b->last++ = CR; *b->last++ = LF;
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1318
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1319 }
8156bc03982a smtp_auth none
Igor Sysoev <igor@sysoev.ru>
parents: 2061
diff changeset
1320
5988
3b3f789655dc Mail: added Auth-SSL header to indicate SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5987
diff changeset
1321 #if (NGX_MAIL_SSL)
3b3f789655dc Mail: added Auth-SSL header to indicate SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5987
diff changeset
1322
5989
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1323 if (c->ssl) {
5988
3b3f789655dc Mail: added Auth-SSL header to indicate SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5987
diff changeset
1324 b->last = ngx_cpymem(b->last, "Auth-SSL: on" CRLF,
3b3f789655dc Mail: added Auth-SSL header to indicate SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5987
diff changeset
1325 sizeof("Auth-SSL: on" CRLF) - 1);
5989
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1326
5990
6a7c6973d6fc Mail: don't emit Auth-SSL-Verify with disabled ssl_verify_client.
Sergey Kandaurov <pluknet@nginx.com>
parents: 5989
diff changeset
1327 if (verify.len) {
6a7c6973d6fc Mail: don't emit Auth-SSL-Verify with disabled ssl_verify_client.
Sergey Kandaurov <pluknet@nginx.com>
parents: 5989
diff changeset
1328 b->last = ngx_cpymem(b->last, "Auth-SSL-Verify: ",
6a7c6973d6fc Mail: don't emit Auth-SSL-Verify with disabled ssl_verify_client.
Sergey Kandaurov <pluknet@nginx.com>
parents: 5989
diff changeset
1329 sizeof("Auth-SSL-Verify: ") - 1);
6a7c6973d6fc Mail: don't emit Auth-SSL-Verify with disabled ssl_verify_client.
Sergey Kandaurov <pluknet@nginx.com>
parents: 5989
diff changeset
1330 b->last = ngx_copy(b->last, verify.data, verify.len);
6a7c6973d6fc Mail: don't emit Auth-SSL-Verify with disabled ssl_verify_client.
Sergey Kandaurov <pluknet@nginx.com>
parents: 5989
diff changeset
1331 *b->last++ = CR; *b->last++ = LF;
6a7c6973d6fc Mail: don't emit Auth-SSL-Verify with disabled ssl_verify_client.
Sergey Kandaurov <pluknet@nginx.com>
parents: 5989
diff changeset
1332 }
5989
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1333
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1334 if (subject.len) {
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1335 b->last = ngx_cpymem(b->last, "Auth-SSL-Subject: ",
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1336 sizeof("Auth-SSL-Subject: ") - 1);
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1337 b->last = ngx_copy(b->last, subject.data, subject.len);
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1338 *b->last++ = CR; *b->last++ = LF;
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1339 }
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1340
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1341 if (issuer.len) {
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1342 b->last = ngx_cpymem(b->last, "Auth-SSL-Issuer: ",
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1343 sizeof("Auth-SSL-Issuer: ") - 1);
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1344 b->last = ngx_copy(b->last, issuer.data, issuer.len);
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1345 *b->last++ = CR; *b->last++ = LF;
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1346 }
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1347
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1348 if (serial.len) {
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1349 b->last = ngx_cpymem(b->last, "Auth-SSL-Serial: ",
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1350 sizeof("Auth-SSL-Serial: ") - 1);
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1351 b->last = ngx_copy(b->last, serial.data, serial.len);
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1352 *b->last++ = CR; *b->last++ = LF;
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1353 }
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1354
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1355 if (fingerprint.len) {
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1356 b->last = ngx_cpymem(b->last, "Auth-SSL-Fingerprint: ",
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1357 sizeof("Auth-SSL-Fingerprint: ") - 1);
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1358 b->last = ngx_copy(b->last, fingerprint.data, fingerprint.len);
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1359 *b->last++ = CR; *b->last++ = LF;
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1360 }
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1361
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1362 if (cert.len) {
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1363 b->last = ngx_cpymem(b->last, "Auth-SSL-Cert: ",
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1364 sizeof("Auth-SSL-Cert: ") - 1);
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1365 b->last = ngx_copy(b->last, cert.data, cert.len);
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1366 *b->last++ = CR; *b->last++ = LF;
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1367 }
5988
3b3f789655dc Mail: added Auth-SSL header to indicate SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5987
diff changeset
1368 }
3b3f789655dc Mail: added Auth-SSL header to indicate SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5987
diff changeset
1369
3b3f789655dc Mail: added Auth-SSL header to indicate SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5987
diff changeset
1370 #endif
3b3f789655dc Mail: added Auth-SSL header to indicate SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5987
diff changeset
1371
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1372 if (ahcf->header.len) {
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1373 b->last = ngx_copy(b->last, ahcf->header.data, ahcf->header.len);
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1374 }
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1375
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1376 /* add "\r\n" at the header end */
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1377 *b->last++ = CR; *b->last++ = LF;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1378
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1379 #if (NGX_DEBUG_MAIL_PASSWD)
6001
add12ee1d01c Style: use %*s format, as in 68d21fd1dc64.
Ruslan Ermilov <ru@nginx.com>
parents: 5990
diff changeset
1380 ngx_log_debug2(NGX_LOG_DEBUG_MAIL, s->connection->log, 0,
add12ee1d01c Style: use %*s format, as in 68d21fd1dc64.
Ruslan Ermilov <ru@nginx.com>
parents: 5990
diff changeset
1381 "mail auth http header:%N\"%*s\"",
add12ee1d01c Style: use %*s format, as in 68d21fd1dc64.
Ruslan Ermilov <ru@nginx.com>
parents: 5990
diff changeset
1382 (size_t) (b->last - b->pos), b->pos);
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1383 #endif
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1384
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1385 return b;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1386 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1387
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1388
633
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1389 static ngx_int_t
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1390 ngx_mail_auth_http_escape(ngx_pool_t *pool, ngx_str_t *text, ngx_str_t *escaped)
633
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1391 {
1405
fdd064faf26a escape " ", "%", and %00-%1F in login and password
Igor Sysoev <igor@sysoev.ru>
parents: 1392
diff changeset
1392 u_char *p;
fdd064faf26a escape " ", "%", and %00-%1F in login and password
Igor Sysoev <igor@sysoev.ru>
parents: 1392
diff changeset
1393 uintptr_t n;
633
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1394
1405
fdd064faf26a escape " ", "%", and %00-%1F in login and password
Igor Sysoev <igor@sysoev.ru>
parents: 1392
diff changeset
1395 n = ngx_escape_uri(NULL, text->data, text->len, NGX_ESCAPE_MAIL_AUTH);
633
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1396
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1397 if (n == 0) {
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1398 *escaped = *text;
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1399 return NGX_OK;
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1400 }
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1401
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1402 escaped->len = text->len + n * 2;
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1403
2049
2a92804f4109 *) back out r2040
Igor Sysoev <igor@sysoev.ru>
parents: 1640
diff changeset
1404 p = ngx_pnalloc(pool, escaped->len);
633
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1405 if (p == NULL) {
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1406 return NGX_ERROR;
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1407 }
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1408
1405
fdd064faf26a escape " ", "%", and %00-%1F in login and password
Igor Sysoev <igor@sysoev.ru>
parents: 1392
diff changeset
1409 (void) ngx_escape_uri(p, text->data, text->len, NGX_ESCAPE_MAIL_AUTH);
633
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1410
1405
fdd064faf26a escape " ", "%", and %00-%1F in login and password
Igor Sysoev <igor@sysoev.ru>
parents: 1392
diff changeset
1411 escaped->data = p;
633
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1412
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1413 return NGX_OK;
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1414 }
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1415
f971949ffb58 nginx-0.3.38-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 583
diff changeset
1416
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1417 static void *
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1418 ngx_mail_auth_http_create_conf(ngx_conf_t *cf)
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
1419 {
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1420 ngx_mail_auth_http_conf_t *ahcf;
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
1421
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1422 ahcf = ngx_pcalloc(cf->pool, sizeof(ngx_mail_auth_http_conf_t));
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1423 if (ahcf == NULL) {
2912
c7d57b539248 return NULL instead of NGX_CONF_ERROR on a create conf failure
Igor Sysoev <igor@sysoev.ru>
parents: 2855
diff changeset
1424 return NULL;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1425 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1426
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1427 ahcf->timeout = NGX_CONF_UNSET_MSEC;
5989
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1428 ahcf->pass_client_cert = NGX_CONF_UNSET;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1429
1392
86acec04b8b0 test http_auth absence
Igor Sysoev <igor@sysoev.ru>
parents: 1391
diff changeset
1430 ahcf->file = cf->conf_file->file.name.data;
86acec04b8b0 test http_auth absence
Igor Sysoev <igor@sysoev.ru>
parents: 1391
diff changeset
1431 ahcf->line = cf->conf_file->line;
86acec04b8b0 test http_auth absence
Igor Sysoev <igor@sysoev.ru>
parents: 1391
diff changeset
1432
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1433 return ahcf;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1434 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1435
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1436
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1437 static char *
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1438 ngx_mail_auth_http_merge_conf(ngx_conf_t *cf, void *parent, void *child)
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1439 {
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1440 ngx_mail_auth_http_conf_t *prev = parent;
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1441 ngx_mail_auth_http_conf_t *conf = child;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1442
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1443 u_char *p;
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1444 size_t len;
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1445 ngx_uint_t i;
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1446 ngx_table_elt_t *header;
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1447
884
4d68c486fcb0 upstream choice modules
Igor Sysoev <igor@sysoev.ru>
parents: 883
diff changeset
1448 if (conf->peer == NULL) {
4d68c486fcb0 upstream choice modules
Igor Sysoev <igor@sysoev.ru>
parents: 883
diff changeset
1449 conf->peer = prev->peer;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1450 conf->host_header = prev->host_header;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1451 conf->uri = prev->uri;
1392
86acec04b8b0 test http_auth absence
Igor Sysoev <igor@sysoev.ru>
parents: 1391
diff changeset
1452
86acec04b8b0 test http_auth absence
Igor Sysoev <igor@sysoev.ru>
parents: 1391
diff changeset
1453 if (conf->peer == NULL) {
86acec04b8b0 test http_auth absence
Igor Sysoev <igor@sysoev.ru>
parents: 1391
diff changeset
1454 ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
4812
785ae4de268b Corrected the directive name in the ngx_mail_auth_http_module error message.
Ruslan Ermilov <ru@nginx.com>
parents: 4412
diff changeset
1455 "no \"auth_http\" is defined for server in %s:%ui",
1392
86acec04b8b0 test http_auth absence
Igor Sysoev <igor@sysoev.ru>
parents: 1391
diff changeset
1456 conf->file, conf->line);
86acec04b8b0 test http_auth absence
Igor Sysoev <igor@sysoev.ru>
parents: 1391
diff changeset
1457
86acec04b8b0 test http_auth absence
Igor Sysoev <igor@sysoev.ru>
parents: 1391
diff changeset
1458 return NGX_CONF_ERROR;
86acec04b8b0 test http_auth absence
Igor Sysoev <igor@sysoev.ru>
parents: 1391
diff changeset
1459 }
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1460 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1461
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1462 ngx_conf_merge_msec_value(conf->timeout, prev->timeout, 60000);
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1463
5989
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1464 ngx_conf_merge_value(conf->pass_client_cert, prev->pass_client_cert, 0);
ec01b1d1fff1 Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 5988
diff changeset
1465
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1466 if (conf->headers == NULL) {
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1467 conf->headers = prev->headers;
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1468 conf->header = prev->header;
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1469 }
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1470
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1471 if (conf->headers && conf->header.len == 0) {
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1472 len = 0;
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1473 header = conf->headers->elts;
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1474 for (i = 0; i < conf->headers->nelts; i++) {
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1475 len += header[i].key.len + 2 + header[i].value.len + 2;
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1476 }
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1477
2049
2a92804f4109 *) back out r2040
Igor Sysoev <igor@sysoev.ru>
parents: 1640
diff changeset
1478 p = ngx_pnalloc(cf->pool, len);
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1479 if (p == NULL) {
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1480 return NGX_CONF_ERROR;
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1481 }
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1482
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1483 conf->header.len = len;
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1484 conf->header.data = p;
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1485
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1486 for (i = 0; i < conf->headers->nelts; i++) {
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1487 p = ngx_cpymem(p, header[i].key.data, header[i].key.len);
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1488 *p++ = ':'; *p++ = ' ';
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1489 p = ngx_cpymem(p, header[i].value.data, header[i].value.len);
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1490 *p++ = CR; *p++ = LF;
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1491 }
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1492 }
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1493
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1494 return NGX_CONF_OK;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1495 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1496
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1497
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1498 static char *
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1499 ngx_mail_auth_http(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
1500 {
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1501 ngx_mail_auth_http_conf_t *ahcf = conf;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1502
805
8ee450f30c25 now the "auth_http" directive uses ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents: 800
diff changeset
1503 ngx_str_t *value;
8ee450f30c25 now the "auth_http" directive uses ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents: 800
diff changeset
1504 ngx_url_t u;
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1505
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1506 value = cf->args->elts;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1507
805
8ee450f30c25 now the "auth_http" directive uses ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents: 800
diff changeset
1508 ngx_memzero(&u, sizeof(ngx_url_t));
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1509
805
8ee450f30c25 now the "auth_http" directive uses ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents: 800
diff changeset
1510 u.url = value[1];
906
a0310ac2814f rewritten upstream
Igor Sysoev <igor@sysoev.ru>
parents: 884
diff changeset
1511 u.default_port = 80;
805
8ee450f30c25 now the "auth_http" directive uses ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents: 800
diff changeset
1512 u.uri_part = 1;
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
1513
1391
4eed21047e4d allow "http://" in auth_http URL
Igor Sysoev <igor@sysoev.ru>
parents: 1390
diff changeset
1514 if (ngx_strncmp(u.url.data, "http://", 7) == 0) {
4eed21047e4d allow "http://" in auth_http URL
Igor Sysoev <igor@sysoev.ru>
parents: 1390
diff changeset
1515 u.url.len -= 7;
4eed21047e4d allow "http://" in auth_http URL
Igor Sysoev <igor@sysoev.ru>
parents: 1390
diff changeset
1516 u.url.data += 7;
4eed21047e4d allow "http://" in auth_http URL
Igor Sysoev <igor@sysoev.ru>
parents: 1390
diff changeset
1517 }
4eed21047e4d allow "http://" in auth_http URL
Igor Sysoev <igor@sysoev.ru>
parents: 1390
diff changeset
1518
1559
fe11e2a3946d use pool instead of ngx_conf_t
Igor Sysoev <igor@sysoev.ru>
parents: 1487
diff changeset
1519 if (ngx_parse_url(cf->pool, &u) != NGX_OK) {
805
8ee450f30c25 now the "auth_http" directive uses ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents: 800
diff changeset
1520 if (u.err) {
8ee450f30c25 now the "auth_http" directive uses ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents: 800
diff changeset
1521 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
8ee450f30c25 now the "auth_http" directive uses ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents: 800
diff changeset
1522 "%s in auth_http \"%V\"", u.err, &u.url);
8ee450f30c25 now the "auth_http" directive uses ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents: 800
diff changeset
1523 }
1390
3e045031ee3b stop configuration on error
Igor Sysoev <igor@sysoev.ru>
parents: 1285
diff changeset
1524
3e045031ee3b stop configuration on error
Igor Sysoev <igor@sysoev.ru>
parents: 1285
diff changeset
1525 return NGX_CONF_ERROR;
805
8ee450f30c25 now the "auth_http" directive uses ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents: 800
diff changeset
1526 }
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1527
884
4d68c486fcb0 upstream choice modules
Igor Sysoev <igor@sysoev.ru>
parents: 883
diff changeset
1528 ahcf->peer = u.addrs;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1529
3406
a2a5812cf4f4 use "localhost" in "Host" header line, if unix socket is used in "auth_http"
Igor Sysoev <igor@sysoev.ru>
parents: 3269
diff changeset
1530 if (u.family != AF_UNIX) {
a2a5812cf4f4 use "localhost" in "Host" header line, if unix socket is used in "auth_http"
Igor Sysoev <igor@sysoev.ru>
parents: 3269
diff changeset
1531 ahcf->host_header = u.host;
a2a5812cf4f4 use "localhost" in "Host" header line, if unix socket is used in "auth_http"
Igor Sysoev <igor@sysoev.ru>
parents: 3269
diff changeset
1532
a2a5812cf4f4 use "localhost" in "Host" header line, if unix socket is used in "auth_http"
Igor Sysoev <igor@sysoev.ru>
parents: 3269
diff changeset
1533 } else {
3516
dd1570b6f237 ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents: 3406
diff changeset
1534 ngx_str_set(&ahcf->host_header, "localhost");
3406
a2a5812cf4f4 use "localhost" in "Host" header line, if unix socket is used in "auth_http"
Igor Sysoev <igor@sysoev.ru>
parents: 3269
diff changeset
1535 }
a2a5812cf4f4 use "localhost" in "Host" header line, if unix socket is used in "auth_http"
Igor Sysoev <igor@sysoev.ru>
parents: 3269
diff changeset
1536
805
8ee450f30c25 now the "auth_http" directive uses ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents: 800
diff changeset
1537 ahcf->uri = u.uri;
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1538
559
c1f965ef9718 nginx-0.3.1-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 555
diff changeset
1539 if (ahcf->uri.len == 0) {
3516
dd1570b6f237 ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents: 3406
diff changeset
1540 ngx_str_set(&ahcf->uri, "/");
555
7bd37aef1e7e nginx-0.2.6-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 547
diff changeset
1541 }
7bd37aef1e7e nginx-0.2.6-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 547
diff changeset
1542
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1543 return NGX_CONF_OK;
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1544 }
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1545
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1546
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1547 static char *
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1548 ngx_mail_auth_http_header(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
1549 {
1136
68f30ab68bb7 Many changes:
Igor Sysoev <igor@sysoev.ru>
parents: 1107
diff changeset
1550 ngx_mail_auth_http_conf_t *ahcf = conf;
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1551
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1552 ngx_str_t *value;
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1553 ngx_table_elt_t *header;
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1554
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1555 if (ahcf->headers == NULL) {
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1556 ahcf->headers = ngx_array_create(cf->pool, 1, sizeof(ngx_table_elt_t));
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1557 if (ahcf->headers == NULL) {
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1558 return NGX_CONF_ERROR;
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1559 }
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1560 }
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1561
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1562 header = ngx_array_push(ahcf->headers);
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1563 if (header == NULL) {
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1564 return NGX_CONF_ERROR;
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1565 }
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1566
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1567 value = cf->args->elts;
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1568
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1569 header->key = value[1];
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1570 header->value = value[2];
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1571
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1572 return NGX_CONF_OK;
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 567
diff changeset
1573 }