]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: apply umask for new files when posix acl is enabled
authorYan, Zheng <zyan@redhat.com>
Tue, 29 Sep 2015 09:00:58 +0000 (17:00 +0800)
committerYan, Zheng <zyan@redhat.com>
Tue, 12 Jan 2016 09:21:01 +0000 (17:21 +0800)
Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/client/Client.cc
src/client/Client.h
src/client/fuse_ll.cc

index 0ad9b327f10e52fab984fb4cc61a83d74bf77a0a..74c5c3bb8fdd7cbf70206a2002a04e47e1d97dc8 100644 (file)
@@ -240,6 +240,7 @@ Client::Client(Messenger *m, MonClient *mc)
     ino_invalidate_cb(NULL),
     dentry_invalidate_cb(NULL),
     getgroups_cb(NULL),
+    umask_cb(NULL),
     can_invalidate_dentries(false),
     require_remount(false),
     async_ino_invalidator(m->cct),
@@ -8844,6 +8845,7 @@ void Client::ll_register_callbacks(struct client_callback_args *args)
     remount_finisher.start();
   }
   getgroups_cb = args->getgroups_cb;
+  umask_cb = args->umask_cb;
 }
 
 int Client::test_dentry_handling(bool can_invalidate)
@@ -11964,6 +11966,8 @@ int Client::_posix_acl_create(Inode *dir, mode_t *mode, bufferlist& xattrs_bl,
       if (r > 0)
        ::encode(xattrs, xattrs_bl);
     } else {
+      if (umask_cb)
+       *mode &= ~umask_cb(callback_handle);
       r = 0;
     }
   }
index 7d3a60a363610444ba0186ad9b8a028f37cf50b1..6c268ae254be268b108c85ab53bb2ba22b2e1c96 100644 (file)
@@ -142,6 +142,7 @@ typedef int (*client_remount_callback_t)(void *handle);
 
 typedef int (*client_getgroups_callback_t)(void *handle, gid_t **sgids);
 typedef void(*client_switch_interrupt_callback_t)(void *handle, void *data);
+typedef mode_t (*client_umask_callback_t)(void *handle);
 
 struct client_callback_args {
   void *handle;
@@ -150,6 +151,7 @@ struct client_callback_args {
   client_switch_interrupt_callback_t switch_intr_cb;
   client_remount_callback_t remount_cb;
   client_getgroups_callback_t getgroups_cb;
+  client_umask_callback_t umask_cb;
 };
 
 // ========================================================
@@ -246,6 +248,7 @@ class Client : public Dispatcher, public md_config_obs_t {
   client_ino_callback_t ino_invalidate_cb;
   client_dentry_callback_t dentry_invalidate_cb;
   client_getgroups_callback_t getgroups_cb;
+  client_umask_callback_t umask_cb;
   bool can_invalidate_dentries;
   bool require_remount;
 
@@ -1081,6 +1084,10 @@ public:
   int ll_flock(Fh *fh, int cmd, uint64_t owner);
   int ll_file_layout(Fh *fh, ceph_file_layout *layout);
   void ll_interrupt(void *d);
+  bool ll_handle_umask() {
+    return acl_type != NO_ACL;
+  }
+
   int ll_get_stripe_osd(struct Inode *in, uint64_t blockno,
                        ceph_file_layout* layout);
   uint64_t ll_get_internal_offset(struct Inode *in, uint64_t blockno);
index 77d696e7204499f57b5060ca1981a79e76914fb0..8c9bff00295d4e14e2cbcd8fa0261f41bce74430 100644 (file)
@@ -768,6 +768,14 @@ static int getgroups_cb(void *handle, gid_t **sgids)
 #endif
 }
 
+static mode_t umask_cb(void *handle)
+{
+  CephFuse::Handle *cfuse = (CephFuse::Handle *)handle;
+  fuse_req_t req = cfuse->get_fuse_req();
+  const struct fuse_ctx *ctx = fuse_req_ctx(req);
+  return ctx->umask;
+}
+
 static void ino_invalidate_cb(void *handle, vinodeno_t vino, int64_t off,
                              int64_t len)
 {
@@ -808,9 +816,18 @@ static int remount_cb(void *handle)
   return r;
 }
 
-static void do_init(void *data, fuse_conn_info *bar)
+static void do_init(void *data, fuse_conn_info *conn)
 {
   CephFuse::Handle *cfuse = (CephFuse::Handle *)data;
+  Client *client = cfuse->client;
+
+  if (!client->cct->_conf->fuse_default_permissions &&
+      client->ll_handle_umask()) {
+    // apply umask in userspace if posix acl is enabled
+    if(conn->capable & FUSE_CAP_DONT_MASK)
+      conn->want |= FUSE_CAP_DONT_MASK;
+  }
+
   if (cfuse->fd_on_success) {
     //cout << "fuse init signaling on fd " << fd_on_success << std::endl;
     uint32_t r = 0;
@@ -1008,6 +1025,7 @@ int CephFuse::Handle::start()
     remount_cb: remount_cb,
 #endif
     getgroups_cb: getgroups_cb,
+    umask_cb: umask_cb,
   };
   client->ll_register_callbacks(&args);