m->put();
}
-int Client::_getgrouplist(gid_t** sgids, uid_t uid, gid_t gid)
-{
- // cppcheck-suppress variableScope
- int sgid_count;
- gid_t *sgid_buf;
-
- if (getgroups_cb) {
- sgid_count = getgroups_cb(callback_handle, &sgid_buf);
- if (sgid_count > 0) {
- *sgids = sgid_buf;
- return sgid_count;
- }
- }
-
-#if HAVE_GETGROUPLIST
- struct passwd *pw;
- pw = getpwuid(uid);
- if (pw == NULL) {
- ldout(cct, 3) << "getting user entry failed" << dendl;
- return -errno;
- }
- //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....
- sgid_count = 16;
- sgid_buf = (gid_t*)malloc(sgid_count * sizeof(gid_t));
- if (sgid_buf == NULL) {
- ldout(cct, 3) << "allocating group memory failed" << dendl;
- return -ENOMEM;
- }
-
- while (1) {
-#if defined(__APPLE__)
- if (getgrouplist(pw->pw_name, gid, (int*)sgid_buf, &sgid_count) == -1) {
-#else
- if (getgrouplist(pw->pw_name, gid, sgid_buf, &sgid_count) == -1) {
-#endif
- // we need to resize the group list and try again
- void *_realloc = NULL;
- if ((_realloc = realloc(sgid_buf, sgid_count * sizeof(gid_t))) == NULL) {
- ldout(cct, 3) << "allocating group memory failed" << dendl;
- free(sgid_buf);
- return -ENOMEM;
- }
- sgid_buf = (gid_t*)_realloc;
- continue;
- }
- // list was successfully retrieved
- break;
- }
- *sgids = sgid_buf;
- return sgid_count;
-#else
- return 0;
-#endif
-}
-
int Client::inode_permission(Inode *in, const UserPerm& perms, unsigned want)
{
if (perms.uid() == 0)
int may_hardlink(Inode *in, const UserPerm& perms);
int _getattr_for_perm(Inode *in, const UserPerm& perms);
- int _getgrouplist(gid_t **sgids, uid_t uid, gid_t gid);
vinodeno_t _get_vino(Inode *in);
inodeno_t _get_inodeno(Inode *in);