The branch, v4-22-test has been updated
       via  77e490b018a vfs_ceph_snapshots: Always calculate absolute snapshot 
path
       via  501f32eab61 vfs_ceph_snapshots: Use full path from dirfsp at 
smb_fname
       via  c9064d2372b lib/krb5_wrap: Fix placement of TALLOC_FREE(frame)
      from  46d661f5a90 VERSION: Bump version up to Samba 4.22.2...

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-22-test


- Log -----------------------------------------------------------------
commit 77e490b018a5c16f8b023539c4daa81bda16e11d
Author: Anoop C S <[email protected]>
Date:   Tue Mar 4 16:15:05 2025 +0530

    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 <[email protected]>
    Reviewed-by: David Disseldorp <[email protected]>
    
    Autobuild-User(master): Anoop C S <[email protected]>
    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 <[email protected]>
    Autobuild-Date(v4-22-test): Thu May  8 12:54:02 UTC 2025 on atb-devel-224

commit 501f32eab618c1bf63a663420092dba14095b4c7
Author: Anoop C S <[email protected]>
Date:   Tue Mar 4 15:09:33 2025 +0530

    vfs_ceph_snapshots: Use full path from dirfsp at smb_fname
    
    In ceph_snap_gmt_openat() we hand in the incoming smb_fname as it is
    to ceph_snap_gmt_strip_snapshot() which is then passed on to derive
    the actual snapshot path using ceph_snap_gmt_convert(). But this can
    go wrong in ceph_snap_gmt_convert_dir() while opening the snapdir.
    Unless we constitute the full path from dirfsp at the first place we
    always end up opening the snapdir from the parent directory with
    OpenDir().
    
    For example with dirfsp("foobar") and smb_fname("shift.txt"), we open
    snapdir from share root because parent is calculated as empty string
    via ceph_snap_get_parent_path(). Instead we could construct the full
    path from dirfsp using full_path_from_dirfsp_atname() to ensure we
    don't open the wrong snapdir.
    
    Since we have access to the twrp token at VFS layer it doesn't make
    much sense to make use of ceph_snap_gmt_strip_snapshot() in openat.
    We could instead directly act based on already available twrp token
    avoiding an extra copy of incoming smb_filename.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15819
    
    Signed-off-by: Anoop C S <[email protected]>
    Reviewed-by: David Disseldorp [email protected]
    (cherry picked from commit ad8b2dbb67d87db22f2fa2df814dd91cbe071e60)

commit c9064d2372bff87bbf79c1ee05588a5d71f067c0
Author: Pavel Filipenský <[email protected]>
Date:   Wed Apr 23 09:34:14 2025 +0200

    lib/krb5_wrap: Fix placement of TALLOC_FREE(frame)
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15727
    
    Signed-off-by: Pavel Filipenský <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>
    
    Autobuild-User(master): Stefan Metzmacher <[email protected]>
    Autobuild-Date(master): Wed Apr 23 12:14:17 UTC 2025 on atb-devel-224
    
    (cherry picked from commit b5bd36dfd7dfd9a09a3f9378330df3be9db4551f)

-----------------------------------------------------------------------

Summary of changes:
 lib/krb5_wrap/krb5_samba.c           |  3 ++-
 source3/modules/vfs_ceph_snapshots.c | 36 ++++++++++++++++++------------------
 2 files changed, 20 insertions(+), 19 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/krb5_wrap/krb5_samba.c b/lib/krb5_wrap/krb5_samba.c
index 0a4a7ea986f..f9d91a4f0c1 100644
--- a/lib/krb5_wrap/krb5_samba.c
+++ b/lib/krb5_wrap/krb5_samba.c
@@ -869,16 +869,17 @@ krb5_error_code smb_krb5_parse_name_flags(krb5_context 
context,
                TALLOC_FREE(frame);
                return ENOMEM;
        }
-       TALLOC_FREE(frame);
 
        ret = krb5_parse_name_flags(context, utf8_name, flags, principal);
        if (ret != KRB5_PARSE_MALFORMED) {
+               TALLOC_FREE(frame);
                return ret;
        }
 
        flags |= KRB5_PRINCIPAL_PARSE_ENTERPRISE;
        ret = krb5_parse_name_flags(context, utf8_name, flags, principal);
 
+       TALLOC_FREE(frame);
        return ret;
 }
 
diff --git a/source3/modules/vfs_ceph_snapshots.c 
b/source3/modules/vfs_ceph_snapshots.c
index 9514b489237..67011735d26 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;
@@ -940,21 +943,11 @@ static int ceph_snap_gmt_openat(vfs_handle_struct *handle,
 {
        time_t timestamp = 0;
        struct smb_filename *smb_fname = NULL;
-       char stripped[PATH_MAX + 1];
        char conv[PATH_MAX + 1];
        int ret;
        int saved_errno = 0;
 
-       ret = ceph_snap_gmt_strip_snapshot(handle,
-                                          smb_fname_in,
-                                          &timestamp,
-                                          stripped,
-                                          sizeof(stripped));
-       if (ret < 0) {
-               errno = -ret;
-               return -1;
-       }
-       if (timestamp == 0) {
+       if (smb_fname_in->twrp == 0) {
                return SMB_VFS_NEXT_OPENAT(handle,
                                           dirfsp,
                                           smb_fname_in,
@@ -962,8 +955,18 @@ static int ceph_snap_gmt_openat(vfs_handle_struct *handle,
                                           how);
        }
 
+       timestamp = nt_time_to_unix(smb_fname_in->twrp);
+
+       smb_fname = full_path_from_dirfsp_atname(talloc_tos(),
+                                                dirfsp,
+                                                smb_fname_in);
+       if (smb_fname == NULL) {
+               errno = ENOMEM;
+               return -1;
+       }
+
        ret = ceph_snap_gmt_convert(handle,
-                                   stripped,
+                                   smb_fname->base_name,
                                    timestamp,
                                    conv,
                                    sizeof(conv));
@@ -971,10 +974,7 @@ static int ceph_snap_gmt_openat(vfs_handle_struct *handle,
                errno = -ret;
                return -1;
        }
-       smb_fname = cp_smb_filename(talloc_tos(), smb_fname_in);
-       if (smb_fname == NULL) {
-               return -1;
-       }
+
        smb_fname->base_name = conv;
 
        ret = SMB_VFS_NEXT_OPENAT(handle,


-- 
Samba Shared Repository

Reply via email to