From: Anoop C S Date: Tue, 4 Mar 2025 10:45:05 +0000 (+0530) Subject: vfs_ceph_snapshots: Always calculate absolute snapshot path X-Git-Tag: samba-4.21.6~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=84d23c82272ea77f6bab16ff8dbec43c016ae9af;p=thirdparty%2Fsamba.git vfs_ceph_snapshots: Always calculate absolute snapshot path Use the same logic from shadow_copy2 module to always prepend the connectpath to the relative snapshot path so as to return converted path corresponding to the file's share root. Please note that with the current working directory staying at the connectpath level we are safe to prefix it to the smb_filename. In other words it seems we never get past the connectpath internally during normal file system operations via chdir(). Since all relative paths are now based on dirfsp we could constitute absolute path by prepending the connectpath to full_path_from_dirfsp_atname() output ignoring the current working directory. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15819 Signed-off-by: Anoop C S Reviewed-by: David Disseldorp Autobuild-User(master): Anoop C S Autobuild-Date(master): Wed Apr 30 11:32:59 UTC 2025 on atb-devel-224 (cherry picked from commit 95a2b50b1983a6ba810a96f50b27db7c992c02c0) Autobuild-User(v4-21-test): Jule Anger Autobuild-Date(v4-21-test): Thu May 8 12:46:14 UTC 2025 on atb-devel-224 --- diff --git a/source3/modules/vfs_ceph_snapshots.c b/source3/modules/vfs_ceph_snapshots.c index 7400bef008e..f5ba0752614 100644 --- a/source3/modules/vfs_ceph_snapshots.c +++ b/source3/modules/vfs_ceph_snapshots.c @@ -531,10 +531,13 @@ static int ceph_snap_gmt_convert_dir(struct vfs_handle_struct *handle, * Temporally use the caller's return buffer for this. */ if (strlen(name) == 0) { - ret = strlcpy(_converted_buf, snapdir, buflen); + ret = snprintf(_converted_buf, buflen, "%s/%s", + handle->conn->connectpath, snapdir); } else { - ret = snprintf(_converted_buf, buflen, "%s/%s", name, snapdir); + ret = snprintf(_converted_buf, buflen, "%s/%s/%s", + handle->conn->connectpath, name, snapdir); } + if (ret >= buflen) { ret = -EINVAL; goto err_out;