~mdw
/
sgt
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Tweak to make it more obvious that the System menu is only available from
[sgt/putty]
/
ssh.c
diff --git
a/ssh.c
b/ssh.c
index
61786b1
..
6c94ba4
100644
(file)
--- a/
ssh.c
+++ b/
ssh.c
@@
-573,6
+573,7
@@
struct ssh_tag {
void *frontend;
void *frontend;
+ int ospeed, ispeed; /* temporaries */
int term_width, term_height;
tree234 *channels; /* indexed by local id */
int term_width, term_height;
tree234 *channels; /* indexed by local id */
@@
-2127,7
+2128,7
@@
static void ssh_sent(Plug plug, int bufsize)
* freed by the caller.
*/
static const char *connect_to_host(Ssh ssh, char *host, int port,
* freed by the caller.
*/
static const char *connect_to_host(Ssh ssh, char *host, int port,
- char **realhost, int nodelay)
+ char **realhost, int nodelay
, int keepalive
)
{
static const struct plug_function_table fn_table = {
ssh_closing,
{
static const struct plug_function_table fn_table = {
ssh_closing,
@@
-2168,7
+2169,7
@@
static const char *connect_to_host(Ssh ssh, char *host, int port,
}
ssh->fn = &fn_table;
ssh->s = new_connection(addr, *realhost, port,
}
ssh->fn = &fn_table;
ssh->s = new_connection(addr, *realhost, port,
- 0, 1, nodelay, (Plug) ssh, &ssh->cfg);
+ 0, 1, nodelay,
keepalive,
(Plug) ssh, &ssh->cfg);
if ((err = sk_socket_error(ssh->s)) != NULL) {
ssh->s = NULL;
return err;
if ((err = sk_socket_error(ssh->s)) != NULL) {
ssh->s = NULL;
return err;
@@
-2767,6
+2768,7
@@
static int do_ssh1_login(Ssh ssh, unsigned char *in, int inlen, int ispkt)
if (s->authed)
break;
}
if (s->authed)
break;
}
+ sfree(s->response);
}
if (s->authed)
break;
}
if (s->authed)
break;
@@
-3400,11
+3402,19
@@
static void ssh1_protocol(Ssh ssh, unsigned char *in, int inlen, int ispkt)
}
if (!ssh->cfg.nopty) {
}
if (!ssh->cfg.nopty) {
+ /* Unpick the terminal-speed string. */
+ /* XXX perhaps we should allow no speeds to be sent. */
+ ssh->ospeed = 38400; ssh->ispeed = 38400; /* last-resort defaults */
+ sscanf(ssh->cfg.termspeed, "%d,%d", &ssh->ospeed, &ssh->ispeed);
+ /* Send the pty request. */
send_packet(ssh, SSH1_CMSG_REQUEST_PTY,
PKT_STR, ssh->cfg.termtype,
PKT_INT, ssh->term_height,
PKT_INT, ssh->term_width,
send_packet(ssh, SSH1_CMSG_REQUEST_PTY,
PKT_STR, ssh->cfg.termtype,
PKT_INT, ssh->term_height,
PKT_INT, ssh->term_width,
- PKT_INT, 0, PKT_INT, 0, PKT_CHAR, 0, PKT_END);
+ PKT_INT, 0, PKT_INT, 0, /* width,height in pixels */
+ PKT_CHAR, 192, PKT_INT, ssh->ispeed, /* TTY_OP_ISPEED */
+ PKT_CHAR, 193, PKT_INT, ssh->ospeed, /* TTY_OP_OSPEED */
+ PKT_CHAR, 0, PKT_END);
ssh->state = SSH_STATE_INTERMED;
do {
crReturnV;
ssh->state = SSH_STATE_INTERMED;
do {
crReturnV;
@@
-3417,7
+3427,8
@@
static void ssh1_protocol(Ssh ssh, unsigned char *in, int inlen, int ispkt)
c_write_str(ssh, "Server refused to allocate pty\r\n");
ssh->editing = ssh->echoing = 1;
}
c_write_str(ssh, "Server refused to allocate pty\r\n");
ssh->editing = ssh->echoing = 1;
}
- logevent("Allocated pty");
+ logeventf(ssh, "Allocated pty (ospeed %dbps, ispeed %dbps)",
+ ssh->ospeed, ssh->ispeed);
} else {
ssh->editing = ssh->echoing = 1;
}
} else {
ssh->editing = ssh->echoing = 1;
}
@@
-4743,6
+4754,7
@@
static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
s->method = 0;
ssh->pkt_ctx &= ~SSH2_PKTCTX_AUTH_MASK;
s->method = 0;
ssh->pkt_ctx &= ~SSH2_PKTCTX_AUTH_MASK;
+ s->need_pw = FALSE;
/*
* Most password/passphrase prompts will be
/*
* Most password/passphrase prompts will be
@@
-4922,6
+4934,7
@@
static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
if (s->authed)
continue;
}
if (s->authed)
continue;
}
+ sfree(s->response);
}
if (!s->method && s->can_pubkey && s->publickey_blob
}
if (!s->method && s->can_pubkey && s->publickey_blob
@@
-4979,9
+4992,11
@@
static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
} else {
s->need_pw = FALSE;
}
} else {
s->need_pw = FALSE;
}
- c_write_str(ssh, "Authenticating with public key \"");
- c_write_str(ssh, comment);
- c_write_str(ssh, "\"\r\n");
+ if (flags & FLAG_VERBOSE) {
+ c_write_str(ssh, "Authenticating with public key \"");
+ c_write_str(ssh, comment);
+ c_write_str(ssh, "\"\r\n");
+ }
s->method = AUTH_PUBLICKEY_FILE;
}
}
s->method = AUTH_PUBLICKEY_FILE;
}
}
@@
-5195,6
+5210,7
@@
static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
ssh2_pkt_send(ssh);
s->type = AUTH_TYPE_PUBLICKEY;
ssh2_pkt_send(ssh);
s->type = AUTH_TYPE_PUBLICKEY;
+ key->alg->freekey(key->data);
}
} else if (s->method == AUTH_PASSWORD) {
/*
}
} else if (s->method == AUTH_PASSWORD) {
/*
@@
-5579,6
+5595,11
@@
static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
* Now allocate a pty for the session.
*/
if (!ssh->cfg.nopty) {
* Now allocate a pty for the session.
*/
if (!ssh->cfg.nopty) {
+ /* Unpick the terminal-speed string. */
+ /* XXX perhaps we should allow no speeds to be sent. */
+ ssh->ospeed = 38400; ssh->ispeed = 38400; /* last-resort defaults */
+ sscanf(ssh->cfg.termspeed, "%d,%d", &ssh->ospeed, &ssh->ispeed);
+ /* Build the pty request. */
ssh2_pkt_init(ssh, SSH2_MSG_CHANNEL_REQUEST);
ssh2_pkt_adduint32(ssh, ssh->mainchan->remoteid); /* recipient channel */
ssh2_pkt_addstring(ssh, "pty-req");
ssh2_pkt_init(ssh, SSH2_MSG_CHANNEL_REQUEST);
ssh2_pkt_adduint32(ssh, ssh->mainchan->remoteid); /* recipient channel */
ssh2_pkt_addstring(ssh, "pty-req");
@@
-5589,7
+5610,11
@@
static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
ssh2_pkt_adduint32(ssh, 0); /* pixel width */
ssh2_pkt_adduint32(ssh, 0); /* pixel height */
ssh2_pkt_addstring_start(ssh);
ssh2_pkt_adduint32(ssh, 0); /* pixel width */
ssh2_pkt_adduint32(ssh, 0); /* pixel height */
ssh2_pkt_addstring_start(ssh);
- ssh2_pkt_addstring_data(ssh, "\0", 1); /* TTY_OP_END, no special options */
+ ssh2_pkt_addbyte(ssh, 128); /* TTY_OP_ISPEED */
+ ssh2_pkt_adduint32(ssh, ssh->ispeed);
+ ssh2_pkt_addbyte(ssh, 129); /* TTY_OP_OSPEED */
+ ssh2_pkt_adduint32(ssh, ssh->ospeed);
+ ssh2_pkt_addstring_data(ssh, "\0", 1); /* TTY_OP_END */
ssh2_pkt_send(ssh);
ssh->state = SSH_STATE_INTERMED;
ssh2_pkt_send(ssh);
ssh->state = SSH_STATE_INTERMED;
@@
-5614,7
+5639,8
@@
static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
c_write_str(ssh, "Server refused to allocate pty\r\n");
ssh->editing = ssh->echoing = 1;
} else {
c_write_str(ssh, "Server refused to allocate pty\r\n");
ssh->editing = ssh->echoing = 1;
} else {
- logevent("Allocated pty");
+ logeventf(ssh, "Allocated pty (ospeed %dbps, ispeed %dbps)",
+ ssh->ospeed, ssh->ispeed);
}
} else {
ssh->editing = ssh->echoing = 1;
}
} else {
ssh->editing = ssh->echoing = 1;
@@
-6157,7
+6183,8
@@
static void ssh2_protocol(Ssh ssh, unsigned char *in, int inlen, int ispkt)
*/
static const char *ssh_init(void *frontend_handle, void **backend_handle,
Config *cfg,
*/
static const char *ssh_init(void *frontend_handle, void **backend_handle,
Config *cfg,
- char *host, int port, char **realhost, int nodelay)
+ char *host, int port, char **realhost, int nodelay,
+ int keepalive)
{
const char *p;
Ssh ssh;
{
const char *p;
Ssh ssh;
@@
-6241,7
+6268,7
@@
static const char *ssh_init(void *frontend_handle, void **backend_handle,
ssh->protocol = NULL;
ssh->protocol = NULL;
- p = connect_to_host(ssh, host, port, realhost, nodelay);
+ p = connect_to_host(ssh, host, port, realhost, nodelay
, keepalive
);
if (p != NULL)
return p;
if (p != NULL)
return p;
@@
-6264,10
+6291,18
@@
static void ssh_free(void *handle)
ssh->csmac->free_context(ssh->cs_mac_ctx);
if (ssh->sc_mac_ctx)
ssh->scmac->free_context(ssh->sc_mac_ctx);
ssh->csmac->free_context(ssh->cs_mac_ctx);
if (ssh->sc_mac_ctx)
ssh->scmac->free_context(ssh->sc_mac_ctx);
- if (ssh->cs_comp_ctx)
- ssh->cscomp->compress_cleanup(ssh->cs_comp_ctx);
- if (ssh->sc_comp_ctx)
- ssh->sccomp->compress_cleanup(ssh->sc_comp_ctx);
+ if (ssh->cs_comp_ctx) {
+ if (ssh->cscomp)
+ ssh->cscomp->compress_cleanup(ssh->cs_comp_ctx);
+ else
+ zlib_compress_cleanup(ssh->cs_comp_ctx);
+ }
+ if (ssh->sc_comp_ctx) {
+ if (ssh->sccomp)
+ ssh->sccomp->decompress_cleanup(ssh->sc_comp_ctx);
+ else
+ zlib_decompress_cleanup(ssh->sc_comp_ctx);
+ }
if (ssh->kex_ctx)
dh_cleanup(ssh->kex_ctx);
sfree(ssh->savedhost);
if (ssh->kex_ctx)
dh_cleanup(ssh->kex_ctx);
sfree(ssh->savedhost);