From: Ralph Boehme Date: Sat, 28 Sep 2024 14:48:31 +0000 (+0200) Subject: smbd: add handle lease breaking when deleting files in tree disconnect X-Git-Tag: tdb-1.4.13~736 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=28f9c520fa412745fa1d32d8650ed01d3e95107f;p=thirdparty%2Fsamba.git smbd: add handle lease breaking when deleting files in tree disconnect BUG: https://bugzilla.samba.org/show_bug.cgi?id=15608 Signed-off-by: Ralph Boehme Reviewed-by: Stefan Metzmacher --- diff --git a/selftest/knownfail.d/samba3.smb2.lease b/selftest/knownfail.d/samba3.smb2.lease deleted file mode 100644 index e9147609a5f..00000000000 --- a/selftest/knownfail.d/samba3.smb2.lease +++ /dev/null @@ -1 +0,0 @@ -^samba3.smb2.lease.initial_delete_tdis\(fileserver\) diff --git a/source3/smbd/smb2_tcon.c b/source3/smbd/smb2_tcon.c index 20d89670df1..0945f00da0f 100644 --- a/source3/smbd/smb2_tcon.c +++ b/source3/smbd/smb2_tcon.c @@ -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