class SSHKit::Sudo::PasswordSendingInteractionHandler
Slightly simplified version of the original:
-
assumed that there is a password
-
assumes the same pwd for the hosts
-
replaced the class/dead methods with constants
-
removed the InteractionHandler subclass
Constants
- PASSWORD_PROMPT_REGEX
- WRONG_PASSWORD_MESSAGE_REGEX
Public Class Methods
new(servers_password)
click to toggle source
# File lib/sshkit/sudo/password_sending_interaction_handler.rb, line 14 def initialize(servers_password) @servers_password = servers_password end
Public Instance Methods
on_data(command, stream_name, data, channel)
click to toggle source
# File lib/sshkit/sudo/password_sending_interaction_handler.rb, line 18 def on_data(command, stream_name, data, channel) raise "Wrong password!" if data =~ WRONG_PASSWORD_MESSAGE_REGEX if data =~ PASSWORD_PROMPT_REGEX pass = @servers_password channel.send_data(pass) end end