From 04515008a112e8ed19c153093592f369b250347d Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Mon, 2 Apr 2018 09:20:41 -0400 Subject: [PATCH] fuse: wire up fuse_ll_access This gets called during chdir and is currently a no-op. Make sure we check permissions appropriately. Tracker: http://tracker.ceph.com/issues/23509 Signed-off-by: Jeff Layton (cherry picked from commit 53b59a3c0b6b4f14e9d0ae9d4900a8b4311159e6) Conflicts: src/client/Client.h: Resolved for inode_permission --- src/client/Client.h | 4 +++- src/client/fuse_ll.cc | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/client/Client.h b/src/client/Client.h index 0d7cd787bad13..2b6fd001ebccf 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -865,7 +865,6 @@ private: void init_groups(UserPerm *groups); - int inode_permission(Inode *in, const UserPerm& perms, unsigned want); int xattr_permission(Inode *in, const char *name, unsigned want, const UserPerm& perms); int may_setattr(Inode *in, struct ceph_statx *stx, int mask, @@ -1126,6 +1125,9 @@ public: int mksnap(const char *path, const char *name, const UserPerm& perm); int rmsnap(const char *path, const char *name, const UserPerm& perm); + // Inode permission checking + int inode_permission(Inode *in, const UserPerm& perms, unsigned want); + // expose caps int get_caps_issued(int fd); int get_caps_issued(const char *path, const UserPerm& perms); diff --git a/src/client/fuse_ll.cc b/src/client/fuse_ll.cc index d24ad5c3451a1..35f591360ce65 100644 --- a/src/client/fuse_ll.cc +++ b/src/client/fuse_ll.cc @@ -748,7 +748,15 @@ static void fuse_ll_fsyncdir(fuse_req_t req, fuse_ino_t ino, int datasync, static void fuse_ll_access(fuse_req_t req, fuse_ino_t ino, int mask) { - fuse_reply_err(req, 0); + CephFuse::Handle *cfuse = fuse_ll_req_prepare(req); + const struct fuse_ctx *ctx = fuse_req_ctx(req); + Inode *in = cfuse->iget(ino); + UserPerm perms(ctx->uid, ctx->gid); + get_fuse_groups(perms, req); + + int r = cfuse->client->inode_permission(in, perms, mask); + fuse_reply_err(req, -r); + cfuse->iput(in); } static void fuse_ll_create(fuse_req_t req, fuse_ino_t parent, const char *name, -- 2.39.5