diff options
-rw-r--r-- | source3/smbd/close.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/source3/smbd/close.c b/source3/smbd/close.c index adcd67a5f5..1fb7bdeb84 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -1047,6 +1047,7 @@ static NTSTATUS rmdir_internals(TALLOC_CTX *ctx, files_struct *fsp) static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp, enum file_close_type close_type) { + struct server_id self = messaging_server_id(fsp->conn->sconn->msg_ctx); struct share_mode_lock *lck = NULL; bool delete_dir = False; NTSTATUS status = NT_STATUS_OK; @@ -1066,11 +1067,6 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp, return NT_STATUS_INVALID_PARAMETER; } - if (!del_share_mode(lck, fsp)) { - DEBUG(0, ("close_directory: Could not delete share entry for " - "%s\n", fsp_str_dbg(fsp))); - } - if (fsp->initial_delete_on_close) { bool became_user = False; @@ -1107,6 +1103,10 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp, if (fsp->posix_open && (e->flags & SHARE_MODE_FLAG_POSIX_OPEN)) { continue; } + if (procid_equal(&self, &e->pid) && + (e->share_file_id == fsp->fh->gen_id)) { + continue; + } if (share_mode_stale_pid(lck->data, i)) { continue; } @@ -1131,6 +1131,11 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp, del_token->groups, del_nt_token); + if (!del_share_mode(lck, fsp)) { + DEBUG(0, ("close_directory: Could not delete share entry for " + "%s\n", fsp_str_dbg(fsp))); + } + TALLOC_FREE(lck); if ((fsp->conn->fs_capabilities & FILE_NAMED_STREAMS) @@ -1162,6 +1167,11 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp, remove_pending_change_notify_requests_by_fid(fsp, NT_STATUS_DELETE_PENDING); } } else { + if (!del_share_mode(lck, fsp)) { + DEBUG(0, ("close_directory: Could not delete share entry for " + "%s\n", fsp_str_dbg(fsp))); + } + TALLOC_FREE(lck); remove_pending_change_notify_requests_by_fid( fsp, NT_STATUS_OK); |