While gid values > INT_MAX are unlikely, we should convert as an unsigned integer with correct range checking, coping with gid_t being unsigned or signed and of any bit length, rather than mapping as a C "int". We also need to allow this to be unspecified, and have a safe default value. uid_t and gid_t are used in a few different functions here, all need to be checked. See the PIDL python range handling for an example of trying to get this right in pidl/lib/Parse/Pidl/Samba4/Python.pm