Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog-fragments/669.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support requesting for a subsystem on a channel -- by :user:`NilashishC`
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 %s: [%d]" % (subsystem, 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
Loading