1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

vfs: Remove shadow_copy2_get_real_filename_at()

The synthetic_pathref() call in shadow_copy2_get_real_filename_at()
fails if shadow:snapdir is set outside of the share root, it creates
an absolute path and non_widelink_open() blocks that.

We don't need shadow_copy2_get_real_filename_at() anymore because the
dirfsp already points at the correct directory in the snapshot
directory. So get_real_filename_full_scan_at() just works fine.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=15556

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Jan 16 19:44:53 UTC 2024 on atb-devel-224
This commit is contained in:
Volker Lendecke 2024-01-11 16:49:29 +00:00 committed by Jeremy Allison
parent 6afcb7f0db
commit 0caaa2d172
2 changed files with 0 additions and 104 deletions

View File

@ -1,9 +0,0 @@
^samba3.blackbox.shadow_copy2.*.shadow copies with wide links allowed - regular file in case insensitive subdir\(fileserver.*\)
^samba3.blackbox.shadow_copy2.*.full volume snapshots mounted under volume - regular file in case insensitive subdir\(fileserver.*\)
^samba3.blackbox.shadow_copy2.*.full volume snapshots mounted outside volume - regular file in case insensitive subdir\(fileserver.*\)
^samba3.blackbox.shadow_copy2.*.sub volume snapshots mounted under snapshot point - regular file in case insensitive subdir\(fileserver.*\)
^samba3.blackbox.shadow_copy2.*.sub volume snapshots mounted outside - regular file in case insensitive subdir\(fileserver.*\)
^samba3.blackbox.shadow_copy2.*.full volume snapshots and share mounted outside - regular file in case insensitive subdir\(fileserver.*\)
^samba3.blackbox.shadow_copy2.*.logical snapshot layout - regular file in case insensitive subdir\(fileserver.*\)
^samba3.blackbox.shadow_copy2.*.'everywhere' full volume snapshots - regular file in case insensitive subdir\(fileserver.*\)
^samba3.blackbox.shadow_copy2.*.'everywhere' sub volume snapshots - regular file in case insensitive subdir\(fileserver.*\)

View File

@ -2524,100 +2524,6 @@ static NTSTATUS shadow_copy2_read_dfs_pathat(struct vfs_handle_struct *handle,
return status;
}
static NTSTATUS shadow_copy2_get_real_filename_at(
struct vfs_handle_struct *handle,
struct files_struct *dirfsp,
const char *name,
TALLOC_CTX *mem_ctx,
char **found_name)
{
struct shadow_copy2_private *priv = NULL;
time_t timestamp = 0;
char *stripped = NULL;
char *conv;
struct smb_filename *conv_fname = NULL;
NTSTATUS status;
bool ok;
SMB_VFS_HANDLE_GET_DATA(handle, priv, struct shadow_copy2_private,
return NT_STATUS_INTERNAL_ERROR);
DBG_DEBUG("Path=[%s] name=[%s]\n", fsp_str_dbg(dirfsp), name);
ok = shadow_copy2_strip_snapshot(
talloc_tos(), handle, dirfsp->fsp_name, &timestamp, &stripped);
if (!ok) {
status = map_nt_error_from_unix(errno);
DEBUG(10, ("shadow_copy2_strip_snapshot failed\n"));
return status;
}
if (timestamp == 0) {
DEBUG(10, ("timestamp == 0\n"));
return SMB_VFS_NEXT_GET_REAL_FILENAME_AT(
handle, dirfsp, name, mem_ctx, found_name);
}
/*
* Note that stripped may be an empty string "" if path was ".". As
* shadow_copy2_convert() combines "" with the shadow-copy tree connect
* root fullpath and get_real_filename_full_scan() has an explicit check
* for "" this works.
*/
DBG_DEBUG("stripped [%s]\n", stripped);
conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
if (conv == NULL) {
status = map_nt_error_from_unix(errno);
DBG_DEBUG("shadow_copy2_convert [%s] failed: %s\n",
stripped,
strerror(errno));
return status;
}
status = synthetic_pathref(
talloc_tos(),
dirfsp->conn->cwd_fsp,
conv,
NULL,
NULL,
0,
0,
&conv_fname);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
DEBUG(10, ("Calling NEXT_GET_REAL_FILE_NAME for conv=[%s], "
"name=[%s]\n", conv, name));
status = SMB_VFS_NEXT_GET_REAL_FILENAME_AT(
handle, conv_fname->fsp, name, mem_ctx, found_name);
DEBUG(10, ("NEXT_REAL_FILE_NAME returned %s\n", nt_errstr(status)));
if (NT_STATUS_IS_OK(status)) {
TALLOC_FREE(conv_fname);
return NT_STATUS_OK;
}
if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
TALLOC_FREE(conv_fname);
TALLOC_FREE(conv);
return NT_STATUS_NOT_SUPPORTED;
}
status = get_real_filename_full_scan_at(
conv_fname->fsp, name, false, mem_ctx, found_name);
TALLOC_FREE(conv_fname);
if (!NT_STATUS_IS_OK(status)) {
DBG_DEBUG("Scan [%s] for [%s] failed\n",
conv, name);
return status;
}
DBG_DEBUG("Scan [%s] for [%s] returned [%s]\n",
conv, name, *found_name);
TALLOC_FREE(conv);
return NT_STATUS_OK;
}
static const char *shadow_copy2_connectpath(
struct vfs_handle_struct *handle,
const struct files_struct *dirfsp,
@ -3382,7 +3288,6 @@ static struct vfs_fn_pointers vfs_shadow_copy2_fns = {
.mkdirat_fn = shadow_copy2_mkdirat,
.fsetxattr_fn = shadow_copy2_fsetxattr,
.fchflags_fn = shadow_copy2_fchflags,
.get_real_filename_at_fn = shadow_copy2_get_real_filename_at,
.pwrite_fn = shadow_copy2_pwrite,
.pwrite_send_fn = shadow_copy2_pwrite_send,
.pwrite_recv_fn = shadow_copy2_pwrite_recv,