Klaus Demo nginx / 99b468d
merge r3502: use lstat() for WebDAV DELETE, COPY, and MOVE to handle symlinks Igor Sysoev 12 years ago
3 changed file(s) with 14 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
324324 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
325325 "http delete filename: \"%s\"", path.data);
326326
327 if (ngx_file_info(path.data, &fi) == NGX_FILE_ERROR) {
327 if (ngx_link_info(path.data, &fi) == NGX_FILE_ERROR) {
328328 err = ngx_errno;
329329
330330 rc = (err == NGX_ENOTDIR) ? NGX_HTTP_CONFLICT : NGX_HTTP_NOT_FOUND;
331331
332332 return ngx_http_dav_error(r->connection->log, err,
333 rc, ngx_file_info_n, path.data);
333 rc, ngx_link_info_n, path.data);
334334 }
335335
336336 if (ngx_is_dir(&fi)) {
357357
358358 /*
359359 * we do not need to test (r->uri.data[r->uri.len - 1] == '/')
360 * because ngx_file_info("/file/") returned NGX_ENOTDIR above
360 * because ngx_link_info("/file/") returned NGX_ENOTDIR above
361361 */
362362
363363 depth = ngx_http_dav_depth(r, 0);
684684 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
685685 "http copy to: \"%s\"", copy.path.data);
686686
687 if (ngx_file_info(copy.path.data, &fi) == NGX_FILE_ERROR) {
687 if (ngx_link_info(copy.path.data, &fi) == NGX_FILE_ERROR) {
688688 err = ngx_errno;
689689
690690 if (err != NGX_ENOENT) {
691691 return ngx_http_dav_error(r->connection->log, err,
692 NGX_HTTP_NOT_FOUND, ngx_file_info_n,
692 NGX_HTTP_NOT_FOUND, ngx_link_info_n,
693693 copy.path.data);
694694 }
695695
718718 dir = ngx_is_dir(&fi);
719719 }
720720
721 if (ngx_file_info(path.data, &fi) == NGX_FILE_ERROR) {
721 if (ngx_link_info(path.data, &fi) == NGX_FILE_ERROR) {
722722 return ngx_http_dav_error(r->connection->log, ngx_errno,
723 NGX_HTTP_NOT_FOUND, ngx_file_info_n,
723 NGX_HTTP_NOT_FOUND, ngx_link_info_n,
724724 path.data);
725725 }
726726
138138 #define ngx_fd_info(fd, sb) fstat(fd, sb)
139139 #define ngx_fd_info_n "fstat()"
140140
141 #define ngx_link_info(file, sb) lstat((const char *) file, sb)
142 #define ngx_link_info_n "lstat()"
143
141144 #define ngx_is_dir(sb) (S_ISDIR((sb)->st_mode))
142145 #define ngx_is_file(sb) (S_ISREG((sb)->st_mode))
143146 #define ngx_is_link(sb) (S_ISLNK((sb)->st_mode))
127127 #define ngx_fd_info_n "GetFileInformationByHandle()"
128128
129129
130 #define ngx_link_info(name, fi) ngx_file_info(name, fi)
131 #define ngx_link_info_n "GetFileAttributesEx()"
132
133
130134 #define ngx_is_dir(fi) \
131135 (((fi)->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
132136 #define ngx_is_file(fi) \