Class: Proxy::RemoteExecution::Ssh::Runners::EffectiveUserMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_proxy_remote_execution_ssh/runners/script_runner.rb

Direct Known Subclasses

DzdoUserMethod, SuUserMethod, SudoUserMethod

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(effective_user, ssh_user, effective_user_password) ⇒ EffectiveUserMethod

Returns a new instance of EffectiveUserMethod.



15
16
17
18
19
20
# File 'lib/smart_proxy_remote_execution_ssh/runners/script_runner.rb', line 15

def initialize(effective_user, ssh_user, effective_user_password)
  @effective_user = effective_user
  @ssh_user = ssh_user
  @effective_user_password = effective_user_password.to_s
  @password_sent = false
end

Instance Attribute Details

#effective_userObject (readonly)

Returns the value of attribute effective_user.



13
14
15
# File 'lib/smart_proxy_remote_execution_ssh/runners/script_runner.rb', line 13

def effective_user
  @effective_user
end

#effective_user_passwordObject (readonly)

Returns the value of attribute effective_user_password.



13
14
15
# File 'lib/smart_proxy_remote_execution_ssh/runners/script_runner.rb', line 13

def effective_user_password
  @effective_user_password
end

#password_sentObject (readonly)

Returns the value of attribute password_sent.



13
14
15
# File 'lib/smart_proxy_remote_execution_ssh/runners/script_runner.rb', line 13

def password_sent
  @password_sent
end

#ssh_userObject (readonly)

Returns the value of attribute ssh_user.



13
14
15
# File 'lib/smart_proxy_remote_execution_ssh/runners/script_runner.rb', line 13

def ssh_user
  @ssh_user
end

Instance Method Details

#cli_command_prefixObject



41
# File 'lib/smart_proxy_remote_execution_ssh/runners/script_runner.rb', line 41

def cli_command_prefix; end

#filter_password?(received_data) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/smart_proxy_remote_execution_ssh/runners/script_runner.rb', line 29

def filter_password?(received_data)
  !@effective_user_password.empty? && @password_sent && received_data.match(Regexp.escape(@effective_user_password))
end

#login_promptObject



43
# File 'lib/smart_proxy_remote_execution_ssh/runners/script_runner.rb', line 43

def ; end

#on_data(received_data, ssh_channel) ⇒ Object



22
23
24
25
26
27
# File 'lib/smart_proxy_remote_execution_ssh/runners/script_runner.rb', line 22

def on_data(received_data, ssh_channel)
  if received_data.match()
    ssh_channel.send_data(effective_user_password + "\n")
    @password_sent = true
  end
end

#resetObject



37
38
39
# File 'lib/smart_proxy_remote_execution_ssh/runners/script_runner.rb', line 37

def reset
  @password_sent = false
end

#sent_all_data?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/smart_proxy_remote_execution_ssh/runners/script_runner.rb', line 33

def sent_all_data?
  effective_user_password.empty? || password_sent
end