summaryrefslogtreecommitdiff
path: root/source4/ntvfs/posix
diff options
context:
space:
mode:
Diffstat (limited to 'source4/ntvfs/posix')
-rw-r--r--source4/ntvfs/posix/pvfs_open.c15
-rw-r--r--source4/ntvfs/posix/pvfs_rename.c11
-rw-r--r--source4/ntvfs/posix/pvfs_unlink.c9
3 files changed, 24 insertions, 11 deletions
diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c
index badd18d370..b66b3725db 100644
--- a/source4/ntvfs/posix/pvfs_open.c
+++ b/source4/ntvfs/posix/pvfs_open.c
@@ -723,17 +723,24 @@ NTSTATUS pvfs_change_create_options(struct pvfs_state *pvfs,
/*
- determine if a file is open - used to prevent some operations on open files
+ determine if a file can be deleted, or if it is prevented by an
+ already open file
*/
-BOOL pvfs_is_open(struct pvfs_state *pvfs, struct pvfs_filename *name)
+NTSTATUS pvfs_can_delete(struct pvfs_state *pvfs, struct pvfs_filename *name)
{
NTSTATUS status;
DATA_BLOB key;
status = pvfs_locking_key(name, name, &key);
if (!NT_STATUS_IS_OK(status)) {
- return False;
+ return NT_STATUS_NO_MEMORY;
}
- return odb_is_open(pvfs->odb_context, &key);
+ status = odb_can_open(pvfs->odb_context, &key,
+ NTCREATEX_SHARE_ACCESS_READ |
+ NTCREATEX_SHARE_ACCESS_WRITE |
+ NTCREATEX_SHARE_ACCESS_DELETE,
+ 0, STD_RIGHT_DELETE_ACCESS);
+
+ return status;
}
diff --git a/source4/ntvfs/posix/pvfs_rename.c b/source4/ntvfs/posix/pvfs_rename.c
index 89d6a0da14..6116f6c7bf 100644
--- a/source4/ntvfs/posix/pvfs_rename.c
+++ b/source4/ntvfs/posix/pvfs_rename.c
@@ -48,9 +48,14 @@ NTSTATUS pvfs_rename(struct ntvfs_module_context *ntvfs,
return status;
}
- if (pvfs_is_open(pvfs, name1) ||
- pvfs_is_open(pvfs, name2)) {
- return NT_STATUS_SHARING_VIOLATION;
+ status = pvfs_can_delete(pvfs, name1);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ status = pvfs_can_delete(pvfs, name2);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
if (name1->has_wildcard || name2->has_wildcard) {
diff --git a/source4/ntvfs/posix/pvfs_unlink.c b/source4/ntvfs/posix/pvfs_unlink.c
index 5733722ad5..10a27a5de7 100644
--- a/source4/ntvfs/posix/pvfs_unlink.c
+++ b/source4/ntvfs/posix/pvfs_unlink.c
@@ -47,6 +47,11 @@ static NTSTATUS pvfs_unlink_one(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx,
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
+ status = pvfs_can_delete(pvfs, name);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
/* finally try the actual unlink */
if (unlink(name->full_name) == -1) {
status = pvfs_map_errno(pvfs, errno);
@@ -80,10 +85,6 @@ NTSTATUS pvfs_unlink(struct ntvfs_module_context *ntvfs,
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
- if (pvfs_is_open(pvfs, name)) {
- return NT_STATUS_SHARING_VIOLATION;
- }
-
dir = talloc_p(req, struct pvfs_dir);
if (dir == NULL) {
return NT_STATUS_NO_MEMORY;