Fix #157: Allow to set terminal modes for PTYs

Added the new function `ssh_channel_request_pty_size_modes` which allows
to pass additional encoded SSH terminal modes (see opcodes in RFC 4245).

Signed-off-by: Daniel Evers (daniel.evers@utimaco.com)
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
Daniel Evers
2023-10-11 19:01:06 +02:00
committed by Jakub Jelen
parent 6ad455a8ac
commit 1291ceb17d
6 changed files with 171 additions and 7 deletions

View File

@@ -479,6 +479,8 @@ LIBSSH_API int ssh_channel_request_exec(ssh_channel channel, const char *cmd);
LIBSSH_API int ssh_channel_request_pty(ssh_channel channel);
LIBSSH_API int ssh_channel_request_pty_size(ssh_channel channel, const char *term,
int cols, int rows);
LIBSSH_API int ssh_channel_request_pty_size_modes(ssh_channel channel, const char *term,
int cols, int rows, const unsigned char* modes, size_t modes_len);
LIBSSH_API int ssh_channel_request_shell(ssh_channel channel);
LIBSSH_API int ssh_channel_request_send_signal(ssh_channel channel, const char *signum);
LIBSSH_API int ssh_channel_request_send_break(ssh_channel channel, uint32_t length);

View File

@@ -587,9 +587,12 @@ public:
ssh_throw(err);
return_throwable;
}
void_throwable requestPty(const char *term=NULL, int cols=0, int rows=0){
void_throwable requestPty(const char *term=NULL, int cols=0, int rows=0,
const unsigned char* modes=NULL, size_t modes_len=0){
int err;
if(term != NULL && cols != 0 && rows != 0)
if(term != NULL && cols != 0 && rows != 0 && modes != NULL)
err=ssh_channel_request_pty_size_modes(channel,term,cols,rows,modes,modes_len);
else if(term != NULL && cols != 0 && rows != 0)
err=ssh_channel_request_pty_size(channel,term,cols,rows);
else
err=ssh_channel_request_pty(channel);