c_types: handle errors from getgroups()/getgrouplist()

The most likely reason for  #236 is that either the getgroups() or getgrouplist() call fails, setting ngroups to -1.
ngroups is then used to size the `groups` Vec via `set_len(ngroups as uint)` which is obviously wrong in that case.

Also remove alot of the i32/u32/... coercions by using libc::{uid_t,gid_t} where appropriate.