/*[XSI]*/
/* Test whether a basic getpwent invocation works. */

#include <errno.h>
#include <pwd.h>
#include <stdbool.h>
#include <unistd.h>

#include "../basic.h"

int main(void)
{
	uid_t uid = getuid();
	struct passwd* pwd;
	bool found = false;
	// getpwent is supposed to setpwent if needed.
	while ( (errno = 0, pwd = getpwent()) )
	{
		if ( pwd->pw_uid == uid )
			found = true;
	}
	if ( errno )
		err(1, "getpwent");
	if ( !found )
		errx(1, "did not find user");
	return 0;
}
