1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-03-22 14:39:24 -05:00

New command-line option: 'putty --host-ca'.

This causes PuTTY to bring up just the host CA configuration dialog
box, and shut down once that box is dismissed.

I can imagine it potentially being useful to users, but in the first
instance, I expect it to be useful to _me_, because it will greatly
streamline testing changes to the UI of that dialog!
This commit is contained in:
Simon Tatham 2022-05-01 08:22:44 +01:00
parent 89883bf158
commit 259e877b92
4 changed files with 28 additions and 3 deletions

View File

@ -4224,6 +4224,7 @@ struct ca_config_box {
GtkWidget *window; GtkWidget *window;
struct controlbox *cb; struct controlbox *cb;
struct Shortcuts scs; struct Shortcuts scs;
bool quit_main;
dlgparam dp; dlgparam dp;
}; };
static struct ca_config_box *cacfg; /* one of these, cross-instance */ 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); dlg_cleanup(&cacfg->dp);
ctrl_free_box(cacfg->cb); ctrl_free_box(cacfg->cb);
cacfg->cb = NULL; 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) { if (!cacfg) {
cacfg = snew(struct ca_config_box); cacfg = snew(struct ca_config_box);
@ -4288,8 +4291,8 @@ void show_ca_config_box(dlgparam *dp)
dlg_refresh(NULL, &cacfg->dp); dlg_refresh(NULL, &cacfg->dp);
if (dp) { if (spawning_window) {
set_transient_window_pos(dp->window, cacfg->window); set_transient_window_pos(spawning_window, cacfg->window);
} else { } else {
gtk_window_set_position(GTK_WINDOW(cacfg->window), GTK_WIN_POS_CENTER); 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_signal_connect(G_OBJECT(cacfg->window), "key_press_event",
G_CALLBACK(win_key_press), &cacfg->dp); 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();
}

View File

@ -532,6 +532,11 @@ bool do_cmdline(int argc, char **argv, bool do_everything, Conf *conf)
pgp_fingerprints(); pgp_fingerprints();
exit(1); 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] != '-') { } else if (p[0] != '-') {
/* Non-option arguments not handled by cmdline.c are errors. */ /* Non-option arguments not handled by cmdline.c are errors. */
if (do_everything) { if (do_everything) {

View File

@ -245,6 +245,7 @@ GtkWidget *create_message_box(
bool selectable, const struct message_box_buttons *buttons, bool selectable, const struct message_box_buttons *buttons,
post_dialog_fn_t after, void *afterctx); post_dialog_fn_t after, void *afterctx);
#endif #endif
void show_ca_config_box_synchronously(void);
/* window.c needs this special function in utils */ /* window.c needs this special function in utils */
int keysym_to_unicode(int keysym); int keysym_to_unicode(int keysym);

View File

@ -87,6 +87,10 @@ void gui_term_process_cmdline(Conf *conf, char *cmdline)
} else if (!strcmp(p, "-pgpfp")) { } else if (!strcmp(p, "-pgpfp")) {
pgp_fingerprints_msgbox(NULL); pgp_fingerprints_msgbox(NULL);
exit(1); 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")) { } else if (!strcmp(p, "-demo-config-box")) {
if (i+1 >= argc) { if (i+1 >= argc) {
cmdline_error("%s expects an output filename", p); cmdline_error("%s expects an output filename", p);