return 0;
}
ssh_gotdata (data, len);
+ if (ssh_state == SSH_STATE_CLOSED) {
+ if (s) {
+ sk_close(s);
+ s = NULL;
+ }
+ return 0;
+ }
return 1;
}
} else if (pktin.type == SSH1_MSG_DISCONNECT) {
ssh_state = SSH_STATE_CLOSED;
logevent("Received disconnect request");
+ crReturnV;
} else if (pktin.type == SSH1_SMSG_AGENT_OPEN) {
/* Remote side is trying to open a channel to talk to our
* agent. Give them back a local channel number. */
ssh2_pkt_addstring_start();
ssh2_pkt_addstring_data("\0", 1);/* TTY_OP_END, no special options */
ssh2_pkt_send();
+ ssh_state = SSH_STATE_INTERMED;
do {
crWaitUntilV(ispkt);
logevent("Started a shell/command");
}
+ ssh_state = SSH_STATE_SESSION;
+ if (size_needed)
+ ssh_size();
+
/*
* Transfer data!
*/
} else if (pktin.type == SSH2_MSG_DISCONNECT) {
ssh_state = SSH_STATE_CLOSED;
logevent("Received disconnect message");
+ crReturnV;
} else if (pktin.type == SSH2_MSG_CHANNEL_REQUEST) {
continue; /* exit status et al; ignore (FIXME?) */
} else if (pktin.type == SSH2_MSG_CHANNEL_EOF) {
ssh2_pkt_init(SSH2_MSG_DISCONNECT);
ssh2_pkt_send();
ssh_state = SSH_STATE_CLOSED;
- sk_close(s);
- s = NULL;
+ crReturnV;
}
continue; /* remote sends close; ignore (FIXME) */
} else if (pktin.type == SSH2_MSG_CHANNEL_WINDOW_ADJUST) {
}
/*
- * Called to set the size of the window from Telnet's POV.
+ * Called to set the size of the window from SSH's POV.
*/
static void ssh_size(void) {
switch (ssh_state) {
break;
case SSH_STATE_SESSION:
if (!cfg.nopty) {
- send_packet(SSH1_CMSG_WINDOW_SIZE,
- PKT_INT, rows, PKT_INT, cols,
- PKT_INT, 0, PKT_INT, 0, PKT_END);
+ if (ssh_version == 1) {
+ send_packet(SSH1_CMSG_WINDOW_SIZE,
+ PKT_INT, rows, PKT_INT, cols,
+ PKT_INT, 0, PKT_INT, 0, PKT_END);
+ } else {
+ ssh2_pkt_init(SSH2_MSG_CHANNEL_REQUEST);
+ ssh2_pkt_adduint32(mainchan->remoteid);
+ ssh2_pkt_addstring("window-change");
+ ssh2_pkt_addbool(0);
+ ssh2_pkt_adduint32(cols);
+ ssh2_pkt_adduint32(rows);
+ ssh2_pkt_adduint32(0);
+ ssh2_pkt_adduint32(0);
+ ssh2_pkt_send();
+ }
}
}
}