Mercurial > hg > nginx
annotate src/mail/ngx_mail_pop3_module.c @ 6749:f88a145b093e stable-1.10
HTTP/2: the "421 Misdirected Request" response (closes #848).
Since 4fbef397c753 nginx rejects with the 400 error any attempts of
requesting different host over the same connection, if the relevant
virtual server requires verification of a client certificate.
While requesting hosts other than negotiated isn't something legal
in HTTP/1.x, the HTTP/2 specification explicitly permits such requests
for connection reuse and has introduced a special response code 421.
According to RFC 7540 Section 9.1.2 this code can be sent by a server
that is not configured to produce responses for the combination of
scheme and authority that are included in the request URI. And the
client may retry the request over a different connection.
Now this code is used for requests that aren't authorized in current
connection. After receiving the 421 response a client will be able
to open a new connection, provide the required certificate and retry
the request.
Unfortunately, not all clients currently are able to handle it well.
Notably Chrome just shows an error, while at least the latest version
of Firefox retries the request over a new connection.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Fri, 20 May 2016 18:41:17 +0300 |
parents | ec01b1d1fff1 |
children | 73b451d304c0 |
rev | line source |
---|---|
521 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4412 | 4 * Copyright (C) Nginx, Inc. |
521 | 5 */ |
6 | |
7 | |
8 #include <ngx_config.h> | |
9 #include <ngx_core.h> | |
10 #include <ngx_event.h> | |
1136 | 11 #include <ngx_mail.h> |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
12 #include <ngx_mail_pop3_module.h> |
521 | 13 |
14 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
15 static void *ngx_mail_pop3_create_srv_conf(ngx_conf_t *cf); |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
16 static char *ngx_mail_pop3_merge_srv_conf(ngx_conf_t *cf, void *parent, |
521 | 17 void *child); |
18 | |
19 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
20 static ngx_str_t ngx_mail_pop3_default_capabilities[] = { |
527 | 21 ngx_string("TOP"), |
22 ngx_string("USER"), | |
23 ngx_string("UIDL"), | |
24 ngx_null_string | |
25 }; | |
26 | |
27 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
28 static ngx_conf_bitmask_t ngx_mail_pop3_auth_methods[] = { |
1136 | 29 { ngx_string("plain"), NGX_MAIL_AUTH_PLAIN_ENABLED }, |
30 { ngx_string("apop"), NGX_MAIL_AUTH_APOP_ENABLED }, | |
31 { ngx_string("cram-md5"), NGX_MAIL_AUTH_CRAM_MD5_ENABLED }, | |
800 | 32 { ngx_null_string, 0 } |
33 }; | |
34 | |
35 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
36 static ngx_str_t ngx_mail_pop3_auth_plain_capability = |
809 | 37 ngx_string("+OK methods supported:" CRLF |
38 "LOGIN" CRLF | |
39 "PLAIN" CRLF | |
40 "." CRLF); | |
41 | |
42 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
43 static ngx_str_t ngx_mail_pop3_auth_cram_md5_capability = |
809 | 44 ngx_string("+OK methods supported:" CRLF |
45 "LOGIN" CRLF | |
46 "PLAIN" CRLF | |
47 "CRAM-MD5" CRLF | |
48 "." CRLF); | |
49 | |
50 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
51 static ngx_mail_protocol_t ngx_mail_pop3_protocol = { |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
52 ngx_string("pop3"), |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
53 { 110, 995, 0, 0 }, |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
54 NGX_MAIL_POP3_PROTOCOL, |
521 | 55 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
56 ngx_mail_pop3_init_session, |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
57 ngx_mail_pop3_init_protocol, |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
58 ngx_mail_pop3_parse_command, |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
59 ngx_mail_pop3_auth_state, |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1323
diff
changeset
|
60 |
5989
ec01b1d1fff1
Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
61 ngx_string("-ERR internal server error" CRLF), |
ec01b1d1fff1
Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
62 ngx_string("-ERR SSL certificate error" CRLF), |
ec01b1d1fff1
Mail: client SSL certificates support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
63 ngx_string("-ERR No required SSL certificate" CRLF) |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
64 }; |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1323
diff
changeset
|
65 |
587 | 66 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
67 static ngx_command_t ngx_mail_pop3_commands[] = { |
521 | 68 |
527 | 69 { ngx_string("pop3_capabilities"), |
1136 | 70 NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_1MORE, |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
71 ngx_mail_capabilities, |
1136 | 72 NGX_MAIL_SRV_CONF_OFFSET, |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
73 offsetof(ngx_mail_pop3_srv_conf_t, capabilities), |
527 | 74 NULL }, |
75 | |
1136 | 76 { ngx_string("pop3_auth"), |
77 NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_1MORE, | |
800 | 78 ngx_conf_set_bitmask_slot, |
1136 | 79 NGX_MAIL_SRV_CONF_OFFSET, |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
80 offsetof(ngx_mail_pop3_srv_conf_t, auth_methods), |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
81 &ngx_mail_pop3_auth_methods }, |
800 | 82 |
521 | 83 ngx_null_command |
84 }; | |
85 | |
86 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
87 static ngx_mail_module_t ngx_mail_pop3_module_ctx = { |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
88 &ngx_mail_pop3_protocol, /* protocol */ |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
89 |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
90 NULL, /* create main configuration */ |
521 | 91 NULL, /* init main configuration */ |
92 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
93 ngx_mail_pop3_create_srv_conf, /* create server configuration */ |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
94 ngx_mail_pop3_merge_srv_conf /* merge server configuration */ |
521 | 95 }; |
96 | |
97 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
98 ngx_module_t ngx_mail_pop3_module = { |
521 | 99 NGX_MODULE_V1, |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
100 &ngx_mail_pop3_module_ctx, /* module context */ |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
101 ngx_mail_pop3_commands, /* module directives */ |
1136 | 102 NGX_MAIL_MODULE, /* module type */ |
541 | 103 NULL, /* init master */ |
521 | 104 NULL, /* init module */ |
541 | 105 NULL, /* init process */ |
106 NULL, /* init thread */ | |
107 NULL, /* exit thread */ | |
108 NULL, /* exit process */ | |
109 NULL, /* exit master */ | |
110 NGX_MODULE_V1_PADDING | |
521 | 111 }; |
112 | |
113 | |
114 static void * | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
115 ngx_mail_pop3_create_srv_conf(ngx_conf_t *cf) |
577 | 116 { |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
117 ngx_mail_pop3_srv_conf_t *pscf; |
641 | 118 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
119 pscf = ngx_pcalloc(cf->pool, sizeof(ngx_mail_pop3_srv_conf_t)); |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
120 if (pscf == NULL) { |
527 | 121 return NULL; |
521 | 122 } |
123 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
124 if (ngx_array_init(&pscf->capabilities, cf->pool, 4, sizeof(ngx_str_t)) |
1136 | 125 != NGX_OK) |
126 { | |
127 return NULL; | |
128 } | |
129 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
130 return pscf; |
521 | 131 } |
132 | |
133 | |
134 static char * | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
135 ngx_mail_pop3_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) |
521 | 136 { |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
137 ngx_mail_pop3_srv_conf_t *prev = parent; |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
138 ngx_mail_pop3_srv_conf_t *conf = child; |
521 | 139 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
140 u_char *p; |
1136 | 141 size_t size, stls_only_size; |
527 | 142 ngx_str_t *c, *d; |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
143 ngx_uint_t i; |
1136 | 144 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
145 ngx_conf_merge_bitmask_value(conf->auth_methods, |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
146 prev->auth_methods, |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
147 (NGX_CONF_BITMASK_SET |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
148 |NGX_MAIL_AUTH_PLAIN_ENABLED)); |
800 | 149 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
150 if (conf->capabilities.nelts == 0) { |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
151 conf->capabilities = prev->capabilities; |
800 | 152 } |
153 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
154 if (conf->capabilities.nelts == 0) { |
527 | 155 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
156 for (d = ngx_mail_pop3_default_capabilities; d->len; d++) { |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
157 c = ngx_array_push(&conf->capabilities); |
527 | 158 if (c == NULL) { |
159 return NGX_CONF_ERROR; | |
160 } | |
161 | |
162 *c = *d; | |
163 } | |
164 } | |
165 | |
166 size = sizeof("+OK Capability list follows" CRLF) - 1 | |
167 + sizeof("." CRLF) - 1; | |
168 | |
1136 | 169 stls_only_size = size + sizeof("STLS" CRLF) - 1; |
170 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
171 c = conf->capabilities.elts; |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
172 for (i = 0; i < conf->capabilities.nelts; i++) { |
527 | 173 size += c[i].len + sizeof(CRLF) - 1; |
1136 | 174 |
175 if (ngx_strcasecmp(c[i].data, (u_char *) "USER") == 0) { | |
176 continue; | |
177 } | |
178 | |
179 stls_only_size += c[i].len + sizeof(CRLF) - 1; | |
527 | 180 } |
181 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
182 if (conf->auth_methods & NGX_MAIL_AUTH_CRAM_MD5_ENABLED) { |
809 | 183 size += sizeof("SASL LOGIN PLAIN CRAM-MD5" CRLF) - 1; |
184 | |
185 } else { | |
186 size += sizeof("SASL LOGIN PLAIN" CRLF) - 1; | |
187 } | |
188 | |
2049 | 189 p = ngx_pnalloc(cf->pool, size); |
583 | 190 if (p == NULL) { |
527 | 191 return NGX_CONF_ERROR; |
192 } | |
193 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
194 conf->capability.len = size; |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
195 conf->capability.data = p; |
583 | 196 |
197 p = ngx_cpymem(p, "+OK Capability list follows" CRLF, | |
198 sizeof("+OK Capability list follows" CRLF) - 1); | |
527 | 199 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
200 for (i = 0; i < conf->capabilities.nelts; i++) { |
583 | 201 p = ngx_cpymem(p, c[i].data, c[i].len); |
202 *p++ = CR; *p++ = LF; | |
527 | 203 } |
204 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
205 if (conf->auth_methods & NGX_MAIL_AUTH_CRAM_MD5_ENABLED) { |
809 | 206 p = ngx_cpymem(p, "SASL LOGIN PLAIN CRAM-MD5" CRLF, |
207 sizeof("SASL LOGIN PLAIN CRAM-MD5" CRLF) - 1); | |
208 | |
209 } else { | |
210 p = ngx_cpymem(p, "SASL LOGIN PLAIN" CRLF, | |
211 sizeof("SASL LOGIN PLAIN" CRLF) - 1); | |
212 } | |
213 | |
583 | 214 *p++ = '.'; *p++ = CR; *p = LF; |
215 | |
216 | |
217 size += sizeof("STLS" CRLF) - 1; | |
527 | 218 |
2049 | 219 p = ngx_pnalloc(cf->pool, size); |
583 | 220 if (p == NULL) { |
221 return NGX_CONF_ERROR; | |
222 } | |
223 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
224 conf->starttls_capability.len = size; |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
225 conf->starttls_capability.data = p; |
583 | 226 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
227 p = ngx_cpymem(p, conf->capability.data, |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
228 conf->capability.len - (sizeof("." CRLF) - 1)); |
583 | 229 |
230 p = ngx_cpymem(p, "STLS" CRLF, sizeof("STLS" CRLF) - 1); | |
231 *p++ = '.'; *p++ = CR; *p = LF; | |
527 | 232 |
233 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
234 if (conf->auth_methods & NGX_MAIL_AUTH_CRAM_MD5_ENABLED) { |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
235 conf->auth_capability = ngx_mail_pop3_auth_cram_md5_capability; |
809 | 236 |
237 } else { | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
238 conf->auth_capability = ngx_mail_pop3_auth_plain_capability; |
809 | 239 } |
240 | |
241 | |
2049 | 242 p = ngx_pnalloc(cf->pool, stls_only_size); |
1136 | 243 if (p == NULL) { |
244 return NGX_CONF_ERROR; | |
245 } | |
246 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
247 conf->starttls_only_capability.len = stls_only_size; |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
248 conf->starttls_only_capability.data = p; |
1136 | 249 |
250 p = ngx_cpymem(p, "+OK Capability list follows" CRLF, | |
251 sizeof("+OK Capability list follows" CRLF) - 1); | |
252 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
253 for (i = 0; i < conf->capabilities.nelts; i++) { |
1136 | 254 if (ngx_strcasecmp(c[i].data, (u_char *) "USER") == 0) { |
255 continue; | |
256 } | |
257 | |
258 p = ngx_cpymem(p, c[i].data, c[i].len); | |
259 *p++ = CR; *p++ = LF; | |
260 } | |
261 | |
262 p = ngx_cpymem(p, "STLS" CRLF, sizeof("STLS" CRLF) - 1); | |
263 *p++ = '.'; *p++ = CR; *p = LF; | |
264 | |
521 | 265 return NGX_CONF_OK; |
266 } |