mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 03:22: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:
@ -191,7 +191,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);
|
||||
postmsg(&cf);
|
||||
return SPR_OK;
|
||||
} else {
|
||||
|
@ -3529,7 +3529,8 @@ static void confirm_ssh_host_key_result_callback(void *vctx, int result)
|
||||
* doesn't care whether we saved the host key or not).
|
||||
*/
|
||||
if (result == 2) {
|
||||
store_host_key(ctx->host, ctx->port, ctx->keytype, ctx->keystr);
|
||||
store_host_key(ctx->seat, ctx->host, ctx->port,
|
||||
ctx->keytype, ctx->keystr);
|
||||
logical_result = SPR_OK;
|
||||
} else if (result == 1) {
|
||||
logical_result = SPR_OK;
|
||||
|
@ -409,6 +409,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 = plink_get_ttymode,
|
||||
.set_busy_status = nullseat_set_busy_status,
|
||||
|
@ -828,7 +828,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)
|
||||
{
|
||||
FILE *rfp, *wfp;
|
||||
@ -846,7 +846,7 @@ void store_host_key(const char *hostname, int port,
|
||||
|
||||
dir = make_filename(INDEX_DIR, NULL);
|
||||
if ((errmsg = make_dir_path(dir, 0700)) != NULL) {
|
||||
nonfatal("Unable to store host key: %s", errmsg);
|
||||
seat_nonfatal(seat, "Unable to store host key: %s", errmsg);
|
||||
sfree(errmsg);
|
||||
sfree(dir);
|
||||
sfree(tmpfilename);
|
||||
@ -857,8 +857,8 @@ void store_host_key(const char *hostname, int port,
|
||||
wfp = fopen(tmpfilename, "w");
|
||||
}
|
||||
if (!wfp) {
|
||||
nonfatal("Unable to store host key: open(\"%s\") "
|
||||
"returned '%s'", tmpfilename, strerror(errno));
|
||||
seat_nonfatal(seat, "Unable to store host key: open(\"%s\") "
|
||||
"returned '%s'", tmpfilename, strerror(errno));
|
||||
sfree(tmpfilename);
|
||||
return;
|
||||
}
|
||||
@ -889,9 +889,9 @@ void store_host_key(const char *hostname, int port,
|
||||
fclose(wfp);
|
||||
|
||||
if (rename(tmpfilename, filename) < 0) {
|
||||
nonfatal("Unable to store host key: rename(\"%s\",\"%s\")"
|
||||
" returned '%s'", tmpfilename, filename,
|
||||
strerror(errno));
|
||||
seat_nonfatal(seat, "Unable to store host key: rename(\"%s\",\"%s\")"
|
||||
" returned '%s'", tmpfilename, filename,
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
sfree(tmpfilename);
|
||||
|
@ -290,6 +290,12 @@ static void gtk_seat_connection_fatal(Seat *seat, const char *msg)
|
||||
queue_toplevel_callback(connection_fatal_callback, inst);
|
||||
}
|
||||
|
||||
static void gtk_seat_nonfatal(Seat *seat, const char *msg)
|
||||
{
|
||||
GtkFrontend *inst = container_of(seat, GtkFrontend, seat);
|
||||
nonfatal_message_box(inst->window, msg);
|
||||
}
|
||||
|
||||
/*
|
||||
* Default settings that are specific to pterm.
|
||||
*/
|
||||
@ -423,6 +429,7 @@ static const SeatVtable gtk_seat_vt = {
|
||||
.notify_remote_exit = gtk_seat_notify_remote_exit,
|
||||
.notify_remote_disconnect = nullseat_notify_remote_disconnect,
|
||||
.connection_fatal = gtk_seat_connection_fatal,
|
||||
.nonfatal = gtk_seat_nonfatal,
|
||||
.update_specials_menu = gtk_seat_update_specials_menu,
|
||||
.get_ttymode = gtk_seat_get_ttymode,
|
||||
.set_busy_status = gtk_seat_set_busy_status,
|
||||
|
Reference in New Issue
Block a user