]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: always pass a UserPerm to listxattr variants
authorGreg Farnum <gfarnum@redhat.com>
Wed, 27 Jul 2016 21:43:05 +0000 (14:43 -0700)
committerGreg Farnum <gfarnum@redhat.com>
Wed, 31 Aug 2016 21:38:49 +0000 (14:38 -0700)
Signed-off-by: Greg Farnum <gfarnum@redhat.com>
src/client/Client.cc
src/client/Client.h
src/libcephfs.cc

index 73db672830c7d5f3fd99ff0b5569e9087abf67e9..8c4f2a17f8e28c0320e5797efd0986b5325ee773 100644 (file)
@@ -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<string,bufferptr>::iterator p = in->xattrs.begin();
         p != in->xattrs.end();
index 78a228775f778cbe6da08daaebdfda746c8ddaa1..60d01f09d8ddd4872aed61c827b87754d51dbfa5 100644 (file)
@@ -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);
index fc3dfcaaed3446e2590463242d1aee1e88817765..a96514b90f0da9300a2eb9505612cd3cf2462933 100644 (file)
@@ -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)