diff --git a/unix/dialog.c b/unix/dialog.c index f6c5ab54..1d9944c5 100644 --- a/unix/dialog.c +++ b/unix/dialog.c @@ -4224,6 +4224,7 @@ struct ca_config_box { GtkWidget *window; struct controlbox *cb; struct Shortcuts scs; + bool quit_main; dlgparam dp; }; static struct ca_config_box *cacfg; /* one of these, cross-instance */ @@ -4234,8 +4235,10 @@ static void cacfg_destroy(GtkWidget *widget, gpointer data) dlg_cleanup(&cacfg->dp); ctrl_free_box(cacfg->cb); cacfg->cb = NULL; + if (cacfg->quit_main) + gtk_main_quit(); } -void show_ca_config_box(dlgparam *dp) +static void make_ca_config_box(GtkWidget *spawning_window) { if (!cacfg) { cacfg = snew(struct ca_config_box); @@ -4288,8 +4291,8 @@ void show_ca_config_box(dlgparam *dp) dlg_refresh(NULL, &cacfg->dp); - if (dp) { - set_transient_window_pos(dp->window, cacfg->window); + if (spawning_window) { + set_transient_window_pos(spawning_window, cacfg->window); } else { gtk_window_set_position(GTK_WINDOW(cacfg->window), GTK_WIN_POS_CENTER); } @@ -4300,3 +4303,15 @@ void show_ca_config_box(dlgparam *dp) g_signal_connect(G_OBJECT(cacfg->window), "key_press_event", G_CALLBACK(win_key_press), &cacfg->dp); } + +void show_ca_config_box(dlgparam *dp) +{ + make_ca_config_box(dp ? dp->window : NULL); +} + +void show_ca_config_box_synchronously(void) +{ + make_ca_config_box(NULL); + cacfg->quit_main = true; + gtk_main(); +} diff --git a/unix/main-gtk-simple.c b/unix/main-gtk-simple.c index e52a18d0..b08a0acc 100644 --- a/unix/main-gtk-simple.c +++ b/unix/main-gtk-simple.c @@ -532,6 +532,11 @@ bool do_cmdline(int argc, char **argv, bool do_everything, Conf *conf) pgp_fingerprints(); exit(1); + } else if (!strcmp(p, "-host-ca") || !strcmp(p, "--host-ca") || + !strcmp(p, "-host_ca") || !strcmp(p, "--host_ca")) { + show_ca_config_box_synchronously(); + exit(0); + } else if (p[0] != '-') { /* Non-option arguments not handled by cmdline.c are errors. */ if (do_everything) { diff --git a/unix/platform.h b/unix/platform.h index 7cdf4d11..6a8c7ba3 100644 --- a/unix/platform.h +++ b/unix/platform.h @@ -245,6 +245,7 @@ GtkWidget *create_message_box( bool selectable, const struct message_box_buttons *buttons, post_dialog_fn_t after, void *afterctx); #endif +void show_ca_config_box_synchronously(void); /* window.c needs this special function in utils */ int keysym_to_unicode(int keysym); diff --git a/windows/putty.c b/windows/putty.c index 83594d61..fca1d4bb 100644 --- a/windows/putty.c +++ b/windows/putty.c @@ -87,6 +87,10 @@ void gui_term_process_cmdline(Conf *conf, char *cmdline) } else if (!strcmp(p, "-pgpfp")) { pgp_fingerprints_msgbox(NULL); exit(1); + } else if (!strcmp(p, "-host-ca") || !strcmp(p, "--host-ca") || + !strcmp(p, "-host_ca") || !strcmp(p, "--host_ca")) { + show_ca_config_box(NULL); + exit(0); } else if (!strcmp(p, "-demo-config-box")) { if (i+1 >= argc) { cmdline_error("%s expects an output filename", p);