diff options
author | Volker Lendecke <vl@samba.org> | 2019-07-25 16:31:17 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2019-08-19 23:14:39 +0000 |
commit | 5c6163d3e664c20034fb41969e886372e3c88aa6 (patch) | |
tree | 7758d38b680474680ed02bf050de87e086064e13 | |
parent | 3ecfa36e777cf377a4ae06644b0880fef4867452 (diff) | |
download | samba-5c6163d3e664c20034fb41969e886372e3c88aa6.tar.gz |
smbd: Move grant_fsp_oplock_type() close to delay_for_oplock()
Note that this is not a cut&paste: Instead of fsp->access_mask we use
the access_mask the client requested. At the new code location
fsp->access_mask (a.k.a. open_access_mask) might have FILE_WRITE_DATA
from O_TRUNC (a.k.a. FILE_OVERWRITE).
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
-rw-r--r-- | source3/smbd/open.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c index ea5be99bd31..3b454dd675c 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -3521,6 +3521,24 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, return NT_STATUS_SHARING_VIOLATION; } + /* + * Setup the oplock info in both the shared memory and + * file structs. + */ + status = grant_fsp_oplock_type( + req, + fsp, + lck, + oplock_request, + lease, + share_access, + access_mask); + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(lck); + fd_close(fsp); + return status; + } + /* Should we atomically (to the client at least) truncate ? */ if ((!new_file_created) && (flags2 & O_TRUNC) && @@ -3530,6 +3548,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, ret = SMB_VFS_FTRUNCATE(fsp, 0); if (ret != 0) { status = map_nt_error_from_unix(errno); + del_share_mode(lck, fsp); TALLOC_FREE(lck); fd_close(fsp); return status; @@ -3549,6 +3568,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, !is_ntfs_stream_smb_fname(smb_fname)) { status = delete_all_streams(conn, smb_fname); if (!NT_STATUS_IS_OK(status)) { + del_share_mode(lck, fsp); TALLOC_FREE(lck); fd_close(fsp); return status; @@ -3569,6 +3589,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, ret_flock = SMB_VFS_KERNEL_FLOCK(fsp, share_access, access_mask); if(ret_flock == -1 ){ + del_share_mode(lck, fsp); TALLOC_FREE(lck); fd_close(fsp); @@ -3615,24 +3636,6 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, *pinfo = info; } - /* - * Setup the oplock info in both the shared memory and - * file structs. - */ - status = grant_fsp_oplock_type( - req, - fsp, - lck, - oplock_request, - lease, - share_access, - fsp->access_mask); - if (!NT_STATUS_IS_OK(status)) { - TALLOC_FREE(lck); - fd_close(fsp); - return status; - } - /* Handle strange delete on close create semantics. */ if (create_options & FILE_DELETE_ON_CLOSE) { if (!new_file_created) { |