1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 11:32:48 -05:00

New Seat method, seat_nonfatal().

This is like the seat-independent nonfatal(), but specifies a Seat,
which allows the GUI dialog box to have the right terminal window as
its parent (if there are multiple ones).

Changed over all the nonfatal() calls in the code base that could be
localised to a Seat, which means all the ones that come up if
something goes horribly wrong in host key storage. To make that
possible, I've added a 'seat' parameter to store_host_key(); it turns
out that all its call sites had one available already.
This commit is contained in:
Simon Tatham
2022-09-13 08:49:38 +01:00
parent c674b2da4f
commit 4249b39ed3
24 changed files with 104 additions and 19 deletions

View File

@ -119,7 +119,7 @@ SeatPromptResult console_confirm_ssh_host_key(
if (line[0] != '\0' && line[0] != '\r' && line[0] != '\n' &&
line[0] != 'q' && line[0] != 'Q') {
if (line[0] == 'y' || line[0] == 'Y')
store_host_key(host, port, keytype, keystr);
store_host_key(seat, host, port, keytype, keystr);
return SPR_OK;
} else {
fputs(console_abandoned_msg, stderr);

View File

@ -1155,7 +1155,7 @@ SeatPromptResult win_seat_confirm_ssh_host_key(
wgs->term_hwnd, HostKeyDialogProc, ctx);
assert(mbret==IDC_HK_ACCEPT || mbret==IDC_HK_ONCE || mbret==IDCANCEL);
if (mbret == IDC_HK_ACCEPT) {
store_host_key(host, port, keytype, keystr);
store_host_key(seat, host, port, keytype, keystr);
return SPR_OK;
} else if (mbret == IDC_HK_ONCE) {
return SPR_OK;

View File

@ -97,6 +97,7 @@ static const SeatVtable plink_seat_vt = {
.notify_remote_exit = nullseat_notify_remote_exit,
.notify_remote_disconnect = nullseat_notify_remote_disconnect,
.connection_fatal = console_connection_fatal,
.nonfatal = console_nonfatal,
.update_specials_menu = nullseat_update_specials_menu,
.get_ttymode = nullseat_get_ttymode,
.set_busy_status = nullseat_set_busy_status,

View File

@ -357,7 +357,7 @@ bool have_ssh_host_key(const char *hostname, int port,
return check_stored_host_key(hostname, port, keytype, "") != 1;
}
void store_host_key(const char *hostname, int port,
void store_host_key(Seat *seat, const char *hostname, int port,
const char *keytype, const char *key)
{
strbuf *regname = strbuf_new();

View File

@ -321,6 +321,7 @@ static bool win_seat_eof(Seat *seat);
static SeatPromptResult win_seat_get_userpass_input(Seat *seat, prompts_t *p);
static void win_seat_notify_remote_exit(Seat *seat);
static void win_seat_connection_fatal(Seat *seat, const char *msg);
static void win_seat_nonfatal(Seat *seat, const char *msg);
static void win_seat_update_specials_menu(Seat *seat);
static void win_seat_set_busy_status(Seat *seat, BusyStatus status);
static void win_seat_set_trust_status(Seat *seat, bool trusted);
@ -338,6 +339,7 @@ static const SeatVtable win_seat_vt = {
.notify_remote_exit = win_seat_notify_remote_exit,
.notify_remote_disconnect = nullseat_notify_remote_disconnect,
.connection_fatal = win_seat_connection_fatal,
.nonfatal = win_seat_nonfatal,
.update_specials_menu = win_seat_update_specials_menu,
.get_ttymode = win_seat_get_ttymode,
.set_busy_status = win_seat_set_busy_status,
@ -1188,6 +1190,17 @@ static void win_seat_connection_fatal(Seat *seat, const char *msg)
}
}
/*
* Print a message box and don't close the connection.
*/
static void win_seat_nonfatal(Seat *seat, const char *msg)
{
char *title = dupprintf("%s Error", appname);
show_mouseptr(true);
MessageBox(wgs.term_hwnd, msg, title, MB_ICONERROR | MB_OK);
sfree(title);
}
/*
* Report an error at the command-line parsing stage.
*/