]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_recycle: Make recycle:touch/touch_mtime work again if recycle:keeptree is set
authorPavel Filipenský <pfilipensky@samba.org>
Fri, 24 Oct 2025 22:24:35 +0000 (00:24 +0200)
committerPavel Filipensky <pfilipensky@samba.org>
Tue, 4 Nov 2025 11:38:52 +0000 (11:38 +0000)
Problem: Since commit c7839fa smbd: Remove non_widelink_open()

the atime/mtime is not updated if recycle:keeptree is set

        recycle:keeptree = yes
        recycle:touch = yes
        recycle:touch_mtime = yes

Cause: recycle_do_touch() fails since the path ".deleted/administrator/./file"
contains a dot '.' - openat_pathref_fsp_nosymlink() loops over all
components and fails if there is a dot:

[2025/10/24 20:09:24.618003, 10, pid=95965, effective(65534, 65534), real(65534, 0)] ../../source3/smbd/files.c:1144(openat_pathref_fsp_nosymlink)
  openat_pathref_fsp_nosymlink: .deleted/administrator/. contains a dot
[2025/10/24 20:09:24.618007,  5, pid=95965, effective(65534, 65534), real(65534, 0)] ../../source3/smbd/files.c:2337(file_free)
  file_free: freed files structure 0 (4 used)
[2025/10/24 20:09:24.618010, 10, pid=95965, effective(65534, 65534), real(65534, 0)] ../../source3/smbd/filename.c:811(filename_convert_dirfsp_nosymlink)
  filename_convert_dirfsp_nosymlink: opening directory .deleted/administrator/. failed: NT_STATUS_OBJECT_NAME_INVALID
[2025/10/24 20:09:24.618014, 10, pid=95965, effective(65534, 65534), real(65534, 0)] ../../source3/smbd/open.c:568(fd_openat)
  fd_openat: filename_convert_dirfsp_rel returned NT_STATUS_OBJECT_PATH_NOT_FOUND
[2025/10/24 20:09:24.618021, 10, pid=95965, effective(65534, 65534), real(65534, 0)] ../../source3/smbd/files.c:487(openat_pathref_fullname)
  openat_pathref_fullname: Opening pathref for [.deleted/administrator/./file] failed: NT_STATUS_OBJECT_NAME_NOT_FOUND

Here is a backtrace when openat_pathref_fsp_nosymlink() hits: DBG_DEBUG("%s contains a dot\n", path_in);

0  openat_pathref_fsp_nosymlink (mem_ctx=0x353463c0, conn=0x35322350, in_dirfsp=0x3532a820, path_in=0x3533afe0 ".trash/.", twrp=0, posix=true, _smb_fname=0x7ffdb25df138, _symlink_err=0x7ffdb25df140) at ../../source3/smbd/files.c:1144
1  filename_convert_dirfsp_nosymlink (mem_ctx=0x353463c0, conn=0x35322350, basedir=0x3532a820, name_in=0x35321a80 ".trash/./mmm", ucf_flags=8, twrp=0, _dirfsp=0x7ffdb25df370, _smb_fname=0x7ffdb25df378, _smb_fname_rel=0x7ffdb25df380, _symlink_err=0x7ffdb25df2d8) at ../../source3/smbd/filename.c:782
2  filename_convert_dirfsp_rel (mem_ctx=0x353463c0, conn=0x35322350, basedir=0x3532a820, name_in=0x35321a80 ".trash/./mmm", ucf_flags=8, twrp=0, _dirfsp=0x7ffdb25df370, _smb_fname=0x7ffdb25df378, _smb_fname_rel=0x7ffdb25df380) at ../../source3/smbd/filename.c:1097
3  fd_openat (dirfsp=0x3532a820, smb_fname=0x35321950, fsp=0x3531b670, _how=0x7ffdb25df4b0) at ../../source3/smbd/open.c:549
4  openat_pathref_fullname (conn=0x35322350, dirfsp=0x3532a820, full_fname=0x7ffdb25df498, smb_fname=0x35321950, how=0x7ffdb25df4b0) at ../../source3/smbd/files.c:437
5  openat_pathref_fsp (dirfsp=0x3532a820, smb_fname=0x35321950) at ../../source3/smbd/files.c:545
6  synthetic_pathref (mem_ctx=0x353463c0, dirfsp=0x3532a820, base_name=0x35346ef0 ".trash/./mmm", stream_name=0x0, psbuf=0x0, twrp=0, flags=0, _smb_fname=0x7ffdb25df578) at ../../source3/smbd/files.c:1871
7  recycle_do_touch (handle=0x35311cb0, smb_fname=0x35346dc0, touch_mtime=true) at ../../source3/modules/vfs_recycle.c:439
8  recycle_unlink_internal (handle=0x35311cb0, dirfsp=0x352592a0, smb_fname=0x35335eb0, flags=0) at ../../source3/modules/vfs_recycle.c:726
9  recycle_unlinkat (handle=0x35311cb0, dirfsp=0x352592a0, smb_fname=0x35335eb0, flags=0) at ../../source3/modules/vfs_recycle.c:746
10 smb_vfs_call_unlinkat (handle=0x35311cb0, dirfsp=0x352592a0, smb_fname=0x35335eb0, flags=0) at ../../source3/smbd/vfs.c:1987
11 close_remove_share_mode (fsp=0x35344a40, close_type=NORMAL_CLOSE) at ../../source3/smbd/close.c:624
12 close_normal_file (req=0x35336eb0, fsp=0x35344a40, close_type=NORMAL_CLOSE) at ../../source3/smbd/close.c:932
13 close_file_smb (req=0x35336eb0, fsp=0x35344a40, close_type=NORMAL_CLOSE) at ../../source3/smbd/close.c:1414

Fix: If the path_name is '.', just do not add it.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15940

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Pavel Filipensky <pfilipensky@samba.org>
Autobuild-Date(master): Tue Nov  4 11:38:52 UTC 2025 on atb-devel-224

selftest/knownfail
source3/modules/vfs_recycle.c

index 717a2576e633a2bbd347b5ef84989c6df34a94fd..ab2d79d7114edb6ee29eafd4ef5e4ce84921471b 100644 (file)
@@ -5,7 +5,6 @@
 # a successful run for any of these tests an error.
 
 ^samba3.blackbox.failure.failure # this is designed to fail, for testing our test infrastructure
-^samba3.blackbox.recycle.recycle_touch # recycle:touch_mtime is not working
 .*driver.add_driver_timestamps # we only can store dates, not timestamps
  ^samba3.smbtorture_s3.crypt_server\(nt4_dc\).SMB2-SESSION-REAUTH # expected to give ACCESS_DENIED SMB2.1 doesn't have encryption
 ^samba3.smbtorture_s3.crypt_server\(nt4_dc\).SMB2-SESSION-RECONNECT # expected to give CONNECTION_DISCONNECTED, we need to fix the test
index 057c1a1be66490ebebee38bf90477c8d86da4be1..421659fa6abb40b755f57abda6d37c73960ae6cf 100644 (file)
@@ -612,7 +612,7 @@ static int recycle_unlink_internal(vfs_handle_struct *handle,
                goto done;
        }
 
-       if (config->keeptree) {
+       if (config->keeptree && !ISDOT(path_name)) {
                temp_name = talloc_asprintf(frame, "%s/%s",
                                            config->repository,
                                            path_name);