*** pam_bsdbioapi.c.BUSERR	2008-01-28 18:00:06.000000000 +0900
--- pam_bsdbioapi.c	2008-01-28 18:47:50.000000000 +0900
***************
*** 224,229 ****
--- 224,230 ----
  	birdb *bdb;
  	void *bmh;
  	int opt;
+ 	int maxtry = 1;
  
  	if (argc < 1) {
  		PAM_VERBOSE_ERROR("BiAPI BSP UUID missing");
***************
*** 244,250 ****
  	skip_unenrolled = 0;
  
  	optind = 2;
! 	while ((opt = getopt(argc, (char **)argv, "m:f:s")) != -1) {
  		switch (opt) {
  		case 'm':
  			msgfile = argv[optind - 1];
--- 245,251 ----
  	skip_unenrolled = 0;
  
  	optind = 2;
! 	while ((opt = getopt(argc, (char **)argv, "m:f:si:")) != -1) {
  		switch (opt) {
  		case 'm':
  			msgfile = argv[optind - 1];
***************
*** 257,262 ****
--- 258,267 ----
  		case 's':
  			skip_unenrolled = 1;
  			break;
+ 		case 'i':
+ 			maxtry = atoi(argv[optind - 1]);
+ 			PAM_LOG("Max try count set to %d", maxtry);
+ 			break;
  		}
  	}
  
***************
*** 316,322 ****
--- 321,329 ----
  	keyrec.br_key = (char *)user;
  	recs = birdb_backend_get(bm, bmh, &keyrec);
  	if (recs != NULL && (!skip_unenrolled || recs[0] != NULL)) {
+ 		int	i;
  		pam_info(pamh, "Initiating biometric authentication..."); 
+ 		for(i=0; i<maxtry; i++){
  		handle = bioapi_attach_bsp(bsp_id);
  		if (handle == NULL) {
  			PAM_VERBOSE_ERROR("Failed to attach the selected BSP");
***************
*** 327,337 ****
  			    bioapi_guicallback, &ch);
  		error = bioapi_verify_many(handle, recs);
  		PAM_LOG("Got biometric authentication");
! 		if (error >= 0)
  			pam_retval = PAM_SUCCESS;
  		else
  			PAM_VERBOSE_ERROR("Biometric authentication refused");
  		bioapi_detach_bsp(handle, bsp_id);
  	}
  	else {
  		PAM_VERBOSE_ERROR("No biometric data avaiable");
--- 334,347 ----
  			    bioapi_guicallback, &ch);
  		error = bioapi_verify_many(handle, recs);
  		PAM_LOG("Got biometric authentication");
! 		if (error >= 0) {
  			pam_retval = PAM_SUCCESS;
+ 			break;
+ 		}
  		else
  			PAM_VERBOSE_ERROR("Biometric authentication refused");
  		bioapi_detach_bsp(handle, bsp_id);
+ 		}
  	}
  	else {
  		PAM_VERBOSE_ERROR("No biometric data avaiable");