summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2019-08-06 16:28:29 +0200
committerJeremy Allison <jra@samba.org>2019-08-19 23:14:39 +0000
commitd4e98b8ae5f08d6e332b15d868e7bf85995974f3 (patch)
tree9dc0ba88320a3d5016e4e7e581e8a75b05147ff0
parent5c6163d3e664c20034fb41969e886372e3c88aa6 (diff)
downloadsamba-d4e98b8ae5f08d6e332b15d868e7bf85995974f3.tar.gz
smbd: Move set_share_mode() out of grant_fsp_oplock_type()
This shows that "req", "share_access" and "access_mask" are not needed for the core logic of grant_fsp_oplock_type() and it separates concerns a bit: open_directory() also does the set_share_mode() in the main open routine, not in a helper like grant_fsp_oplock_type() Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
-rw-r--r--source3/smbd/open.c60
1 files changed, 27 insertions, 33 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 3b454dd675c..d06db5f20a3 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -2207,20 +2207,16 @@ static int map_lease_type_to_oplock(uint32_t lease_type)
return result;
}
-static NTSTATUS grant_fsp_oplock_type(struct smb_request *req,
- struct files_struct *fsp,
+static NTSTATUS grant_fsp_oplock_type(struct files_struct *fsp,
struct share_mode_lock *lck,
int oplock_request,
- const struct smb2_lease *lease,
- uint32_t share_access,
- uint32_t access_mask)
+ const struct smb2_lease *lease)
{
struct share_mode_data *d = lck->data;
bool got_handle_lease = false;
bool got_oplock = false;
uint32_t i;
uint32_t granted;
- bool ok;
NTSTATUS status;
if (oplock_request & INTERNAL_OPEN_ONLY) {
@@ -2333,29 +2329,6 @@ static NTSTATUS grant_fsp_oplock_type(struct smb_request *req,
}
}
- ok = set_share_mode(
- lck,
- fsp,
- get_current_uid(fsp->conn),
- req ? req->mid : 0,
- fsp->oplock_type,
- share_access,
- access_mask);
- if (!ok) {
- if (fsp->oplock_type == LEASE_OPLOCK) {
- status = remove_lease_if_stale(
- lck->data,
- fsp_client_guid(fsp),
- &fsp->lease->lease.lease_key);
- if (!NT_STATUS_IS_OK(status)) {
- DBG_WARNING("remove_lease_if_stale "
- "failed: %s\n",
- nt_errstr(status));
- }
- }
- return NT_STATUS_NO_MEMORY;
- }
-
if (granted & SMB2_LEASE_READ) {
lck->data->flags |= SHARE_MODE_HAS_READ_LEASE;
}
@@ -3021,6 +2994,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
SMB_STRUCT_STAT saved_stat = smb_fname->st;
struct timespec old_write_time;
struct file_id id;
+ bool ok;
if (conn->printer) {
/*
@@ -3526,19 +3500,39 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
* file structs.
*/
status = grant_fsp_oplock_type(
- req,
fsp,
lck,
oplock_request,
- lease,
- share_access,
- access_mask);
+ lease);
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(lck);
fd_close(fsp);
return status;
}
+ ok = set_share_mode(
+ lck,
+ fsp,
+ get_current_uid(fsp->conn),
+ req ? req->mid : 0,
+ fsp->oplock_type,
+ share_access,
+ access_mask);
+ if (!ok) {
+ if (fsp->oplock_type == LEASE_OPLOCK) {
+ status = remove_lease_if_stale(
+ lck->data,
+ fsp_client_guid(fsp),
+ &fsp->lease->lease.lease_key);
+ if (!NT_STATUS_IS_OK(status)) {
+ DBG_WARNING("remove_lease_if_stale "
+ "failed: %s\n",
+ nt_errstr(status));
+ }
+ }
+ return NT_STATUS_NO_MEMORY;
+ }
+
/* Should we atomically (to the client at least) truncate ? */
if ((!new_file_created) &&
(flags2 & O_TRUNC) &&