mirror of https://github.com/wolfSSL/wolfssh.git
commit
74ca7161a5
|
@ -316,15 +316,6 @@ static THREAD_RET readInput(void* in)
|
||||||
#else
|
#else
|
||||||
ret = (int)read(STDIN_FILENO, buf, bufSz -1);
|
ret = (int)read(STDIN_FILENO, buf, bufSz -1);
|
||||||
sz = (word32)ret;
|
sz = (word32)ret;
|
||||||
|
|
||||||
/* add carriage returns for interop with windows server */
|
|
||||||
if (ret > 0) {
|
|
||||||
if (ret == 1 && buf[0] == '\n') {
|
|
||||||
buf[1] = '\r';
|
|
||||||
ret++;
|
|
||||||
sz++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
if (ret <= 0) {
|
if (ret <= 0) {
|
||||||
fprintf(stderr, "Error reading stdin\n");
|
fprintf(stderr, "Error reading stdin\n");
|
||||||
|
|
118
src/internal.c
118
src/internal.c
|
@ -12343,57 +12343,60 @@ int SendChannelOpenConf(WOLFSSH* ssh, WOLFSSH_CHANNEL* channel)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SendChannelOpenFail(WOLFSSH* ssh, word32 channel, word32 reason, const char *description, const char *language)
|
int SendChannelOpenFail(WOLFSSH* ssh, word32 channel, word32 reason,
|
||||||
|
const char* description, const char* language)
|
||||||
{
|
{
|
||||||
byte* output;
|
byte* output;
|
||||||
word32 idx;
|
word32 idx;
|
||||||
word32 descriptionSz = (word32)WSTRLEN(description);
|
word32 descriptionSz = (word32)WSTRLEN(description);
|
||||||
word32 languageSz = (word32)WSTRLEN(language);
|
word32 languageSz = (word32)WSTRLEN(language);
|
||||||
int ret = WS_SUCCESS;
|
int ret = WS_SUCCESS;
|
||||||
|
|
||||||
WLOG(WS_LOG_DEBUG, "Entering SendChannelOpenFail()");
|
WLOG(WS_LOG_DEBUG, "Entering SendChannelOpenFail()");
|
||||||
|
|
||||||
if (ssh == NULL)
|
if (ssh == NULL)
|
||||||
ret = WS_BAD_ARGUMENT;
|
ret = WS_BAD_ARGUMENT;
|
||||||
|
|
||||||
if (ret == WS_SUCCESS) {
|
if (ret == WS_SUCCESS) {
|
||||||
WLOG(WS_LOG_INFO, " channelId = %u", channel);
|
WLOG(WS_LOG_INFO, " channelId = %u", channel);
|
||||||
WLOG(WS_LOG_INFO, " reason = %u", reason);
|
WLOG(WS_LOG_INFO, " reason = %u", reason);
|
||||||
WLOG(WS_LOG_INFO, " description = %s", description);
|
WLOG(WS_LOG_INFO, " description = %s", description);
|
||||||
WLOG(WS_LOG_INFO, " language = %s", language);
|
WLOG(WS_LOG_INFO, " language = %s", language);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == WS_SUCCESS)
|
if (ret == WS_SUCCESS) {
|
||||||
ret = PreparePacket(ssh, MSG_ID_SZ + UINT32_SZ + UINT32_SZ + LENGTH_SZ + descriptionSz + LENGTH_SZ + languageSz);
|
ret = PreparePacket(ssh, MSG_ID_SZ + UINT32_SZ + UINT32_SZ
|
||||||
|
+ LENGTH_SZ + descriptionSz + LENGTH_SZ + languageSz);
|
||||||
|
}
|
||||||
|
|
||||||
if (ret == WS_SUCCESS) {
|
if (ret == WS_SUCCESS) {
|
||||||
output = ssh->outputBuffer.buffer;
|
output = ssh->outputBuffer.buffer;
|
||||||
idx = ssh->outputBuffer.length;
|
idx = ssh->outputBuffer.length;
|
||||||
|
|
||||||
output[idx++] = MSGID_CHANNEL_OPEN_FAIL;
|
output[idx++] = MSGID_CHANNEL_OPEN_FAIL;
|
||||||
c32toa(channel, output + idx);
|
c32toa(channel, output + idx);
|
||||||
idx += UINT32_SZ;
|
idx += UINT32_SZ;
|
||||||
c32toa(reason, output + idx);
|
c32toa(reason, output + idx);
|
||||||
idx += UINT32_SZ;
|
idx += UINT32_SZ;
|
||||||
c32toa(descriptionSz, output + idx);
|
c32toa(descriptionSz, output + idx);
|
||||||
idx += UINT32_SZ;
|
idx += LENGTH_SZ;
|
||||||
WMEMCPY(output + idx, description, descriptionSz);
|
WMEMCPY(output + idx, description, descriptionSz);
|
||||||
idx += descriptionSz;
|
idx += descriptionSz;
|
||||||
c32toa(languageSz, output + idx);
|
c32toa(languageSz, output + idx);
|
||||||
idx += UINT32_SZ;
|
idx += LENGTH_SZ;
|
||||||
WMEMCPY(output + idx, language, languageSz);
|
WMEMCPY(output + idx, language, languageSz);
|
||||||
idx += languageSz;
|
idx += languageSz;
|
||||||
|
|
||||||
ssh->outputBuffer.length = idx;
|
ssh->outputBuffer.length = idx;
|
||||||
|
|
||||||
ret = BundlePacket(ssh);
|
ret = BundlePacket(ssh);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == WS_SUCCESS)
|
if (ret == WS_SUCCESS)
|
||||||
ret = wolfSSH_SendPacket(ssh);
|
ret = wolfSSH_SendPacket(ssh);
|
||||||
|
|
||||||
WLOG(WS_LOG_DEBUG, "Leaving SendChannelOpenFail(), ret = %d", ret);
|
WLOG(WS_LOG_DEBUG, "Leaving SendChannelOpenFail(), ret = %d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SendChannelEof(WOLFSSH* ssh, word32 peerChannelId)
|
int SendChannelEof(WOLFSSH* ssh, word32 peerChannelId)
|
||||||
|
@ -13073,8 +13076,8 @@ int SendChannelTerminalResize(WOLFSSH* ssh, word32 columns, word32 rows,
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void GetTerminalSize(word32* width, word32* height,
|
static void GetTerminalInfo(word32* width, word32* height,
|
||||||
word32* pixWidth, word32* pixHeight)
|
word32* pixWidth, word32* pixHeight, const char** term)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SYS_IOCTL_H
|
#ifdef HAVE_SYS_IOCTL_H
|
||||||
struct winsize windowSize = { 0,0,0,0 };
|
struct winsize windowSize = { 0,0,0,0 };
|
||||||
|
@ -13084,6 +13087,7 @@ static void GetTerminalSize(word32* width, word32* height,
|
||||||
*height = (word32)windowSize.ws_row;
|
*height = (word32)windowSize.ws_row;
|
||||||
*pixWidth = (word32)windowSize.ws_xpixel;
|
*pixWidth = (word32)windowSize.ws_xpixel;
|
||||||
*pixHeight = (word32)windowSize.ws_ypixel;
|
*pixHeight = (word32)windowSize.ws_ypixel;
|
||||||
|
*term = getenv("TERM");
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
CONSOLE_SCREEN_BUFFER_INFO cs;
|
CONSOLE_SCREEN_BUFFER_INFO cs;
|
||||||
|
|
||||||
|
@ -13108,9 +13112,9 @@ int SendChannelTerminalRequest(WOLFSSH* ssh)
|
||||||
int ret = WS_SUCCESS;
|
int ret = WS_SUCCESS;
|
||||||
WOLFSSH_CHANNEL* channel;
|
WOLFSSH_CHANNEL* channel;
|
||||||
const char cType[] = "pty-req";
|
const char cType[] = "pty-req";
|
||||||
const char envVar[] = "xterm";
|
const char* term = NULL;
|
||||||
byte mode[4096];
|
byte mode[4096];
|
||||||
word32 envSz, typeSz, modeSz;
|
word32 termSz, typeSz, modeSz;
|
||||||
word32 w = 0, h = 0, pxW = 0, pxH = 0;
|
word32 w = 0, h = 0, pxW = 0, pxH = 0;
|
||||||
|
|
||||||
WLOG(WS_LOG_DEBUG, "Entering SendChannelTerminalRequest()");
|
WLOG(WS_LOG_DEBUG, "Entering SendChannelTerminalRequest()");
|
||||||
|
@ -13118,8 +13122,11 @@ int SendChannelTerminalRequest(WOLFSSH* ssh)
|
||||||
if (ssh == NULL)
|
if (ssh == NULL)
|
||||||
ret = WS_BAD_ARGUMENT;
|
ret = WS_BAD_ARGUMENT;
|
||||||
|
|
||||||
GetTerminalSize(&w, &h, &pxW, &pxH);
|
GetTerminalInfo(&w, &h, &pxW, &pxH, &term);
|
||||||
envSz = (word32)WSTRLEN(envVar);
|
if (term == NULL) {
|
||||||
|
term = "xterm";
|
||||||
|
}
|
||||||
|
termSz = (word32)WSTRLEN(term);
|
||||||
typeSz = (word32)WSTRLEN(cType);
|
typeSz = (word32)WSTRLEN(cType);
|
||||||
modeSz = CreateMode(ssh, mode);
|
modeSz = CreateMode(ssh, mode);
|
||||||
|
|
||||||
|
@ -13143,12 +13150,11 @@ int SendChannelTerminalRequest(WOLFSSH* ssh)
|
||||||
* string encoded terminal modes
|
* string encoded terminal modes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (ret == WS_SUCCESS)
|
if (ret == WS_SUCCESS) {
|
||||||
ret = PreparePacket(ssh, MSG_ID_SZ + UINT32_SZ + LENGTH_SZ +
|
ret = PreparePacket(ssh, MSG_ID_SZ + UINT32_SZ + LENGTH_SZ + typeSz
|
||||||
typeSz + BOOLEAN_SZ +
|
+ BOOLEAN_SZ + LENGTH_SZ + termSz + UINT32_SZ * 4
|
||||||
((envSz > 0)? UINT32_SZ : 0) + envSz +
|
+ LENGTH_SZ + modeSz);
|
||||||
UINT32_SZ * 4 +
|
}
|
||||||
((modeSz > 0)? UINT32_SZ : 0) + modeSz);
|
|
||||||
|
|
||||||
if (ret == WS_SUCCESS) {
|
if (ret == WS_SUCCESS) {
|
||||||
output = ssh->outputBuffer.buffer;
|
output = ssh->outputBuffer.buffer;
|
||||||
|
@ -13160,9 +13166,11 @@ int SendChannelTerminalRequest(WOLFSSH* ssh)
|
||||||
WMEMCPY(output + idx, cType, typeSz); idx += typeSz;
|
WMEMCPY(output + idx, cType, typeSz); idx += typeSz;
|
||||||
output[idx++] = 1; /* want reply */
|
output[idx++] = 1; /* want reply */
|
||||||
|
|
||||||
if (envSz > 0) {
|
c32toa(termSz, output + idx);
|
||||||
c32toa(envSz, output + idx); idx += UINT32_SZ;
|
idx += UINT32_SZ;
|
||||||
WMEMCPY(output + idx, envVar, envSz); idx += envSz;
|
if (termSz > 0) {
|
||||||
|
WMEMCPY(output + idx, term, termSz);
|
||||||
|
idx += termSz;
|
||||||
}
|
}
|
||||||
|
|
||||||
c32toa(w, output + idx); idx += UINT32_SZ;
|
c32toa(w, output + idx); idx += UINT32_SZ;
|
||||||
|
|
|
@ -920,7 +920,8 @@ WOLFSSH_LOCAL int SendRequestSuccess(WOLFSSH*, int);
|
||||||
WOLFSSH_LOCAL int SendChannelOpenSession(WOLFSSH*, WOLFSSH_CHANNEL*);
|
WOLFSSH_LOCAL int SendChannelOpenSession(WOLFSSH*, WOLFSSH_CHANNEL*);
|
||||||
WOLFSSH_LOCAL int SendChannelOpenForward(WOLFSSH*, WOLFSSH_CHANNEL*);
|
WOLFSSH_LOCAL int SendChannelOpenForward(WOLFSSH*, WOLFSSH_CHANNEL*);
|
||||||
WOLFSSH_LOCAL int SendChannelOpenConf(WOLFSSH*, WOLFSSH_CHANNEL*);
|
WOLFSSH_LOCAL int SendChannelOpenConf(WOLFSSH*, WOLFSSH_CHANNEL*);
|
||||||
WOLFSSH_LOCAL int SendChannelOpenFail(WOLFSSH*, word32, word32, const char*, const char*);
|
WOLFSSH_LOCAL int SendChannelOpenFail(WOLFSSH* ssh, word32 channel,
|
||||||
|
word32 reason, const char* description, const char* language);
|
||||||
WOLFSSH_LOCAL int SendChannelEof(WOLFSSH*, word32);
|
WOLFSSH_LOCAL int SendChannelEof(WOLFSSH*, word32);
|
||||||
WOLFSSH_LOCAL int SendChannelEow(WOLFSSH*, word32);
|
WOLFSSH_LOCAL int SendChannelEow(WOLFSSH*, word32);
|
||||||
WOLFSSH_LOCAL int SendChannelClose(WOLFSSH*, word32);
|
WOLFSSH_LOCAL int SendChannelClose(WOLFSSH*, word32);
|
||||||
|
|
Loading…
Reference in New Issue