+ encrypted = pw_encrypt(plaintext, /*salt:*/ pw_pass, 1);
+ r = (strcmp(encrypted, pw_pass) == 0);
+ free(encrypted);
+ return r;
+}
+
+
+/* Ask the user for a password.
+ * Return 1 without asking if PW has an empty password.
+ * Return -1 on EOF, error while reading input, or timeout.
+ * Return 1 if the user gives the correct password for entry PW,
+ * 0 if not.
+ *
+ * NULL pw means "just fake it for login with bad username"
+ */
+int FAST_FUNC ask_and_check_password_extended(const struct passwd *pw,
+ int timeout, const char *prompt)
+{
+ IF_FEATURE_SHADOWPASSWDS(char buffer[SHADOW_BUFSIZE];)
+ char *plaintext;
+ const char *pw_pass;
+ int r;
+
+ pw_pass = get_passwd(pw, buffer);
+ if (!pw_pass[0]) /* empty password field? */
+ return 1;
+
+ plaintext = bb_ask(STDIN_FILENO, timeout, prompt);
+ if (!plaintext) {
+ /* EOF (such as ^D) or error (such as ^C) or timeout */
+ return -1;