mirror of
https://github.com/nginx/nginx.git
synced 2025-06-07 17:52:38 +08:00
use lstat() for WebDAV DELETE, COPY, and MOVE to handle symlinks
This commit is contained in:
parent
fa7d06ee4f
commit
3ec15dd090
@ -325,13 +325,13 @@ ok:
|
|||||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
"http delete filename: \"%s\"", path.data);
|
"http delete filename: \"%s\"", path.data);
|
||||||
|
|
||||||
if (ngx_file_info(path.data, &fi) == NGX_FILE_ERROR) {
|
if (ngx_link_info(path.data, &fi) == NGX_FILE_ERROR) {
|
||||||
err = ngx_errno;
|
err = ngx_errno;
|
||||||
|
|
||||||
rc = (err == NGX_ENOTDIR) ? NGX_HTTP_CONFLICT : NGX_HTTP_NOT_FOUND;
|
rc = (err == NGX_ENOTDIR) ? NGX_HTTP_CONFLICT : NGX_HTTP_NOT_FOUND;
|
||||||
|
|
||||||
return ngx_http_dav_error(r->connection->log, err,
|
return ngx_http_dav_error(r->connection->log, err,
|
||||||
rc, ngx_file_info_n, path.data);
|
rc, ngx_link_info_n, path.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ngx_is_dir(&fi)) {
|
if (ngx_is_dir(&fi)) {
|
||||||
@ -358,7 +358,7 @@ ok:
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* we do not need to test (r->uri.data[r->uri.len - 1] == '/')
|
* we do not need to test (r->uri.data[r->uri.len - 1] == '/')
|
||||||
* because ngx_file_info("/file/") returned NGX_ENOTDIR above
|
* because ngx_link_info("/file/") returned NGX_ENOTDIR above
|
||||||
*/
|
*/
|
||||||
|
|
||||||
depth = ngx_http_dav_depth(r, 0);
|
depth = ngx_http_dav_depth(r, 0);
|
||||||
@ -685,12 +685,12 @@ overwrite_done:
|
|||||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
"http copy to: \"%s\"", copy.path.data);
|
"http copy to: \"%s\"", copy.path.data);
|
||||||
|
|
||||||
if (ngx_file_info(copy.path.data, &fi) == NGX_FILE_ERROR) {
|
if (ngx_link_info(copy.path.data, &fi) == NGX_FILE_ERROR) {
|
||||||
err = ngx_errno;
|
err = ngx_errno;
|
||||||
|
|
||||||
if (err != NGX_ENOENT) {
|
if (err != NGX_ENOENT) {
|
||||||
return ngx_http_dav_error(r->connection->log, err,
|
return ngx_http_dav_error(r->connection->log, err,
|
||||||
NGX_HTTP_NOT_FOUND, ngx_file_info_n,
|
NGX_HTTP_NOT_FOUND, ngx_link_info_n,
|
||||||
copy.path.data);
|
copy.path.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -719,9 +719,9 @@ overwrite_done:
|
|||||||
dir = ngx_is_dir(&fi);
|
dir = ngx_is_dir(&fi);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ngx_file_info(path.data, &fi) == NGX_FILE_ERROR) {
|
if (ngx_link_info(path.data, &fi) == NGX_FILE_ERROR) {
|
||||||
return ngx_http_dav_error(r->connection->log, ngx_errno,
|
return ngx_http_dav_error(r->connection->log, ngx_errno,
|
||||||
NGX_HTTP_NOT_FOUND, ngx_file_info_n,
|
NGX_HTTP_NOT_FOUND, ngx_link_info_n,
|
||||||
path.data);
|
path.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,6 +139,9 @@ ngx_int_t ngx_set_file_time(u_char *name, ngx_fd_t fd, time_t s);
|
|||||||
#define ngx_fd_info(fd, sb) fstat(fd, sb)
|
#define ngx_fd_info(fd, sb) fstat(fd, sb)
|
||||||
#define ngx_fd_info_n "fstat()"
|
#define ngx_fd_info_n "fstat()"
|
||||||
|
|
||||||
|
#define ngx_link_info(file, sb) lstat((const char *) file, sb)
|
||||||
|
#define ngx_link_info_n "lstat()"
|
||||||
|
|
||||||
#define ngx_is_dir(sb) (S_ISDIR((sb)->st_mode))
|
#define ngx_is_dir(sb) (S_ISDIR((sb)->st_mode))
|
||||||
#define ngx_is_file(sb) (S_ISREG((sb)->st_mode))
|
#define ngx_is_file(sb) (S_ISREG((sb)->st_mode))
|
||||||
#define ngx_is_link(sb) (S_ISLNK((sb)->st_mode))
|
#define ngx_is_link(sb) (S_ISLNK((sb)->st_mode))
|
||||||
|
@ -128,6 +128,10 @@ ngx_int_t ngx_file_info(u_char *filename, ngx_file_info_t *fi);
|
|||||||
#define ngx_fd_info_n "GetFileInformationByHandle()"
|
#define ngx_fd_info_n "GetFileInformationByHandle()"
|
||||||
|
|
||||||
|
|
||||||
|
#define ngx_link_info(name, fi) ngx_file_info(name, fi)
|
||||||
|
#define ngx_link_info_n "GetFileAttributesEx()"
|
||||||
|
|
||||||
|
|
||||||
#define ngx_is_dir(fi) \
|
#define ngx_is_dir(fi) \
|
||||||
(((fi)->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
|
(((fi)->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
|
||||||
#define ngx_is_file(fi) \
|
#define ngx_is_file(fi) \
|
||||||
|
Loading…
Reference in New Issue
Block a user