]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: lseek shouldn't do permission checking
authorJeff Layton <jlayton@redhat.com>
Wed, 12 Oct 2016 11:04:42 +0000 (07:04 -0400)
committerJeff Layton <jlayton@redhat.com>
Wed, 12 Oct 2016 11:04:42 +0000 (07:04 -0400)
With the addition of the UserPerm changes, ceph_lseek started
checking for open permissions using the default mount perms. lseek
should not require those permissions though, as it operates on an
already-opened file descriptor. Remove the perms argument from most
of these functions.

Fixes: be9e43e2da41e91ffd8577dfd0b890cdb361a08e
Signed-off-by: Jeff Layton <jlayton@redhat.com>
src/client/Client.cc
src/client/Client.h
src/client/SyntheticClient.cc
src/libcephfs.cc

index 48620577ec1bb374d8fb51c321fd121b14a74d84..5ec790b0469b47af4f1a13d5e56cb3199c0f7528 100644 (file)
@@ -8102,7 +8102,7 @@ int Client::close(int fd)
 // ------------
 // read, write
 
-loff_t Client::lseek(int fd, loff_t offset, int whence, const UserPerm& perms)
+loff_t Client::lseek(int fd, loff_t offset, int whence)
 {
   Mutex::Locker lock(client_lock);
   tout(cct) << "lseek" << std::endl;
@@ -8117,18 +8117,14 @@ loff_t Client::lseek(int fd, loff_t offset, int whence, const UserPerm& perms)
   if (f->flags & O_PATH)
     return -EBADF;
 #endif
-  return _lseek(f, offset, whence, perms);
+  return _lseek(f, offset, whence);
 }
 
-loff_t Client::_lseek(Fh *f, loff_t offset, int whence, const UserPerm& perms)
+loff_t Client::_lseek(Fh *f, loff_t offset, int whence)
 {
   Inode *in = f->inode.get();
   int r;
 
-  if (!may_open(f->inode.get(), f->flags, perms)) {
-    return -EPERM;
-  }
-
   switch (whence) {
   case SEEK_SET:
     f->pos = offset;
@@ -8139,7 +8135,7 @@ loff_t Client::_lseek(Fh *f, loff_t offset, int whence, const UserPerm& perms)
     break;
 
   case SEEK_END:
-    r = _getattr(in, CEPH_STAT_CAP_SIZE, perms);
+    r = _getattr(in, CEPH_STAT_CAP_SIZE, f->actor_perms);
     if (r < 0)
       return r;
     f->pos = in->size + offset;
@@ -8686,7 +8682,7 @@ int Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf,
      * change out from under us.
      */
     if (f->flags & O_APPEND) {
-      int r = _lseek(f, 0, SEEK_END, f->actor_perms);
+      int r = _lseek(f, 0, SEEK_END);
       if (r < 0) {
         unlock_fh_pos(f);
         return r;
@@ -11706,15 +11702,14 @@ out:
   return r;
 }
 
-loff_t Client::ll_lseek(Fh *fh, loff_t offset, int whence,
-                       const UserPerm& perms)
+loff_t Client::ll_lseek(Fh *fh, loff_t offset, int whence)
 {
   Mutex::Locker lock(client_lock);
   tout(cct) << "ll_lseek" << std::endl;
   tout(cct) << offset << std::endl;
   tout(cct) << whence << std::endl;
 
-  return _lseek(fh, offset, whence, perms);
+  return _lseek(fh, offset, whence);
 }
 
 int Client::ll_read(Fh *fh, loff_t off, loff_t len, bufferlist *bl)
index 353771cb1c09994fee5ee881fc0bb63ff16f1fab..91863ff4932004b3f4d715a1afc5bb3f6a08e038 100644 (file)
@@ -809,7 +809,6 @@ private:
              const char *data_pool, bool *created, const UserPerm &perms);
 
   loff_t _lseek(Fh *fh, loff_t offset, int whence);
-  loff_t _lseek(Fh *fh, loff_t offset, int whence, const UserPerm& perms);
   int _read(Fh *fh, int64_t offset, uint64_t size, bufferlist *bl);
   int _write(Fh *fh, int64_t offset, uint64_t size, const char *buf,
           const struct iovec *iov, int iovcnt);
@@ -1033,7 +1032,7 @@ public:
   int lookup_parent(Inode *in, const UserPerm& perms, Inode **parent=NULL);
   int lookup_name(Inode *in, Inode *parent, const UserPerm& perms);
   int close(int fd);
-  loff_t lseek(int fd, loff_t offset, int whence, const UserPerm& perms);
+  loff_t lseek(int fd, loff_t offset, int whence);
   int read(int fd, char *buf, loff_t size, loff_t offset=-1);
   int preadv(int fd, const struct iovec *iov, int iovcnt, loff_t offset=-1);
   int write(int fd, const char *buf, loff_t size, loff_t offset=-1);
@@ -1168,7 +1167,7 @@ public:
 
   int ll_read(Fh *fh, loff_t off, loff_t len, bufferlist *bl);
   int ll_write(Fh *fh, loff_t off, loff_t len, const char *data);
-  loff_t ll_lseek(Fh *fh, loff_t offset, int whence, const UserPerm& perms);
+  loff_t ll_lseek(Fh *fh, loff_t offset, int whence);
   int ll_flush(Fh *fh);
   int ll_fsync(Fh *fh, bool syncdataonly);
   int ll_fallocate(Fh *fh, int mode, loff_t offset, loff_t length);
index 77de39596471d5b855c98fe81bfcaab89168c226..0a48d2680cff45e3f5b910bd2d940860460f1de0 100644 (file)
@@ -1173,7 +1173,7 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only)
       int fd = open_files[f];
       int64_t off = t.get_int();
       int64_t whence = t.get_int();
-      client->lseek(fd, off, whence, perms);
+      client->lseek(fd, off, whence);
     } else if (strcmp(op, "read") == 0) {
       int64_t f = t.get_int();
       int64_t size = t.get_int();
index f24ff945fe4dfd17d2aa5263dc5a6f1c98321213..cc8af424d35f58d7614b634dfee1ec79b36a72ad 100644 (file)
@@ -833,7 +833,7 @@ extern "C" int64_t ceph_lseek(struct ceph_mount_info *cmount, int fd,
 {
   if (!cmount->is_mounted())
     return -ENOTCONN;
-  return cmount->get_client()->lseek(fd, offset, whence, cmount->default_perms);
+  return cmount->get_client()->lseek(fd, offset, whence);
 }
 
 extern "C" int ceph_read(struct ceph_mount_info *cmount, int fd, char *buf,
@@ -1532,7 +1532,7 @@ extern "C" int ceph_ll_fsync(class ceph_mount_info *cmount,
 extern "C" off_t ceph_ll_lseek(class ceph_mount_info *cmount,
                                Fh *fh, off_t offset, int whence)
 {
-  return (cmount->get_client()->ll_lseek(fh, offset, whence, cmount->default_perms));
+  return (cmount->get_client()->ll_lseek(fh, offset, whence));
 }
 
 extern "C" int ceph_ll_write(class ceph_mount_info *cmount,