s4-pvfs: use pvfs_sys_*() functions to wrap posix calls
authorAndrew Tridgell <tridge@samba.org>
Fri, 5 Mar 2010 06:52:35 +0000 (17:52 +1100)
committerAndrew Tridgell <tridge@samba.org>
Fri, 5 Mar 2010 12:07:31 +0000 (23:07 +1100)
This allows for root override, which fixes many problems with
mismatches between NT ACL permissions and unix permissions.

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

source4/ntvfs/posix/pvfs_mkdir.c
source4/ntvfs/posix/pvfs_open.c
source4/ntvfs/posix/pvfs_rename.c
source4/ntvfs/posix/pvfs_unlink.c
source4/ntvfs/posix/pvfs_util.c

index 6ec9e60955d94fb9b18830e84f3dc416bc02e05f..10de1d6d5c122d6f940c2d104adbf0c23e41eac2 100644 (file)
@@ -51,7 +51,7 @@ static NTSTATUS pvfs_t2mkdir(struct pvfs_state *pvfs,
 
        mode = pvfs_fileperms(pvfs, FILE_ATTRIBUTE_DIRECTORY);
 
-       if (mkdir(name->full_name, mode) == -1) {
+       if (pvfs_sys_mkdir(pvfs, name->full_name, mode) == -1) {
                return pvfs_map_errno(pvfs, errno);
        }
 
@@ -69,7 +69,7 @@ static NTSTATUS pvfs_t2mkdir(struct pvfs_state *pvfs,
        /* setup an inherited acl from the parent */
        status = pvfs_acl_inherit(pvfs, req, name, -1);
        if (!NT_STATUS_IS_OK(status)) {
-               rmdir(name->full_name);
+               pvfs_sys_rmdir(pvfs, name->full_name);
                return status;
        }
 
@@ -78,7 +78,7 @@ static NTSTATUS pvfs_t2mkdir(struct pvfs_state *pvfs,
                                         md->t2mkdir.in.num_eas,
                                         md->t2mkdir.in.eas);
        if (!NT_STATUS_IS_OK(status)) {
-               rmdir(name->full_name);
+               pvfs_sys_rmdir(pvfs, name->full_name);
                return status;
        }
 
@@ -127,7 +127,7 @@ NTSTATUS pvfs_mkdir(struct ntvfs_module_context *ntvfs,
 
        mode = pvfs_fileperms(pvfs, FILE_ATTRIBUTE_DIRECTORY);
 
-       if (mkdir(name->full_name, mode) == -1) {
+       if (pvfs_sys_mkdir(pvfs, name->full_name, mode) == -1) {
                return pvfs_map_errno(pvfs, errno);
        }
 
@@ -136,7 +136,7 @@ NTSTATUS pvfs_mkdir(struct ntvfs_module_context *ntvfs,
        /* setup an inherited acl from the parent */
        status = pvfs_acl_inherit(pvfs, req, name, -1);
        if (!NT_STATUS_IS_OK(status)) {
-               rmdir(name->full_name);
+               pvfs_sys_rmdir(pvfs, name->full_name);
                return status;
        }
 
@@ -179,7 +179,7 @@ NTSTATUS pvfs_rmdir(struct ntvfs_module_context *ntvfs,
                return status;
        }
 
-       if (rmdir(name->full_name) == -1) {
+       if (pvfs_sys_rmdir(pvfs, name->full_name) == -1) {
                /* some olders systems don't return ENOTEMPTY to rmdir() */
                if (errno == EEXIST) {
                        return NT_STATUS_DIRECTORY_NOT_EMPTY;
index d9d0d2178ab134949398e5acdb439fd02927c777..f88e21e7386fa8c3288618ff482741bc370862fd 100644 (file)
@@ -73,7 +73,7 @@ static int pvfs_dir_handle_destructor(struct pvfs_file_handle *h)
                                DEBUG(0,("Warning: xattr unlink hook failed for '%s' - %s\n",
                                         delete_path, nt_errstr(status)));
                        }
-                       if (rmdir(delete_path) != 0) {
+                       if (pvfs_sys_rmdir(h->pvfs, delete_path) != 0) {
                                DEBUG(0,("pvfs_dir_handle_destructor: failed to rmdir '%s' - %s\n",
                                         delete_path, strerror(errno)));
                        }
@@ -344,7 +344,7 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
                uint32_t attrib = io->generic.in.file_attr | FILE_ATTRIBUTE_DIRECTORY;
                mode_t mode = pvfs_fileperms(pvfs, attrib);
 
-               if (mkdir(name->full_name, mode) == -1) {
+               if (pvfs_sys_mkdir(pvfs, name->full_name, mode) == -1) {
                        return pvfs_map_errno(pvfs,errno);
                }
 
@@ -432,7 +432,7 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
        return NT_STATUS_OK;
 
 cleanup_delete:
-       rmdir(name->full_name);
+       pvfs_sys_rmdir(pvfs, name->full_name);
        return status;
 }
 
@@ -514,7 +514,7 @@ static int pvfs_handle_destructor(struct pvfs_file_handle *h)
                                DEBUG(0,("Warning: xattr unlink hook failed for '%s' - %s\n",
                                         delete_path, nt_errstr(status)));
                        }
-                       if (unlink(delete_path) != 0) {
+                       if (pvfs_sys_unlink(h->pvfs, delete_path) != 0) {
                                DEBUG(0,("pvfs_close: failed to delete '%s' - %s\n",
                                         delete_path, strerror(errno)));
                        } else {
@@ -677,7 +677,7 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
        mode = pvfs_fileperms(pvfs, attrib);
 
        /* create the file */
-       fd = open(name->full_name, flags | O_CREAT | O_EXCL| O_NONBLOCK, mode);
+       fd = pvfs_sys_open(pvfs, name->full_name, flags | O_CREAT | O_EXCL| O_NONBLOCK, mode);
        if (fd == -1) {
                return pvfs_map_errno(pvfs, errno);
        }
@@ -856,7 +856,7 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
 
 cleanup_delete:
        close(fd);
-       unlink(name->full_name);
+       pvfs_sys_unlink(pvfs, name->full_name);
        return status;
 }
 
@@ -1549,7 +1549,7 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
        }
 
        /* do the actual open */
-       fd = open(f->handle->name->full_name, flags | O_NONBLOCK);
+       fd = pvfs_sys_open(pvfs, f->handle->name->full_name, flags | O_NONBLOCK, 0);
        if (fd == -1) {
                status = pvfs_map_errno(f->pvfs, errno);
 
index 66c1427a11bdeb78946dd308b27724f665a02026..e4448d3442b431f43a927305484258afa380da49 100644 (file)
@@ -37,7 +37,7 @@ NTSTATUS pvfs_do_rename(struct pvfs_state *pvfs,
        uint32_t mask;
        NTSTATUS status;
 
-       if (rename(name1->full_name, name2) == -1) {
+       if (pvfs_sys_rename(pvfs, name1->full_name, name2) == -1) {
                return pvfs_map_errno(pvfs, errno);
        }
 
index 67e7d76b47f6fbd116dccd84f6523b4fdce68c87..be2ba531488c8eaccc7251941dbcefbc3a9a263b 100644 (file)
@@ -123,7 +123,7 @@ static NTSTATUS pvfs_unlink_file(struct pvfs_state *pvfs,
        }
 
        /* finally try the actual unlink */
-       if (unlink(name->full_name) == -1) {
+       if (pvfs_sys_unlink(pvfs, name->full_name) == -1) {
                status = pvfs_map_errno(pvfs, errno);
        }
 
index b1b0a647892d74722beb8f254bf76f654cf6e7b4..63651c203a35b461459e7b08c98578421f4343ff 100644 (file)
@@ -102,13 +102,13 @@ NTSTATUS pvfs_copy_file(struct pvfs_state *pvfs,
                return NT_STATUS_NO_MEMORY;
        }
 
-       fd1 = open(name1->full_name, O_RDONLY);
+       fd1 = pvfs_sys_open(pvfs, name1->full_name, O_RDONLY, 0);
        if (fd1 == -1) {
                talloc_free(buf);
                return pvfs_map_errno(pvfs, errno);
        }
 
-       fd2 = open(name2->full_name, O_CREAT|O_EXCL|O_WRONLY, 0);
+       fd2 = pvfs_sys_open(pvfs, name2->full_name, O_CREAT|O_EXCL|O_WRONLY, 0);
        if (fd2 == -1) {
                close(fd1);
                talloc_free(buf);
@@ -133,7 +133,7 @@ NTSTATUS pvfs_copy_file(struct pvfs_state *pvfs,
                        close(fd1);
                        close(fd2);
                        talloc_free(buf);
-                       unlink(name2->full_name);
+                       pvfs_sys_unlink(pvfs, name2->full_name);
                        if (ret2 == -1) {
                                return pvfs_map_errno(pvfs, errno);
                        }
@@ -148,7 +148,7 @@ NTSTATUS pvfs_copy_file(struct pvfs_state *pvfs,
        if (fchmod(fd2, mode) == -1) {
                status = pvfs_map_errno(pvfs, errno);
                close(fd2);
-               unlink(name2->full_name);
+               pvfs_sys_unlink(pvfs, name2->full_name);
                return status;
        }
 
@@ -158,7 +158,7 @@ NTSTATUS pvfs_copy_file(struct pvfs_state *pvfs,
        status = pvfs_dosattrib_save(pvfs, name2, fd2);
        if (!NT_STATUS_IS_OK(status)) {
                close(fd2);
-               unlink(name2->full_name);
+               pvfs_sys_unlink(pvfs, name2->full_name);
                return status;
        }