]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: add handle lease breaking when deleting files in tree disconnect
authorRalph Boehme <slow@samba.org>
Sat, 28 Sep 2024 14:48:31 +0000 (16:48 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 5 Nov 2024 14:39:30 +0000 (14:39 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15608

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
selftest/knownfail.d/samba3.smb2.lease [deleted file]
source3/smbd/smb2_tcon.c

diff --git a/selftest/knownfail.d/samba3.smb2.lease b/selftest/knownfail.d/samba3.smb2.lease
deleted file mode 100644 (file)
index e914760..0000000
+++ /dev/null
@@ -1 +0,0 @@
-^samba3.smb2.lease.initial_delete_tdis\(fileserver\)
index 20d89670df18a01b3628fdce103addac2a2dba26..0945f00da0fcac4a274db5e79bf5480fb77e8650 100644 (file)
@@ -26,6 +26,7 @@
 #include "auth.h"
 #include "lib/param/loadparm.h"
 #include "../lib/util/tevent_ntstatus.h"
+#include "smbd/smbXsrv_session.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_SMB2
@@ -662,6 +663,19 @@ struct smbd_smb2_tdis_state {
 
 static void smbd_smb2_tdis_wait_done(struct tevent_req *subreq);
 
+struct check_for_lease_break_fsp_cmp_state {
+       struct smbXsrv_tcon *tcon;
+};
+
+static bool check_for_lease_break_fsp_cmp_fn(struct files_struct *fsp,
+                                            void *private_data)
+{
+       struct check_for_lease_break_fsp_cmp_state *state =
+               (struct check_for_lease_break_fsp_cmp_state *)private_data;
+
+       return (fsp->conn == state->tcon->compat);
+}
+
 static struct tevent_req *smbd_smb2_tdis_send(TALLOC_CTX *mem_ctx,
                                        struct tevent_context *ev,
                                        struct smbd_smb2_request *smb2req)
@@ -670,6 +684,7 @@ static struct tevent_req *smbd_smb2_tdis_send(TALLOC_CTX *mem_ctx,
        struct smbd_smb2_tdis_state *state;
        struct tevent_req *subreq;
        struct smbXsrv_connection *xconn = NULL;
+       struct check_for_lease_break_fsp_cmp_state fsp_cmp_state;
 
        req = tevent_req_create(mem_ctx, &state,
                        struct smbd_smb2_tdis_state);
@@ -720,6 +735,20 @@ static struct tevent_req *smbd_smb2_tdis_send(TALLOC_CTX *mem_ctx,
                }
        }
 
+       fsp_cmp_state = (struct check_for_lease_break_fsp_cmp_state) {
+               .tcon = smb2req->tcon,
+       };
+
+       smbXsrv_wait_for_handle_lease_break(req,
+                                           ev,
+                                           smb2req->xconn->client,
+                                           state->wait_queue,
+                                           check_for_lease_break_fsp_cmp_fn,
+                                           &fsp_cmp_state);
+       if (!tevent_req_is_in_progress(req)) {
+               return tevent_req_post(req, ev);
+       }
+
        /*
         * Now we add our own waiter to the end of the queue,
         * this way we get notified when all pending requests are finished