Commit c12d3ab9 authored by Sam Rushing's avatar Sam Rushing

Interactive_Session_Server: fleshed out a bit

parent e1b2bc69
...@@ -30,6 +30,8 @@ import channel ...@@ -30,6 +30,8 @@ import channel
from coro.ssh.util import packet as ssh_packet from coro.ssh.util import packet as ssh_packet
from connect import * from connect import *
from coro import write_stderr as W
class Interactive_Session(channel.Channel): class Interactive_Session(channel.Channel):
name = 'session' name = 'session'
...@@ -58,25 +60,34 @@ class Interactive_Session_Client(Interactive_Session): ...@@ -58,25 +60,34 @@ class Interactive_Session_Client(Interactive_Session):
class Interactive_Session_Server(Interactive_Session): class Interactive_Session_Server(Interactive_Session):
def handle_request(self, request_type, want_reply, type_specific_packet_data): def handle_request(self, request_type, want_reply, type_specific_packet_data):
W ('interactive_session_server: handle_request %r %r %r\n' % (request_type, want_reply, type_specific_packet_data))
if self.request_handlers.has_key(request_type): if self.request_handlers.has_key(request_type):
f = self.request_handlers[request_type] self.request_handlers[request_type] (self, want_reply, type_specific_packet_data)
f(want_reply, type_specific_packet_data)
else: else:
if want_reply: if want_reply:
packet = ssh_packet.pack_payload(SSH_MSG_CHANNEL_FAILURE_PAYLOAD, (self.remote_channel.channel_id,)) packet = ssh_packet.pack_payload(SSH_MSG_CHANNEL_FAILURE_PAYLOAD, (self.remote_channel.channel_id,))
self.transport.send_packet(packet) self.transport.send_packet(packet)
def handle_pty_request(self, want_reply, type_specific_packet_data): def handle_pty_request(self, want_reply, type_specific_packet_data):
term, width_char, height_char, width_pixels, height_pixels, modes = ssh_packet.unpack_payload(PTY_CHANNEL_REQUEST_PAYLOAD, type_specific_packet_data) term, width_char, height_char, width_pixels, height_pixels, modes = ssh_packet.unpack_payload(PTY_CHANNEL_REQUEST_PAYLOAD, type_specific_packet_data)
# XXX: NOT FINISHED # XXX do some PTY crap here
self.send_channel_request_failure()
def handle_x11_request(self, want_reply, type_specific_packet_data): def handle_x11_request(self, want_reply, type_specific_packet_data):
single_connection, auth_protocol, auth_cookie, screen_number = ssh_packet.unpack_payload(X11_CHANNEL_REQUEST_PAYLOAD, type_specific_packet_data) single_connection, auth_protocol, auth_cookie, screen_number = ssh_packet.unpack_payload(X11_CHANNEL_REQUEST_PAYLOAD, type_specific_packet_data)
# XXX: NOT FINISHED # XXX fantasize about doing X11 forwarding here? I think not.
self.send_channel_request_failure()
def handle_shell_request(self, want_reply, type_specific_packet_data):
# XXX whatever, sure, it worked.
self.send_channel_request_success()
request_handlers = {'pty-req': handle_pty_request, request_handlers = {
'pty-req': handle_pty_request,
'x11-req': handle_x11_request, 'x11-req': handle_x11_request,
'shell' : handle_shell_request,
# exec :
# subsystem :
} }
PTY_CHANNEL_REQUEST_PAYLOAD = (ssh_packet.STRING, # TERM environment variable value (e.g., vt100) PTY_CHANNEL_REQUEST_PAYLOAD = (ssh_packet.STRING, # TERM environment variable value (e.g., vt100)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment