Redmine #5721: Fix getgrnam()/getgrgid() failure in NIS/NSS setup.

Following up on fix 3e8b6898fd141919, also for getgrnam/getgrgid.

Also add declaration for AIX5, which has the function, but lacks the
declaration.