]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_glusterfs: implement pathref opens with become_root() fallback
authorRalph Boehme <slow@samba.org>
Thu, 1 Oct 2020 13:44:15 +0000 (15:44 +0200)
committerRalph Boehme <slow@samba.org>
Wed, 16 Dec 2020 09:08:30 +0000 (09:08 +0000)
Until glusterfs supports O_PATH, fallback to become_root().

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

index 1d636471812c1e3f6d2b18868fc03bd2ea1a7f05..e4c129319385f15a19c4ed259b855ee34106caee 100644 (file)
@@ -729,6 +729,7 @@ static int vfs_gluster_openat(struct vfs_handle_struct *handle,
                              int flags,
                              mode_t mode)
 {
+       bool became_root = false;
        glfs_fd_t *glfd;
        glfs_fd_t **p_tmp;
 
@@ -746,6 +747,15 @@ static int vfs_gluster_openat(struct vfs_handle_struct *handle,
                return -1;
        }
 
+       if (fsp->fsp_flags.is_pathref) {
+               /*
+                * ceph doesn't support O_PATH so we have to fallback to
+                * become_root().
+                */
+               become_root();
+               became_root = true;
+       }
+
        if (flags & O_DIRECTORY) {
                glfd = glfs_opendir(handle->data, smb_fname->base_name);
        } else if (flags & O_CREAT) {
@@ -755,6 +765,12 @@ static int vfs_gluster_openat(struct vfs_handle_struct *handle,
                glfd = glfs_open(handle->data, smb_fname->base_name, flags);
        }
 
+       if (became_root) {
+               unbecome_root();
+       }
+
+       fsp->fsp_flags.have_proc_fds = false;
+
        if (glfd == NULL) {
                END_PROFILE(syscall_openat);
                /* no extension destroy_fn, so no need to save errno */