From: Greg Farnum Date: Wed, 27 Jul 2016 22:08:36 +0000 (-0700) Subject: client: always pass a UserPerm to removexattr variants X-Git-Tag: v11.0.1~36^2~82 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d1a77ee653491b4f4252baae0f492aa1d05b0afb;p=ceph.git client: always pass a UserPerm to removexattr variants Signed-off-by: Greg Farnum --- diff --git a/src/client/Client.cc b/src/client/Client.cc index ad817faa9d4..28209010f25 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -9800,33 +9800,35 @@ int Client::flistxattr(int fd, char *list, size_t size, const UserPerm& perms) return Client::_listxattr(f->inode.get(), list, size, perms); } -int Client::removexattr(const char *path, const char *name) +int Client::removexattr(const char *path, const char *name, + 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 _removexattr(in, name); + return _removexattr(in, name, perms); } -int Client::lremovexattr(const char *path, const char *name) +int Client::lremovexattr(const char *path, const char *name, + 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 _removexattr(in, name); + return _removexattr(in, name, perms); } -int Client::fremovexattr(int fd, const char *name) +int Client::fremovexattr(int fd, const char *name, const UserPerm& perms) { Mutex::Locker lock(client_lock); Fh *f = get_filehandle(fd); if (!f) return -EBADF; - return _removexattr(f->inode, name); + return _removexattr(f->inode, name, perms); } int Client::setxattr(const char *path, const char *name, const void *value, @@ -10183,7 +10185,7 @@ int Client::ll_setxattr(Inode *in, const char *name, const void *value, return _setxattr(in, name, value, size, flags, perms); } -int Client::_removexattr(Inode *in, const char *name, int uid, int gid) +int Client::_removexattr(Inode *in, const char *name, const UserPerm& perms) { if (in->snapid != CEPH_NOSNAP) { return -EROFS; @@ -10208,21 +10210,20 @@ int Client::_removexattr(Inode *in, const char *name, int uid, int gid) req->set_filepath2(name); req->set_inode(in); - int res = make_request(req, uid, gid); + int res = make_request(req, perms); trim_cache(); ldout(cct, 3) << "_removexattr(" << in->ino << ", \"" << name << "\") = " << res << dendl; return res; } -int Client::_removexattr(InodeRef &in, const char *name) +int Client::_removexattr(InodeRef &in, const char *name, const UserPerm& perms) { if (cct->_conf->client_permissions) { - int r = xattr_permission(in.get(), name, MAY_WRITE); + int r = xattr_permission(in.get(), name, MAY_WRITE, perms); if (r < 0) return r; } - UserPerm perms(0, 0); // FIXME return _removexattr(in.get(), name, perms); } diff --git a/src/client/Client.h b/src/client/Client.h index 800cd56b0cd..c43ff714ed0 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -826,11 +826,8 @@ private: int flags, const UserPerm& perms); int _setxattr(InodeRef &in, const char *name, const void *value, size_t len, int flags, const UserPerm& perms); - int _removexattr(Inode *in, const char *nm, int uid=-1, int gid=-1); - int _removexattr(Inode *in, const char *nm, const UserPerm& perms) { - return _removexattr(in, nm, perms.uid(), perms.gid()); - } - int _removexattr(InodeRef &in, const char *nm); + int _removexattr(Inode *in, const char *nm, const UserPerm& perms); + int _removexattr(InodeRef &in, const char *nm, const UserPerm& perms); int _open(Inode *in, int flags, mode_t mode, Fh **fhp, int uid, int gid); int _renew_caps(Inode *in); int _create(Inode *in, const char *name, int flags, mode_t mode, InodeRef *inp, Fh **fhp, @@ -1109,9 +1106,9 @@ public: 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); + int removexattr(const char *path, const char *name, const UserPerm& perms); + int lremovexattr(const char *path, const char *name, const UserPerm& perms); + int fremovexattr(int fd, const char *name, const UserPerm& perms); int setxattr(const char *path, const char *name, const void *value, size_t size, int flags, const UserPerm& perms); int lsetxattr(const char *path, const char *name, const void *value, diff --git a/src/libcephfs.cc b/src/libcephfs.cc index 1d9b6d909f4..f72b6db3a3f 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -686,21 +686,24 @@ extern "C" int ceph_removexattr(struct ceph_mount_info *cmount, const char *path { if (!cmount->is_mounted()) return -ENOTCONN; - return cmount->get_client()->removexattr(path, name); + UserPerm perms = cmount->get_client()->pick_my_perms(); + return cmount->get_client()->removexattr(path, name, perms); } extern "C" int ceph_lremovexattr(struct ceph_mount_info *cmount, const char *path, const char *name) { if (!cmount->is_mounted()) return -ENOTCONN; - return cmount->get_client()->lremovexattr(path, name); + UserPerm perms = cmount->get_client()->pick_my_perms(); + return cmount->get_client()->lremovexattr(path, name, perms); } extern "C" int ceph_fremovexattr(struct ceph_mount_info *cmount, int fd, const char *name) { if (!cmount->is_mounted()) return -ENOTCONN; - return cmount->get_client()->fremovexattr(fd, name); + UserPerm perms = cmount->get_client()->pick_my_perms(); + return cmount->get_client()->fremovexattr(fd, name, perms); } extern "C" int ceph_setxattr(struct ceph_mount_info *cmount, const char *path, const char *name, const void *value, size_t size, int flags)