Skip to content

Commit

Permalink
client: use fuse_req_getgroups() to get group list
Browse files Browse the repository at this point in the history
Signed-off-by: Yan, Zheng <zyan@redhat.com>
(cherry picked from commit 0eb6d0b)
  • Loading branch information
ukernel committed Mar 3, 2016
1 parent a84ed87 commit c4ba93a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 23 deletions.
7 changes: 3 additions & 4 deletions src/client/Client.cc
Expand Up @@ -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....
Expand Down
2 changes: 1 addition & 1 deletion src/client/Client.h
Expand Up @@ -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 {
Expand Down
28 changes: 10 additions & 18 deletions src/client/fuse_ll.cc
Expand Up @@ -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;
}
Expand All @@ -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)
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit c4ba93a

Please sign in to comment.