Disable symlinks: added the "from" parameter support to the open file cache.
Valentin Bartenev
10 years ago
228 | 228 | && now - file->created < of->valid |
229 | 229 | #if (NGX_HAVE_OPENAT) |
230 | 230 | && of->disable_symlinks == file->disable_symlinks |
231 | && of->disable_symlinks_from == file->disable_symlinks_from | |
231 | 232 | #endif |
232 | 233 | )) |
233 | 234 | { |
394 | 395 | file->err = of->err; |
395 | 396 | #if (NGX_HAVE_OPENAT) |
396 | 397 | file->disable_symlinks = of->disable_symlinks; |
398 | file->disable_symlinks_from = of->disable_symlinks_from; | |
397 | 399 | #endif |
398 | 400 | |
399 | 401 | if (of->err == 0) { |
582 | 584 | |
583 | 585 | at_name = *name; |
584 | 586 | |
585 | if (*p == '/') { | |
587 | if (of->disable_symlinks_from) { | |
588 | ||
589 | cp = p + of->disable_symlinks_from; | |
590 | ||
591 | *cp = '\0'; | |
592 | ||
593 | at_fd = ngx_open_file(p, NGX_FILE_SEARCH|NGX_FILE_NONBLOCK, | |
594 | NGX_FILE_OPEN, 0); | |
595 | ||
596 | *cp = '/'; | |
597 | ||
598 | if (at_fd == NGX_INVALID_FILE) { | |
599 | of->err = ngx_errno; | |
600 | of->failed = ngx_open_file_n; | |
601 | return NGX_INVALID_FILE; | |
602 | } | |
603 | ||
604 | at_name.len = of->disable_symlinks_from; | |
605 | p = cp + 1; | |
606 | ||
607 | } else if (*p == '/') { | |
608 | ||
586 | 609 | at_fd = ngx_open_file("/", |
587 | 610 | NGX_FILE_SEARCH|NGX_FILE_NONBLOCK, |
588 | 611 | NGX_FILE_OPEN, 0); |