Skip to content

Commit

Permalink
wolfSSHd Terminal
Browse files Browse the repository at this point in the history
1. Use the correct FD for updating the term settings.
  • Loading branch information
ejohnstown committed Nov 30, 2023
1 parent 0e2a2a9 commit e8dce9e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions apps/wolfsshd/wolfsshd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
return WS_FATAL_ERROR;
}

wolfSSH_DoModes(ssh->modes, ssh->modesSz);
wolfSSH_DoModes(ssh->modes, ssh->modesSz, childFd);
{
struct winsize windowSize = { 0 };

Expand All @@ -1324,7 +1324,7 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
windowSize.ws_xpixel = ssh->widthPixels;
windowSize.ws_ypixel = ssh->heightPixels;

ioctl(STDOUT_FILENO, TIOCSWINSZ, &windowSize);
ioctl(childFd, TIOCSWINSZ, &windowSize);
}


Expand Down
6 changes: 3 additions & 3 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -7103,7 +7103,7 @@ static int DoChannelClose(WOLFSSH* ssh,
#define TTY_SET_CHAR(x,y,z) (x)[(y)] = (byte)(z)
#define TTY_SET_FLAG(x,y,z) (x) = (z) ? ((x) | (y)) : ((x) & ~(y))

int wolfSSH_DoModes(const byte* modes, word32 modesSz)
int wolfSSH_DoModes(const byte* modes, word32 modesSz, int fd)
{
WOLFSSH_TERMIOS term;
word32 idx = 0, arg;
Expand All @@ -7119,7 +7119,7 @@ int wolfSSH_DoModes(const byte* modes, word32 modesSz)
* byte left over.
*/

tcgetattr(STDIN_FILENO, &term);
tcgetattr(fd, &term);

while (idx < modesSz && modes[idx] != WOLFSSH_TTY_OP_END
&& modes[idx] < WOLFSSH_TTY_INVALID) {
Expand Down Expand Up @@ -7331,7 +7331,7 @@ int wolfSSH_DoModes(const byte* modes, word32 modesSz)
idx += TERMINAL_MODE_SZ;
}

tcsetattr(STDIN_FILENO, TCSANOW, &term);
tcsetattr(fd, TCSANOW, &term);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion wolfssh/ssh.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ typedef enum {
WOLFSSH_SESSION_TERMINAL,
} WS_SessionType;

WOLFSSH_API int wolfSSH_DoModes(const byte* modes, word32 modesSz);
WOLFSSH_API int wolfSSH_DoModes(const byte* modes, word32 modesSz, int fd);
WOLFSSH_API WS_SessionType wolfSSH_GetSessionType(const WOLFSSH*);
WOLFSSH_API const char* wolfSSH_GetSessionCommand(const WOLFSSH*);
WOLFSSH_API int wolfSSH_SetChannelType(WOLFSSH*, byte, byte*, word32);
Expand Down

0 comments on commit e8dce9e

Please sign in to comment.