1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-06-30 19:12:48 -05:00

Richer data type for interactive prompt results.

All the seat functions that request an interactive prompt of some kind
to the user - both the main seat_get_userpass_input and the various
confirmation dialogs for things like host keys - were using a simple
int return value, with the general semantics of 0 = "fail", 1 =
"proceed" (and in the case of seat_get_userpass_input, answers to the
prompts were provided), and -1 = "request in progress, wait for a
callback".

In this commit I change all those functions' return types to a new
struct called SeatPromptResult, whose primary field is an enum
replacing those simple integer values.

The main purpose is that the enum has not three but _four_ values: the
"fail" result has been split into 'user abort' and 'software abort'.
The distinction is that a user abort occurs as a result of an
interactive UI action, such as the user clicking 'cancel' in a dialog
box or hitting ^D or ^C at a terminal password prompt - and therefore,
there's no need to display an error message telling the user that the
interactive operation has failed, because the user already knows,
because they _did_ it. 'Software abort' is from any other cause, where
PuTTY is the first to know there was a problem, and has to tell the
user.

We already had this 'user abort' vs 'software abort' distinction in
other parts of the code - the SSH backend has separate termination
functions which protocol layers can call. But we assumed that any
failure from an interactive prompt request fell into the 'user abort'
category, which is not true. A couple of examples: if you configure a
host key fingerprint in your saved session via the SSH > Host keys
pane, and the server presents a host key that doesn't match it, then
verify_ssh_host_key would report that the user had aborted the
connection, and feel no need to tell the user what had gone wrong!
Similarly, if a password provided on the command line was not
accepted, then (after I fixed the semantics of that in the previous
commit) the same wrong handling would occur.

So now, those Seat prompt functions too can communicate whether the
user or the software originated a connection abort. And in the latter
case, we also provide an error message to present to the user. Result:
in those two example cases (and others), error messages should no
longer go missing.

Implementation note: to avoid the hassle of having the error message
in a SeatPromptResult being a dynamically allocated string (and hence,
every recipient of one must always check whether it's non-NULL and
free it on every exit path, plus being careful about copying the
struct around), I've instead arranged that the structure contains a
function pointer and a couple of parameters, so that the string form
of the message can be constructed on demand. That way, the only users
who need to free it are the ones who actually _asked_ for it in the
first place, which is a much smaller set.

(This is one of the rare occasions that I regret not having C++'s
extra features available in this code base - a unique_ptr or
shared_ptr to a string would have been just the thing here, and the
compiler would have done all the hard work for me of remembering where
to insert the frees!)
This commit is contained in:
Simon Tatham
2021-12-28 17:52:00 +00:00
parent a82ab70b0b
commit a2ff884512
51 changed files with 648 additions and 372 deletions

View File

@ -845,15 +845,13 @@ bool ssh2_bpp_check_unimplemented(BinaryPacketProtocol *bpp, PktIn *pktin)
* host key is already known. If so, it returns success on its own
* account; otherwise, it calls out to the Seat to give an interactive
* prompt (the nature of which varies depending on the Seat itself).
*
* Return values are 0 for 'abort connection', 1 for 'ok, carry on',
* and negative for 'answer not received yet, wait for a callback'.
*/
int verify_ssh_host_key(
SeatPromptResult verify_ssh_host_key(
InteractionReadySeat iseat, Conf *conf, const char *host, int port,
ssh_key *key, const char *keytype, char *keystr, const char *keydisp,
char **fingerprints, void (*callback)(void *ctx, int result), void *ctx)
char **fingerprints, void (*callback)(void *ctx, SeatPromptResult result),
void *ctx)
{
/*
* First, check if the Conf includes a manual specification of the
@ -878,7 +876,7 @@ int verify_ssh_host_key(
fingerprint = p ? p+1 : fingerprint;
if (conf_get_str_str_opt(conf, CONF_ssh_manual_hostkeys,
fingerprint))
return 1; /* success */
return SPR_OK;
}
}
@ -902,12 +900,12 @@ int verify_ssh_host_key(
if (conf_get_str_str_opt(conf, CONF_ssh_manual_hostkeys,
base64blob)) {
sfree(base64blob);
return 1; /* success */
return SPR_OK;
}
sfree(base64blob);
}
return 0;
return SPR_SW_ABORT("Host key not in manually configured list");
}
/*
@ -915,7 +913,7 @@ int verify_ssh_host_key(
*/
int storage_status = check_stored_host_key(host, port, keytype, keystr);
if (storage_status == 0) /* matching key was found in the cache */
return 1; /* success */
return SPR_OK;
/*
* The key is either missing from the cache, or does not match.
@ -994,3 +992,22 @@ void ssh1_compute_session_id(
put_data(hash, cookie, 8);
ssh_hash_final(hash, session_id);
}
/* ----------------------------------------------------------------------
* Wrapper function to handle the abort-connection modes of a
* SeatPromptResult without a lot of verbiage at every call site.
*
* Can become ssh_sw_abort or ssh_user_close, depending on the kind of
* negative SeatPromptResult.
*/
void ssh_spr_close(Ssh *ssh, SeatPromptResult spr, const char *context)
{
if (spr.kind == SPRK_USER_ABORT) {
ssh_user_close(ssh, "User aborted at %s", context);
} else {
assert(spr.kind == SPRK_SW_ABORT);
char *err = spr_get_error_message(spr);
ssh_sw_abort(ssh, "%s", err);
sfree(err);
}
}

View File

@ -381,7 +381,7 @@ static void ssh1_connection_process_queue(PacketProtocolLayer *ppl)
dupstr("Access granted. Press Return to begin session. "), false);
s->antispoof_ret = seat_get_userpass_input(
ppl_get_iseat(&s->ppl), s->antispoof_prompt);
while (s->antispoof_ret < 0) {
while (s->antispoof_ret.kind == SPRK_INCOMPLETE) {
crReturnV;
s->antispoof_ret = seat_get_userpass_input(
ppl_get_iseat(&s->ppl), s->antispoof_prompt);

View File

@ -50,7 +50,7 @@ struct ssh1_connection_state {
bool sent_exit_status; /* also for server mode */
prompts_t *antispoof_prompt;
int antispoof_ret;
SeatPromptResult antispoof_ret;
const SshServerConfig *ssc;

View File

@ -994,7 +994,7 @@ static void ssh2_connection_process_queue(PacketProtocolLayer *ppl)
dupstr("Access granted. Press Return to begin session. "), false);
s->antispoof_ret = seat_get_userpass_input(
ppl_get_iseat(&s->ppl), s->antispoof_prompt);
while (s->antispoof_ret < 0) {
while (s->antispoof_ret.kind == SPRK_INCOMPLETE) {
crReturnV;
s->antispoof_ret = seat_get_userpass_input(
ppl_get_iseat(&s->ppl), s->antispoof_prompt);

View File

@ -37,7 +37,7 @@ struct ssh2_connection_state {
bool portfwdmgr_configured;
prompts_t *antispoof_prompt;
int antispoof_ret;
SeatPromptResult antispoof_ret;
const SftpServerVtable *sftpserver_vt;
const SshServerConfig *ssc;

View File

@ -853,7 +853,7 @@ void ssh2kex_coroutine(struct ssh2_transport_state *s, bool *aborted)
ppl_logevent("Host key fingerprint is:");
ppl_logevent("%s", fingerprints[fptype_default]);
s->dlgret = verify_ssh_host_key(
s->spr = verify_ssh_host_key(
ppl_get_iseat(&s->ppl), s->conf, s->savedhost, s->savedport,
s->hkey, ssh_key_cache_id(s->hkey), s->keystr, keydisp,
fingerprints, ssh2_transport_dialog_callback, s);
@ -862,13 +862,12 @@ void ssh2kex_coroutine(struct ssh2_transport_state *s, bool *aborted)
sfree(keydisp);
}
#ifdef FUZZING
s->dlgret = 1;
s->spr = SPR_OK;
#endif
crMaybeWaitUntilV(s->dlgret >= 0);
if (s->dlgret == 0) {
ssh_user_close(s->ppl.ssh,
"User aborted at host key verification");
crMaybeWaitUntilV(s->spr.kind != SPRK_INCOMPLETE);
if (spr_is_abort(s->spr)) {
*aborted = true;
ssh_spr_close(s->ppl.ssh, s->spr, "host key verification");
return;
}

View File

@ -47,7 +47,7 @@ struct ssh1_login_state {
char *publickey_comment;
bool privatekey_available, privatekey_encrypted;
prompts_t *cur_prompt;
int userpass_ret;
SeatPromptResult spr;
char c;
int pwpkt_type;
void *agent_response_to_free;
@ -58,7 +58,6 @@ struct ssh1_login_state {
size_t agent_key_index, agent_key_limit;
bool authed;
RSAKey key;
int dlgret;
Filename *keyfile;
RSAKey servkey, hostkey;
@ -70,7 +69,7 @@ struct ssh1_login_state {
static void ssh1_login_free(PacketProtocolLayer *);
static void ssh1_login_process_queue(PacketProtocolLayer *);
static void ssh1_login_dialog_callback(void *, int);
static void ssh1_login_dialog_callback(void *, SeatPromptResult);
static void ssh1_login_special_cmd(PacketProtocolLayer *ppl,
SessionSpecialCode code, int arg);
static void ssh1_login_reconfigure(PacketProtocolLayer *ppl, Conf *conf);
@ -242,7 +241,7 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
char *keydisp = ssh1_pubkey_str(&s->hostkey);
char **fingerprints = rsa_ssh1_fake_all_fingerprints(&s->hostkey);
s->dlgret = verify_ssh_host_key(
s->spr = verify_ssh_host_key(
ppl_get_iseat(&s->ppl), s->conf, s->savedhost, s->savedport, NULL,
"rsa", keystr, keydisp, fingerprints,
ssh1_login_dialog_callback, s);
@ -253,13 +252,12 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
}
#ifdef FUZZING
s->dlgret = 1;
s->spr = SPR_OK;
#endif
crMaybeWaitUntilV(s->dlgret >= 0);
crMaybeWaitUntilV(s->spr.kind != SPRK_INCOMPLETE);
if (s->dlgret == 0) {
ssh_user_close(s->ppl.ssh,
"User aborted at host key verification");
if (spr_is_abort(s->spr)) {
ssh_spr_close(s->ppl.ssh, s->spr, "host key verification");
return;
}
@ -324,12 +322,12 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
/* Warn about chosen cipher if necessary. */
if (warn) {
s->dlgret = seat_confirm_weak_crypto_primitive(
s->spr = seat_confirm_weak_crypto_primitive(
ppl_get_iseat(&s->ppl), "cipher", cipher_string,
ssh1_login_dialog_callback, s);
crMaybeWaitUntilV(s->dlgret >= 0);
if (s->dlgret == 0) {
ssh_user_close(s->ppl.ssh, "User aborted at cipher warning");
crMaybeWaitUntilV(s->spr.kind != SPRK_INCOMPLETE);
if (spr_is_abort(s->spr)) {
ssh_spr_close(s->ppl.ssh, s->spr, "cipher warning");
return;
}
}
@ -391,18 +389,18 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
s->cur_prompt->from_server = false;
s->cur_prompt->name = dupstr("SSH login name");
add_prompt(s->cur_prompt, dupstr("login as: "), true);
s->userpass_ret = seat_get_userpass_input(
s->spr = seat_get_userpass_input(
ppl_get_iseat(&s->ppl), s->cur_prompt);
while (s->userpass_ret < 0) {
while (s->spr.kind == SPRK_INCOMPLETE) {
crReturnV;
s->userpass_ret = seat_get_userpass_input(
s->spr = seat_get_userpass_input(
ppl_get_iseat(&s->ppl), s->cur_prompt);
}
if (!s->userpass_ret) {
if (spr_is_abort(s->spr)) {
/*
* Failed to get a username. Terminate.
*/
ssh_user_close(s->ppl.ssh, "No username provided");
ssh_spr_close(s->ppl.ssh, s->spr, "username prompt");
return;
}
s->username = prompt_get_result(s->cur_prompt->prompts[0]);
@ -688,17 +686,16 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
add_prompt(s->cur_prompt,
dupprintf("Passphrase for key \"%s\": ",
s->publickey_comment), false);
s->userpass_ret = seat_get_userpass_input(
s->spr = seat_get_userpass_input(
ppl_get_iseat(&s->ppl), s->cur_prompt);
while (s->userpass_ret < 0) {
while (s->spr.kind == SPRK_INCOMPLETE) {
crReturnV;
s->userpass_ret = seat_get_userpass_input(
s->spr = seat_get_userpass_input(
ppl_get_iseat(&s->ppl), s->cur_prompt);
}
if (!s->userpass_ret) {
if (spr_is_abort(s->spr)) {
/* Failed to get a passphrase. Terminate. */
ssh_user_close(s->ppl.ssh,
"User aborted at passphrase prompt");
ssh_spr_close(s->ppl.ssh, s->spr, "passphrase prompt");
return;
}
passphrase = prompt_get_result(s->cur_prompt->prompts[0]);
@ -943,20 +940,20 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
* or CryptoCard exchange if we're doing TIS or CryptoCard
* authentication.
*/
s->userpass_ret = seat_get_userpass_input(
s->spr = seat_get_userpass_input(
ppl_get_iseat(&s->ppl), s->cur_prompt);
while (s->userpass_ret < 0) {
while (s->spr.kind == SPRK_INCOMPLETE) {
crReturnV;
s->userpass_ret = seat_get_userpass_input(
s->spr = seat_get_userpass_input(
ppl_get_iseat(&s->ppl), s->cur_prompt);
}
if (!s->userpass_ret) {
if (spr_is_abort(s->spr)) {
/*
* Failed to get a password (for example
* because one was supplied on the command line
* which has already failed to work). Terminate.
*/
ssh_user_close(s->ppl.ssh, "User aborted at password prompt");
ssh_spr_close(s->ppl.ssh, s->spr, "password prompt");
return;
}
@ -1141,10 +1138,10 @@ static void ssh1_login_setup_tis_scc(struct ssh1_login_state *s)
s->tis_scc_initialised = true;
}
static void ssh1_login_dialog_callback(void *loginv, int ret)
static void ssh1_login_dialog_callback(void *loginv, SeatPromptResult spr)
{
struct ssh1_login_state *s = (struct ssh1_login_state *)loginv;
s->dlgret = ret;
s->spr = spr;
ssh_ppl_process_queue(&s->ppl);
}

View File

@ -97,12 +97,14 @@ void mainchan_terminal_size(mainchan *mc, int width, int height) {}
/* Seat functions to ensure we don't get choosy about crypto - as the
* server, it's not up to us to give user warnings */
static int server_confirm_weak_crypto_primitive(
static SeatPromptResult server_confirm_weak_crypto_primitive(
Seat *seat, const char *algtype, const char *algname,
void (*callback)(void *ctx, int result), void *ctx) { return 1; }
static int server_confirm_weak_cached_hostkey(
void (*callback)(void *ctx, SeatPromptResult result), void *ctx)
{ return SPR_OK; }
static SeatPromptResult server_confirm_weak_cached_hostkey(
Seat *seat, const char *algname, const char *betteralgs,
void (*callback)(void *ctx, int result), void *ctx) { return 1; }
void (*callback)(void *ctx, SeatPromptResult result), void *ctx)
{ return SPR_OK; }
static const SeatVtable server_seat_vt = {
.output = nullseat_output,

View File

@ -97,7 +97,7 @@ static void ssh2_transport_gss_update(struct ssh2_transport_state *s,
static bool ssh2_transport_timer_update(struct ssh2_transport_state *s,
unsigned long rekey_time);
static int ssh2_transport_confirm_weak_crypto_primitive(
static SeatPromptResult ssh2_transport_confirm_weak_crypto_primitive(
struct ssh2_transport_state *s, const char *type, const char *name,
const void *alg);
@ -1265,11 +1265,11 @@ static void ssh2_transport_process_queue(PacketProtocolLayer *ppl)
}
if (s->warn_kex) {
s->dlgret = ssh2_transport_confirm_weak_crypto_primitive(
s->spr = ssh2_transport_confirm_weak_crypto_primitive(
s, "key-exchange algorithm", s->kex_alg->name, s->kex_alg);
crMaybeWaitUntilV(s->dlgret >= 0);
if (s->dlgret == 0) {
ssh_user_close(s->ppl.ssh, "User aborted at kex warning");
crMaybeWaitUntilV(s->spr.kind != SPRK_INCOMPLETE);
if (spr_is_abort(s->spr)) {
ssh_spr_close(s->ppl.ssh, s->spr, "kex warning");
return;
}
}
@ -1312,42 +1312,42 @@ static void ssh2_transport_process_queue(PacketProtocolLayer *ppl)
if (betteralgs) {
/* Use the special warning prompt that lets us provide
* a list of better algorithms */
s->dlgret = seat_confirm_weak_cached_hostkey(
s->spr = seat_confirm_weak_cached_hostkey(
ppl_get_iseat(&s->ppl), s->hostkey_alg->ssh_id, betteralgs,
ssh2_transport_dialog_callback, s);
sfree(betteralgs);
} else {
/* If none exist, use the more general 'weak crypto'
* warning prompt */
s->dlgret = ssh2_transport_confirm_weak_crypto_primitive(
s->spr = ssh2_transport_confirm_weak_crypto_primitive(
s, "host key type", s->hostkey_alg->ssh_id,
s->hostkey_alg);
}
crMaybeWaitUntilV(s->dlgret >= 0);
if (s->dlgret == 0) {
ssh_user_close(s->ppl.ssh, "User aborted at host key warning");
crMaybeWaitUntilV(s->spr.kind != SPRK_INCOMPLETE);
if (spr_is_abort(s->spr)) {
ssh_spr_close(s->ppl.ssh, s->spr, "host key warning");
return;
}
}
if (s->warn_cscipher) {
s->dlgret = ssh2_transport_confirm_weak_crypto_primitive(
s->spr = ssh2_transport_confirm_weak_crypto_primitive(
s, "client-to-server cipher", s->out.cipher->ssh2_id,
s->out.cipher);
crMaybeWaitUntilV(s->dlgret >= 0);
if (s->dlgret == 0) {
ssh_user_close(s->ppl.ssh, "User aborted at cipher warning");
crMaybeWaitUntilV(s->spr.kind != SPRK_INCOMPLETE);
if (spr_is_abort(s->spr)) {
ssh_spr_close(s->ppl.ssh, s->spr, "cipher warning");
return;
}
}
if (s->warn_sccipher) {
s->dlgret = ssh2_transport_confirm_weak_crypto_primitive(
s->spr = ssh2_transport_confirm_weak_crypto_primitive(
s, "server-to-client cipher", s->in.cipher->ssh2_id,
s->in.cipher);
crMaybeWaitUntilV(s->dlgret >= 0);
if (s->dlgret == 0) {
ssh_user_close(s->ppl.ssh, "User aborted at cipher warning");
crMaybeWaitUntilV(s->spr.kind != SPRK_INCOMPLETE);
if (spr_is_abort(s->spr)) {
ssh_spr_close(s->ppl.ssh, s->spr, "cipher warning");
return;
}
}
@ -1815,10 +1815,10 @@ static bool ssh2_transport_timer_update(struct ssh2_transport_state *s,
return false;
}
void ssh2_transport_dialog_callback(void *vctx, int ret)
void ssh2_transport_dialog_callback(void *vctx, SeatPromptResult spr)
{
struct ssh2_transport_state *s = (struct ssh2_transport_state *)vctx;
s->dlgret = ret;
s->spr = spr;
ssh_ppl_process_queue(&s->ppl);
}
@ -2139,12 +2139,12 @@ static int weak_algorithm_compare(void *av, void *bv)
* tree234 s->weak_algorithms_consented_to to ensure we ask at most
* once about any given crypto primitive.
*/
static int ssh2_transport_confirm_weak_crypto_primitive(
static SeatPromptResult ssh2_transport_confirm_weak_crypto_primitive(
struct ssh2_transport_state *s, const char *type, const char *name,
const void *alg)
{
if (find234(s->weak_algorithms_consented_to, (void *)alg, NULL))
return 1;
return SPR_OK;
add234(s->weak_algorithms_consented_to, (void *)alg);
return seat_confirm_weak_crypto_primitive(

View File

@ -186,7 +186,7 @@ struct ssh2_transport_state {
bool warned_about_no_gss_transient_hostkey;
bool got_session_id;
bool can_send_ext_info, post_newkeys_ext_info;
int dlgret;
SeatPromptResult spr;
bool guessok;
bool ignorepkt;
struct kexinit_algorithm kexlists[NKEXLIST][MAXKEXLIST];
@ -231,7 +231,7 @@ struct ssh2_transport_state {
/* Helpers shared between transport and kex */
PktIn *ssh2_transport_pop(struct ssh2_transport_state *s);
void ssh2_transport_dialog_callback(void *, int);
void ssh2_transport_dialog_callback(void *, SeatPromptResult);
/* Provided by transport for use in kex */
void ssh2transport_finalise_exhash(struct ssh2_transport_state *s);

View File

@ -45,7 +45,7 @@ struct ssh2_userauth_state {
AUTH_TYPE_KEYBOARD_INTERACTIVE_QUIET
} type;
bool need_pw, can_pubkey, can_passwd, can_keyb_inter;
int userpass_ret;
SeatPromptResult spr;
bool tried_pubkey_config, done_agent;
struct ssh_connection_shared_gss_state *shgss;
#ifndef NO_GSSAPI
@ -442,21 +442,21 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
s->cur_prompt->from_server = false;
s->cur_prompt->name = dupstr("SSH login name");
add_prompt(s->cur_prompt, dupstr("login as: "), true);
s->userpass_ret = seat_get_userpass_input(
s->spr = seat_get_userpass_input(
ppl_get_iseat(&s->ppl), s->cur_prompt);
while (s->userpass_ret < 0) {
while (s->spr.kind == SPRK_INCOMPLETE) {
crReturnV;
s->userpass_ret = seat_get_userpass_input(
s->spr = seat_get_userpass_input(
ppl_get_iseat(&s->ppl), s->cur_prompt);
}
if (!s->userpass_ret) {
if (spr_is_abort(s->spr)) {
/*
* seat_get_userpass_input() failed to get a username.
* Terminate.
*/
free_prompts(s->cur_prompt);
s->cur_prompt = NULL;
ssh_user_close(s->ppl.ssh, "No username provided");
ssh_spr_close(s->ppl.ssh, s->spr, "username prompt");
return;
}
sfree(s->locally_allocated_username); /* for change_username */
@ -912,22 +912,22 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
dupprintf("Passphrase for key \"%s\": ",
s->publickey_comment),
false);
s->userpass_ret = seat_get_userpass_input(
s->spr = seat_get_userpass_input(
ppl_get_iseat(&s->ppl), s->cur_prompt);
while (s->userpass_ret < 0) {
while (s->spr.kind == SPRK_INCOMPLETE) {
crReturnV;
s->userpass_ret = seat_get_userpass_input(
s->spr = seat_get_userpass_input(
ppl_get_iseat(&s->ppl), s->cur_prompt);
}
if (!s->userpass_ret) {
if (spr_is_abort(s->spr)) {
/* Failed to get a passphrase. Terminate. */
free_prompts(s->cur_prompt);
s->cur_prompt = NULL;
ssh_bpp_queue_disconnect(
s->ppl.bpp, "Unable to authenticate",
SSH2_DISCONNECT_AUTH_CANCELLED_BY_USER);
ssh_user_close(s->ppl.ssh, "User aborted at "
"passphrase prompt");
ssh_spr_close(s->ppl.ssh, s->spr,
"passphrase prompt");
return;
}
passphrase =
@ -1391,14 +1391,14 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
* Our prompts_t is fully constructed now. Get the
* user's response(s).
*/
s->userpass_ret = seat_get_userpass_input(
s->spr = seat_get_userpass_input(
ppl_get_iseat(&s->ppl), s->cur_prompt);
while (s->userpass_ret < 0) {
while (s->spr.kind == SPRK_INCOMPLETE) {
crReturnV;
s->userpass_ret = seat_get_userpass_input(
s->spr = seat_get_userpass_input(
ppl_get_iseat(&s->ppl), s->cur_prompt);
}
if (!s->userpass_ret) {
if (spr_is_abort(s->spr)) {
/*
* Failed to get responses. Terminate.
*/
@ -1407,8 +1407,8 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
ssh_bpp_queue_disconnect(
s->ppl.bpp, "Unable to authenticate",
SSH2_DISCONNECT_AUTH_CANCELLED_BY_USER);
ssh_user_close(s->ppl.ssh, "User aborted during "
"keyboard-interactive authentication");
ssh_spr_close(s->ppl.ssh, s->spr, "keyboard-"
"interactive authentication prompt");
return;
}
@ -1473,14 +1473,14 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
s->username, s->hostname),
false);
s->userpass_ret = seat_get_userpass_input(
s->spr = seat_get_userpass_input(
ppl_get_iseat(&s->ppl), s->cur_prompt);
while (s->userpass_ret < 0) {
while (s->spr.kind == SPRK_INCOMPLETE) {
crReturnV;
s->userpass_ret = seat_get_userpass_input(
s->spr = seat_get_userpass_input(
ppl_get_iseat(&s->ppl), s->cur_prompt);
}
if (!s->userpass_ret) {
if (spr_is_abort(s->spr)) {
/*
* Failed to get responses. Terminate.
*/
@ -1489,8 +1489,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
ssh_bpp_queue_disconnect(
s->ppl.bpp, "Unable to authenticate",
SSH2_DISCONNECT_AUTH_CANCELLED_BY_USER);
ssh_user_close(s->ppl.ssh, "User aborted during password "
"authentication");
ssh_spr_close(s->ppl.ssh, s->spr, "password prompt");
return;
}
/*
@ -1585,14 +1584,14 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
* password twice.
*/
while (!got_new) {
s->userpass_ret = seat_get_userpass_input(
s->spr = seat_get_userpass_input(
ppl_get_iseat(&s->ppl), s->cur_prompt);
while (s->userpass_ret < 0) {
while (s->spr.kind == SPRK_INCOMPLETE) {
crReturnV;
s->userpass_ret = seat_get_userpass_input(
s->spr = seat_get_userpass_input(
ppl_get_iseat(&s->ppl), s->cur_prompt);
}
if (!s->userpass_ret) {
if (spr_is_abort(s->spr)) {
/*
* Failed to get responses. Terminate.
*/
@ -1604,8 +1603,8 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
ssh_bpp_queue_disconnect(
s->ppl.bpp, "Unable to authenticate",
SSH2_DISCONNECT_AUTH_CANCELLED_BY_USER);
ssh_user_close(s->ppl.ssh, "User aborted during "
"password changing");
ssh_spr_close(s->ppl.ssh, s->spr,
"password-change prompt");
return;
}