Route outgoing keystrokes through ssh_protocol_write(), rather than sockets and GUSI

This commit is contained in:
Brendan Shanks 2018-06-27 23:04:28 -07:00
parent 7208d01e91
commit 152f7a8d10
2 changed files with 13 additions and 29 deletions

View File

@ -518,6 +518,7 @@ short netwrite(short pnum, void *buffer, short nsend)
if (i < 0) return Rnetwrite(pnum, buffer, nsend);
/* NONO */
/*
if ( screens[i].protocol == PROTOCOL_SSH ) {
WindRec *wind = &screens[i];
lshcontext *context = (lshcontext *)wind->sshdata.context;
@ -549,12 +550,11 @@ short netwrite(short pnum, void *buffer, short nsend)
}
return nsend;
}
/*
*/
if (screens[i].protocol == PROTOCOL_SSH) {
ssh_glue_write(&screens[i], buffer, nsend);
return nsend;
}
*/
/* NONO */

View File

@ -1812,13 +1812,8 @@ void *ssh2_thread(WindRec*w)
libssh2_session_set_blocking(session, 0);
{
int stdinfd;
char c;
stdinfd = open("dev:ttyin", O_RDONLY);
syslog( 0, "stdin %d\n", stdinfd);
{
char buf[64];
ssize_t bytes;
@ -1857,10 +1852,6 @@ void *ssh2_thread(WindRec*w)
if (sock > maxfd)
maxfd = sock;
FD_SET(stdinfd, &readfds);
if (stdinfd > maxfd)
maxfd = stdinfd;
//FD_SET(stdoutfd, &writefds);
//if (stdinfd > maxfd)
// maxfd = stdinfd;
@ -1875,22 +1866,6 @@ void *ssh2_thread(WindRec*w)
syslog(0, "select returned %d\n", rc);
}
if (FD_ISSET(stdinfd, &readfds)) {
char buf[64];
int bytes;
bytes = read(stdinfd, buf, sizeof(buf));
syslog(0, "read %d bytes from stdin\n", bytes);
if (bytes > 0)
libssh2_channel_write(channel, buf, bytes);
else if (bytes == 0)
break; // EOF: window was closed. Close channel/session/connection.
else {
syslog(0, "read() from stdin returned -1 errno %d\n", errno);
break;
}
}
//if (FD_ISSET(stdoutfd, &writefds))
//{
//}
@ -1921,8 +1896,6 @@ void *ssh2_thread(WindRec*w)
break;
}
}
close(stdinfd);
}
libssh2_channel_free(channel);
@ -2197,6 +2170,17 @@ void ssh_packet_read(struct WindRec*w, unsigned char*databuf, short datalen)
void ssh_protocol_write(struct WindRec*w, unsigned char*databuf, short datalen)
{
syslog( 0, "### ssh_protocol_write, len : %d\n", datalen );
if (w->sshdata.thread) {
LIBSSH2_CHANNEL *channel = (LIBSSH2_CHANNEL *)w->sshdata.channel;
if (channel) {
if (datalen > 0) {
ssize_t ret = libssh2_channel_write(channel, databuf, datalen);
if (ret != datalen)
syslog( 0, "libssh2_channel_write returned %d\n", ret );
}
}
}
}