From: Ralph Boehme Date: Wed, 16 Oct 2024 05:37:25 +0000 (+0200) Subject: smbd: add has_nonposix_opens() X-Git-Tag: tdb-1.4.13~727 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c78ffae3b3a93cf31bb826f6a66fb955385e11c5;p=thirdparty%2Fsamba.git smbd: add has_nonposix_opens() ...reusing has_other_nonposix_opens_fn(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=15608 Signed-off-by: Ralph Boehme Reviewed-by: Stefan Metzmacher --- diff --git a/source3/smbd/close.c b/source3/smbd/close.c index 5cb2bb6f17c..b14955c511e 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -239,18 +239,20 @@ static bool has_other_nonposix_opens_fn( struct has_other_nonposix_opens_state *state = private_data; struct files_struct *fsp = state->fsp; - if (e->name_hash != fsp->name_hash) { - return false; - } if (e->flags & SHARE_MODE_FLAG_POSIX_OPEN) { return false; } - if (e->share_file_id == fh_get_gen_id(fsp->fh)) { - struct server_id self = messaging_server_id( - fsp->conn->sconn->msg_ctx); - if (server_id_equal(&self, &e->pid)) { + if (fsp != NULL) { + if (e->name_hash != fsp->name_hash) { return false; } + if (e->share_file_id == fh_get_gen_id(fsp->fh)) { + struct server_id self = messaging_server_id( + fsp->conn->sconn->msg_ctx); + if (server_id_equal(&self, &e->pid)) { + return false; + } + } } if (share_entry_stale_pid(e)) { return false; @@ -274,6 +276,19 @@ bool has_other_nonposix_opens(struct share_mode_lock *lck, return state.found_another; } +bool has_nonposix_opens(struct share_mode_lock *lck) +{ + struct has_other_nonposix_opens_state state = {}; + bool ok; + + ok = share_mode_forall_entries( + lck, has_other_nonposix_opens_fn, &state); + if (!ok) { + return false; + } + return state.found_another; +} + struct close_share_mode_lock_state { struct share_mode_entry_prepare_state prepare_state; const char *object_type; diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 8437b4d140e..7b1b40e094b 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -137,6 +137,7 @@ NTSTATUS recursive_rmdir(TALLOC_CTX *ctx, struct smb_filename *smb_dname); bool has_other_nonposix_opens(struct share_mode_lock *lck, struct files_struct *fsp); +bool has_nonposix_opens(struct share_mode_lock *lck); /* The following definitions come from smbd/conn.c */