comparison src/core/ngx_open_file_cache.c @ 4493:47ece8818978

Disable symlinks: added the "from" parameter support to the open file cache.
author Valentin Bartenev <vbart@nginx.com>
date Mon, 27 Feb 2012 16:46:57 +0000
parents d33ce8cd0d70
children 95ab6658654a
comparison
equal deleted inserted replaced
4492:4871a7dc12a9 4493:47ece8818978
227 || (file->event == NULL 227 || (file->event == NULL
228 && (of->uniq == 0 || of->uniq == file->uniq) 228 && (of->uniq == 0 || of->uniq == file->uniq)
229 && now - file->created < of->valid 229 && now - file->created < of->valid
230 #if (NGX_HAVE_OPENAT) 230 #if (NGX_HAVE_OPENAT)
231 && of->disable_symlinks == file->disable_symlinks 231 && of->disable_symlinks == file->disable_symlinks
232 && of->disable_symlinks_from == file->disable_symlinks_from
232 #endif 233 #endif
233 )) 234 ))
234 { 235 {
235 if (file->err == 0) { 236 if (file->err == 0) {
236 237
393 394
394 file->fd = of->fd; 395 file->fd = of->fd;
395 file->err = of->err; 396 file->err = of->err;
396 #if (NGX_HAVE_OPENAT) 397 #if (NGX_HAVE_OPENAT)
397 file->disable_symlinks = of->disable_symlinks; 398 file->disable_symlinks = of->disable_symlinks;
399 file->disable_symlinks_from = of->disable_symlinks_from;
398 #endif 400 #endif
399 401
400 if (of->err == 0) { 402 if (of->err == 0) {
401 file->uniq = of->uniq; 403 file->uniq = of->uniq;
402 file->mtime = of->mtime; 404 file->mtime = of->mtime;
581 p = name->data; 583 p = name->data;
582 end = p + name->len; 584 end = p + name->len;
583 585
584 at_name = *name; 586 at_name = *name;
585 587
586 if (*p == '/') { 588 if (of->disable_symlinks_from) {
589
590 cp = p + of->disable_symlinks_from;
591
592 *cp = '\0';
593
594 at_fd = ngx_open_file(p, NGX_FILE_SEARCH|NGX_FILE_NONBLOCK,
595 NGX_FILE_OPEN, 0);
596
597 *cp = '/';
598
599 if (at_fd == NGX_INVALID_FILE) {
600 of->err = ngx_errno;
601 of->failed = ngx_open_file_n;
602 return NGX_INVALID_FILE;
603 }
604
605 at_name.len = of->disable_symlinks_from;
606 p = cp + 1;
607
608 } else if (*p == '/') {
609
587 at_fd = ngx_open_file("/", 610 at_fd = ngx_open_file("/",
588 NGX_FILE_SEARCH|NGX_FILE_NONBLOCK, 611 NGX_FILE_SEARCH|NGX_FILE_NONBLOCK,
589 NGX_FILE_OPEN, 0); 612 NGX_FILE_OPEN, 0);
590 613
591 if (at_fd == NGX_INVALID_FILE) { 614 if (at_fd == NGX_INVALID_FILE) {