Class: ForemanRemoteExecutionCore::EffectiveUserMethod
- Inherits:
-
Object
- Object
- ForemanRemoteExecutionCore::EffectiveUserMethod
show all
- Defined in:
- lib/foreman_remote_execution_core/script_runner.rb
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.
14
15
16
17
18
19
|
# File 'lib/foreman_remote_execution_core/script_runner.rb', line 14
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_user ⇒ Object
Returns the value of attribute effective_user.
12
13
14
|
# File 'lib/foreman_remote_execution_core/script_runner.rb', line 12
def effective_user
@effective_user
end
|
#effective_user_password ⇒ Object
Returns the value of attribute effective_user_password.
12
13
14
|
# File 'lib/foreman_remote_execution_core/script_runner.rb', line 12
def effective_user_password
@effective_user_password
end
|
#password_sent ⇒ Object
Returns the value of attribute password_sent.
12
13
14
|
# File 'lib/foreman_remote_execution_core/script_runner.rb', line 12
def password_sent
@password_sent
end
|
#ssh_user ⇒ Object
Returns the value of attribute ssh_user.
12
13
14
|
# File 'lib/foreman_remote_execution_core/script_runner.rb', line 12
def ssh_user
@ssh_user
end
|
Instance Method Details
#cli_command_prefix ⇒ Object
40
41
|
# File 'lib/foreman_remote_execution_core/script_runner.rb', line 40
def cli_command_prefix
end
|
#filter_password?(received_data) ⇒ Boolean
28
29
30
|
# File 'lib/foreman_remote_execution_core/script_runner.rb', line 28
def filter_password?(received_data)
!@effective_user_password.empty? && @password_sent && received_data.match(Regexp.escape(@effective_user_password))
end
|
#login_prompt ⇒ Object
43
44
|
# File 'lib/foreman_remote_execution_core/script_runner.rb', line 43
def login_prompt
end
|
#on_data(received_data, ssh_channel) ⇒ Object
21
22
23
24
25
26
|
# File 'lib/foreman_remote_execution_core/script_runner.rb', line 21
def on_data(received_data, ssh_channel)
if received_data.match(login_prompt)
ssh_channel.send_data(effective_user_password + "\n")
@password_sent = true
end
end
|
#reset ⇒ Object
36
37
38
|
# File 'lib/foreman_remote_execution_core/script_runner.rb', line 36
def reset
@password_sent = false
end
|
#sent_all_data? ⇒ Boolean
32
33
34
|
# File 'lib/foreman_remote_execution_core/script_runner.rb', line 32
def sent_all_data?
effective_user_password.empty? || password_sent
end
|