48968f9
--- Linux-PAM-0.99.3.0/modules/pam_cracklib/pam_cracklib.c.try-first-pass	2006-01-08 10:49:05.000000000 +0100
48968f9
+++ Linux-PAM-0.99.3.0/modules/pam_cracklib/pam_cracklib.c	2006-02-24 10:42:53.000000000 +0100
48968f9
@@ -93,6 +93,7 @@
48968f9
 	int low_credit;
48968f9
 	int oth_credit;
48968f9
 	int use_authtok;
48968f9
+	int try_first_pass;
48968f9
 	char prompt_type[BUFSIZ];
48968f9
         char cracklib_dictpath[PATH_MAX];
48968f9
 };
48968f9
@@ -158,6 +159,10 @@
48968f9
 		 opt->oth_credit = 0;
48968f9
 	 } else if (!strncmp(*argv,"use_authtok",11)) {
48968f9
 		 opt->use_authtok = 1;
48968f9
+	 } else if (!strncmp(*argv,"use_first_pass",14)) {
48968f9
+		 opt->use_authtok = 1;
48968f9
+	 } else if (!strncmp(*argv,"try_first_pass",14)) {
48968f9
+		 opt->try_first_pass = 1;
48968f9
 	 } else if (!strncmp(*argv,"dictpath=",9)) {
48968f9
 	     strncpy(opt->cracklib_dictpath, *argv+9,
48968f9
 		     sizeof(opt->cracklib_dictpath) - 1);
48968f9
@@ -559,7 +564,7 @@
48968f9
          * set PAM_AUTHTOK and return
48968f9
          */
48968f9
 
48968f9
-	if (options.use_authtok == 1) {
48968f9
+	if (options.use_authtok == 1 || options.try_first_pass == 1) {
48968f9
 	    const void *item = NULL;
48968f9
 
48968f9
 	    retval = pam_get_item(pamh, PAM_AUTHTOK, &item);
48968f9
@@ -570,11 +575,13 @@
48968f9
 	    } else if (item != NULL) {      /* we have a password! */
48968f9
 		token1 = x_strdup(item);
48968f9
 		item = NULL;
48968f9
+		options.use_authtok = 1;    /* don't ask for the password again */
48968f9
 	    } else {
48968f9
 		retval = PAM_AUTHTOK_RECOVERY_ERR;         /* didn't work */
48968f9
 	    }
48968f9
-
48968f9
-	} else {
48968f9
+	}
48968f9
+	
48968f9
+	if (options.use_authtok != 1) {
48968f9
             /* Prepare to ask the user for the first time */
48968f9
             resp = NULL;
48968f9
 	    retval = pam_prompt (pamh, PAM_PROMPT_ECHO_OFF, &resp,