Klaus Demo nginx / 0e05ca0
Disable symlinks: initialization of the "disable_symlinks" field in ngx_open_file_info_t moved to a separate function. This is preparation for the "from=" parameter implementation of the "disable_symlinks" directive. Valentin Bartenev 10 years ago
10 changed file(s) with 65 addition(s) and 33 deletion(s). Raw diff Collapse all Expand all
108108 of.min_uses = clcf->open_file_cache_min_uses;
109109 of.errors = clcf->open_file_cache_errors;
110110 of.events = clcf->open_file_cache_events;
111 #if (NGX_HAVE_OPENAT)
112 of.disable_symlinks = clcf->disable_symlinks;
113 #endif
111
112 if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) {
113 return NGX_HTTP_INTERNAL_SERVER_ERROR;
114 }
114115
115116 if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
116117 != NGX_OK)
128128 of.min_uses = clcf->open_file_cache_min_uses;
129129 of.errors = clcf->open_file_cache_errors;
130130 of.events = clcf->open_file_cache_events;
131 #if (NGX_HAVE_OPENAT)
132 of.disable_symlinks = clcf->disable_symlinks;
133 #endif
131
132 if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) {
133 return NGX_HTTP_INTERNAL_SERVER_ERROR;
134 }
134135
135136 if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
136137 != NGX_OK)
208208 of.test_only = 1;
209209 of.errors = clcf->open_file_cache_errors;
210210 of.events = clcf->open_file_cache_events;
211 #if (NGX_HAVE_OPENAT)
212 of.disable_symlinks = clcf->disable_symlinks;
213 #endif
211
212 if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) {
213 return NGX_HTTP_INTERNAL_SERVER_ERROR;
214 }
214215
215216 if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
216217 != NGX_OK)
306307 of.test_only = 1;
307308 of.valid = clcf->open_file_cache_valid;
308309 of.errors = clcf->open_file_cache_errors;
309 #if (NGX_HAVE_OPENAT)
310 of.disable_symlinks = clcf->disable_symlinks;
311 #endif
310
311 if (ngx_http_set_disable_symlinks(r, clcf, &dir, &of) != NGX_OK) {
312 return NGX_HTTP_INTERNAL_SERVER_ERROR;
313 }
312314
313315 if (ngx_open_cached_file(clcf->open_file_cache, &dir, &of, r->pool)
314316 != NGX_OK)
393393 of.test_only = 1;
394394 of.errors = clcf->open_file_cache_errors;
395395 of.events = clcf->open_file_cache_events;
396 #if (NGX_HAVE_OPENAT)
397 of.disable_symlinks = clcf->disable_symlinks;
398 #endif
396
397 if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) {
398 /* simulate successful logging */
399 return len;
400 }
399401
400402 if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
401403 != NGX_OK)
443445 of.valid = llcf->open_file_cache_valid;
444446 of.min_uses = llcf->open_file_cache_min_uses;
445447 of.directio = NGX_OPEN_FILE_DIRECTIO_OFF;
446 #if (NGX_HAVE_OPENAT)
447 of.disable_symlinks = clcf->disable_symlinks;
448 #endif
448
449 if (ngx_http_set_disable_symlinks(r, clcf, &log, &of) != NGX_OK) {
450 /* simulate successful logging */
451 return len;
452 }
449453
450454 if (ngx_open_cached_file(llcf->open_file_cache, &log, &of, r->pool)
451455 != NGX_OK)
439439 of.min_uses = clcf->open_file_cache_min_uses;
440440 of.errors = clcf->open_file_cache_errors;
441441 of.events = clcf->open_file_cache_events;
442 #if (NGX_HAVE_OPENAT)
443 of.disable_symlinks = clcf->disable_symlinks;
444 #endif
442
443 if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) {
444 return NGX_HTTP_INTERNAL_SERVER_ERROR;
445 }
445446
446447 if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
447448 != NGX_OK)
9393 of.min_uses = clcf->open_file_cache_min_uses;
9494 of.errors = clcf->open_file_cache_errors;
9595 of.events = clcf->open_file_cache_events;
96 #if (NGX_HAVE_OPENAT)
97 of.disable_symlinks = clcf->disable_symlinks;
98 #endif
96
97 if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) {
98 return NGX_HTTP_INTERNAL_SERVER_ERROR;
99 }
99100
100101 if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
101102 != NGX_OK)
661661 of.min_uses = clcf->open_file_cache_min_uses;
662662 of.errors = clcf->open_file_cache_errors;
663663 of.events = clcf->open_file_cache_events;
664 #if (NGX_HAVE_OPENAT)
665 of.disable_symlinks = clcf->disable_symlinks;
666 #endif
664
665 if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) {
666 XSRETURN_EMPTY;
667 }
667668
668669 if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
669670 != NGX_OK)
13191319 of.test_only = 1;
13201320 of.errors = clcf->open_file_cache_errors;
13211321 of.events = clcf->open_file_cache_events;
1322 #if (NGX_HAVE_OPENAT)
1323 of.disable_symlinks = clcf->disable_symlinks;
1324 #endif
1322
1323 if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) {
1324 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
1325 return NGX_OK;
1326 }
13251327
13261328 if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
13271329 != NGX_OK)
26412643 "http cleanup add: %p", cln);
26422644
26432645 return cln;
2646 }
2647
2648
2649 ngx_int_t
2650 ngx_http_set_disable_symlinks(ngx_http_request_t *r,
2651 ngx_http_core_loc_conf_t *clcf, ngx_str_t *path, ngx_open_file_info_t *of)
2652 {
2653 #if (NGX_HAVE_OPENAT)
2654 of->disable_symlinks = clcf->disable_symlinks;
2655 #endif
2656
2657 return NGX_OK;
26442658 }
26452659
26462660
506506
507507 ngx_int_t ngx_http_output_filter(ngx_http_request_t *r, ngx_chain_t *chain);
508508 ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *chain);
509
510
511 ngx_int_t ngx_http_set_disable_symlinks(ngx_http_request_t *r,
512 ngx_http_core_loc_conf_t *clcf, ngx_str_t *path, ngx_open_file_info_t *of);
509513
510514
511515 extern ngx_module_t ngx_http_core_module;
15041504 of.test_only = 1;
15051505 of.errors = clcf->open_file_cache_errors;
15061506 of.events = clcf->open_file_cache_events;
1507 #if (NGX_HAVE_OPENAT)
1508 of.disable_symlinks = clcf->disable_symlinks;
1509 #endif
1507
1508 if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) {
1509 e->ip = ngx_http_script_exit;
1510 e->status = NGX_HTTP_INTERNAL_SERVER_ERROR;
1511 return;
1512 }
15101513
15111514 if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
15121515 != NGX_OK)