From: Ralph Boehme Date: Mon, 5 Feb 2024 14:03:48 +0000 (+0100) Subject: smbd: simplify handling of failing fstat() after unlinking file X-Git-Tag: tdb-1.4.11~1476 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6e6324cff29089a636823786183222a73fe7cb28;p=thirdparty%2Fsamba.git smbd: simplify handling of failing fstat() after unlinking file close_remove_share_mode() already called vfs_stat_fsp(), so we can skip the fstat() triggered in fd_close() by fsp->fsp_flags.fstat_before_close being true. This avoids getting an EACCESS error when doing an fstat() on the removed file which seems to happen with some FUSE filesystems. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15527 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/close.c b/source3/smbd/close.c index 538435ca834..bbca474a28a 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -603,6 +603,7 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp, */ fsp->fsp_flags.delete_on_close = false; + fsp->fsp_flags.fstat_before_close = false; lck_state.reset_delete_on_close = true; done: diff --git a/source3/smbd/open.c b/source3/smbd/open.c index e63ebf2e7c6..ac8b0c6194f 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -953,20 +953,7 @@ NTSTATUS fd_close(files_struct *fsp) if (fsp->fsp_flags.fstat_before_close) { status = vfs_stat_fsp(fsp); if (!NT_STATUS_IS_OK(status)) { - /* - * If this is a stream and delete-on-close was set, the - * backing object (an xattr from streams_xattr) might - * already be deleted so fstat() fails with - * NT_STATUS_NOT_FOUND. So if fsp refers to a stream we - * ignore the error and only bail for normal files where - * an fstat() should still work. NB. We cannot use - * fsp_is_alternate_stream(fsp) for this as the base_fsp - * has already been closed at this point and so the value - * fsp_is_alternate_stream() checks for is already NULL. - */ - if (fsp->fsp_name->stream_name == NULL) { - return status; - } + return status; } }