comparison src/imap/ngx_imap_core_module.c @ 583:4e296b7d25bf release-0.3.13

nginx-0.3.13-RELEASE import *) Feature: the IMAP/POP3 proxy supports STARTTLS and STLS. *) Bugfix: the IMAP/POP3 proxy did not work with the select, poll, and /dev/poll methods. *) Bugfix: in SSI handling. *) Bugfix: now Solaris sendfilev() is not used to transfer the client request body to FastCGI-server via the unix domain socket. *) Bugfix: the "auth_basic" directive did not disable the authorization; the bug had appeared in 0.3.11.
author Igor Sysoev <igor@sysoev.ru>
date Mon, 05 Dec 2005 13:18:09 +0000
parents 4d9ea73a627a
children 284cc140593b
comparison
equal deleted inserted replaced
582:6646640ac20b 583:4e296b7d25bf
179 ngx_imap_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) 179 ngx_imap_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
180 { 180 {
181 ngx_imap_core_srv_conf_t *prev = parent; 181 ngx_imap_core_srv_conf_t *prev = parent;
182 ngx_imap_core_srv_conf_t *conf = child; 182 ngx_imap_core_srv_conf_t *conf = child;
183 183
184 u_char *p;
184 size_t size; 185 size_t size;
185 ngx_buf_t *b;
186 ngx_str_t *c, *d; 186 ngx_str_t *c, *d;
187 ngx_uint_t i; 187 ngx_uint_t i;
188 188
189 ngx_conf_merge_size_value(conf->imap_client_buffer_size, 189 ngx_conf_merge_size_value(conf->imap_client_buffer_size,
190 prev->imap_client_buffer_size, 190 prev->imap_client_buffer_size,
216 c = conf->pop3_capabilities.elts; 216 c = conf->pop3_capabilities.elts;
217 for (i = 0; i < conf->pop3_capabilities.nelts; i++) { 217 for (i = 0; i < conf->pop3_capabilities.nelts; i++) {
218 size += c[i].len + sizeof(CRLF) - 1; 218 size += c[i].len + sizeof(CRLF) - 1;
219 } 219 }
220 220
221 b = ngx_create_temp_buf(cf->pool, size); 221 p = ngx_palloc(cf->pool, size);
222 if (b == NULL) { 222 if (p == NULL) {
223 return NGX_CONF_ERROR; 223 return NGX_CONF_ERROR;
224 } 224 }
225 225
226 b->last = ngx_cpymem(b->last, "+OK Capability list follows" CRLF, 226 conf->pop3_capability.len = size;
227 sizeof("+OK Capability list follows" CRLF) - 1); 227 conf->pop3_capability.data = p;
228
229 p = ngx_cpymem(p, "+OK Capability list follows" CRLF,
230 sizeof("+OK Capability list follows" CRLF) - 1);
228 231
229 for (i = 0; i < conf->pop3_capabilities.nelts; i++) { 232 for (i = 0; i < conf->pop3_capabilities.nelts; i++) {
230 b->last = ngx_cpymem(b->last, c[i].data, c[i].len); 233 p = ngx_cpymem(p, c[i].data, c[i].len);
231 *b->last++ = CR; *b->last++ = LF; 234 *p++ = CR; *p++ = LF;
232 } 235 }
233 236
234 *b->last++ = '.'; *b->last++ = CR; *b->last++ = LF; 237 *p++ = '.'; *p++ = CR; *p = LF;
235 238
236 conf->pop3_capability = b; 239
240 size += sizeof("STLS" CRLF) - 1;
241
242 p = ngx_palloc(cf->pool, size);
243 if (p == NULL) {
244 return NGX_CONF_ERROR;
245 }
246
247 conf->pop3_starttls_capability.len = size;
248 conf->pop3_starttls_capability.data = p;
249
250 p = ngx_cpymem(p, conf->pop3_capability.data,
251 conf->pop3_capability.len - (sizeof("." CRLF) - 1));
252
253 p = ngx_cpymem(p, "STLS" CRLF, sizeof("STLS" CRLF) - 1);
254 *p++ = '.'; *p++ = CR; *p = LF;
237 255
238 256
239 if (conf->imap_capabilities.nelts == 0) { 257 if (conf->imap_capabilities.nelts == 0) {
240 conf->imap_capabilities = prev->imap_capabilities; 258 conf->imap_capabilities = prev->imap_capabilities;
241 } 259 }
257 c = conf->imap_capabilities.elts; 275 c = conf->imap_capabilities.elts;
258 for (i = 0; i < conf->imap_capabilities.nelts; i++) { 276 for (i = 0; i < conf->imap_capabilities.nelts; i++) {
259 size += 1 + c[i].len; 277 size += 1 + c[i].len;
260 } 278 }
261 279
262 b = ngx_create_temp_buf(cf->pool, size); 280 p = ngx_palloc(cf->pool, size);
263 if (b == NULL) { 281 if (p == NULL) {
264 return NGX_CONF_ERROR; 282 return NGX_CONF_ERROR;
265 } 283 }
266 284
267 b->last = ngx_cpymem(b->last, "* CAPABILITY", sizeof("* CAPABILITY") - 1); 285 conf->imap_capability.len = size;
286 conf->imap_capability.data = p;
287
288 p = ngx_cpymem(p, "* CAPABILITY", sizeof("* CAPABILITY") - 1);
268 289
269 for (i = 0; i < conf->imap_capabilities.nelts; i++) { 290 for (i = 0; i < conf->imap_capabilities.nelts; i++) {
270 *b->last++ = ' '; 291 *p++ = ' ';
271 b->last = ngx_cpymem(b->last, c[i].data, c[i].len); 292 p = ngx_cpymem(p, c[i].data, c[i].len);
272 } 293 }
273 294
274 *b->last++ = CR; *b->last++ = LF; 295 *p++ = CR; *p = LF;
275 296
276 conf->imap_capability = b; 297
298 size += sizeof(" STARTTLS") - 1;
299
300 p = ngx_palloc(cf->pool, size);
301 if (p == NULL) {
302 return NGX_CONF_ERROR;
303 }
304
305 conf->imap_starttls_capability.len = size;
306 conf->imap_starttls_capability.data = p;
307
308 p = ngx_cpymem(p, conf->imap_capability.data,
309 conf->imap_capability.len - (sizeof(CRLF) - 1));
310 p = ngx_cpymem(p, " STARTTLS", sizeof(" STARTTLS") - 1);
311 *p++ = CR; *p = LF;
312
313
314 size += sizeof(" LOGINDISABLED") - 1;
315
316 p = ngx_palloc(cf->pool, size);
317 if (p == NULL) {
318 return NGX_CONF_ERROR;
319 }
320
321 conf->imap_starttls_only_capability.len = size;
322 conf->imap_starttls_only_capability.data = p;
323
324 p = ngx_cpymem(p, conf->imap_starttls_capability.data,
325 conf->imap_starttls_capability.len - (sizeof(CRLF) - 1));
326 p = ngx_cpymem(p, " LOGINDISABLED", sizeof(" LOGINDISABLED") - 1);
327 *p++ = CR; *p = LF;
328
277 329
278 return NGX_CONF_OK; 330 return NGX_CONF_OK;
279 } 331 }
280 332
281 333