]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: use fuse_req_getgroups() to get group list 6604/head
authorYan, Zheng <zyan@redhat.com>
Tue, 29 Sep 2015 07:24:41 +0000 (15:24 +0800)
committerYan, Zheng <zyan@redhat.com>
Thu, 3 Mar 2016 12:30:07 +0000 (20:30 +0800)
Signed-off-by: Yan, Zheng <zyan@redhat.com>
(cherry picked from commit 0eb6d0ba1b65ac0aaffc72a82f07857cc65a6b88)

src/client/Client.cc
src/client/Client.h
src/client/fuse_ll.cc

index a966b1702116675ae26dc2a7d891e69c53c21a3b..21b80cddd2e9fc61a1d6949aa10d45020869d220 100644 (file)
@@ -4391,14 +4391,13 @@ int Client::check_permissions(Inode *in, int flags, int uid, int gid)
   gid_t *sgids = NULL;
   int sgid_count = 0;
   if (getgroups_cb) {
-    sgid_count = getgroups_cb(callback_handle, uid, &sgids);
-    if (sgid_count < 0) {
+    sgid_count = getgroups_cb(callback_handle, &sgids);
+    if (sgid_count > 0) {
       ldout(cct, 3) << "getgroups failed!" << dendl;
-      return sgid_count;
     }
   }
 #if HAVE_GETGROUPLIST
-  else {
+  if (sgid_count <= 0) {
     // use PAM to get the group list
     // initial number of group entries, defaults to posix standard of 16
     // PAM implementations may provide more than 16 groups....
index b476f5eff8597d7f5bd2b5bbfe1ba29f4ea79f93..91383f30e633df2199fe0302e3a2a276d07c1019 100644 (file)
@@ -138,7 +138,7 @@ typedef void (*client_dentry_callback_t)(void *handle, vinodeno_t dirino,
                                         vinodeno_t ino, string& name);
 typedef int (*client_remount_callback_t)(void *handle);
 
-typedef int (*client_getgroups_callback_t)(void *handle, uid_t uid, gid_t **sgids);
+typedef int (*client_getgroups_callback_t)(void *handle, gid_t **sgids);
 typedef void(*client_switch_interrupt_callback_t)(void *req, void *data);
 
 struct client_callback_args {
index a83e5a698c3c673a2f8d2d30bc8ffc774fbfb91b..d65149563fa3971dcaceb6cc0ab893e981559258 100644 (file)
@@ -715,12 +715,14 @@ static void fuse_ll_flock(fuse_req_t req, fuse_ino_t ino,
 }
 #endif
 
-#if 0
-static int getgroups_cb(void *handle, uid_t uid, gid_t **sgids)
+static int getgroups_cb(void *handle, gid_t **sgids)
 {
-#ifdef HAVE_FUSE_GETGROUPS
+#if FUSE_VERSION >= FUSE_MAKE_VERSION(2, 8)
+  CephFuse::Handle *cfuse = (CephFuse::Handle *)handle;
+  fuse_req_t req = cfuse->get_fuse_req();
+
   assert(sgids);
-  int c = fuse_getgroups(0, NULL);
+  int c = fuse_req_getgroups(req, 0, NULL);
   if (c < 0) {
     return c;
   }
@@ -732,16 +734,16 @@ static int getgroups_cb(void *handle, uid_t uid, gid_t **sgids)
   if (!*sgids) {
     return -ENOMEM;
   }
-  c = fuse_getgroups(c, *sgids);
+  c = fuse_req_getgroups(req, c, *sgids);
   if (c < 0) {
     free(*sgids);
     return c;
   }
   return c;
+#else
+  return -ENOSYS;
 #endif
-  return 0;
 }
-#endif
 
 static void ino_invalidate_cb(void *handle, vinodeno_t vino, int64_t off,
                              int64_t len)
@@ -979,17 +981,7 @@ int CephFuse::Handle::start()
     dentry_cb: dentry_invalidate_cb,
     switch_intr_cb: switch_interrupt_cb,
     remount_cb: remount_cb,
-    /*
-     * this is broken:
-     *
-     * - the cb needs the request handle to be useful; we should get the
-     *   gids in the method here in fuse_ll.c and pass the gid list in,
-     *   not use a callback.
-     * - the callback mallocs the list but it is not free()'d
-     *
-     * so disable it for now...
-     getgroups_cb: getgroups_cb,
-     */
+    getgroups_cb: getgroups_cb,
   };
   client->ll_register_callbacks(&args);