56c56
< int r;
---
> int r, style;
61,67c61,67
< r = pam_get_item(pamh, PAM_AUTHTOK, (const void **)authtok);
< if (r == PAM_SUCCESS && *authtok != NULL)
< return (PAM_SUCCESS);
< if (prompt == NULL) {
< if (pam_get_item(pamh, PAM_AUTHTOK_PROMPT,
< (const void **)&p) != PAM_SUCCESS || p == NULL)
< prompt = "Password:";
---
> if (openpam_get_option(pamh, "try_first_pass") ||
> openpam_get_option(pamh, "use_first_pass")) {
> r = pam_get_item(pamh, PAM_AUTHTOK, (const void **)authtok);
> if (r == PAM_SUCCESS && *authtok != NULL)
> return (PAM_SUCCESS);
> else if (openpam_get_option(pamh, "use_first_pass"))
> return (r == PAM_SUCCESS ? PAM_AUTH_ERR : r);
69,70c69,75
< r = pam_prompt(pamh, PAM_PROMPT_ECHO_OFF, &resp,
< "%s", prompt ? prompt : p);
---
> if (pam_get_item(pamh, PAM_AUTHTOK_PROMPT,
> (const void **)&p) != PAM_SUCCESS || p == NULL)
> if (prompt == NULL)
> prompt = "Password:";
> style = openpam_get_option(pamh, "echo_pass") ?
> PAM_PROMPT_ECHO_ON : PAM_PROMPT_ECHO_OFF;
> r = pam_prompt(pamh, style, &resp, "%s", p ? p : prompt);
75a81,89
>
> /*
> * Error codes:
> *
> * =pam_get_item
> * =pam_prompt
> * =pam_set_item
> * !PAM_SYMBOL_ERR
> */
< int r;
---
> int r, style;
61,67c61,67
< r = pam_get_item(pamh, PAM_AUTHTOK, (const void **)authtok);
< if (r == PAM_SUCCESS && *authtok != NULL)
< return (PAM_SUCCESS);
< if (prompt == NULL) {
< if (pam_get_item(pamh, PAM_AUTHTOK_PROMPT,
< (const void **)&p) != PAM_SUCCESS || p == NULL)
< prompt = "Password:";
---
> if (openpam_get_option(pamh, "try_first_pass") ||
> openpam_get_option(pamh, "use_first_pass")) {
> r = pam_get_item(pamh, PAM_AUTHTOK, (const void **)authtok);
> if (r == PAM_SUCCESS && *authtok != NULL)
> return (PAM_SUCCESS);
> else if (openpam_get_option(pamh, "use_first_pass"))
> return (r == PAM_SUCCESS ? PAM_AUTH_ERR : r);
69,70c69,75
< r = pam_prompt(pamh, PAM_PROMPT_ECHO_OFF, &resp,
< "%s", prompt ? prompt : p);
---
> if (pam_get_item(pamh, PAM_AUTHTOK_PROMPT,
> (const void **)&p) != PAM_SUCCESS || p == NULL)
> if (prompt == NULL)
> prompt = "Password:";
> style = openpam_get_option(pamh, "echo_pass") ?
> PAM_PROMPT_ECHO_ON : PAM_PROMPT_ECHO_OFF;
> r = pam_prompt(pamh, style, &resp, "%s", p ? p : prompt);
75a81,89
>
> /*
> * Error codes:
> *
> * =pam_get_item
> * =pam_prompt
> * =pam_set_item
> * !PAM_SYMBOL_ERR
> */