diff options
author | Valentin Bartenev <vbart@nginx.com> | 2012-02-21 15:04:41 +0000 |
---|---|---|
committer | Valentin Bartenev <vbart@nginx.com> | 2012-02-21 15:04:41 +0000 |
commit | 15b3173c5e5108287f5d74126f29854b14c1db94 (patch) | |
tree | 7f0a3b5b3653fec26d89c1167df28545f0370c18 /src/core/ngx_open_file_cache.c | |
parent | 8c27e6429aa634091ad07e02bfee91084497549f (diff) | |
download | nginx-15b3173c5e5108287f5d74126f29854b14c1db94.tar.gz nginx-15b3173c5e5108287f5d74126f29854b14c1db94.zip |
Disable symlinks: don't allow creating or truncating a file via a symlink in
the last path component if "if_not_owner" parameter is used.
To prevent race condition we have to open a file before checking its owner and
there's no way to change access flags for already opened file descriptor, so
we disable symlinks for the last path component at all if flags allow creating
or truncating the file.
Diffstat (limited to 'src/core/ngx_open_file_cache.c')
-rw-r--r-- | src/core/ngx_open_file_cache.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/core/ngx_open_file_cache.c b/src/core/ngx_open_file_cache.c index 9ce0308ce..7dd968f36 100644 --- a/src/core/ngx_open_file_cache.c +++ b/src/core/ngx_open_file_cache.c @@ -678,7 +678,9 @@ ngx_open_file_wrapper(ngx_str_t *name, ngx_open_file_info_t *of, goto failed; } - if (of->disable_symlinks == NGX_DISABLE_SYMLINKS_NOTOWNER) { + if (of->disable_symlinks == NGX_DISABLE_SYMLINKS_NOTOWNER + && !(create & (NGX_FILE_CREATE_OR_OPEN|NGX_FILE_TRUNCATE))) + { fd = ngx_openat_file_owner(at_fd, p, mode, create, access, log); } else { |