Shared development hardware often has storage partitioned up by project
groups, with the root of the shared storage owned by root:project.
Since this group isn't the primary group of the user
using setgroups and restoring groups to just the user's primary gid
will mean that it does not have this project group gid
and so won't be able to see the contents of this shared directory.
Using getgrouplist to get all of the groups from the user database
allows these additional groups to be set.