From: Volker Lendecke Date: Tue, 17 Feb 2026 11:03:45 +0000 (+0100) Subject: vfs_shadow_copy2: Remove special chdir-handling X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=84aff2e3d64504aca533079fbfa23329251f822b;p=thirdparty%2Fsamba.git vfs_shadow_copy2: Remove special chdir-handling With only changing into the share root, and the share root never being a @GMT-path or one with a twrp, we don't need special handling. Signed-off-by: Volker Lendecke Reviewed-by: Anoop C S --- diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index 2c1d3072d49..0c47f09268b 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -79,8 +79,6 @@ struct shadow_copy2_private { char *shadow_cwd; /* Absolute $cwd path. */ /* Absolute connectpath - can vary depending on $cwd. */ char *shadow_connectpath; - /* talloc'ed realpath return. */ - struct smb_filename *shadow_realpath; }; static int shadow_copy2_get_shadow_copy_data( @@ -1665,106 +1663,33 @@ static int shadow_copy2_fchmod(vfs_handle_struct *handle, return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode); } -static void store_cwd_data(vfs_handle_struct *handle, - const char *connectpath) -{ - struct shadow_copy2_private *priv = NULL; - struct smb_filename *cwd_fname = NULL; - - SMB_VFS_HANDLE_GET_DATA(handle, priv, struct shadow_copy2_private, - return); - - TALLOC_FREE(priv->shadow_cwd); - cwd_fname = SMB_VFS_NEXT_GETWD(handle, talloc_tos()); - if (cwd_fname == NULL) { - smb_panic("getwd failed\n"); - } - DBG_DEBUG("shadow cwd = %s\n", cwd_fname->base_name); - priv->shadow_cwd = talloc_strdup(priv, cwd_fname->base_name); - TALLOC_FREE(cwd_fname); - if (priv->shadow_cwd == NULL) { - smb_panic("talloc failed\n"); - } - TALLOC_FREE(priv->shadow_connectpath); - if (connectpath) { - DBG_DEBUG("shadow connectpath = %s\n", connectpath); - priv->shadow_connectpath = talloc_strdup(priv, connectpath); - if (priv->shadow_connectpath == NULL) { - smb_panic("talloc failed\n"); - } - } -} - static int shadow_copy2_chdir(vfs_handle_struct *handle, const struct smb_filename *smb_fname) { - time_t timestamp = 0; - char *stripped = NULL; - char *snappath = NULL; - int ret = -1; - int saved_errno = 0; - char *conv = NULL; - size_t rootpath_len = 0; - struct smb_filename *conv_smb_fname = NULL; + struct shadow_copy2_private *priv = NULL; + char *shadow_cwd = NULL; + int ret; - if (!shadow_copy2_strip_snapshot_internal(talloc_tos(), - handle, - smb_fname, - ×tamp, - &stripped, - &snappath, - NULL)) { - return -1; - } - if (stripped != NULL) { - conv = shadow_copy2_do_convert(talloc_tos(), - handle, - stripped, - timestamp, - &rootpath_len); - TALLOC_FREE(stripped); - if (conv == NULL) { - return -1; - } - conv_smb_fname = synthetic_smb_fname(talloc_tos(), - conv, - NULL, - NULL, - 0, - smb_fname->flags); - } else { - conv_smb_fname = cp_smb_filename(talloc_tos(), smb_fname); - } + SMB_VFS_HANDLE_GET_DATA(handle, + priv, + struct shadow_copy2_private, + return -1); - if (conv_smb_fname == NULL) { - TALLOC_FREE(conv); + shadow_cwd = talloc_strdup(priv, smb_fname->base_name); + if (shadow_cwd == NULL) { errno = ENOMEM; return -1; } - ret = SMB_VFS_NEXT_CHDIR(handle, conv_smb_fname); + ret = SMB_VFS_NEXT_CHDIR(handle, smb_fname); if (ret == -1) { - saved_errno = errno; - } - - if (ret == 0) { - if (conv != NULL && rootpath_len != 0) { - conv[rootpath_len] = '\0'; - } else if (snappath != 0) { - TALLOC_FREE(conv); - conv = snappath; - } - store_cwd_data(handle, conv); + return -1; } - TALLOC_FREE(stripped); - TALLOC_FREE(conv); - TALLOC_FREE(conv_smb_fname); + TALLOC_FREE(priv->shadow_cwd); + priv->shadow_cwd = shadow_cwd; - if (saved_errno != 0) { - errno = saved_errno; - } - return ret; + return 0; } static int shadow_copy2_fntimes(vfs_handle_struct *handle,