The Samba-Bugzilla – Attachment 15251 Details for
Bug 13997
Windows client error handling for failing write on macOS stream AFP_AfpInfo depends on Directory Leases
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Fake Directory Leases
hack_dirleases.patch (text/plain), 4.09 KB, created by
Ralph Böhme
on 2019-06-17 09:15:42 UTC
(
hide
)
Description:
Fake Directory Leases
Filename:
MIME Type:
Creator:
Ralph Böhme
Created:
2019-06-17 09:15:42 UTC
Size:
4.09 KB
patch
obsolete
>From e87675202a7d0370eaed344cc741ac67fb914904 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Tue, 26 Mar 2019 12:13:52 +0100 >Subject: [PATCH] HACK: smbd: directory leases > >--- > source3/smbd/open.c | 24 ++++++++++++++++-------- > source3/smbd/oplock.c | 4 ++++ > source3/smbd/smb2_negprot.c | 7 ++++++- > 3 files changed, 26 insertions(+), 9 deletions(-) > >diff --git a/source3/smbd/open.c b/source3/smbd/open.c >index bab9286751f..720124fe120 100644 >--- a/source3/smbd/open.c >+++ b/source3/smbd/open.c >@@ -2111,6 +2111,8 @@ static NTSTATUS grant_fsp_lease(struct files_struct *fsp, > fsp->lease->sconn = fsp->conn->sconn; > fsp->lease->lease.lease_version = lease->lease_version; > fsp->lease->lease.lease_key = lease->lease_key; >+ fsp->lease->lease.parent_lease_key = lease->parent_lease_key; >+ fsp->lease->lease.lease_flags = lease->lease_flags; > fsp->lease->lease.lease_state = granted; > fsp->lease->lease.lease_epoch = lease->lease_epoch + 1; > >@@ -2209,6 +2211,9 @@ static NTSTATUS grant_fsp_oplock_type(struct smb_request *req, > DEBUG(10, ("write and handle lease requested\n")); > granted = SMB2_LEASE_NONE; > } >+ if (fsp->is_directory) { >+ granted &= ~SMB2_LEASE_WRITE; >+ } > } else { > granted = map_oplock_to_lease_type( > oplock_request & ~SAMBA_PRIVATE_OPLOCK_MASK); >@@ -3972,6 +3977,8 @@ static NTSTATUS open_directory(connection_struct *conn, > uint32_t create_disposition, > uint32_t create_options, > uint32_t file_attributes, >+ int oplock_request, >+ struct smb2_lease *lease, > int *pinfo, > files_struct **result) > { >@@ -3981,7 +3988,6 @@ static NTSTATUS open_directory(connection_struct *conn, > NTSTATUS status; > struct timespec mtimespec; > int info = 0; >- bool ok; > > if (is_ntfs_stream_smb_fname(smb_dname)) { > DEBUG(2, ("open_directory: %s is a stream name!\n", >@@ -4269,14 +4275,15 @@ static NTSTATUS open_directory(connection_struct *conn, > return status; > } > >- ok = set_share_mode(lck, fsp, get_current_uid(conn), >- req ? req->mid : 0, NO_OPLOCK, >- UINT32_MAX); >- if (!ok) { >+ /* >+ * Setup the oplock info in both the shared memory and >+ * file structs. >+ */ >+ status = grant_fsp_oplock_type(req, fsp, lck, oplock_request, lease); >+ if (!NT_STATUS_IS_OK(status)) { > TALLOC_FREE(lck); > fd_close(fsp); >- file_free(req, fsp); >- return NT_STATUS_NO_MEMORY; >+ return status; > } > > /* For directories the delete on close bit at open time seems >@@ -5255,10 +5262,10 @@ static NTSTATUS create_file_unixpath(connection_struct *conn, > * CreateDirectory() call. > */ > >- oplock_request = 0; > status = open_directory( > conn, req, smb_fname, access_mask, share_access, > create_disposition, create_options, file_attributes, >+ oplock_request, lease, > &info, &fsp); > } else { > >@@ -5332,6 +5339,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn, > conn, req, smb_fname, access_mask, > share_access, create_disposition, > create_options, file_attributes, >+ oplock_request, lease, > &info, &fsp); > } > } >diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c >index 31a36304310..7d4b1c39885 100644 >--- a/source3/smbd/oplock.c >+++ b/source3/smbd/oplock.c >@@ -187,6 +187,10 @@ bool update_num_read_oplocks(files_struct *fsp, struct share_mode_lock *lck) > uint32_t num_read_oplocks = 0; > uint32_t i; > >+ if (fsp->is_directory) { >+ return true; >+ } >+ > if (fsp_lease_type_is_exclusive(fsp)) { > const struct share_mode_entry *e = NULL; > uint32_t e_lease_type = 0; >diff --git a/source3/smbd/smb2_negprot.c b/source3/smbd/smb2_negprot.c >index 2b725f30f75..3df5e3c188b 100644 >--- a/source3/smbd/smb2_negprot.c >+++ b/source3/smbd/smb2_negprot.c >@@ -338,7 +338,12 @@ NTSTATUS smbd_smb2_request_process_negprot(struct smbd_smb2_request *req) > if ((protocol >= PROTOCOL_SMB2_24) && > (lp_smb_encrypt(-1) != SMB_SIGNING_OFF) && > (in_capabilities & SMB2_CAP_ENCRYPTION)) { >- capabilities |= SMB2_CAP_ENCRYPTION; >+ } >+ >+ if (protocol >= PROTOCOL_SMB3_00 && >+ in_capabilities & SMB2_CAP_DIRECTORY_LEASING) >+ { >+ capabilities |= SMB2_CAP_DIRECTORY_LEASING; > } > > /* >-- >2.17.2 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 13997
: 15251