s3: VFS: ceph. Fix enumerating directories. dirfsp->fh->fd != AT_FDCWD in this case.
authorJeremy Allison <jra@samba.org>
Sat, 17 Jul 2021 01:53:24 +0000 (18:53 -0700)
committerRalph Boehme <slow@samba.org>
Thu, 5 Aug 2021 06:15:14 +0000 (06:15 +0000)
Same as the fix for glusterfs.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Thu Aug  5 06:15:14 UTC 2021 on sn-devel-184

source3/modules/vfs_ceph.c

index 594ebce4b9a608896cff7a76a7c68b81d8933ccd..3f55d7241434fc0687b899fd782d68f40fc0b11b 100644 (file)
@@ -403,14 +403,23 @@ static int cephwrap_openat(struct vfs_handle_struct *handle,
                           int flags,
                           mode_t mode)
 {
+       struct smb_filename *name = NULL;
        bool have_opath = false;
        bool became_root = false;
        int result = -ENOENT;
 
        /*
-        * cephfs API doesn't have ceph_openat(), so for now assert this.
+        * ceph doesn't have openat().
         */
-       SMB_ASSERT(fsp_get_pathref_fd(dirfsp) == AT_FDCWD);
+       if (fsp_get_pathref_fd(dirfsp) != AT_FDCWD) {
+               name = full_path_from_dirfsp_atname(talloc_tos(),
+                                                   dirfsp,
+                                                   smb_fname);
+               if (name == NULL) {
+                       return -1;
+               }
+               smb_fname = name;
+       }
 
        DBG_DEBUG("[CEPH] openat(%p, %s, %p, %d, %d)\n", handle,
                  smb_fname_str_dbg(smb_fname), fsp, flags, mode);
@@ -438,6 +447,7 @@ static int cephwrap_openat(struct vfs_handle_struct *handle,
        }
 
 out:
+       TALLOC_FREE(name);
        fsp->fsp_flags.have_proc_fds = false;
        DBG_DEBUG("[CEPH] open(...) = %d\n", result);
        WRAP_RETURN(result);