use childFd when not handling a forced command

pull/776/head
JacobBarthelmeh 2025-02-19 12:00:38 -07:00
parent 60cd4bca73
commit 3859213936
1 changed files with 9 additions and 3 deletions

View File

@ -1511,8 +1511,14 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
if (cnt_r <= 0)
break;
cnt_w = (int)write(stdinPipe[1], channelBuffer,
cnt_r);
if (forcedCmd) {
cnt_w = (int)write(stdinPipe[1], channelBuffer,
cnt_r);
}
else {
cnt_w = (int)write(childFd, channelBuffer,
cnt_r);
}
if (cnt_w <= 0)
break;
}
@ -1545,7 +1551,7 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
current = wolfSSH_ChannelFind(ssh, lastChannel,
WS_CHANNEL_ID_SELF);
eof = wolfSSH_ChannelGetEof(current);
if (eof) {
if (eof && forcedCmd) {
/* SSH is done, close stdin pipe to child process */
close(stdinPipe[1]);
stdinPipe[1] = -1;