Handle ERANGE from getpwnam_r / getgrnam_r

These functions return ERANGE if the supplied buffer is too small to
fit a line.  Try doubling the buffer a few times until it works.