smart_proxy_remote_execution_ssh 0.11.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88b0285639f42712b4f588b01c4830b7155d971dc0677a4cf3a04e2557b742a0
|
4
|
+
data.tar.gz: a3b3af8bb1bf183a4156af74b758120f1039de80add807e1cea8713bcd6e982e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12bfc09f6535367e6f090b0d0401b57e9395bd44b3c41603ec06279930bd1c1f48ef24d6a8088999aa323bf42901e9dd9b0460dfb634712b2cd4119374c377ee
|
7
|
+
data.tar.gz: 6715dbc41c631447a1e2817e4e8ab289230258a49b874f837d7e529bdb6e7f05ddae670389b2a2e3466a02598ee9238dfbb3ce13ea19c6e47a6fbf9624a88c41
|
@@ -118,7 +118,6 @@ module Proxy::RemoteExecution::Ssh::Runners
|
|
118
118
|
@first_execution = options.fetch(:first_execution, false)
|
119
119
|
@user_method = user_method
|
120
120
|
@options = options
|
121
|
-
@supports_unshare = false
|
122
121
|
end
|
123
122
|
|
124
123
|
def self.build(options, suspended_action:)
|
@@ -150,7 +149,6 @@ module Proxy::RemoteExecution::Ssh::Runners
|
|
150
149
|
@connection = MultiplexedSSHConnection.new(@options.merge(:id => @id), logger: logger)
|
151
150
|
@connection.establish!
|
152
151
|
preflight_checks
|
153
|
-
detect_capabilities
|
154
152
|
prepare_start
|
155
153
|
script = initialization_script
|
156
154
|
logger.debug("executing script:\n#{indent_multiline(script)}")
|
@@ -164,16 +162,6 @@ module Proxy::RemoteExecution::Ssh::Runners
|
|
164
162
|
run_async(*args)
|
165
163
|
end
|
166
164
|
|
167
|
-
def detect_capabilities
|
168
|
-
script = cp_script_to_remote("#!/bin/sh\nexec #{UNSHARE_PREFIX} true")
|
169
|
-
begin
|
170
|
-
ensure_remote_command(script)
|
171
|
-
@supports_unshare = true
|
172
|
-
rescue; end
|
173
|
-
# The path should already be escaped
|
174
|
-
ensure_remote_command("rm #{script}")
|
175
|
-
end
|
176
|
-
|
177
165
|
def preflight_checks
|
178
166
|
script = cp_script_to_remote("#!/bin/sh\nexec true")
|
179
167
|
ensure_remote_command(script,
|
@@ -195,27 +183,32 @@ module Proxy::RemoteExecution::Ssh::Runners
|
|
195
183
|
@output_path = File.join(File.dirname(@remote_script), 'output')
|
196
184
|
@exit_code_path = File.join(File.dirname(@remote_script), 'exit_code')
|
197
185
|
@pid_path = File.join(File.dirname(@remote_script), 'pid')
|
186
|
+
su_method = @user_method.instance_of?(SuUserMethod)
|
187
|
+
wrapper = <<~SCRIPT
|
188
|
+
if [ "$1" == "inner" ]; then
|
189
|
+
echo \$$ > #{@pid_path}
|
190
|
+
(
|
191
|
+
#{@user_method.cli_command_prefix}#{su_method ? "'exec #{@remote_script} < /dev/null '" : "#{@remote_script} < /dev/null"}
|
192
|
+
echo \$? >#{@exit_code_path}
|
193
|
+
) | tee #{@output_path}
|
194
|
+
else
|
195
|
+
UNSHARE=''
|
196
|
+
if #{UNSHARE_PREFIX} true >/dev/null 2>/dev/null; then
|
197
|
+
UNSHARE='#{UNSHARE_PREFIX}'
|
198
|
+
fi
|
199
|
+
exec $UNSHARE "$0" inner
|
200
|
+
fi
|
201
|
+
SCRIPT
|
198
202
|
@remote_script_wrapper = upload_data(
|
199
|
-
|
203
|
+
wrapper,
|
200
204
|
File.join(File.dirname(@remote_script), 'script-wrapper'),
|
201
205
|
555)
|
202
206
|
end
|
203
207
|
|
204
208
|
# the script that initiates the execution
|
205
209
|
def initialization_script
|
206
|
-
su_method = @user_method.instance_of?(SuUserMethod)
|
207
210
|
# pipe the output to tee while capturing the exit code in a file
|
208
|
-
|
209
|
-
sh <<EOF | /usr/bin/tee #{@output_path}
|
210
|
-
#{@remote_script_wrapper} #{@user_method.cli_command_prefix}#{su_method ? "'#{@remote_script} < /dev/null '" : "#{@remote_script} < /dev/null"}
|
211
|
-
echo \\$?>#{@exit_code_path}
|
212
|
-
EOF
|
213
|
-
if [ -f #{@exit_code_path} ] && [ $(wc -l < #{@exit_code_path}) -gt 0 ]; then
|
214
|
-
exit $(cat #{@exit_code_path})
|
215
|
-
else
|
216
|
-
exit 1
|
217
|
-
fi
|
218
|
-
SCRIPT
|
211
|
+
@remote_script_wrapper
|
219
212
|
end
|
220
213
|
|
221
214
|
def refresh
|
@@ -227,7 +220,7 @@ module Proxy::RemoteExecution::Ssh::Runners
|
|
227
220
|
|
228
221
|
def kill
|
229
222
|
if @process_manager&.started?
|
230
|
-
run_sync("
|
223
|
+
run_sync("kill $(cat #{@pid_path})")
|
231
224
|
else
|
232
225
|
logger.debug('connection closed')
|
233
226
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_proxy_remote_execution_ssh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|