]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_ceph_new: Add path based fallback for SMB_VFS_FCHOWN
authorAnoop C S <anoopcs@samba.org>
Fri, 14 Mar 2025 14:17:42 +0000 (19:47 +0530)
committerJule Anger <janger@samba.org>
Tue, 18 Mar 2025 15:46:17 +0000 (15:46 +0000)
Fallback mechanism was missing in vfs_ceph_fchown() for path based call.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15834

Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
(cherry picked from commit abb97683902f50b2a57989f30c0fb53fd3492af9)

source3/modules/vfs_ceph_new.c

index 4f1849b3ed57b27352c494d54f3be50588db44e5..e85995cc2d08405a03169479e3ab0c1e7a137461 100644 (file)
@@ -3168,15 +3168,33 @@ static int vfs_ceph_fchown(struct vfs_handle_struct *handle,
                           gid_t gid)
 {
        int result;
-       struct vfs_ceph_fh *cfh = NULL;
 
        START_PROFILE(syscall_fchown);
        DBG_DEBUG("[CEPH] fchown(%p, %p, %d, %d)\n", handle, fsp, uid, gid);
-       result = vfs_ceph_fetch_io_fh(handle, fsp, &cfh);
-       if (result != 0) {
-               goto out;
+
+       if (!fsp->fsp_flags.is_pathref) {
+               struct vfs_ceph_fh *cfh = NULL;
+
+               result = vfs_ceph_fetch_io_fh(handle, fsp, &cfh);
+               if (result != 0) {
+                       goto out;
+               }
+
+               result = vfs_ceph_ll_fchown(handle, cfh, uid, gid);
+       } else {
+               struct vfs_ceph_iref iref = {0};
+
+               result = vfs_ceph_iget(handle,
+                                      fsp->fsp_name->base_name,
+                                      0,
+                                      &iref);
+               if (result != 0) {
+                       goto out;
+               }
+
+               result = vfs_ceph_ll_chown(handle, &iref, uid, gid);
+               vfs_ceph_iput(handle, &iref);
        }
-       result = vfs_ceph_ll_fchown(handle, cfh, uid, gid);
 out:
        DBG_DEBUG("[CEPH] fchown(...) = %d\n", result);
        END_PROFILE(syscall_fchown);