mirror of
https://github.com/samba-team/samba.git
synced 2025-02-28 01:58:17 +03:00
s4-pvfs: use pvfs_sys_*() functions to wrap posix calls
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>
This commit is contained in:
parent
034bcaf14d
commit
ace6d75ae6
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user