Skip to content

Commit

Permalink
Make getgroups(2) actually work
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Apr 12, 2020
1 parent 4c18647 commit 806d1f1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion kernel/getset.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,26 @@ int_t sys_getresgid(addr_t rgid_addr, addr_t egid_addr, addr_t sgid_addr) {
}

int_t sys_getgroups(dword_t size, addr_t list) {
STRACE("getgroups(%d, %#x)", size, list);
if (size == 0)
return current->ngroups;
if (size < current->ngroups)
return _EINVAL;
for (unsigned i = 0; i < current->ngroups; i++)
STRACE(" %d", current->groups[i]);
if (user_write(list, current->groups, size * sizeof(uid_t_)))
return _EFAULT;
return 0;
return current->ngroups;
}

int_t sys_setgroups(dword_t size, addr_t list) {
STRACE("setgroups(%d, %#x)", size, list);
if (size > MAX_GROUPS)
return _EINVAL;
if (user_read(list, current->groups, size * sizeof(uid_t_)))
return _EFAULT;
for (unsigned i = 0; i < size; i++)
STRACE(" %d", current->groups[i]);
current->ngroups = size;
return 0;
}
Expand Down

0 comments on commit 806d1f1

Please sign in to comment.