The branch, v4-23-test has been updated
       via  74001ee99f0 vfs_recycle: Make recycle:touch/touch_mtime work again 
if recycle:keeptree is set
       via  ad4bbed0563 vfs_recycle: Fix trailing whitespace in vfs_recycle.c
       via  633a74d3d60 selftest: Add a test for 
recycle:touch,touch_mtime,keeptree
      from  5ca842bc6c0 mdssvc: add support for parsing date ranges

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-23-test


- Log -----------------------------------------------------------------
commit 74001ee99f00c3de9a90111b3c70a8808dfbfb83
Author: Pavel Filipenský <[email protected]>
Date:   Sat Oct 25 00:24:35 2025 +0200

    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ý <[email protected]>
    Reviewed-by: Andreas Schneider <[email protected]>
    
    Autobuild-User(master): Pavel Filipensky <[email protected]>
    Autobuild-Date(master): Tue Nov  4 11:38:52 UTC 2025 on atb-devel-224
    
    (cherry picked from commit 9bbdfee7f2fdeee3cf530becb2a6f06345627b23)
    
    Autobuild-User(v4-23-test): Jule Anger <[email protected]>
    Autobuild-Date(v4-23-test): Wed Nov  5 14:28:30 UTC 2025 on atb-devel-224

commit ad4bbed0563fe27a9b95ae0c460d4e771745bfbd
Author: Pavel Filipenský <[email protected]>
Date:   Sat Oct 25 00:24:33 2025 +0200

    vfs_recycle: Fix trailing whitespace in vfs_recycle.c
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15940
    
    Signed-off-by: Pavel Filipenský <[email protected]>
    Reviewed-by: Andreas Schneider <[email protected]>
    (cherry picked from commit 5124acec34c20391cdfeb9d9005365047b7d7eee)

commit 633a74d3d6035a426564dade56b36c6f3ee2f5b6
Author: Pavel Filipenský <[email protected]>
Date:   Sun Oct 26 21:01:40 2025 +0100

    selftest: Add a test for recycle:touch,touch_mtime,keeptree
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15940
    
    Signed-off-by: Pavel Filipenský <[email protected]>
    Reviewed-by: Andreas Schneider <[email protected]>
    (cherry picked from commit 498984cf346630c17169dbdb13a232854309f6a8)

-----------------------------------------------------------------------

Summary of changes:
 selftest/target/Samba3.pm            |  3 +++
 source3/modules/vfs_recycle.c        |  6 +++---
 source3/script/tests/test_recycle.sh | 37 ++++++++++++++++++++++++++++++++++++
 3 files changed, 43 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index 6ea64ff3525..6f17d659d96 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -3718,6 +3718,9 @@ sub provision($$)
        path = $recycle_shrdir
        vfs objects = recycle
        recycle : repository = .trash
+       recycle : keeptree = yes
+       recycle : touch = yes
+       recycle : touch_mtime = yes
        recycle : exclude = *.tmp
        recycle : directory_mode = 755
 
diff --git a/source3/modules/vfs_recycle.c b/source3/modules/vfs_recycle.c
index 9c0020a8dbe..421659fa6ab 100644
--- a/source3/modules/vfs_recycle.c
+++ b/source3/modules/vfs_recycle.c
@@ -363,9 +363,9 @@ static bool matchdirparam(const char **dir_exclude_list, 
char *path)
                return False;
        }
 
-       /* 
+       /*
         * Walk the components of path, looking for matches with the
-        * exclude list on each component. 
+        * exclude list on each component.
         */
 
        for (startp = path; startp; startp = endp) {
@@ -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);
diff --git a/source3/script/tests/test_recycle.sh 
b/source3/script/tests/test_recycle.sh
index 779683f4822..9f98841bd32 100755
--- a/source3/script/tests/test_recycle.sh
+++ b/source3/script/tests/test_recycle.sh
@@ -42,6 +42,7 @@ do_cleanup()
                cd "$share_test_dir" || return
                rm -f testfile1
                rm -f testfile2.tmp
+               rm -f test_mtime
                rm -rf .trash
        )
        (
@@ -117,6 +118,38 @@ quit
        return 0
 }
 
+test_touch()
+{
+       tmpfile=$PREFIX/test_mtime
+       touch "$tmpfile"
+       if ! $SMBCLIENT -U$USERNAME%$PASSWORD //$SERVER/recycle -I$SERVER_IP 
$ADDARGS -c "put $tmpfile test_mtime" ; then
+               printf "failed recycle smbclient"
+               return 1
+       fi
+       rm -f "$tmpfile"
+       atime1=`stat -c '%x' "$share_test_dir/test_mtime"`
+       mtime1=`stat -c '%y' "$share_test_dir/test_mtime"`
+       if ! $SMBCLIENT -U$USERNAME%$PASSWORD //$SERVER/recycle -I$SERVER_IP 
$ADDARGS -c 'del test_mtime' ; then
+               printf "failed recycle smbclient"
+               return 1
+       fi
+       test -e "$share_test_dir/.trash/test_mtime" || {
+               printf ".trash/test_mtime expected to exist but does NOT 
exist\n"
+               return 1
+       }
+       atime2=`stat -c '%x' "$share_test_dir/.trash/test_mtime"`
+       mtime2=`stat -c '%y' "$share_test_dir/.trash/test_mtime"`
+       test "$atime1" != "$atime2" || {
+               printf "recycle:touch failed: atime should differ: $atime1, 
$atime2\n"
+               return 1
+       }
+       test "$mtime1" != "$mtime2" || {
+               printf "recycle:touch_mtime failed: mtime should differ: 
$mtime1, $mtime2\n"
+               return 1
+       }
+       return 0
+}
+
 test_recycle_crossrename()
 {
        tmpfile=$PREFIX/smbclient_interactive_prompt_commands
@@ -168,6 +201,10 @@ testit "recycle" \
        test_recycle ||
        failed=$((failed + 1))
 
+testit "recycle_touch" \
+       test_touch ||
+       failed=$((failed + 1))
+
 testit "recycle_crossrename" \
        test_recycle_crossrename ||
        failed=$((failed + 1))


-- 
Samba Shared Repository

Reply via email to