1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 09:27:59 +00:00

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.

[originally from svn r5040]
[r5031 == d77102a8d5]
This commit is contained in:
Simon Tatham 2004-12-29 12:32:25 +00:00
parent 6120d91507
commit b0bf176dfb
16 changed files with 99 additions and 40 deletions

View File

@ -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");
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", "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");
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));
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) {

View File

@ -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;

View File

@ -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.

9
raw.c
View File

@ -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
};

View File

@ -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
};

11
ssh.c
View File

@ -7860,6 +7860,16 @@ static int ssh_return_exitcode(void *handle)
return (ssh->exitcode >= 0 ? ssh->exitcode : 0);
}
/*
* 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
@ -7887,5 +7897,6 @@ Backend ssh_backend = {
ssh_provide_ldisc,
ssh_provide_logctx,
ssh_unthrottle,
ssh_cfg_info,
22
};

View File

@ -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
};

View File

@ -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:

View File

@ -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);

View File

@ -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 */

View File

@ -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
};

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;
{

View File

@ -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);