]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: simplify handling of failing fstat() after unlinking file
authorRalph Boehme <slow@samba.org>
Mon, 5 Feb 2024 14:03:48 +0000 (15:03 +0100)
committerNoel Power <npower@samba.org>
Wed, 13 Mar 2024 09:25:33 +0000 (09:25 +0000)
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>
source3/smbd/close.c
source3/smbd/open.c

index 538435ca834cc37c17122b50ad6746463732bea3..bbca474a28a06113ba7f269f9eb5465154a16b2a 100644 (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:
index e63ebf2e7c6b806eba0c58cc74fb1747a6c48779..ac8b0c6194f69603fd0a397dd699ecb0076d0ada 100644 (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;
                }
        }