]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: make Client::open() pass proper cap mask to path_walk 36701/head
authorYan, Zheng <zyan@redhat.com>
Tue, 18 Aug 2020 14:20:45 +0000 (22:20 +0800)
committerYan, Zheng <zyan@redhat.com>
Wed, 19 Aug 2020 00:07:17 +0000 (08:07 +0800)
variable 'mode' is new file's mode. It shouldn't be passed to
ceph_caps_for_mode().

Fixes: https://tracker.ceph.com/issues/47011
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/client/Client.cc

index e7eb2c23ef76d9c2a4960054cb757b2f164d5e56..c7f69f554355484d8aea34d53d17054eb25a428e 100755 (executable)
@@ -6517,6 +6517,8 @@ int Client::_lookup(Inode *dir, const string& dname, int mask, InodeRef *target,
 {
   int r = 0;
   Dentry *dn = NULL;
+  // can only request shared caps
+  mask &= CEPH_CAP_ANY_SHARED;
 
   if (dname == "..") {
     if (dir->dentries.empty()) {
@@ -8739,10 +8741,12 @@ int Client::open(const char *relpath, int flags, const UserPerm& perms,
   if (!mref_reader.is_state_satisfied())
     return -ENOTCONN;
 
-  ldout(cct, 3) << "open enter(" << relpath << ", " << ceph_flags_sys2wire(flags) << "," << mode << ")" << dendl;
+  int cflags = ceph_flags_sys2wire(flags);
+
+  ldout(cct, 3) << "open enter(" << relpath << ", " << cflags << "," << mode << ")" << dendl;
   tout(cct) << "open" << std::endl;
   tout(cct) << relpath << std::endl;
-  tout(cct) << ceph_flags_sys2wire(flags) << std::endl;
+  tout(cct) << cflags << std::endl;
 
   Fh *fh = NULL;
 
@@ -8759,9 +8763,10 @@ int Client::open(const char *relpath, int flags, const UserPerm& perms,
   bool created = false;
   /* O_CREATE with O_EXCL enforces O_NOFOLLOW. */
   bool followsym = !((flags & O_NOFOLLOW) || ((flags & O_CREAT) && (flags & O_EXCL)));
+  int mask = ceph_caps_for_mode(ceph_flags_to_mode(cflags));
 
   std::scoped_lock lock(client_lock);
-  int r = path_walk(path, &in, perms, followsym, ceph_caps_for_mode(mode));
+  int r = path_walk(path, &in, perms, followsym, mask);
 
   if (r == 0 && (flags & O_CREAT) && (flags & O_EXCL))
     return -EEXIST;
@@ -8814,7 +8819,7 @@ int Client::open(const char *relpath, int flags, const UserPerm& perms,
   
  out:
   tout(cct) << r << std::endl;
-  ldout(cct, 3) << "open exit(" << path << ", " << ceph_flags_sys2wire(flags) << ") = " << r << dendl;
+  ldout(cct, 3) << "open exit(" << path << ", " << cflags << ") = " << r << dendl;
   return r;
 }