s3: smbd: Fix our leases code to return the correct error in the non-dynamic share...
authorJeremy Allison <jra@samba.org>
Thu, 17 Feb 2022 19:12:39 +0000 (11:12 -0800)
committerJule Anger <janger@samba.org>
Mon, 7 Mar 2022 14:34:46 +0000 (14:34 +0000)
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

selftest/knownfail.d/smb2-lease-duplicateopen [deleted file]
source3/smbd/open.c

diff --git a/selftest/knownfail.d/smb2-lease-duplicateopen b/selftest/knownfail.d/smb2-lease-duplicateopen
deleted file mode 100644 (file)
index 1336b02..0000000
+++ /dev/null
@@ -1 +0,0 @@
-^samba3.smb2.lease.duplicate_open\(nt4_dc\)
index 5d2e2a1abf2c72d843479bf86950f694a697d61e..ad0fcb8ac6f969b170fc55e6ca4152caf3d4b50a 100644 (file)
@@ -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)) {