]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: Fix executeable access check for the root user 40882/head
authorKotresh HR <khiremat@redhat.com>
Fri, 16 Apr 2021 04:14:05 +0000 (09:44 +0530)
committerKotresh HR <khiremat@redhat.com>
Fri, 16 Apr 2021 04:21:04 +0000 (09:51 +0530)
Executeable permission check always returned sucessful
even when executeable bit is not set on any of the user,
group or others. This patch fixes it by overiding
executeable permission check for root only if one of
the executeable bit is set

Signed-off-by: Kotresh HR <khiremat@redhat.com>
Fixes: https://tracker.ceph.com/issues/50060
src/client/Client.cc

index f5e9ae933bce9089cdcb751ee1a097a779d55979..1368bf8ea65aeb0e8b92fcca16d67e40ce81c430 100644 (file)
 
 #define DEBUG_GETATTR_CAPS (CEPH_CAP_XATTR_SHARED)
 
+#ifndef S_IXUGO
+#define S_IXUGO        (S_IXUSR|S_IXGRP|S_IXOTH)
+#endif
+
 using namespace TOPNSPC::common;
 
 namespace bs = boost::system;
@@ -5597,8 +5601,12 @@ void Client::handle_cap_grant(MetaSession *session, Inode *in, Cap *cap, const M
 
 int Client::inode_permission(Inode *in, const UserPerm& perms, unsigned want)
 {
-  if (perms.uid() == 0)
+  if (perms.uid() == 0) {
+    // Executable are overridable when there is at least one exec bit set
+    if((want & MAY_EXEC) && !(in->mode & S_IXUGO))
+      return -CEPHFS_EACCES;
     return 0;
+  }
   
   if (perms.uid() != in->uid && (in->mode & S_IRWXG)) {
     int ret = _posix_acl_permission(in, perms, want);