1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

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 <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 6e6324cff2)
This commit is contained in:
Ralph Boehme 2024-02-05 15:03:48 +01:00 committed by Jule Anger
parent 3be368ff2b
commit 72f7086825
2 changed files with 2 additions and 14 deletions

View File

@ -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:

View File

@ -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;
}
}