From 8e25894f64fb51996114a66adfc40a431295a659 Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Wed, 14 Dec 2011 02:21:12 +0100 Subject: [PATCH] sync tortoiseplink with TortoiseSVN rev. 22375 Signed-off-by: Sven Strickroth --- src/TortoisePlink/SETTINGS.C | 7 +-- src/TortoisePlink/SSH.C | 71 +++++++++++++++++++++--------- src/TortoisePlink/VERSION.C | 5 +++ src/TortoisePlink/Windows/TortoisePlink.rc | 8 ++-- src/TortoisePlink/Windows/WINPLINK.C | 16 +++++-- 5 files changed, 75 insertions(+), 32 deletions(-) diff --git a/src/TortoisePlink/SETTINGS.C b/src/TortoisePlink/SETTINGS.C index b2f3ddcf9..9a62f7ea7 100644 --- a/src/TortoisePlink/SETTINGS.C +++ b/src/TortoisePlink/SETTINGS.C @@ -303,11 +303,11 @@ static void wprefs(void *sesskey, char *name, for (maxlen = i = 0; i < nvals; i++) { const char *s = val2key(mapping, nvals, array[i]); if (s) { - maxlen += 1 + strlen(s); + maxlen += (maxlen > 0 ? 1 : 0) + strlen(s); } } - buf = snewn(maxlen, char); + buf = snewn(maxlen + 1, char); p = buf; for (i = 0; i < nvals; i++) { @@ -317,7 +317,8 @@ static void wprefs(void *sesskey, char *name, } } - assert(p - buf == maxlen - 1); /* maxlen counted the NUL */ + assert(p - buf == maxlen); + *p = '\0'; write_setting_s(sesskey, name, buf); diff --git a/src/TortoisePlink/SSH.C b/src/TortoisePlink/SSH.C index 950af144b..6b7eb8d9d 100644 --- a/src/TortoisePlink/SSH.C +++ b/src/TortoisePlink/SSH.C @@ -7312,7 +7312,7 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, AUTH_TYPE_PUBLICKEY_OFFER_LOUD, AUTH_TYPE_PUBLICKEY_OFFER_QUIET, AUTH_TYPE_PASSWORD, - AUTH_TYPE_GSSAPI, + AUTH_TYPE_GSSAPI, /* always QUIET */ AUTH_TYPE_KEYBOARD_INTERACTIVE, AUTH_TYPE_KEYBOARD_INTERACTIVE_QUIET } type; @@ -7675,19 +7675,20 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, /* * We have received an unequivocal Access * Denied. This can translate to a variety of - * messages: - * - * - if we'd just tried "none" authentication, - * it's not worth printing anything at all - * - * - if we'd just tried a public key _offer_, - * the message should be "Server refused our - * key" (or no message at all if the key - * came from Pageant) - * - * - if we'd just tried anything else, the - * message really should be "Access denied". - * + * messages, or no message at all. + * + * For forms of authentication which are attempted + * implicitly, by which I mean without printing + * anything in the window indicating that we're + * trying them, we should never print 'Access + * denied'. + * + * If we do print a message saying that we're + * attempting some kind of authentication, it's OK + * to print a followup message saying it failed - + * but the message may sometimes be more specific + * than simply 'Access denied'. + * * Additionally, if we'd just tried password * authentication, we should break out of this * whole loop so as to go back to the username @@ -7700,14 +7701,31 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, s->type == AUTH_TYPE_PUBLICKEY_OFFER_QUIET) { if (s->type == AUTH_TYPE_PUBLICKEY_OFFER_LOUD) c_write_str(ssh, "Server refused our key\r\n"); - logevent("Server refused public key"); + logevent("Server refused our key"); + } else if (s->type == AUTH_TYPE_PUBLICKEY) { + /* This _shouldn't_ happen except by a + * protocol bug causing client and server to + * disagree on what is a correct signature. */ + c_write_str(ssh, "Server refused public-key signature" + " despite accepting key!\r\n"); + logevent("Server refused public-key signature" + " despite accepting key!"); } else if (s->type==AUTH_TYPE_KEYBOARD_INTERACTIVE_QUIET) { - /* server declined keyboard-interactive; ignore */ - } else { + /* quiet, so no c_write */ + logevent("Server refused keyboard-interactive authentication"); + } else if (s->type==AUTH_TYPE_GSSAPI) { + /* always quiet, so no c_write */ + /* also, the code down in the GSSAPI block has + * already logged this in the Event Log */ + } else if (s->type == AUTH_TYPE_KEYBOARD_INTERACTIVE) { + logevent("Keyboard-interactive authentication failed"); + c_write_str(ssh, "Access denied\r\n"); + } else { + assert(s->type == AUTH_TYPE_PASSWORD); + logevent("Password authentication failed"); c_write_str(ssh, "Access denied\r\n"); - logevent("Access denied"); - if (s->type == AUTH_TYPE_PASSWORD && - ssh->cfg.change_username) { + + if (ssh->cfg.change_username) { /* XXX perhaps we should allow * keyboard-interactive to do this too? */ s->we_are_in = FALSE; @@ -8056,6 +8074,7 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, sfree(sigdata); ssh2_pkt_send(ssh, s->pktout); + logevent("Sent public key signature"); s->type = AUTH_TYPE_PUBLICKEY; key->alg->freekey(key->data); } @@ -8107,6 +8126,7 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, ssh2_pkt_addstring(s->pktout, s->username); ssh2_pkt_addstring(s->pktout, "ssh-connection"); ssh2_pkt_addstring(s->pktout, "gssapi-with-mic"); + logevent("Attempting GSSAPI authentication"); /* add mechanism info */ s->gsslib->indicate_mech(s->gsslib, &s->gss_buf); @@ -8270,6 +8290,8 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, ssh2_pkt_addstring(s->pktout, ""); /* lang */ ssh2_pkt_addstring(s->pktout, ""); /* submethods */ ssh2_pkt_send(ssh, s->pktout); + + logevent("Attempting keyboard-interactive authentication"); crWaitUntilV(pktin); if (pktin->type != SSH2_MSG_USERAUTH_INFO_REQUEST) { @@ -8278,8 +8300,6 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, * user without actually issuing any prompts). * Give up on it entirely. */ s->gotit = TRUE; - if (pktin->type == SSH2_MSG_USERAUTH_FAILURE) - logevent("Keyboard-interactive authentication refused"); s->type = AUTH_TYPE_KEYBOARD_INTERACTIVE_QUIET; s->kbd_inter_refused = TRUE; /* don't try it again */ continue; @@ -8391,6 +8411,13 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, } ssh2_pkt_send_with_padding(ssh, s->pktout, 256); + /* + * Free the prompts structure from this iteration. + * If there's another, a new one will be allocated + * when we return to the top of this while loop. + */ + free_prompts(s->cur_prompt); + /* * Get the next packet in case it's another * INFO_REQUEST. diff --git a/src/TortoisePlink/VERSION.C b/src/TortoisePlink/VERSION.C index ece99fbde..918a92052 100644 --- a/src/TortoisePlink/VERSION.C +++ b/src/TortoisePlink/VERSION.C @@ -23,6 +23,11 @@ char sshver[] = "PuTTY-Snapshot-" SNAPSHOT_TEXT; char ver[] = "Release " STR(RELEASE); char sshver[] = "PuTTY-Release-" STR(RELEASE); +#elif defined PRERELEASE + +char ver[] = "Pre-release " STR(PRERELEASE) ":r" STR(SVN_REV); +char sshver[] = "PuTTY-Prerelease-" STR(PRERELEASE) ":r" STR(SVN_REV); + #elif defined SVN_REV char ver[] = "Custom build r" STR(SVN_REV) ", " __DATE__ " " __TIME__; diff --git a/src/TortoisePlink/Windows/TortoisePlink.rc b/src/TortoisePlink/Windows/TortoisePlink.rc index 241925b3a..5dfc6deef 100644 --- a/src/TortoisePlink/Windows/TortoisePlink.rc +++ b/src/TortoisePlink/Windows/TortoisePlink.rc @@ -70,14 +70,14 @@ BEGIN BLOCK "080904b0" BEGIN VALUE "Comments", "Adapted from PuTTY plink (http://www.chiark.greenend.org.uk/~sgtatham/putty/)" - VALUE "CompanyName", "tortoisesvn.net" + VALUE "CompanyName", "TortoiseGit team and TortoiseSVN team" VALUE "FileDescription", "TortoisePlink" - VALUE "FileVersion", "Release 0.61" + VALUE "FileVersion", "Release 0.62" VALUE "InternalName", "TortoisePlink" VALUE "LegalCopyright", "Copyright © 2003-2011" VALUE "OriginalFilename", "TortoisePlink.exe" - VALUE "ProductName", "TortoiseSVN TortoisePlink" - VALUE "ProductVersion", "Release 0.61" + VALUE "ProductName", "TortoiseGit TortoisePlink" + VALUE "ProductVersion", "Release 0.62" END END BLOCK "VarFileInfo" diff --git a/src/TortoisePlink/Windows/WINPLINK.C b/src/TortoisePlink/Windows/WINPLINK.C index b15796377..88c2219d5 100644 --- a/src/TortoisePlink/Windows/WINPLINK.C +++ b/src/TortoisePlink/Windows/WINPLINK.C @@ -12,7 +12,6 @@ #include "storage.h" #include "tree234.h" -#include "LoginDialog.h" #define WM_AGENT_CALLBACK (WM_APP + 4) struct agent_callback { @@ -33,6 +32,10 @@ void fatalbox(char *p, ...) sprintf(morestuff, "%.70s Fatal Error", appname); MessageBox(GetParentHwnd(), stuff, morestuff, MB_ICONERROR | MB_OK); sfree(stuff); + if (logctx) { + log_free(logctx); + logctx = NULL; + } cleanup_exit(1); } void modalfatalbox(char *p, ...) @@ -47,6 +50,10 @@ void modalfatalbox(char *p, ...) MessageBox(GetParentHwnd(), stuff, morestuff, MB_SYSTEMMODAL | MB_ICONERROR | MB_OK); sfree(stuff); + if (logctx) { + log_free(logctx); + logctx = NULL; + } cleanup_exit(1); } void connection_fatal(void *frontend, char *p, ...) @@ -61,6 +68,10 @@ void connection_fatal(void *frontend, char *p, ...) MessageBox(GetParentHwnd(), stuff, morestuff, MB_SYSTEMMODAL | MB_ICONERROR | MB_OK); sfree(stuff); + if (logctx) { + log_free(logctx); + logctx = NULL; + } cleanup_exit(1); } void cmdline_error(char *p, ...) @@ -74,7 +85,7 @@ void cmdline_error(char *p, ...) sprintf(morestuff, "%.70s Command Line Error", appname); MessageBox(GetParentHwnd(), stuff, morestuff, MB_ICONERROR | MB_OK); sfree(stuff); - exit(1); + exit(1); } HANDLE inhandle, outhandle, errhandle; @@ -278,7 +289,6 @@ void stdouterr_sent(struct handle *h, int new_backlog) } } - int main(int argc, char **argv) { int sending; -- 2.11.4.GIT