comparison src/mail/ngx_mail_auth_http_module.c @ 324:7cf404023f50 NGINX_0_5_32

nginx 0.5.32 *) Change: now nginx tries to set the "worker_priority", "worker_rlimit_nofile", "worker_rlimit_core", and "worker_rlimit_sigpending" without super-user privileges. *) Change: now nginx escapes space and "%" in request to a mail proxy authentication server. *) Change: now nginx escapes "%" in $memcached_key variable. *) Change: the special make target "upgrade1" was defined for online upgrade of 0.1.x versions. *) Feature: the "add_header Last-Modified ..." directive changes the "Last-Modified" response header line. *) Feature: the mail proxy supports AUTHENTICATE in IMAP mode. Thanks to Maxim Dounin. *) Feature: the mail proxy supports STARTTLS in SMTP mode. Thanks to Maxim Dounin. *) Bugfix: nginx did not close directory file on HEAD request if autoindex was used. Thanks to Arkadiusz Patyk. *) Bugfix: the "proxy_hide_header" and "fastcgi_hide_header" directives did not hide response header lines whose name was longer than 32 characters. Thanks to Manlio Perillo. *) Bugfix: active connection counter always increased if mail proxy was used. *) Bugfix: if backend returned response header only using non-buffered proxy, then nginx closed backend connection on timeout. *) Bugfix: nginx did not support several "Connection" request header lines. *) Bugfix: a charset set by the "charset" directive was not appended to the "Content-Type" header set by $r->send_http_header(). *) Bugfix: a segmentation fault might occur in worker process if /dev/poll method was used. *) Bugfix: nginx did not work on FreeBSD/sparc64. *) Bugfix: a segmentation fault occurred in worker process if invalid address was set in the "auth_http" directive. *) Bugfix: now nginx uses default listen backlog value 511 on all platforms except FreeBSD. Thanks to Jiang Hong. *) Bugfix: now Solaris sendfilev() is not used to transfer the client request body to FastCGI-server via the unix domain socket. *) Bugfix: if the same host without specified port was used as backend for HTTP and HTTPS, then nginx used only one port - 80 or 443. *) Bugfix: the "proxy_ignore_client_abort" and "fastcgi_ignore_client_abort" directives did not work; bug appeared in 0.5.13.
author Igor Sysoev <http://sysoev.ru>
date Mon, 24 Sep 2007 00:00:00 +0400
parents 24def6198d7f
children f70f2f565fe0
comparison
equal deleted inserted replaced
323:85aeb2da6e4c 324:7cf404023f50
19 ngx_str_t host_header; 19 ngx_str_t host_header;
20 ngx_str_t uri; 20 ngx_str_t uri;
21 ngx_str_t header; 21 ngx_str_t header;
22 22
23 ngx_array_t *headers; 23 ngx_array_t *headers;
24
25 u_char *file;
26 ngx_uint_t line;
24 } ngx_mail_auth_http_conf_t; 27 } ngx_mail_auth_http_conf_t;
25 28
26 29
27 typedef struct ngx_mail_auth_http_ctx_s ngx_mail_auth_http_ctx_t; 30 typedef struct ngx_mail_auth_http_ctx_s ngx_mail_auth_http_ctx_t;
28 31
1246 1249
1247 1250
1248 static ngx_int_t 1251 static ngx_int_t
1249 ngx_mail_auth_http_escape(ngx_pool_t *pool, ngx_str_t *text, ngx_str_t *escaped) 1252 ngx_mail_auth_http_escape(ngx_pool_t *pool, ngx_str_t *text, ngx_str_t *escaped)
1250 { 1253 {
1251 u_char ch, *p; 1254 u_char *p;
1252 ngx_uint_t i, n; 1255 uintptr_t n;
1253 1256
1254 n = 0; 1257 n = ngx_escape_uri(NULL, text->data, text->len, NGX_ESCAPE_MAIL_AUTH);
1255
1256 for (i = 0; i < text->len; i++) {
1257 ch = text->data[i];
1258
1259 if (ch == CR || ch == LF) {
1260 n++;
1261 }
1262 }
1263 1258
1264 if (n == 0) { 1259 if (n == 0) {
1265 *escaped = *text; 1260 *escaped = *text;
1266 return NGX_OK; 1261 return NGX_OK;
1267 } 1262 }
1271 p = ngx_palloc(pool, escaped->len); 1266 p = ngx_palloc(pool, escaped->len);
1272 if (p == NULL) { 1267 if (p == NULL) {
1273 return NGX_ERROR; 1268 return NGX_ERROR;
1274 } 1269 }
1275 1270
1271 (void) ngx_escape_uri(p, text->data, text->len, NGX_ESCAPE_MAIL_AUTH);
1272
1276 escaped->data = p; 1273 escaped->data = p;
1277
1278 for (i = 0; i < text->len; i++) {
1279 ch = text->data[i];
1280
1281 if (ch == CR) {
1282 *p++ = '%';
1283 *p++ = '0';
1284 *p++ = 'D';
1285 continue;
1286 }
1287
1288 if (ch == LF) {
1289 *p++ = '%';
1290 *p++ = '0';
1291 *p++ = 'A';
1292 continue;
1293 }
1294
1295 *p++ = ch;
1296 }
1297 1274
1298 return NGX_OK; 1275 return NGX_OK;
1299 } 1276 }
1300 1277
1301 1278
1308 if (ahcf == NULL) { 1285 if (ahcf == NULL) {
1309 return NGX_CONF_ERROR; 1286 return NGX_CONF_ERROR;
1310 } 1287 }
1311 1288
1312 ahcf->timeout = NGX_CONF_UNSET_MSEC; 1289 ahcf->timeout = NGX_CONF_UNSET_MSEC;
1290
1291 ahcf->file = cf->conf_file->file.name.data;
1292 ahcf->line = cf->conf_file->line;
1313 1293
1314 return ahcf; 1294 return ahcf;
1315 } 1295 }
1316 1296
1317 1297
1328 1308
1329 if (conf->peer == NULL) { 1309 if (conf->peer == NULL) {
1330 conf->peer = prev->peer; 1310 conf->peer = prev->peer;
1331 conf->host_header = prev->host_header; 1311 conf->host_header = prev->host_header;
1332 conf->uri = prev->uri; 1312 conf->uri = prev->uri;
1313
1314 if (conf->peer == NULL) {
1315 ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
1316 "no \"http_auth\" is defined for server in %s:%ui",
1317 conf->file, conf->line);
1318
1319 return NGX_CONF_ERROR;
1320 }
1333 } 1321 }
1334 1322
1335 ngx_conf_merge_msec_value(conf->timeout, prev->timeout, 60000); 1323 ngx_conf_merge_msec_value(conf->timeout, prev->timeout, 60000);
1336 1324
1337 if (conf->headers == NULL) { 1325 if (conf->headers == NULL) {
1381 u.url = value[1]; 1369 u.url = value[1];
1382 u.default_port = 80; 1370 u.default_port = 80;
1383 u.uri_part = 1; 1371 u.uri_part = 1;
1384 u.one_addr = 1; 1372 u.one_addr = 1;
1385 1373
1374 if (ngx_strncmp(u.url.data, "http://", 7) == 0) {
1375 u.url.len -= 7;
1376 u.url.data += 7;
1377 }
1378
1386 if (ngx_parse_url(cf, &u) != NGX_OK) { 1379 if (ngx_parse_url(cf, &u) != NGX_OK) {
1387 if (u.err) { 1380 if (u.err) {
1388 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 1381 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1389 "%s in auth_http \"%V\"", u.err, &u.url); 1382 "%s in auth_http \"%V\"", u.err, &u.url);
1390 } 1383 }
1384
1385 return NGX_CONF_ERROR;
1391 } 1386 }
1392 1387
1393 ahcf->peer = u.addrs; 1388 ahcf->peer = u.addrs;
1394 1389
1395 ahcf->host_header = u.host; 1390 ahcf->host_header = u.host;