Skip to content

Commit

Permalink
support requesting a subsystem on a channel
Browse files Browse the repository at this point in the history
Signed-off-by: NilashishC <[email protected]>
  • Loading branch information
NilashishC committed Dec 10, 2024
1 parent 6cbf2dd commit 392dbc3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/pylibsshext/channel.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ cdef class Channel:
if rc != libssh.SSH_OK:
raise LibsshChannelException("Failed to request_shell: [%d]" % rc)

def request_subsystem(self, subsystem):
rc = libssh.ssh_channel_request_subsystem(self._libssh_channel, subsystem.encode("utf-8"))
if rc != libssh.SSH_OK:
raise LibsshChannelException("Failed to request subsystem: [%d]" % rc)

def poll(self, timeout=-1, stderr=0):
if timeout < 0:
rc = libssh.ssh_channel_poll(self._libssh_channel, stderr)
Expand Down
1 change: 1 addition & 0 deletions src/pylibsshext/includes/libssh.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ cdef extern from "libssh/libssh.h" nogil:
int ssh_channel_open_session(ssh_channel channel)
int ssh_channel_request_pty(ssh_channel channel)
int ssh_channel_request_pty_size(ssh_channel channel, const char *term, int cols, int rows)
int ssh_channel_request_subsystem (ssh_channel channel, const char *subsys )
int ssh_channel_request_shell(ssh_channel channel)
int ssh_channel_is_open(ssh_channel channel)
int ssh_channel_write(ssh_channel channel, const void *data, uint32_t len)
Expand Down
5 changes: 5 additions & 0 deletions src/pylibsshext/session.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,11 @@ cdef class Session(object):
def invoke_shell(self):
return self.new_shell_channel()

def invoke_subsystem(self, subsystem):
channel = self.new_channel()
channel.request_subsystem(subsystem)
return channel

def scp(self):
return SCP(self)

Expand Down

0 comments on commit 392dbc3

Please sign in to comment.