From: Ralph Boehme Date: Thu, 1 Oct 2020 13:44:15 +0000 (+0200) Subject: vfs_ceph: implement pathref opens in cephwrap_openat() X-Git-Tag: samba-4.14.0rc1~388 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd8825742f7cc4acb705fdaec41ddb91967e37c5;p=thirdparty%2Fsamba.git vfs_ceph: implement pathref opens in cephwrap_openat() 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 Reviewed-by: Jeremy Allison --- diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index 9133949c84a..502b72359b3 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -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); }