]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: use fuse_req_getgroups() to get group list
authorYan, Zheng <zyan@redhat.com>
Tue, 29 Sep 2015 07:24:41 +0000 (15:24 +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 f93936113a4463b73a103696a80dd4f6aaee8c16..e64e42a874a76d47cb82769b05f415ac417413d1 100644 (file)
@@ -4779,7 +4779,7 @@ int Client::_getgrouplist(gid_t** sgids, int uid, int gid)
   gid_t *sgid_buf;
 
   if (getgroups_cb) {
-    sgid_count = getgroups_cb(callback_handle, uid, &sgid_buf);
+    sgid_count = getgroups_cb(callback_handle, &sgid_buf);
     if (sgid_count > 0) {
       *sgids = sgid_buf;
       return sgid_count;
index c684ecd9ce334006b1ebe33b3ad41071fcdf0660..16f525ad9aed49a1d312c7710908d45461835c1b 100644 (file)
@@ -140,7 +140,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 *handle, void *data);
 
 struct client_callback_args {
index b2e3d3daa705c3bdc0571f6c5a4667a9cdb849f2..866a9ffd20bf5f06b295f5bd620166bd986b891c 100644 (file)
@@ -738,12 +738,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;
   }
@@ -755,16 +757,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)
@@ -1005,17 +1007,7 @@ int CephFuse::Handle::start()
 #if defined(__linux__)
     remount_cb: remount_cb,
 #endif
-    /*
-     * 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);