Land #15889, Add validation for resizeable interactive shells

This commit is contained in:
Grant Willcox 2021-11-18 14:12:56 -06:00
commit 7b06ee9701
No known key found for this signature in database
GPG Key ID: D35E05C0F2B81E83
2 changed files with 11 additions and 1 deletions

View File

@ -395,7 +395,16 @@ class Console::CommandDispatcher::Stdapi::Sys
#
def pty_shell(sh_path, raw: false)
args = ['-p']
args << '-r' if raw
if raw
args << '-r' if raw
if client.commands.include?(Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_SET_TERM_SIZE)
print_line("Terminal size will be synced automatically.")
else
print_line("You may want to set the correct terminal size manually.")
print_line("Example: `stty rows {rows} cols {columns}`")
end
end
sh_path = client.fs.file.exist?(sh_path) ? sh_path : '/bin/sh'
# Python Meterpreter calls pty.openpty() - No need for other methods

View File

@ -111,6 +111,7 @@ module Console::InteractiveChannel
end
def update_term_size
return unless self.client.commands.include?(Extensions::Stdapi::COMMAND_ID_STDAPI_SYS_PROCESS_SET_TERM_SIZE)
rows, cols = ::IO.console.winsize
unless rows == self.rows && cols == self.cols
set_term_size(rows, cols)