rhc 1.32.2 → 1.33.4
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.
|
@@ -131,7 +131,7 @@ module RHC::Commands
|
|
|
131
131
|
debug args.inspect
|
|
132
132
|
ssh.forward.local(*args)
|
|
133
133
|
fs.bound = true
|
|
134
|
-
rescue Errno::EADDRINUSE, Errno::EACCES => e
|
|
134
|
+
rescue Errno::EADDRINUSE, Errno::EACCES, Errno::EPERM => e
|
|
135
135
|
warn "#{e} while forwarding port #{fs.port_from}. Trying local port #{fs.port_from+1}"
|
|
136
136
|
fs.port_from += 1
|
|
137
137
|
rescue Timeout::Error, Errno::EADDRNOTAVAIL, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Net::SSH::AuthenticationFailed => e
|
data/lib/rhc/commands/ssh.rb
CHANGED
|
@@ -39,10 +39,19 @@ module RHC::Commands
|
|
|
39
39
|
|
|
40
40
|
debug "Using user specified SSH: #{options.ssh}" if options.ssh
|
|
41
41
|
|
|
42
|
-
command_line = [RHC::Helpers.split_path(ssh), ('-
|
|
42
|
+
command_line = [RHC::Helpers.split_path(ssh), ('-vv' if debug?), rest_app.ssh_string.to_s, command].flatten.compact
|
|
43
43
|
|
|
44
44
|
debug "Invoking Kernel.exec with #{command_line.inspect}"
|
|
45
|
-
|
|
45
|
+
begin
|
|
46
|
+
Kernel.send(:exec, *command_line)
|
|
47
|
+
rescue Errno::ENOENT
|
|
48
|
+
debug "SSH executable #{ssh.inspect} not found, splitting and trying again..."
|
|
49
|
+
|
|
50
|
+
command_line = [ssh.chomp('"').reverse.chomp('"').reverse.split(' '), ('-vv' if debug?), rest_app.ssh_string.to_s, command].flatten.compact
|
|
51
|
+
debug "Invoking Kernel.exec with #{command_line.inspect}"
|
|
52
|
+
|
|
53
|
+
Kernel.send(:exec, *command_line)
|
|
54
|
+
end
|
|
46
55
|
end
|
|
47
56
|
end
|
|
48
57
|
|
data/lib/rhc/ssh_helpers.rb
CHANGED
|
@@ -268,7 +268,7 @@ module RHC
|
|
|
268
268
|
else
|
|
269
269
|
Net::SSH.start(ssh_uri.host, ssh_uri.user) do |ssh|
|
|
270
270
|
File.open(filename, 'wb') do |file|
|
|
271
|
-
ssh.exec!
|
|
271
|
+
ssh.exec! snapshot_cmd do |channel, stream, data|
|
|
272
272
|
if stream == :stdout
|
|
273
273
|
file.write(data)
|
|
274
274
|
else
|
|
@@ -131,6 +131,24 @@ describe RHC::Commands::PortForward do
|
|
|
131
131
|
end
|
|
132
132
|
end
|
|
133
133
|
|
|
134
|
+
# Windows 7 reportedly returns EPERM rather than EACCES when the
|
|
135
|
+
# port is in use by a local service (see
|
|
136
|
+
# <https://bugzilla.redhat.com/show_bug.cgi?id=1125963>).
|
|
137
|
+
context 'when local port is in use by local service on Windows 7' do
|
|
138
|
+
before(:each) do
|
|
139
|
+
Net::SSH.should_receive(:start).with(@uri.host, @uri.user).and_yield(@ssh).twice
|
|
140
|
+
@ssh.should_receive(:exec!).with("rhc-list-ports").and_yield(nil, :stderr, 'mysql -> 127.0.0.1:3306')
|
|
141
|
+
forward = double(Net::SSH::Service::Forward)
|
|
142
|
+
@ssh.should_receive(:forward).at_least(2).and_return(forward)
|
|
143
|
+
forward.should_receive(:local).with(3306, '127.0.0.1', 3306).and_raise(Errno::EPERM)
|
|
144
|
+
forward.should_receive(:local).with(3307, '127.0.0.1', 3306)
|
|
145
|
+
@ssh.should_receive(:loop).and_raise(Interrupt.new)
|
|
146
|
+
end
|
|
147
|
+
it 'should bind to a higher port' do
|
|
148
|
+
run_output.should include("3307")
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
134
152
|
context 'when host refuses connection' do
|
|
135
153
|
before(:each) do
|
|
136
154
|
Net::SSH.should_receive(:start).with(@uri.host, @uri.user).and_yield(@ssh).twice
|
|
@@ -36,7 +36,7 @@ describe RHC::Commands::Ssh do
|
|
|
36
36
|
before(:each) do
|
|
37
37
|
@domain = rest_client.add_domain("mockdomain")
|
|
38
38
|
@domain.add_application("app1", "mock_type")
|
|
39
|
-
Kernel.should_receive(:exec).with("ssh", "-
|
|
39
|
+
Kernel.should_receive(:exec).with("ssh", "-vv", "fakeuuidfortestsapp1@127.0.0.1").and_return(0)
|
|
40
40
|
end
|
|
41
41
|
# It would be nice if this checked for the debug[123]: messages from standard error but im not sure how to look for that.
|
|
42
42
|
it { run_output.should match("Connecting to fakeuuidfortestsapp") }
|
|
@@ -171,6 +171,23 @@ describe RHC::Commands::Ssh do
|
|
|
171
171
|
end
|
|
172
172
|
end
|
|
173
173
|
|
|
174
|
+
describe 'app ssh custom ssh with spaces' do
|
|
175
|
+
let(:arguments) { ['app', 'ssh', 'app1', '--ssh', '/path/to/ssh --with_custom_flag'] }
|
|
176
|
+
context 'when custom ssh does not exist as a path' do
|
|
177
|
+
before(:each) do
|
|
178
|
+
@domain = rest_client.add_domain("mockdomain")
|
|
179
|
+
@domain.add_application("app1", "mock_type")
|
|
180
|
+
RHC::Commands::Ssh.any_instance.should_not_receive(:has_ssh?)
|
|
181
|
+
File.should_receive(:exist?).at_least(1).and_return(true)
|
|
182
|
+
File.should_receive(:executable?).at_least(1).and_return(true)
|
|
183
|
+
subject.class.any_instance.stub(:discover_git_executable).and_return('git')
|
|
184
|
+
Kernel.should_receive(:exec).with('/path/to/ssh --with_custom_flag', "fakeuuidfortestsapp1@127.0.0.1").once.times.and_raise(Errno::ENOENT)
|
|
185
|
+
Kernel.should_receive(:exec).with('/path/to/ssh', '--with_custom_flag', "fakeuuidfortestsapp1@127.0.0.1").once.times.and_return(0)
|
|
186
|
+
end
|
|
187
|
+
it { expect { run }.to exit_with_code(0) }
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
174
191
|
describe 'ssh tests' do
|
|
175
192
|
let(:arguments) { ['app', 'ssh', 'app1', '-s /bin/blah'] }
|
|
176
193
|
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rhc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 155
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 1
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
version: 1.
|
|
8
|
+
- 33
|
|
9
|
+
- 4
|
|
10
|
+
version: 1.33.4
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Red Hat
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2014-
|
|
18
|
+
date: 2014-12-04 00:00:00 Z
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
21
21
|
name: net-ssh
|