From adf799ddb18af44ae2c4f68d9252af8c1848d0c5 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 11 Sep 2000 09:37:43 +0000 Subject: [PATCH] Add switch to choose SSH v1-versus-v2 protocol preference where both are available git-svn-id: svn://svn.tartarus.org/sgt/putty@584 cda61777-01e9-0310-a592-d414129be87e --- putty.h | 1 + ssh.c | 6 +++++- win_res.h | 3 +++ win_res.rc | 11 ++++++++--- windlg.c | 15 ++++++++++++++- 5 files changed, 31 insertions(+), 5 deletions(-) diff --git a/putty.h b/putty.h index f89aeac4..15054779 100644 --- a/putty.h +++ b/putty.h @@ -139,6 +139,7 @@ typedef struct { int nopty; enum { CIPHER_3DES, CIPHER_BLOWFISH, CIPHER_DES } cipher; char keyfile[FILENAME_MAX]; + int sshprot; /* use v1 or v2 when both available */ int try_tis_auth; /* Telnet options */ char termtype[32]; diff --git a/ssh.c b/ssh.c index 16e72043..e8d8230a 100644 --- a/ssh.c +++ b/ssh.c @@ -952,7 +952,11 @@ static int do_ssh_init(void) { vlog[strcspn(vlog, "\r\n")] = '\0'; logevent(vlog); - if (ssh_versioncmp(version, "2.0" /* FIXME: "1.99" */ ) >= 0) { + /* + * Server version "1.99" means we can choose whether we use v1 + * or v2 protocol. Choice is based on cfg.sshprot. + */ + if (ssh_versioncmp(version, cfg.sshprot == 1 ? "2.0" : "1.99") >= 0) { /* * This is a v2 server. Begin v2 protocol. */ diff --git a/win_res.h b/win_res.h index 7f4955a3..bf517eca 100644 --- a/win_res.h +++ b/win_res.h @@ -114,6 +114,9 @@ #define IDC3_PKSTATIC 1024 #define IDC3_PKEDIT 1025 #define IDC3_PKBUTTON 1026 +#define IDC3_SSHPROTSTATIC 1027 +#define IDC3_SSHPROT1 1028 +#define IDC3_SSHPROT2 1029 #define IDC4_MBSTATIC 1001 #define IDC4_MBWINDOWS 1002 diff --git a/win_res.rc b/win_res.rc index 9fb515e0..bc37c4f7 100644 --- a/win_res.rc +++ b/win_res.rc @@ -238,10 +238,15 @@ BEGIN AUTOCHECKBOX "Attempt TIS authentication", IDC3_AUTHTIS, 3, 55, 162, 8 - LTEXT "Public key file:", IDC3_PKSTATIC, 3, 75, 119, 8 - EDITTEXT IDC3_PKEDIT, 3, 83, 119, 12, ES_AUTOHSCROLL + LTEXT "Prefer protocol version:", IDC3_SSHPROTSTATIC, 3, 75, 105, 8 + AUTORADIOBUTTON "&1", IDC3_SSHPROT1, 115, 75, 21, 8, WS_GROUP + AUTORADIOBUTTON "&2", IDC3_SSHPROT2, 143, 75, 21, 8 - PUSHBUTTON "C&hange...", IDC3_PKBUTTON, 129, 83, 35, 12 + + LTEXT "Public key file:", IDC3_PKSTATIC, 3, 85, 119, 8 + EDITTEXT IDC3_PKEDIT, 3, 93, 119, 12, ES_AUTOHSCROLL + + PUSHBUTTON "C&hange...", IDC3_PKBUTTON, 129, 93, 35, 12 END IDD_PANEL4 DIALOG DISCARDABLE 6, 30, 168, 163 diff --git a/windlg.c b/windlg.c index 825072b0..e98db053 100644 --- a/windlg.c +++ b/windlg.c @@ -153,6 +153,7 @@ static void save_settings (char *section, int do_host) { wpps (sesskey, "Cipher", cfg.cipher == CIPHER_BLOWFISH ? "blowfish" : cfg.cipher == CIPHER_DES ? "des" : "3des"); wppi (sesskey, "AuthTIS", cfg.try_tis_auth); + wppi (sesskey, "SshProt", cfg.sshprot); wpps (sesskey, "PublicKeyFile", cfg.keyfile); wppi (sesskey, "RFCEnviron", cfg.rfc_environ); wppi (sesskey, "BackspaceIsDelete", cfg.bksp_is_delete); @@ -295,6 +296,7 @@ static void load_settings (char *section, int do_host) { else cfg.cipher = CIPHER_3DES; } + gppi (sesskey, "SshProt", 1, &cfg.sshprot); gppi (sesskey, "AuthTIS", 0, &cfg.try_tis_auth); gpps (sesskey, "PublicKeyFile", "", cfg.keyfile, sizeof(cfg.keyfile)); gppi (sesskey, "RFCEnviron", 0, &cfg.rfc_environ); @@ -1010,8 +1012,9 @@ static int CALLBACK SshProc (HWND hwnd, UINT msg, CheckRadioButton (hwnd, IDC3_CIPHER3DES, IDC3_CIPHERDES, cfg.cipher == CIPHER_BLOWFISH ? IDC3_CIPHERBLOWF : cfg.cipher == CIPHER_DES ? IDC3_CIPHERDES : - IDC3_CIPHER3DES); + CheckRadioButton (hwnd, IDC3_SSHPROT1, IDC3_SSHPROT2, + cfg.sshprot == 1 ? IDC3_SSHPROT1 : IDC3_SSHPROT2); CheckDlgButton (hwnd, IDC3_AUTHTIS, cfg.try_tis_auth); SetDlgItemText (hwnd, IDC3_PKEDIT, cfg.keyfile); break; @@ -1045,6 +1048,16 @@ static int CALLBACK SshProc (HWND hwnd, UINT msg, cfg.cipher = CIPHER_DES; } break; + case IDC3_SSHPROT1: + case IDC3_SSHPROT2: + if (HIWORD(wParam) == BN_CLICKED || + HIWORD(wParam) == BN_DOUBLECLICKED) { + if (IsDlgButtonChecked (hwnd, IDC3_SSHPROT1)) + cfg.sshprot = 1; + else if (IsDlgButtonChecked (hwnd, IDC3_SSHPROT2)) + cfg.sshprot = 2; + } + break; case IDC3_AUTHTIS: if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DOUBLECLICKED) -- 2.11.0