From: Ralph Boehme Date: Tue, 9 Apr 2024 12:53:32 +0000 (+0200) Subject: smbd: remove just created sharemode entry in the error codepaths X-Git-Tag: ldb-2.8.2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=335ce71c63634c5eadb287b3ddf8ee283d1cc18b;p=thirdparty%2Fsamba.git smbd: remove just created sharemode entry in the error codepaths Without this we leave stale sharemode entries around that can lead to all sorts of havoc. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15624 Signed-off-by: Ralph Boehme Reviewed-by: Stefan Metzmacher Reviewed-by: Guenther Deschner Autobuild-User(master): Günther Deschner Autobuild-Date(master): Thu Sep 19 19:36:19 UTC 2024 on atb-devel-224 (cherry picked from commit 2ff3b9bc0d254a63a913ff9084de3d794fee27d0) --- diff --git a/selftest/knownfail.d/samba3.blackbox.durable_v2_delay b/selftest/knownfail.d/samba3.blackbox.durable_v2_delay deleted file mode 100644 index 88e29960797..00000000000 --- a/selftest/knownfail.d/samba3.blackbox.durable_v2_delay +++ /dev/null @@ -1 +0,0 @@ -^samba3.blackbox.durable_v2_delay.durable-v2-regressions.durable_v2_reconnect_bug15624 diff --git a/source3/smbd/durable.c b/source3/smbd/durable.c index 50075ddd3f7..98d0d403e30 100644 --- a/source3/smbd/durable.c +++ b/source3/smbd/durable.c @@ -538,6 +538,7 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn, enum ndr_err_code ndr_err; struct vfs_default_durable_cookie cookie; DATA_BLOB new_cookie_blob = data_blob_null; + bool have_share_mode_entry = false; *result = NULL; *new_cookie = data_blob_null; @@ -776,6 +777,7 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn, status = NT_STATUS_INTERNAL_ERROR; goto fail; } + have_share_mode_entry = true; ok = brl_reconnect_disconnected(fsp); if (!ok) { @@ -872,6 +874,12 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn, return NT_STATUS_OK; fail: + if (fsp != NULL && have_share_mode_entry) { + /* + * Something is screwed up, delete the sharemode entry. + */ + del_share_mode(lck, fsp); + } if (fsp != NULL && fsp_get_pathref_fd(fsp) != -1) { NTSTATUS close_status; close_status = fd_close(fsp);