]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: always pass a UserPerm to removexattr variants
authorGreg Farnum <gfarnum@redhat.com>
Wed, 27 Jul 2016 22:08:36 +0000 (15:08 -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 ad817faa9d48dfbae7a353575146877e5b3d463a..28209010f2593567291770af6af110a94b90f7d6 100644 (file)
@@ -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);
 }
 
index 800cd56b0cd54ae29b6403f2365a2a4f5c0109d4..c43ff714ed0992d1b155be4fd99d0f570af44119 100644 (file)
@@ -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,
index 1d9b6d909f42d5a25456c954b720bad8bc448853..f72b6db3a3f8db5bdd3827a9e37407e86d530a5d 100644 (file)
@@ -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)