From: Greg Farnum Date: Wed, 27 Jul 2016 21:43:05 +0000 (-0700) Subject: client: always pass a UserPerm to listxattr variants X-Git-Tag: v11.0.1~36^2~84 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2312d9a001806c6f1fc1e0819d2681c7c859347c;p=ceph.git client: always pass a UserPerm to listxattr variants Signed-off-by: Greg Farnum --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 73db672830c7..8c4f2a17f8e2 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -9772,33 +9772,35 @@ int Client::fgetxattr(int fd, const char *name, void *value, size_t size, return _getxattr(f->inode, name, value, size, perms); } -int Client::listxattr(const char *path, char *list, size_t size) +int Client::listxattr(const char *path, char *list, size_t size, + const UserPerm& perms) { Mutex::Locker lock(client_lock); InodeRef in; - int r = Client::path_walk(path, &in, true); + int r = Client::path_walk(path, &in, perms, true); if (r < 0) return r; - return Client::_listxattr(in.get(), list, size); + return Client::_listxattr(in.get(), list, size, perms); } -int Client::llistxattr(const char *path, char *list, size_t size) +int Client::llistxattr(const char *path, char *list, size_t size, + const UserPerm& perms) { Mutex::Locker lock(client_lock); InodeRef in; - int r = Client::path_walk(path, &in, false); + int r = Client::path_walk(path, &in, perms, false); if (r < 0) return r; - return Client::_listxattr(in.get(), list, size); + return Client::_listxattr(in.get(), list, size, perms); } -int Client::flistxattr(int fd, char *list, size_t size) +int Client::flistxattr(int fd, char *list, size_t size, const UserPerm& perms) { Mutex::Locker lock(client_lock); Fh *f = get_filehandle(fd); if (!f) return -EBADF; - return Client::_listxattr(f->inode.get(), list, size); + return Client::_listxattr(f->inode.get(), list, size, perms); } int Client::removexattr(const char *path, const char *name) @@ -9939,9 +9941,10 @@ int Client::ll_getxattr(Inode *in, const char *name, void *value, return _getxattr(in, name, value, size, perms); } -int Client::_listxattr(Inode *in, char *name, size_t size, int uid, int gid) +int Client::_listxattr(Inode *in, char *name, size_t size, + const UserPerm& perms) { - int r = _getattr(in, CEPH_STAT_CAP_XATTR, uid, gid, in->xattr_version == 0); + int r = _getattr(in, CEPH_STAT_CAP_XATTR, perms, in->xattr_version == 0); if (r == 0) { for (map::iterator p = in->xattrs.begin(); p != in->xattrs.end(); diff --git a/src/client/Client.h b/src/client/Client.h index 78a228775f77..60d01f09d8dd 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -818,10 +818,7 @@ private: const UserPerm& perms); int _getxattr(InodeRef &in, const char *name, void *value, size_t len, const UserPerm& perms); - int _listxattr(Inode *in, char *names, size_t len, int uid=-1, int gid=-1); - int _listxattr(Inode *in, char *names, size_t len, const UserPerm& perms) { - return _listxattr(in, names, len, perms.uid(), perms.gid()); - } + int _listxattr(Inode *in, char *names, size_t len, const UserPerm& perms); int _do_setxattr(Inode *in, const char *name, const void *value, size_t len, int flags, int uid, int gid); int _setxattr(Inode *in, const char *name, const void *value, size_t len, int flags, int uid=-1, int gid=-1); @@ -1110,9 +1107,9 @@ public: const UserPerm& perms); int fgetxattr(int fd, const char *name, void *value, size_t size, const UserPerm& perms); - int listxattr(const char *path, char *list, size_t size); - int llistxattr(const char *path, char *list, size_t size); - int flistxattr(int fd, char *list, size_t size); + int listxattr(const char *path, char *list, size_t size, const UserPerm& perms); + int llistxattr(const char *path, char *list, size_t size, const UserPerm& perms); + int flistxattr(int fd, char *list, size_t size, const UserPerm& perms); int removexattr(const char *path, const char *name); int lremovexattr(const char *path, const char *name); int fremovexattr(int fd, const char *name); diff --git a/src/libcephfs.cc b/src/libcephfs.cc index fc3dfcaaed34..a96514b90f0d 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -662,21 +662,24 @@ extern "C" int ceph_listxattr(struct ceph_mount_info *cmount, const char *path, { if (!cmount->is_mounted()) return -ENOTCONN; - return cmount->get_client()->listxattr(path, list, size); + UserPerm perms = cmount->get_client()->pick_my_perms(); + return cmount->get_client()->listxattr(path, list, size, perms); } extern "C" int ceph_llistxattr(struct ceph_mount_info *cmount, const char *path, char *list, size_t size) { if (!cmount->is_mounted()) return -ENOTCONN; - return cmount->get_client()->llistxattr(path, list, size); + UserPerm perms = cmount->get_client()->pick_my_perms(); + return cmount->get_client()->llistxattr(path, list, size, perms); } extern "C" int ceph_flistxattr(struct ceph_mount_info *cmount, int fd, char *list, size_t size) { if (!cmount->is_mounted()) return -ENOTCONN; - return cmount->get_client()->flistxattr(fd, list, size); + UserPerm perms = cmount->get_client()->pick_my_perms(); + return cmount->get_client()->flistxattr(fd, list, size, perms); } extern "C" int ceph_removexattr(struct ceph_mount_info *cmount, const char *path, const char *name)