From: simon Date: Wed, 29 Dec 2004 12:32:25 +0000 (+0000) Subject: Loose end from r5031: the Kex panel should only be displayed in X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/commitdiff_plain/f89c329410c18fe1f09d843747fad77babb9f89c Loose end from r5031: the Kex panel should only be displayed in mid-session if we are not using SSHv1. I've done this by introducing a generic `cfg_info' function which every back end can use to communicate an int's worth of data to setup_config_box; in SSH that's the protocol version in use, and in everything else it's currently zero. git-svn-id: svn://svn.tartarus.org/sgt/putty@5040 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/config.c b/config.c index 6d918c2c..6a5961c4 100644 --- a/config.c +++ b/config.c @@ -770,7 +770,7 @@ static void portfwd_handler(union control *ctrl, void *dlg, } void setup_config_box(struct controlbox *b, struct sesslist *sesslist, - int midsession, int protocol) + int midsession, int protocol, int protcfginfo) { struct controlset *s; struct sessionsaver_data *ssd; @@ -1583,33 +1583,36 @@ void setup_config_box(struct controlbox *b, struct sesslist *sesslist, /* * The Connection/SSH/Kex panel. (Owing to repeat key - * exchange, this is all meaningful in mid-session.) + * exchange, this is all meaningful in mid-session _if_ + * we're using SSH2 or haven't decided yet.) */ - ctrl_settitle(b, "Connection/SSH/Kex", - "Options controlling SSH key exchange"); - - s = ctrl_getset(b, "Connection/SSH/Kex", "main", - "Key exchange algorithm options"); - c = ctrl_draglist(s, "Algorithm selection policy", 's', - HELPCTX(ssh_kexlist), - kexlist_handler, P(NULL)); - c->listbox.height = 5; - - s = ctrl_getset(b, "Connection/SSH/Kex", "repeat", - "Options controlling key re-exchange"); - - ctrl_editbox(s, "Max minutes before rekey (0 for no limit)", 't', 20, - HELPCTX(ssh_kex_repeat), - dlg_stdeditbox_handler, - I(offsetof(Config,ssh_rekey_time)), - I(-1)); - ctrl_editbox(s, "Max data before rekey (0 for no limit)", 'x', 20, - HELPCTX(ssh_kex_repeat), - dlg_stdeditbox_handler, - I(offsetof(Config,ssh_rekey_data)), - I(16)); - ctrl_text(s, "(Use 1M for 1 megabyte, 1G for 1 gigabyte etc)", - HELPCTX(ssh_kex_repeat)); + if (protcfginfo != 1) { + ctrl_settitle(b, "Connection/SSH/Kex", + "Options controlling SSH key exchange"); + + s = ctrl_getset(b, "Connection/SSH/Kex", "main", + "Key exchange algorithm options"); + c = ctrl_draglist(s, "Algorithm selection policy", 's', + HELPCTX(ssh_kexlist), + kexlist_handler, P(NULL)); + c->listbox.height = 5; + + s = ctrl_getset(b, "Connection/SSH/Kex", "repeat", + "Options controlling key re-exchange"); + + ctrl_editbox(s, "Max minutes before rekey (0 for no limit)", 't', 20, + HELPCTX(ssh_kex_repeat), + dlg_stdeditbox_handler, + I(offsetof(Config,ssh_rekey_time)), + I(-1)); + ctrl_editbox(s, "Max data before rekey (0 for no limit)", 'x', 20, + HELPCTX(ssh_kex_repeat), + dlg_stdeditbox_handler, + I(offsetof(Config,ssh_rekey_data)), + I(16)); + ctrl_text(s, "(Use 1M for 1 megabyte, 1G for 1 gigabyte etc)", + HELPCTX(ssh_kex_repeat)); + } if (!midsession) { diff --git a/mac/macdlg.c b/mac/macdlg.c index 872d1894..544d9a19 100644 --- a/mac/macdlg.c +++ b/mac/macdlg.c @@ -1,4 +1,4 @@ -/* $Id: macdlg.c,v 1.18 2003/04/05 15:01:16 ben Exp $ */ +/* $Id$ */ /* * Copyright (c) 2002 Ben Harris * All rights reserved. @@ -67,7 +67,7 @@ void mac_newsession(void) get_sesslist(&sesslist, TRUE); s->ctrlbox = ctrl_new_box(); - setup_config_box(s->ctrlbox, &sesslist, FALSE, 0); + setup_config_box(s->ctrlbox, &sesslist, FALSE, 0, 0); s->settings_ctrls.data = &s->cfg; s->settings_ctrls.end = &mac_enddlg; diff --git a/putty.h b/putty.h index 4b0e3fef..0d74e940 100644 --- a/putty.h +++ b/putty.h @@ -340,6 +340,7 @@ struct backend_tag { * buffer is clearing. */ void (*unthrottle) (void *handle, int); + int (*cfg_info) (void *handle); int default_port; }; @@ -920,7 +921,7 @@ void cmdline_error(char *, ...); */ struct controlbox; void setup_config_box(struct controlbox *b, struct sesslist *sesslist, - int midsession, int protocol); + int midsession, int protocol, int protcfginfo); /* * Exports from minibidi.c. diff --git a/raw.c b/raw.c index 8b1b1e9b..631320c0 100644 --- a/raw.c +++ b/raw.c @@ -236,6 +236,14 @@ static int raw_exitcode(void *handle) return 0; } +/* + * cfg_info for Raw does nothing at all. + */ +static int raw_cfg_info(void *handle) +{ + return 0; +} + Backend raw_backend = { raw_init, raw_free, @@ -252,5 +260,6 @@ Backend raw_backend = { raw_provide_ldisc, raw_provide_logctx, raw_unthrottle, + raw_cfg_info, 1 }; diff --git a/rlogin.c b/rlogin.c index 06c8b12b..2f262300 100644 --- a/rlogin.c +++ b/rlogin.c @@ -303,6 +303,14 @@ static int rlogin_exitcode(void *handle) return 0; } +/* + * cfg_info for rlogin does nothing at all. + */ +static int rlogin_cfg_info(void *handle) +{ + return 0; +} + Backend rlogin_backend = { rlogin_init, rlogin_free, @@ -319,5 +327,6 @@ Backend rlogin_backend = { rlogin_provide_ldisc, rlogin_provide_logctx, rlogin_unthrottle, + rlogin_cfg_info, 1 }; diff --git a/ssh.c b/ssh.c index de768d3d..f92975d9 100644 --- a/ssh.c +++ b/ssh.c @@ -7861,6 +7861,16 @@ static int ssh_return_exitcode(void *handle) } /* + * cfg_info for SSH is the currently running version of the + * protocol. (1 for 1; 2 for 2; 0 for not-decided-yet.) + */ +static int ssh_cfg_info(void *handle) +{ + Ssh ssh = (Ssh) handle; + return ssh->version; +} + +/* * Gross hack: pscp will try to start SFTP but fall back to scp1 if * that fails. This variable is the means by which scp.c can reach * into the SSH code and find out which one it got. @@ -7887,5 +7897,6 @@ Backend ssh_backend = { ssh_provide_ldisc, ssh_provide_logctx, ssh_unthrottle, + ssh_cfg_info, 22 }; diff --git a/telnet.c b/telnet.c index 8b2c4289..13c2d3c2 100644 --- a/telnet.c +++ b/telnet.c @@ -1050,6 +1050,14 @@ static int telnet_exitcode(void *handle) return 0; } +/* + * cfg_info for Telnet does nothing at all. + */ +static int telnet_cfg_info(void *handle) +{ + return 0; +} + Backend telnet_backend = { telnet_init, telnet_free, @@ -1066,5 +1074,6 @@ Backend telnet_backend = { telnet_provide_ldisc, telnet_provide_logctx, telnet_unthrottle, + telnet_cfg_info, 23 }; diff --git a/testback.c b/testback.c index bc2eb31f..4bfb52d8 100644 --- a/testback.c +++ b/testback.c @@ -1,4 +1,4 @@ -/* $Id: testback.c,v 1.10 2004/06/20 17:07:32 jacob Exp $ */ +/* $Id$ */ /* * Copyright (c) 1999 Simon Tatham * Copyright (c) 1999 Ben Harris @@ -57,13 +57,15 @@ static void null_unthrottle(void *, int); Backend null_backend = { null_init, null_free, null_reconfig, null_send, null_sendbuffer, null_size, null_special, null_get_specials, null_socket, null_exitcode, null_sendok, - null_ldisc, null_provide_ldisc, null_provide_logctx, null_unthrottle, 0 + null_ldisc, null_provide_ldisc, null_provide_logctx, null_unthrottle, + null_cfg_info, 0 }; Backend loop_backend = { loop_init, loop_free, null_reconfig, loop_send, null_sendbuffer, null_size, null_special, null_get_specials, null_socket, null_exitcode, null_sendok, - null_ldisc, null_provide_ldisc, null_provide_logctx, null_unthrottle, 0 + null_ldisc, null_provide_ldisc, null_provide_logctx, null_unthrottle, + null_cfg_info, 0 }; struct loop_state { @@ -163,6 +165,12 @@ static void null_provide_logctx(void *handle, void *logctx) { } +static int null_cfg_info(void *handle) +{ + return 0; +} + + /* * Emacs magic: * Local Variables: diff --git a/unix/gtkdlg.c b/unix/gtkdlg.c index 6b5659c2..0ea6615f 100644 --- a/unix/gtkdlg.c +++ b/unix/gtkdlg.c @@ -1945,7 +1945,8 @@ int get_listitemheight(void) return req.height; } -int do_config_box(const char *title, Config *cfg, int midsession) +int do_config_box(const char *title, Config *cfg, int midsession, + int protcfginfo) { GtkWidget *window, *hbox, *vbox, *cols, *label, *tree, *treescroll, *panels, *panelvbox; @@ -1974,7 +1975,7 @@ int do_config_box(const char *title, Config *cfg, int midsession) window = gtk_dialog_new(); ctrlbox = ctrl_new_box(); - setup_config_box(ctrlbox, &sl, midsession, cfg->protocol); + setup_config_box(ctrlbox, &sl, midsession, cfg->protocol, protcfginfo); unix_setup_config_box(ctrlbox, midsession, window); gtk_window_set_title(GTK_WINDOW(window), title); diff --git a/unix/pterm.c b/unix/pterm.c index 54ab31d8..b1cd7d0f 100644 --- a/unix/pterm.c +++ b/unix/pterm.c @@ -2857,7 +2857,8 @@ void change_settings_menuitem(GtkMenuItem *item, gpointer data) cfg2 = inst->cfg; /* structure copy */ - if (do_config_box(title, &cfg2, 1)) { + if (do_config_box(title, &cfg2, 1, + inst->back?inst->back->cfg_info(inst->backhandle):0)) { oldcfg = inst->cfg; /* structure copy */ inst->cfg = cfg2; /* structure copy */ diff --git a/unix/pty.c b/unix/pty.c index bef9f2fa..d99d4e50 100644 --- a/unix/pty.c +++ b/unix/pty.c @@ -804,6 +804,11 @@ static int pty_exitcode(void *handle) return pty_exit_code; } +static int pty_cfg_info(void *handle) +{ + return 0; +} + Backend pty_backend = { pty_init, pty_free, @@ -820,5 +825,6 @@ Backend pty_backend = { pty_provide_ldisc, pty_provide_logctx, pty_unthrottle, + pty_cfg_info, 1 }; diff --git a/unix/unix.h b/unix/unix.h index 969cdbbf..909b3d49 100644 --- a/unix/unix.h +++ b/unix/unix.h @@ -60,7 +60,8 @@ long get_windowid(void *frontend); void *get_window(void *frontend); /* void * to avoid depending on gtk.h */ /* Things pterm.c needs from gtkdlg.c */ -int do_config_box(const char *title, Config *cfg, int midsession); +int do_config_box(const char *title, Config *cfg, + int midsession, int protcfginfo); void fatal_message_box(void *window, char *msg); void about_box(void *window); void *eventlogstuff_new(void); diff --git a/unix/uxputty.c b/unix/uxputty.c index d71d2898..58ae24da 100644 --- a/unix/uxputty.c +++ b/unix/uxputty.c @@ -40,7 +40,7 @@ Backend *select_backend(Config *cfg) int cfgbox(Config *cfg) { - return do_config_box("PuTTY Configuration", cfg, 0); + return do_config_box("PuTTY Configuration", cfg, 0, 0); } static int got_host = 0; diff --git a/windows/windlg.c b/windows/windlg.c index 285691bf..ba67ef56 100644 --- a/windows/windlg.c +++ b/windows/windlg.c @@ -598,7 +598,7 @@ int do_config(void) int ret; ctrlbox = ctrl_new_box(); - setup_config_box(ctrlbox, &sesslist, FALSE, 0); + setup_config_box(ctrlbox, &sesslist, FALSE, 0, 0); win_setup_config_box(ctrlbox, &dp.hwnd, (help_path != NULL), FALSE); dp_init(&dp); winctrl_init(&ctrls_base); @@ -624,7 +624,7 @@ int do_config(void) return ret; } -int do_reconfig(HWND hwnd) +int do_reconfig(HWND hwnd, int protcfginfo) { Config backup_cfg; int ret; @@ -632,7 +632,7 @@ int do_reconfig(HWND hwnd) backup_cfg = cfg; /* structure copy */ ctrlbox = ctrl_new_box(); - setup_config_box(ctrlbox, &sesslist, TRUE, cfg.protocol); + setup_config_box(ctrlbox, &sesslist, TRUE, cfg.protocol, protcfginfo); win_setup_config_box(ctrlbox, &dp.hwnd, (help_path != NULL), TRUE); dp_init(&dp); winctrl_init(&ctrls_base); diff --git a/windows/window.c b/windows/window.c index b0d7d5c2..68ba61f7 100644 --- a/windows/window.c +++ b/windows/window.c @@ -1900,7 +1900,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, GetWindowText(hwnd, cfg.wintitle, sizeof(cfg.wintitle)); prev_cfg = cfg; - if (!do_reconfig(hwnd)) + if (!do_reconfig(hwnd, back ? back->cfg_info(backhandle) : 0)) break; { diff --git a/windows/winstuff.h b/windows/winstuff.h index 84db7b04..020f43b8 100644 --- a/windows/winstuff.h +++ b/windows/winstuff.h @@ -327,7 +327,7 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help, */ void defuse_showwindow(void); int do_config(void); -int do_reconfig(HWND); +int do_reconfig(HWND, int); void showeventlog(HWND); void showabout(HWND); void force_normal(HWND hwnd);