From: Pavel Filipenský Date: Fri, 24 Oct 2025 22:24:35 +0000 (+0200) Subject: vfs_recycle: Make recycle:touch/touch_mtime work again if recycle:keeptree is set X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fv4-22-test;p=thirdparty%2Fsamba.git vfs_recycle: Make recycle:touch/touch_mtime work again if recycle:keeptree is set 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ý Reviewed-by: Andreas Schneider Autobuild-User(master): Pavel Filipensky Autobuild-Date(master): Tue Nov 4 11:38:52 UTC 2025 on atb-devel-224 (cherry picked from commit 9bbdfee7f2fdeee3cf530becb2a6f06345627b23) Autobuild-User(v4-22-test): Jule Anger Autobuild-Date(v4-22-test): Wed Nov 5 10:04:58 UTC 2025 on atb-devel-224 --- diff --git a/selftest/knownfail b/selftest/knownfail index 717a2576e63..ab2d79d7114 100644 --- a/selftest/knownfail +++ b/selftest/knownfail @@ -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 diff --git a/source3/modules/vfs_recycle.c b/source3/modules/vfs_recycle.c index 057c1a1be66..421659fa6ab 100644 --- a/source3/modules/vfs_recycle.c +++ b/source3/modules/vfs_recycle.c @@ -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);