Mercurial > hg > nginx-quic
annotate src/mail/ngx_mail_pop3_module.c @ 4160:88369902edb1 stable-1.0
Merging r4010, r4065:
SSL related fixes:
*) Fixing proxy_set_body and proxy_pass_request_body with SSL.
Flush flag wasn't set in constructed buffer and this prevented any data
from being actually sent to upstream due to SSL buffering. Make sure
we always set flush in the last buffer we are going to sent.
See here for report:
http://nginx.org/pipermail/nginx-ru/2011-June/041552.html
*) Proper SSL shutdown handling.
If connection has unsent alerts, SSL_shutdown() tries to send them even
if SSL_set_shutdown(SSL_RECEIVED_SHUTDOWN|SSL_SENT_SHUTDOWN) was used.
This can be prevented by SSL_set_quiet_shutdown(). SSL_set_shutdown()
is required nevertheless to preserve session.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 30 Sep 2011 13:42:59 +0000 |
parents | 2a92804f4109 |
children | d620f497c50f |
rev | line source |
---|---|
521 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4 */ | |
5 | |
6 | |
7 #include <ngx_config.h> | |
8 #include <ngx_core.h> | |
9 #include <ngx_event.h> | |
1136 | 10 #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
|
11 #include <ngx_mail_pop3_module.h> |
521 | 12 |
13 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
14 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
|
15 static char *ngx_mail_pop3_merge_srv_conf(ngx_conf_t *cf, void *parent, |
521 | 16 void *child); |
17 | |
18 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
19 static ngx_str_t ngx_mail_pop3_default_capabilities[] = { |
527 | 20 ngx_string("TOP"), |
21 ngx_string("USER"), | |
22 ngx_string("UIDL"), | |
23 ngx_null_string | |
24 }; | |
25 | |
26 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
27 static ngx_conf_bitmask_t ngx_mail_pop3_auth_methods[] = { |
1136 | 28 { ngx_string("plain"), NGX_MAIL_AUTH_PLAIN_ENABLED }, |
29 { ngx_string("apop"), NGX_MAIL_AUTH_APOP_ENABLED }, | |
30 { ngx_string("cram-md5"), NGX_MAIL_AUTH_CRAM_MD5_ENABLED }, | |
800 | 31 { ngx_null_string, 0 } |
32 }; | |
33 | |
34 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
35 static ngx_str_t ngx_mail_pop3_auth_plain_capability = |
809 | 36 ngx_string("+OK methods supported:" CRLF |
37 "LOGIN" CRLF | |
38 "PLAIN" CRLF | |
39 "." CRLF); | |
40 | |
41 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
42 static ngx_str_t ngx_mail_pop3_auth_cram_md5_capability = |
809 | 43 ngx_string("+OK methods supported:" CRLF |
44 "LOGIN" CRLF | |
45 "PLAIN" CRLF | |
46 "CRAM-MD5" CRLF | |
47 "." CRLF); | |
48 | |
49 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
50 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
|
51 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
|
52 { 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
|
53 NGX_MAIL_POP3_PROTOCOL, |
521 | 54 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
55 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
|
56 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
|
57 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
|
58 ngx_mail_pop3_auth_state, |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1323
diff
changeset
|
59 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
60 ngx_string("-ERR internal server error" CRLF) |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
61 }; |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1323
diff
changeset
|
62 |
587 | 63 |
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 static ngx_command_t ngx_mail_pop3_commands[] = { |
521 | 65 |
527 | 66 { ngx_string("pop3_capabilities"), |
1136 | 67 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
|
68 ngx_mail_capabilities, |
1136 | 69 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
|
70 offsetof(ngx_mail_pop3_srv_conf_t, capabilities), |
527 | 71 NULL }, |
72 | |
1136 | 73 { ngx_string("pop3_auth"), |
74 NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_1MORE, | |
800 | 75 ngx_conf_set_bitmask_slot, |
1136 | 76 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
|
77 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
|
78 &ngx_mail_pop3_auth_methods }, |
800 | 79 |
521 | 80 ngx_null_command |
81 }; | |
82 | |
83 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
84 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
|
85 &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
|
86 |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
87 NULL, /* create main configuration */ |
521 | 88 NULL, /* init main configuration */ |
89 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
90 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
|
91 ngx_mail_pop3_merge_srv_conf /* merge server configuration */ |
521 | 92 }; |
93 | |
94 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
95 ngx_module_t ngx_mail_pop3_module = { |
521 | 96 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
|
97 &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
|
98 ngx_mail_pop3_commands, /* module directives */ |
1136 | 99 NGX_MAIL_MODULE, /* module type */ |
541 | 100 NULL, /* init master */ |
521 | 101 NULL, /* init module */ |
541 | 102 NULL, /* init process */ |
103 NULL, /* init thread */ | |
104 NULL, /* exit thread */ | |
105 NULL, /* exit process */ | |
106 NULL, /* exit master */ | |
107 NGX_MODULE_V1_PADDING | |
521 | 108 }; |
109 | |
110 | |
111 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
|
112 ngx_mail_pop3_create_srv_conf(ngx_conf_t *cf) |
577 | 113 { |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
114 ngx_mail_pop3_srv_conf_t *pscf; |
641 | 115 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
116 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
|
117 if (pscf == NULL) { |
527 | 118 return NULL; |
521 | 119 } |
120 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
121 if (ngx_array_init(&pscf->capabilities, cf->pool, 4, sizeof(ngx_str_t)) |
1136 | 122 != NGX_OK) |
123 { | |
124 return NULL; | |
125 } | |
126 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
127 return pscf; |
521 | 128 } |
129 | |
130 | |
131 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
|
132 ngx_mail_pop3_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) |
521 | 133 { |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
134 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
|
135 ngx_mail_pop3_srv_conf_t *conf = 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 u_char *p; |
1136 | 138 size_t size, stls_only_size; |
527 | 139 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
|
140 ngx_uint_t i; |
1136 | 141 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
142 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
|
143 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
|
144 (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
|
145 |NGX_MAIL_AUTH_PLAIN_ENABLED)); |
800 | 146 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
147 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
|
148 conf->capabilities = prev->capabilities; |
800 | 149 } |
150 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
151 if (conf->capabilities.nelts == 0) { |
527 | 152 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
153 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
|
154 c = ngx_array_push(&conf->capabilities); |
527 | 155 if (c == NULL) { |
156 return NGX_CONF_ERROR; | |
157 } | |
158 | |
159 *c = *d; | |
160 } | |
161 } | |
162 | |
163 size = sizeof("+OK Capability list follows" CRLF) - 1 | |
164 + sizeof("." CRLF) - 1; | |
165 | |
1136 | 166 stls_only_size = size + sizeof("STLS" CRLF) - 1; |
167 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
168 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
|
169 for (i = 0; i < conf->capabilities.nelts; i++) { |
527 | 170 size += c[i].len + sizeof(CRLF) - 1; |
1136 | 171 |
172 if (ngx_strcasecmp(c[i].data, (u_char *) "USER") == 0) { | |
173 continue; | |
174 } | |
175 | |
176 stls_only_size += c[i].len + sizeof(CRLF) - 1; | |
527 | 177 } |
178 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
179 if (conf->auth_methods & NGX_MAIL_AUTH_CRAM_MD5_ENABLED) { |
809 | 180 size += sizeof("SASL LOGIN PLAIN CRAM-MD5" CRLF) - 1; |
181 | |
182 } else { | |
183 size += sizeof("SASL LOGIN PLAIN" CRLF) - 1; | |
184 } | |
185 | |
2049 | 186 p = ngx_pnalloc(cf->pool, size); |
583 | 187 if (p == NULL) { |
527 | 188 return NGX_CONF_ERROR; |
189 } | |
190 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
191 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
|
192 conf->capability.data = p; |
583 | 193 |
194 p = ngx_cpymem(p, "+OK Capability list follows" CRLF, | |
195 sizeof("+OK Capability list follows" CRLF) - 1); | |
527 | 196 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
197 for (i = 0; i < conf->capabilities.nelts; i++) { |
583 | 198 p = ngx_cpymem(p, c[i].data, c[i].len); |
199 *p++ = CR; *p++ = LF; | |
527 | 200 } |
201 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
202 if (conf->auth_methods & NGX_MAIL_AUTH_CRAM_MD5_ENABLED) { |
809 | 203 p = ngx_cpymem(p, "SASL LOGIN PLAIN CRAM-MD5" CRLF, |
204 sizeof("SASL LOGIN PLAIN CRAM-MD5" CRLF) - 1); | |
205 | |
206 } else { | |
207 p = ngx_cpymem(p, "SASL LOGIN PLAIN" CRLF, | |
208 sizeof("SASL LOGIN PLAIN" CRLF) - 1); | |
209 } | |
210 | |
583 | 211 *p++ = '.'; *p++ = CR; *p = LF; |
212 | |
213 | |
214 size += sizeof("STLS" CRLF) - 1; | |
527 | 215 |
2049 | 216 p = ngx_pnalloc(cf->pool, size); |
583 | 217 if (p == NULL) { |
218 return NGX_CONF_ERROR; | |
219 } | |
220 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
221 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
|
222 conf->starttls_capability.data = p; |
583 | 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 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
|
225 conf->capability.len - (sizeof("." CRLF) - 1)); |
583 | 226 |
227 p = ngx_cpymem(p, "STLS" CRLF, sizeof("STLS" CRLF) - 1); | |
228 *p++ = '.'; *p++ = CR; *p = LF; | |
527 | 229 |
230 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
231 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
|
232 conf->auth_capability = ngx_mail_pop3_auth_cram_md5_capability; |
809 | 233 |
234 } 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
|
235 conf->auth_capability = ngx_mail_pop3_auth_plain_capability; |
809 | 236 } |
237 | |
238 | |
2049 | 239 p = ngx_pnalloc(cf->pool, stls_only_size); |
1136 | 240 if (p == NULL) { |
241 return NGX_CONF_ERROR; | |
242 } | |
243 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
244 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
|
245 conf->starttls_only_capability.data = p; |
1136 | 246 |
247 p = ngx_cpymem(p, "+OK Capability list follows" CRLF, | |
248 sizeof("+OK Capability list follows" CRLF) - 1); | |
249 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
250 for (i = 0; i < conf->capabilities.nelts; i++) { |
1136 | 251 if (ngx_strcasecmp(c[i].data, (u_char *) "USER") == 0) { |
252 continue; | |
253 } | |
254 | |
255 p = ngx_cpymem(p, c[i].data, c[i].len); | |
256 *p++ = CR; *p++ = LF; | |
257 } | |
258 | |
259 p = ngx_cpymem(p, "STLS" CRLF, sizeof("STLS" CRLF) - 1); | |
260 *p++ = '.'; *p++ = CR; *p = LF; | |
261 | |
521 | 262 return NGX_CONF_OK; |
263 } |