mirror of
https://github.com/nginx/nginx.git
synced 2025-07-25 22:56:59 +08:00
Disable symlinks: added the "from" parameter support to the open file cache.
This commit is contained in:
parent
075e852a4e
commit
346791187f
@ -229,6 +229,7 @@ ngx_open_cached_file(ngx_open_file_cache_t *cache, ngx_str_t *name,
|
|||||||
&& now - file->created < of->valid
|
&& now - file->created < of->valid
|
||||||
#if (NGX_HAVE_OPENAT)
|
#if (NGX_HAVE_OPENAT)
|
||||||
&& of->disable_symlinks == file->disable_symlinks
|
&& of->disable_symlinks == file->disable_symlinks
|
||||||
|
&& of->disable_symlinks_from == file->disable_symlinks_from
|
||||||
#endif
|
#endif
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
@ -395,6 +396,7 @@ update:
|
|||||||
file->err = of->err;
|
file->err = of->err;
|
||||||
#if (NGX_HAVE_OPENAT)
|
#if (NGX_HAVE_OPENAT)
|
||||||
file->disable_symlinks = of->disable_symlinks;
|
file->disable_symlinks = of->disable_symlinks;
|
||||||
|
file->disable_symlinks_from = of->disable_symlinks_from;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (of->err == 0) {
|
if (of->err == 0) {
|
||||||
@ -583,7 +585,28 @@ ngx_open_file_wrapper(ngx_str_t *name, ngx_open_file_info_t *of,
|
|||||||
|
|
||||||
at_name = *name;
|
at_name = *name;
|
||||||
|
|
||||||
if (*p == '/') {
|
if (of->disable_symlinks_from) {
|
||||||
|
|
||||||
|
cp = p + of->disable_symlinks_from;
|
||||||
|
|
||||||
|
*cp = '\0';
|
||||||
|
|
||||||
|
at_fd = ngx_open_file(p, NGX_FILE_SEARCH|NGX_FILE_NONBLOCK,
|
||||||
|
NGX_FILE_OPEN, 0);
|
||||||
|
|
||||||
|
*cp = '/';
|
||||||
|
|
||||||
|
if (at_fd == NGX_INVALID_FILE) {
|
||||||
|
of->err = ngx_errno;
|
||||||
|
of->failed = ngx_open_file_n;
|
||||||
|
return NGX_INVALID_FILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
at_name.len = of->disable_symlinks_from;
|
||||||
|
p = cp + 1;
|
||||||
|
|
||||||
|
} else if (*p == '/') {
|
||||||
|
|
||||||
at_fd = ngx_open_file("/",
|
at_fd = ngx_open_file("/",
|
||||||
NGX_FILE_SEARCH|NGX_FILE_NONBLOCK,
|
NGX_FILE_SEARCH|NGX_FILE_NONBLOCK,
|
||||||
NGX_FILE_OPEN, 0);
|
NGX_FILE_OPEN, 0);
|
||||||
|
@ -33,6 +33,7 @@ typedef struct {
|
|||||||
ngx_uint_t min_uses;
|
ngx_uint_t min_uses;
|
||||||
|
|
||||||
#if (NGX_HAVE_OPENAT)
|
#if (NGX_HAVE_OPENAT)
|
||||||
|
size_t disable_symlinks_from;
|
||||||
unsigned disable_symlinks:2;
|
unsigned disable_symlinks:2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -69,6 +70,7 @@ struct ngx_cached_open_file_s {
|
|||||||
uint32_t uses;
|
uint32_t uses;
|
||||||
|
|
||||||
#if (NGX_HAVE_OPENAT)
|
#if (NGX_HAVE_OPENAT)
|
||||||
|
size_t disable_symlinks_from;
|
||||||
unsigned disable_symlinks:2;
|
unsigned disable_symlinks:2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user