Fix setting the right uid

Before it only worked when setting it to root's, otherwise it'd get
the one of the user running xrootd.
Set also the gid to the user's
Apply also the gid of the user

This implied changing the cache and the function to get the gid.