]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: VFS: ceph_snapshots: In ceph_snap_enum_snapdir(), re-use the directory handle...
authorJeremy Allison <jra@samba.org>
Mon, 7 Jun 2021 17:22:53 +0000 (10:22 -0700)
committerRalph Boehme <slow@samba.org>
Wed, 9 Jun 2021 13:14:30 +0000 (13:14 +0000)
Similar change to the one that went into shadow_copy2.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/modules/vfs_ceph_snapshots.c

index a9f09f0aa4b3cf0100d43cc872b77db98e8180ea..5249aac8db9b24995214595d83a2e4d2a63312a1 100644 (file)
@@ -183,6 +183,7 @@ static int ceph_snap_enum_snapdir(struct vfs_handle_struct *handle,
 {
        TALLOC_CTX *frame = talloc_stackframe();
        struct smb_Dir *dir_hnd = NULL;
+       struct files_struct *dirfsp = NULL;
        const char *dname = NULL;
        char *talloced = NULL;
        long offset = 0;
@@ -190,19 +191,6 @@ static int ceph_snap_enum_snapdir(struct vfs_handle_struct *handle,
        int ret;
        uint32_t slots;
 
-       status = smbd_check_access_rights(handle->conn,
-                                       handle->conn->cwd_fsp,
-                                       snaps_dname,
-                                       false,
-                                       SEC_DIR_LIST);
-       if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(0,("user does not have list permission "
-                       "on snapdir %s\n",
-                       snaps_dname->base_name));
-               ret = -map_errno_from_nt_status(status);
-               goto err_out;
-       }
-
        DBG_DEBUG("enumerating shadow copy dir at %s\n",
                  snaps_dname->base_name);
 
@@ -219,6 +207,19 @@ static int ceph_snap_enum_snapdir(struct vfs_handle_struct *handle,
                goto err_out;
        }
 
+       /* Check we have SEC_DIR_LIST access on this fsp. */
+       dirfsp = dir_hnd_fetch_fsp(dir_hnd);
+       status = smbd_check_access_rights_fsp(dirfsp,
+                                             false,
+                                             SEC_DIR_LIST);
+       if (!NT_STATUS_IS_OK(status)) {
+               DBG_ERR("user does not have list permission "
+                       "on snapdir %s\n",
+                       fsp_str_dbg(dirfsp));
+               ret = -map_errno_from_nt_status(status);
+               goto err_out;
+       }
+
        slots = 0;
        sc_data->num_volumes = 0;
        sc_data->labels = NULL;