]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: drop MAY_CREATE
authorSage Weil <sage@redhat.com>
Thu, 3 Sep 2015 16:44:20 +0000 (12:44 -0400)
committerSage Weil <sage@redhat.com>
Thu, 1 Oct 2015 13:42:36 +0000 (09:42 -0400)
The check is a no-op.  We already verify the uid/gid combo is valid and
that the dir is writeable with MAY_WRITE.  The new file is always set to
the caller uid:gid.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mds/MDSAuthCaps.cc
src/mds/MDSAuthCaps.h
src/mds/Server.cc
src/mds/SessionMap.cc
src/test/mds/TestMDSAuthCaps.cc

index 9f1709f8715a643c294558e53746890a2c0091e2..42d01aff0a03dfbdabe9d0b5053d8c19b479501b 100644 (file)
@@ -164,12 +164,6 @@ bool MDSAuthCaps::is_capable(const std::string &inode_path,
         return true;
       }
 
-      // we may only create things owned by caller
-      if ((mask & MAY_CREATE) &&
-         (inode_gid != caller_gid || inode_uid != caller_uid)) {
-       continue;
-      }
-
       // chown/chgrp
       if (mask & MAY_CHOWN) {
        if (new_uid != caller_uid ||   // you can't chown to someone else
index 68034ecc82fcaf4203d099241c21b181c4ee7553..112a7fb12aeffafdd20ec202248f6026de6ef072 100644 (file)
@@ -27,7 +27,6 @@ enum {
   MAY_READ = 1,
   MAY_WRITE = 2,
   MAY_EXECUTE = 4,
-  MAY_CREATE = 8,
   MAY_CHOWN = 16,
   MAY_CHGRP = 32
 };
index 13e460df60fb31058676446d7b2d5e6a00718407..5889ac37519ae8333668b59c5301ab7eb2bd9164 100644 (file)
@@ -3097,7 +3097,7 @@ void Server::handle_client_openc(MDRequestRef& mdr)
   if (!mds->locker->acquire_locks(mdr, rdlocks, wrlocks, xlocks))
     return;
 
-  if (!check_access(mdr, diri, MAY_WRITE|MAY_CREATE))
+  if (!check_access(mdr, diri, MAY_WRITE))
     return;
 
   CDentry::linkage_t *dnl = dn->get_projected_linkage();
@@ -4448,7 +4448,7 @@ void Server::handle_client_mknod(MDRequestRef& mdr)
   if (!mds->locker->acquire_locks(mdr, rdlocks, wrlocks, xlocks))
     return;
 
-  if (!check_access(mdr, diri, MAY_WRITE|MAY_CREATE))
+  if (!check_access(mdr, diri, MAY_WRITE))
     return;
 
   unsigned mode = req->head.args.mknod.mode;
@@ -4540,7 +4540,7 @@ void Server::handle_client_mkdir(MDRequestRef& mdr)
     return;
 
   // mkdir check access
-  if (!check_access(mdr, diri, (MAY_WRITE | MAY_CREATE)))
+  if (!check_access(mdr, diri, MAY_WRITE))
     return;
 
   // new inode
@@ -4619,7 +4619,7 @@ void Server::handle_client_symlink(MDRequestRef& mdr)
   if (!mds->locker->acquire_locks(mdr, rdlocks, wrlocks, xlocks))
     return;
 
-  if (!check_access(mdr, diri, MAY_WRITE|MAY_CREATE))
+  if (!check_access(mdr, diri, MAY_WRITE))
    return;
 
   unsigned mode = S_IFLNK | 0777;
index e2034f89f2ca21c7bf8db2f138f7e71c70474efb..3593867de76039a28ef38dfd8bf32e343b610b69 100644 (file)
@@ -851,18 +851,6 @@ bool Session::check_access(CInode *in, unsigned mask,
   if (path.length())
     path = path.substr(1);    // drop leading /
 
-  // for creation, we always assign the new inode the caller uid+gid.
-  // verify that is permitted.
-  if (mask & MAY_CREATE) {
-    if (!(auth_caps.is_capable(path, caller_uid, caller_gid,
-                              0 /* irrelevant */,
-                              caller_uid, caller_gid,
-                              MAY_CREATE, 0, 0))) {
-      return false;
-    }
-    mask &= ~MAY_CREATE;
-  }
-
   if (auth_caps.is_capable(path, in->inode.uid, in->inode.gid, in->inode.mode,
                           caller_uid, caller_gid, mask,
                           new_uid, new_gid)) {
index b7d3c0b0877abfbb00dd9b782cb7a74130a95263..d7aebfe82336a0a3a59d69afb1919494faaaafe1 100644 (file)
@@ -127,10 +127,9 @@ TEST(MDSAuthCaps, AllowUid) {
   ASSERT_TRUE(cap.is_capable("foo", 0, 10, 0775, 10, 10, MAY_READ, 0, 0));
   ASSERT_TRUE(cap.is_capable("foo", 0, 10, 0777, 10, 10, MAY_WRITE, 0, 0));
   ASSERT_TRUE(cap.is_capable("foo", 10, 10, 0755, 10, 10, MAY_WRITE, 0, 0));
-  ASSERT_FALSE(cap.is_capable("foo", 0, 0, 0777, 0, 10, MAY_READ|MAY_CREATE, 0, 0));
+  ASSERT_FALSE(cap.is_capable("foo", 0, 0, 0777, 0, 10, MAY_READ, 0, 0));
   ASSERT_FALSE(cap.is_capable("foo", 10, 10, 0755, 0, 0, MAY_READ, 0, 0));
   ASSERT_TRUE(cap.is_capable("foo", 0, 10, 0777, 10, 10, MAY_READ, 0, 0));
-  ASSERT_FALSE(cap.is_capable("foo", 0, 10, 0777, 10, 10, MAY_READ|MAY_CREATE, 0, 0));
   ASSERT_TRUE(cap.is_capable("foo", 0, 10, 0557, 10, 10, MAY_READ, 0, 0));
   ASSERT_TRUE(cap.is_capable("foo", 0, 0, 0557, 10, 10, MAY_READ, 0, 0));
   ASSERT_TRUE(cap.is_capable("foo", 0, 0, 0557, 10, 10, MAY_WRITE, 0, 0));