From 1e677da50b49838c801d2e4ddc02fc3735de6a5c Mon Sep 17 00:00:00 2001 From: Samuel Cabrero Date: Wed, 14 Apr 2021 11:26:38 +0200 Subject: [PATCH] s3: VFS: recycle: set the recycled file times using SMB_VFS_FNTIMES() Signed-off-by: Samuel Cabrero Reviewed-by: Ralph Boehme --- source3/modules/vfs_recycle.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/source3/modules/vfs_recycle.c b/source3/modules/vfs_recycle.c index 7ec2938ebfb..1c18f232c32 100644 --- a/source3/modules/vfs_recycle.c +++ b/source3/modules/vfs_recycle.c @@ -417,33 +417,38 @@ static void recycle_do_touch(vfs_handle_struct *handle, struct smb_filename *smb_fname_tmp = NULL; struct smb_file_time ft; int ret, err; + NTSTATUS status; init_smb_file_time(&ft); - smb_fname_tmp = cp_smb_filename(talloc_tos(), smb_fname); - if (smb_fname_tmp == NULL) { + status = synthetic_pathref(talloc_tos(), + handle->conn->cwd_fsp, + smb_fname->base_name, + smb_fname->stream_name, + NULL, + smb_fname->twrp, + smb_fname->flags, + &smb_fname_tmp); + if (!NT_STATUS_IS_OK(status)) { + DBG_DEBUG("synthetic_pathref for '%s' failed: %s\n", + smb_fname_str_dbg(smb_fname), nt_errstr(status)); return; } - if (SMB_VFS_STAT(handle->conn, smb_fname_tmp) != 0) { - DEBUG(0,("recycle: stat for %s returned %s\n", - smb_fname_str_dbg(smb_fname_tmp), strerror(errno))); - goto out; - } /* atime */ ft.atime = timespec_current(); /* mtime */ ft.mtime = touch_mtime ? ft.atime : smb_fname_tmp->st.st_ex_mtime; become_root(); - ret = SMB_VFS_NEXT_NTIMES(handle, smb_fname_tmp, &ft); + ret = SMB_VFS_NEXT_FNTIMES(handle, smb_fname_tmp->fsp, &ft); err = errno; unbecome_root(); if (ret == -1 ) { DEBUG(0, ("recycle: touching %s failed, reason = %s\n", smb_fname_str_dbg(smb_fname_tmp), strerror(err))); } - out: + TALLOC_FREE(smb_fname_tmp); } -- 2.47.3