]> 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)
committerGünther Deschner <gd@samba.org>
Mon, 17 Mar 2025 19:48:38 +0000 (19:48 +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>
source3/modules/vfs_ceph_new.c

index 4b784ea68ed53ac0c2d6e443ea94971308a1b30f..a570928d9fbd8a13c96f045d96eeb88b3bbc3f5c 100644 (file)
@@ -3163,15 +3163,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);