]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_ceph: implement pathref opens in cephwrap_openat()
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)
Ceph supports O_PATH since v0.93 from 2015:

https://ceph.io/geen-categorie/v0-93-hammer-release-candidate-released/

This seems to be old enough so we can hopefully use this without a runtime
version check.

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

index 9133949c84ab175afa5ea9cc6e8f632f05106b65..502b72359b3aa5350a4d4bb9faad4e4343829c1e 100644 (file)
@@ -407,6 +407,8 @@ static int cephwrap_openat(struct vfs_handle_struct *handle,
                           int flags,
                           mode_t mode)
 {
+       bool have_opath = false;
+       bool became_root = false;
        int result = -ENOENT;
 
        /*
@@ -421,8 +423,26 @@ static int cephwrap_openat(struct vfs_handle_struct *handle,
                goto out;
        }
 
+#ifdef O_PATH
+       have_opath = true;
+       if (fsp->fsp_flags.is_pathref) {
+               flags |= O_PATH;
+       }
+#endif
+
+       if (fsp->fsp_flags.is_pathref && !have_opath) {
+               become_root();
+               became_root = true;
+       }
+
        result = ceph_open(handle->data, smb_fname->base_name, flags, mode);
+
+       if (became_root) {
+               unbecome_root();
+       }
+
 out:
+       fsp->fsp_flags.have_proc_fds = false;
        DBG_DEBUG("[CEPH] open(...) = %d\n", result);
        WRAP_RETURN(result);
 }