diff options
author | Jeremy Allison <jra@samba.org> | 2022-02-17 11:12:39 -0800 |
---|---|---|
committer | Jule Anger <janger@samba.org> | 2022-03-07 14:34:46 +0000 |
commit | 7417480d1603dd7966b41d56e1f37b357b95896e (patch) | |
tree | c36b47dea65eb15a4bddbfecffc9321287fdea23 | |
parent | 58605094f14ad5321efb2e6bf29e746e5384ca9f (diff) | |
download | samba-7417480d1603dd7966b41d56e1f37b357b95896e.tar.gz |
s3: smbd: Fix our leases code to return the correct error in the non-dynamic share case.
We now return INVALID_PARAMETER when trying to open a
different file with a duplicate lease key on the same
(non-dynamic) share. This will enable us to pass another
Windows test suite leases test.
We now behave the same as Windows10.
Remove knownfail.d/smb2-lease-duplicateopen
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14737
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@suse.com>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Feb 18 20:12:12 UTC 2022 on sn-devel-184
(cherry picked from commit 408be54323861c24b6377b804be4428cf45b471e)
Autobuild-User(v4-15-test): Jule Anger <janger@samba.org>
Autobuild-Date(v4-15-test): Mon Mar 7 14:34:46 UTC 2022 on sn-devel-184
-rw-r--r-- | selftest/knownfail.d/smb2-lease-duplicateopen | 1 | ||||
-rw-r--r-- | source3/smbd/open.c | 38 |
2 files changed, 36 insertions, 3 deletions
diff --git a/selftest/knownfail.d/smb2-lease-duplicateopen b/selftest/knownfail.d/smb2-lease-duplicateopen deleted file mode 100644 index 1336b02d74c..00000000000 --- a/selftest/knownfail.d/smb2-lease-duplicateopen +++ /dev/null @@ -1 +0,0 @@ -^samba3.smb2.lease.duplicate_open\(nt4_dc\) diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 5d2e2a1abf2..ad0fcb8ac6f 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -5307,8 +5307,42 @@ static void lease_match_parser( /* Everything should be the same. */ if (!file_id_equal(&state->id, &f->id)) { - /* This should catch all dynamic share cases. */ - state->match_status = NT_STATUS_OPLOCK_NOT_GRANTED; + /* + * The client asked for a lease on a + * file that doesn't match the file_id + * in the database. + * + * Maybe this is a dynamic share, i.e. + * a share where the servicepath is + * different for different users (e.g. + * the [HOMES] share. + * + * If the servicepath is different, but the requested + * file name + stream name is the same then this is + * a dynamic share, the client is using the same share + * name and doesn't know that the underlying servicepath + * is different. It was expecting a lease on the + * same file. Return NT_STATUS_OPLOCK_NOT_GRANTED + * to break leases + * + * Otherwise the client has messed up, or is + * testing our error codes, so return + * NT_STATUS_INVALID_PARAMETER. + */ + if (!strequal(f->servicepath, state->servicepath) && + strequal(f->base_name, state->fname->base_name) && + strequal(f->stream_name, state->fname->stream_name)) + { + /* + * Name is the same but servicepath is + * different, dynamic share. Break leases. + */ + state->match_status = + NT_STATUS_OPLOCK_NOT_GRANTED; + } else { + state->match_status = + NT_STATUS_INVALID_PARAMETER; + } break; } if (!strequal(f->servicepath, state->servicepath)) { |