From e46dc20cdfb157f94781032451057d1e138535cc Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Thu, 19 Oct 2023 10:20:55 +0800 Subject: [PATCH] client: use the fs' full path instead of from mountpoint's root The mountpoint's root ino# possibly not be the full CephFS filesystem root, it's just the mountpoint of this particular client. Just prepend the mountpoint path to the full path. Introduced-by: c1bf8d88e9d client: check the cephx mds auth access for setattr Introduced-by: ce216595c03 client: check the cephx mds auth access for open Fixes: https://github.com/ceph/ceph/pull/48027#issuecomment-1741019086 Signed-off-by: Xiubo Li --- src/client/Client.cc | 20 ++++++++++++++++---- src/client/Client.h | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 4e7e3961e8e..84b30a2d367 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -8000,6 +8000,20 @@ int Client::_getvxattr( return res; } +bool Client::make_absolute_path_string(Inode *in, std::string& path) +{ + if (!metadata.count("root") || !in) + return false; + + path = metadata["root"].data(); + if (!in->make_path_string(path)) { + path.clear(); + return false; + } + + return true; +} + int Client::_do_setattr(Inode *in, struct ceph_statx *stx, int mask, const UserPerm& perms, InodeRef *inp, std::vector* aux) @@ -8042,8 +8056,7 @@ int Client::_do_setattr(Inode *in, struct ceph_statx *stx, int mask, int res; { std::string path; - res = in->make_path_string(path); - if (res) { + if (make_absolute_path_string(in, path)) { ldout(cct, 20) << " absolute path: " << path << dendl; if (path.length()) path = path.substr(1); // drop leading / @@ -10272,8 +10285,7 @@ int Client::_open(Inode *in, int flags, mode_t mode, Fh **fhp, } std::string path; - int result = in->make_path_string(path); - if (result) { + if (make_absolute_path_string(in, path)) { ldout(cct, 20) << __func__ << " absolute path: " << path << dendl; if (path.length()) path = path.substr(1); // drop leading / diff --git a/src/client/Client.h b/src/client/Client.h index 63df6b815bd..9c1303384be 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -1625,6 +1625,7 @@ private: const UserPerm& perms, std::string alternate_name, InodeRef *inp = 0); int _mknod(Inode *dir, const char *name, mode_t mode, dev_t rdev, const UserPerm& perms, InodeRef *inp = 0); + bool make_absolute_path_string(Inode *in, std::string& path); int _do_setattr(Inode *in, struct ceph_statx *stx, int mask, const UserPerm& perms, InodeRef *inp, std::vector* aux=nullptr); -- 2.39.5