]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_ceph_snapshots: Always calculate absolute snapshot path
authorAnoop C S <anoopcs@samba.org>
Tue, 4 Mar 2025 10:45:05 +0000 (16:15 +0530)
committerJule Anger <janger@samba.org>
Thu, 8 May 2025 12:54:02 +0000 (12:54 +0000)
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 <anoopcs@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Wed Apr 30 11:32:59 UTC 2025 on atb-devel-224

(cherry picked from commit 95a2b50b1983a6ba810a96f50b27db7c992c02c0)

Autobuild-User(v4-22-test): Jule Anger <janger@samba.org>
Autobuild-Date(v4-22-test): Thu May  8 12:54:02 UTC 2025 on atb-devel-224

source3/modules/vfs_ceph_snapshots.c

index c764148d8a0483220b28862a1d7e2eb058f652c7..67011735d26da15bbbdcdab5ea7ba0712fce16eb 100644 (file)
@@ -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;