ПРОЕКТЫ 


  АРХИВ 


Apache-Talk @lexa.ru 

Inet-Admins @info.east.ru 

Filmscanners @halftone.co.uk 

Security-alerts @yandex-team.ru 

nginx-ru @sysoev.ru 


  СТАТЬИ 


  ПЕРСОНАЛЬНОЕ 


  ПРОГРАММЫ 



ПИШИТЕ
ПИСЬМА












     АРХИВ :: nginx-ru
Nginx-ru mailing list archive (nginx-ru@sysoev.ru)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MOVE вызывает 500 ош ибку



On Wed, Dec 10, 2008 at 02:01:40PM +0300, Монашёв Михаил wrote:

> MOVE создаёт директории с немерными правами:
> 
>  ls -l /usr/home/beon/www/i/users/1/52/
> total 4
> d---------  2 www   beon  512 Dec 10 13:53 235201
> drwxrwxrwx  3 beon  beon  512 Nov  3 22:44 275201

Новый патч.


-- 
Игорь Сысоев
http://sysoev.ru
Index: src/http/ngx_http_upstream.c
===================================================================
--- src/http/ngx_http_upstream.c        (revision 1709)
+++ src/http/ngx_http_upstream.c        (working copy)
@@ -2288,9 +2288,11 @@
     }
 
     ext.access = u->conf->store_access;
+    ext.path_access = u->conf->store_access;
     ext.time = -1;
     ext.create_path = 1;
     ext.delete_file = 1;
+    ext.log_rename_error = 1;
     ext.log = r->connection->log;
 
     if (u->headers_in.last_modified) {
Index: src/http/modules/ngx_http_dav_module.c
===================================================================
--- src/http/modules/ngx_http_dav_module.c      (revision 1709)
+++ src/http/modules/ngx_http_dav_module.c      (working copy)
@@ -246,9 +246,11 @@
     dlcf = ngx_http_get_module_loc_conf(r, ngx_http_dav_module);
 
     ext.access = dlcf->access;
+    ext.path_access = dlcf->access;
     ext.time = -1;
     ext.create_path = dlcf->create_full_put_path;
     ext.delete_file = 1;
+    ext.log_rename_error = 1;
     ext.log = r->connection->log;
 
     if (r->headers_in.date) {
@@ -521,6 +523,7 @@
     ngx_tree_ctx_t            tree;
     ngx_file_info_t           fi;
     ngx_table_elt_t          *dest, *over;
+    ngx_ext_rename_file_t     ext;
     ngx_http_dav_copy_ctx_t   copy;
     ngx_http_dav_loc_conf_t  *dlcf;
 
@@ -781,9 +784,32 @@
     } else {
 
         if (r->method == NGX_HTTP_MOVE) {
-            if (ngx_rename_file(path.data, copy.path.data) != NGX_FILE_ERROR) {
+
+            dlcf = ngx_http_get_module_loc_conf(r, ngx_http_dav_module);
+
+            ext.access = 0;
+            ext.path_access = dlcf->access;
+            ext.time = -1;
+            ext.create_path = 1;
+            ext.delete_file = 0;
+            ext.log_rename_error = 0;
+            ext.log = r->connection->log;
+
+            if (ngx_ext_rename_file(&path, &copy.path, &ext) == NGX_OK) {
                 return NGX_HTTP_NO_CONTENT;
             }
+
+            if (ext.rename_error != NGX_EXDEV) {
+
+                if (ext.rename_error) {
+                    ngx_log_error(NGX_LOG_CRIT, r->connection->log,
+                                  ext.rename_error,
+                                  ngx_rename_file_n " \"%s\" to \"%s\" failed",
+                                  path.data, copy.path.data);
+                }
+
+                return NGX_HTTP_INTERNAL_SERVER_ERROR;
+            }
         }
 
         dlcf = ngx_http_get_module_loc_conf(r, ngx_http_dav_module);
Index: src/os/unix/ngx_errno.h
===================================================================
--- src/os/unix/ngx_errno.h     (revision 1709)
+++ src/os/unix/ngx_errno.h     (working copy)
@@ -23,6 +23,7 @@
 #define NGX_EACCES        EACCES
 #define NGX_EBUSY         EBUSY
 #define NGX_EEXIST        EEXIST
+#define NGX_EXDEV         EXDEV
 #define NGX_ENOTDIR       ENOTDIR
 #define NGX_EISDIR        EISDIR
 #define NGX_EINVAL        EINVAL
Index: src/core/ngx_file.c
===================================================================
--- src/core/ngx_file.c (revision 1709)
+++ src/core/ngx_file.c (working copy)
@@ -487,11 +487,13 @@
 
 #if !(NGX_WIN32)
 
-    if (ngx_change_file_access(src->data, ext->access) == NGX_FILE_ERROR) {
-        ngx_log_error(NGX_LOG_CRIT, ext->log, ngx_errno,
-                      ngx_change_file_access_n " \"%s\" failed", src->data);
-        err = 0;
-        goto failed;
+    if (ext->access) {
+        if (ngx_change_file_access(src->data, ext->access) == NGX_FILE_ERROR) {
+            ngx_log_error(NGX_LOG_CRIT, ext->log, ngx_errno,
+                          ngx_change_file_access_n " \"%s\" failed", 
src->data);
+            err = 0;
+            goto failed;
+        }
     }
 
 #endif
@@ -517,7 +519,7 @@
             goto failed;
         }
 
-        err = ngx_create_full_path(to->data, ngx_dir_access(ext->access));
+        err = ngx_create_full_path(to->data, ngx_dir_access(ext->path_access));
 
         if (err) {
             ngx_log_error(NGX_LOG_CRIT, ext->log, err,
@@ -561,12 +563,14 @@
         }
     }
 
-    if (err) {
+    if (err && ext->log_rename_error) {
         ngx_log_error(NGX_LOG_CRIT, ext->log, err,
                       ngx_rename_file_n " \"%s\" to \"%s\" failed",
                       src->data, to->data);
     }
 
+    ext->rename_error = err;
+
     return NGX_ERROR;
 }
 
Index: src/core/ngx_file.h
===================================================================
--- src/core/ngx_file.h (revision 1709)
+++ src/core/ngx_file.h (working copy)
@@ -60,11 +60,14 @@
 
 typedef struct {
     ngx_uint_t          access;
+    ngx_uint_t          path_access;
     time_t              time;
     ngx_fd_t            fd;
+    ngx_err_t           rename_error;
 
     unsigned            create_path:1;
     unsigned            delete_file:1;
+    unsigned            log_rename_error:1;
 
     ngx_log_t          *log;
 } ngx_ext_rename_file_t;


 




Copyright © Lexa Software, 1996-2009.