foreman_remote_execution_core 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dffd5715e2f9f015bb0797db3ac51bbbd8398032459ba8108bb7b7b015edefaa
|
4
|
+
data.tar.gz: 5c6092674e23f651612964b94b3ba33e07f3be381d634767e94cfaa204f6bebb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8bb7142e790e7724fd2e81bc80c95c3d542552003055c9ef4f1c71149ed9c8c64efa9fb701f47eccd62a7f54c31290f984ad50cf1eb2e5612c32ba14a2e08b7
|
7
|
+
data.tar.gz: c4ee503e2ca8fdced721e5b802a4b0e7fad7824dbeb12bbedbc959704701e3716cd195048e764745012f68fbf429f1c4e55ee4725d705fb830ea302f40f6b60f
|
@@ -8,9 +8,7 @@ rescue LoadError; end
|
|
8
8
|
# rubocop:enable Lint/SuppressedException:
|
9
9
|
|
10
10
|
module ForemanRemoteExecutionCore
|
11
|
-
class
|
12
|
-
LOGIN_PROMPT = 'rex login: '.freeze
|
13
|
-
|
11
|
+
class EffectiveUserMethod
|
14
12
|
attr_reader :effective_user, :ssh_user, :effective_user_password, :password_sent
|
15
13
|
|
16
14
|
def initialize(effective_user, ssh_user, effective_user_password)
|
@@ -27,10 +25,6 @@ module ForemanRemoteExecutionCore
|
|
27
25
|
end
|
28
26
|
end
|
29
27
|
|
30
|
-
def login_prompt
|
31
|
-
LOGIN_PROMPT
|
32
|
-
end
|
33
|
-
|
34
28
|
def filter_password?(received_data)
|
35
29
|
!@effective_user_password.empty? && @password_sent && received_data.match(Regexp.escape(@effective_user_password))
|
36
30
|
end
|
@@ -39,52 +33,51 @@ module ForemanRemoteExecutionCore
|
|
39
33
|
effective_user_password.empty? || password_sent
|
40
34
|
end
|
41
35
|
|
36
|
+
def reset
|
37
|
+
@password_sent = false
|
38
|
+
end
|
39
|
+
|
42
40
|
def cli_command_prefix
|
43
|
-
"sudo -p '#{LOGIN_PROMPT}' -u #{effective_user} "
|
44
41
|
end
|
45
42
|
|
46
|
-
def
|
47
|
-
@password_sent = false
|
43
|
+
def login_prompt
|
48
44
|
end
|
49
45
|
end
|
50
46
|
|
51
|
-
class
|
52
|
-
LOGIN_PROMPT =
|
47
|
+
class SudoUserMethod < EffectiveUserMethod
|
48
|
+
LOGIN_PROMPT = 'rex login: '.freeze
|
53
49
|
|
54
50
|
def login_prompt
|
55
51
|
LOGIN_PROMPT
|
56
52
|
end
|
57
53
|
|
58
54
|
def cli_command_prefix
|
59
|
-
"
|
55
|
+
"sudo -p '#{LOGIN_PROMPT}' -u #{effective_user} "
|
60
56
|
end
|
61
57
|
end
|
62
58
|
|
63
|
-
class
|
64
|
-
|
59
|
+
class DzdoUserMethod < EffectiveUserMethod
|
60
|
+
LOGIN_PROMPT = /password/i.freeze
|
65
61
|
|
66
|
-
def
|
67
|
-
|
68
|
-
@ssh_user = ssh_user
|
62
|
+
def login_prompt
|
63
|
+
LOGIN_PROMPT
|
69
64
|
end
|
70
65
|
|
71
|
-
def
|
66
|
+
def cli_command_prefix
|
67
|
+
"dzdo -u #{effective_user} "
|
72
68
|
end
|
69
|
+
end
|
73
70
|
|
74
|
-
|
75
|
-
|
76
|
-
end
|
71
|
+
class SuUserMethod < EffectiveUserMethod
|
72
|
+
LOGIN_PROMPT = /Password: /i.freeze
|
77
73
|
|
78
|
-
def
|
79
|
-
|
74
|
+
def login_prompt
|
75
|
+
LOGIN_PROMPT
|
80
76
|
end
|
81
77
|
|
82
78
|
def cli_command_prefix
|
83
79
|
"su - #{effective_user} -c "
|
84
80
|
end
|
85
|
-
|
86
|
-
def reset
|
87
|
-
end
|
88
81
|
end
|
89
82
|
|
90
83
|
class NoopUserMethod
|
@@ -141,12 +134,13 @@ module ForemanRemoteExecutionCore
|
|
141
134
|
NoopUserMethod.new
|
142
135
|
elsif effective_user_method == 'sudo'
|
143
136
|
SudoUserMethod.new(effective_user, ssh_user,
|
144
|
-
options.fetch(:secrets, {}).fetch(:
|
137
|
+
options.fetch(:secrets, {}).fetch(:effective_user_password, nil))
|
145
138
|
elsif effective_user_method == 'dzdo'
|
146
139
|
DzdoUserMethod.new(effective_user, ssh_user,
|
147
|
-
options.fetch(:secrets, {}).fetch(:
|
140
|
+
options.fetch(:secrets, {}).fetch(:effective_user_password, nil))
|
148
141
|
elsif effective_user_method == 'su'
|
149
|
-
SuUserMethod.new(effective_user, ssh_user
|
142
|
+
SuUserMethod.new(effective_user, ssh_user,
|
143
|
+
options.fetch(:secrets, {}).fetch(:effective_user_password, nil))
|
150
144
|
else
|
151
145
|
raise "effective_user_method '#{effective_user_method}' not supported"
|
152
146
|
end
|
@@ -176,12 +170,11 @@ module ForemanRemoteExecutionCore
|
|
176
170
|
|
177
171
|
# the script that initiates the execution
|
178
172
|
def initialization_script
|
173
|
+
su_method = @user_method.instance_of?(ForemanRemoteExecutionCore::SuUserMethod)
|
179
174
|
# pipe the output to tee while capturing the exit code in a file
|
180
175
|
<<-SCRIPT.gsub(/^\s+\| /, '')
|
181
|
-
| sh
|
182
|
-
| (#{@
|
183
|
-
| exit \\$(cat #{@exit_code_path})
|
184
|
-
| WRAPPER
|
176
|
+
| sh -c "(#{@user_method.cli_command_prefix}#{su_method ? "'#{@remote_script} < /dev/null '" : "#{@remote_script} < /dev/null"}; echo \\$?>#{@exit_code_path}) | /usr/bin/tee #{@output_path}
|
177
|
+
| exit \\$(cat #{@exit_code_path})"
|
185
178
|
SCRIPT
|
186
179
|
end
|
187
180
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_remote_execution_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 1980-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: foreman-tasks-core
|
@@ -60,7 +60,7 @@ homepage: https://github.com/theforeman/foreman_remote_execution
|
|
60
60
|
licenses:
|
61
61
|
- GPL-3.0
|
62
62
|
metadata: {}
|
63
|
-
post_install_message:
|
63
|
+
post_install_message:
|
64
64
|
rdoc_options: []
|
65
65
|
require_paths:
|
66
66
|
- lib
|
@@ -75,8 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
77
|
requirements: []
|
78
|
-
rubygems_version: 3.
|
79
|
-
signing_key:
|
78
|
+
rubygems_version: 3.1.2
|
79
|
+
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: Foreman remote execution - core bits
|
82
82
|
test_files: []
|