Пример #1
0
static int
passwd_test_getpwnam(struct passwd *pwd_model, void *mdata)
{
	struct passwd *pwd;

#ifdef DEBUG
	printf("testing getpwnam() with the following data:\n");
	dump_passwd(pwd_model);
#endif

	pwd = getpwnam(pwd_model->pw_name);
	if (passwd_test_correctness(pwd, NULL) != 0)
		goto errfin;

	if ((compare_passwd(pwd, pwd_model, NULL) != 0) &&
	    (passwd_check_ambiguity((struct passwd_test_data *)mdata, pwd)
	    !=0))
	    goto errfin;

#ifdef DEBUG
	printf("ok\n");
#endif
	return (0);

errfin:
#ifdef DEBUG
	printf("not ok\n");
#endif
	return (-1);
}
Пример #2
0
static int
passwd_test_getpwuid(struct passwd *pwd_model, void *mdata)
{
	struct passwd *pwd;

#ifdef DEBUG
	printf("testing getpwuid() with the following data...\n");
	dump_passwd(pwd_model);
#endif

	pwd = getpwuid(pwd_model->pw_uid);
	if ((passwd_test_correctness(pwd, NULL) != 0) ||
	    ((compare_passwd(pwd, pwd_model, NULL) != 0) &&
	    (passwd_check_ambiguity((struct passwd_test_data *)mdata, pwd)
	    != 0))) {
#ifdef DEBUG
		printf("not ok\n");
#endif
		return (-1);
	} else {
#ifdef DEBUG
		printf("ok\n");
#endif
		return (0);
	}
}
Пример #3
0
int main (int argc, char **argv)
{
	char *pass;

	if (argc !=2)
		err_quit ("Usage: passwd_comp username");

	pass = getpassphrase ("Password: "******"Password = \"%s\"\n", pass);

	if (compare_passwd (argv [1], pass))
		printf ("Passwords match\n");
	else
		printf ("Passwords don't match\n");

	return (0);
}