comparison src/http/modules/ngx_http_index_module.c @ 4478:08713bac87fc

Support for disable_symlinks in various modules.
author Andrey Belov <defan@nginx.com>
date Mon, 13 Feb 2012 16:32:21 +0000
parents d620f497c50f
children 13e09cf11d4e
comparison
equal deleted inserted replaced
4477:7033faf6dc3c 4478:08713bac87fc
207 of.valid = clcf->open_file_cache_valid; 207 of.valid = clcf->open_file_cache_valid;
208 of.min_uses = clcf->open_file_cache_min_uses; 208 of.min_uses = clcf->open_file_cache_min_uses;
209 of.test_only = 1; 209 of.test_only = 1;
210 of.errors = clcf->open_file_cache_errors; 210 of.errors = clcf->open_file_cache_errors;
211 of.events = clcf->open_file_cache_events; 211 of.events = clcf->open_file_cache_events;
212 #if (NGX_HAVE_OPENAT)
213 of.disable_symlinks = clcf->disable_symlinks;
214 #endif
212 215
213 if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool) 216 if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
214 != NGX_OK) 217 != NGX_OK)
215 { 218 {
216 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, of.err, 219 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, of.err,
218 221
219 if (of.err == 0) { 222 if (of.err == 0) {
220 return NGX_HTTP_INTERNAL_SERVER_ERROR; 223 return NGX_HTTP_INTERNAL_SERVER_ERROR;
221 } 224 }
222 225
226 #if (NGX_HAVE_OPENAT)
227 if (of.err == NGX_EMLINK
228 || of.err == NGX_ELOOP)
229 {
230 return NGX_HTTP_FORBIDDEN;
231 }
232 #endif
233
223 if (of.err == NGX_ENOTDIR 234 if (of.err == NGX_ENOTDIR
224 || of.err == NGX_ENAMETOOLONG 235 || of.err == NGX_ENAMETOOLONG
225 || of.err == NGX_EACCES) 236 || of.err == NGX_EACCES)
226 { 237 {
227 return ngx_http_index_error(r, clcf, path.data, of.err); 238 return ngx_http_index_error(r, clcf, path.data, of.err);
294 305
295 of.test_dir = 1; 306 of.test_dir = 1;
296 of.test_only = 1; 307 of.test_only = 1;
297 of.valid = clcf->open_file_cache_valid; 308 of.valid = clcf->open_file_cache_valid;
298 of.errors = clcf->open_file_cache_errors; 309 of.errors = clcf->open_file_cache_errors;
310 #if (NGX_HAVE_OPENAT)
311 of.disable_symlinks = clcf->disable_symlinks;
312 #endif
299 313
300 if (ngx_open_cached_file(clcf->open_file_cache, &dir, &of, r->pool) 314 if (ngx_open_cached_file(clcf->open_file_cache, &dir, &of, r->pool)
301 != NGX_OK) 315 != NGX_OK)
302 { 316 {
303 if (of.err) { 317 if (of.err) {
318
319 #if (NGX_HAVE_OPENAT)
320 if (of.err == NGX_EMLINK
321 || of.err == NGX_ELOOP)
322 {
323 return NGX_HTTP_FORBIDDEN;
324 }
325 #endif
304 326
305 if (of.err == NGX_ENOENT) { 327 if (of.err == NGX_ENOENT) {
306 *last = c; 328 *last = c;
307 return ngx_http_index_error(r, clcf, dir.data, NGX_ENOENT); 329 return ngx_http_index_error(r, clcf, dir.data, NGX_ENOENT);
308 } 330 }