net-ssh 3.1.0.beta2 → 3.1.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGES.txt +6 -1
- data/Rakefile +25 -0
- data/lib/net/ssh/authentication/session.rb +1 -1
- data/lib/net/ssh/config.rb +16 -5
- data/lib/net/ssh/known_hosts.rb +1 -1
- data/lib/net/ssh/service/forward.rb +1 -1
- data/lib/net/ssh/version.rb +1 -1
- data/net-ssh.gemspec +3 -3
- data/test/integration/test_forward.rb +99 -2
- data/test/test_config.rb +36 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9170e4ec18254639ebeab82be271d685637f44f
|
4
|
+
data.tar.gz: 02f77daa8e46de9274ee27a9c2a432a3283df456
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5c05d3ed42d10f531f644c6eed5d57e481a5c67f0948f17b2e410371e447bcf472293c3821cc66c54eaff6be4d144184e6be92a264402003b552417f6fe7853
|
7
|
+
data.tar.gz: 2014b67019c22d96d73248e90a0c086d90b0824c77b6fe23786dd6a33c38264b60d135f1aacd06087319668d59327c62fc7b9861ec873b8f8d120a14e9e27e5d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGES.txt
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
=== 3.1.0.
|
1
|
+
=== 3.1.0.beta3
|
2
|
+
|
3
|
+
* forward/on_open_failed should stop listning closed socket otherwise it locks #269 [Miklos Fazekas,Scott McGillivray]
|
4
|
+
* fix incorrect pattern handling in config files #310 [Miklos Fazekas]
|
5
|
+
|
6
|
+
=== 3.1.0.beta2
|
2
7
|
|
3
8
|
* trying to execute something on a not yet opend channel throws nicer messag [Miklos Fazekas]
|
4
9
|
* calling close on a not opened channel marks the channel for close [Miklos Fazekas]
|
data/Rakefile
CHANGED
@@ -72,6 +72,31 @@ RDoc::Task.new do |rdoc|
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
+
namespace :rdoc do
|
76
|
+
desc "Update gh-pages branch"
|
77
|
+
task :publish do
|
78
|
+
# copy/checkout
|
79
|
+
rm_rf "/tmp/net-ssh-rdoc"
|
80
|
+
rm_rf "/tmp/net-ssh-gh-pages"
|
81
|
+
cp_r "./rdoc", "/tmp/net-ssh-rdoc"
|
82
|
+
mkdir "/tmp/net-ssh-gh-pages"
|
83
|
+
Dir.chdir "/tmp/net-ssh-gh-pages" do
|
84
|
+
sh "git clone --branch gh-pages --single-branch https://github.com/net-ssh/net-ssh"
|
85
|
+
rm_rf "/tmp/net-ssh-gh-pages/net-ssh/*"
|
86
|
+
end
|
87
|
+
# update
|
88
|
+
sh "cp -rf ./rdoc/* /tmp/net-ssh-gh-pages/net-ssh/"
|
89
|
+
Dir.chdir "/tmp/net-ssh-gh-pages/net-ssh" do
|
90
|
+
sh "git add -A ."
|
91
|
+
sh "git commit -m \"Update docs\""
|
92
|
+
end
|
93
|
+
# publish
|
94
|
+
Dir.chdir "/tmp/net-ssh-gh-pages/net-ssh" do
|
95
|
+
sh "git push origin gh-pages"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
75
100
|
require 'rake/testtask'
|
76
101
|
Rake::TestTask.new do |t|
|
77
102
|
if ENV['NET_SSH_RUN_INTEGRATION_TESTS']
|
@@ -69,7 +69,7 @@ module Net; module SSH; module Authentication
|
|
69
69
|
attempted << name
|
70
70
|
|
71
71
|
debug { "trying #{name}" }
|
72
|
-
begin
|
72
|
+
begin
|
73
73
|
method = Methods.const_get(name.split(/\W+/).map { |p| p.capitalize }.join).new(self, :key_manager => key_manager)
|
74
74
|
rescue NameError
|
75
75
|
debug{"Mechanism #{name} was requested, but isn't a known type. Ignoring it."}
|
data/lib/net/ssh/config.rb
CHANGED
@@ -242,11 +242,22 @@ module Net; module SSH
|
|
242
242
|
# Converts an ssh_config pattern into a regex for matching against
|
243
243
|
# host names.
|
244
244
|
def pattern2regex(pattern)
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
245
|
+
tail = pattern
|
246
|
+
prefix = ""
|
247
|
+
while !tail.empty? do
|
248
|
+
head,sep,tail = tail.partition(/[\*\?]/)
|
249
|
+
prefix = prefix + Regexp.quote(head)
|
250
|
+
case sep
|
251
|
+
when '*'
|
252
|
+
prefix += '.*'
|
253
|
+
when '?'
|
254
|
+
prefix += '.'
|
255
|
+
when ''
|
256
|
+
else
|
257
|
+
fail "Unpexpcted sep:#{sep}"
|
258
|
+
end
|
259
|
+
end
|
260
|
+
Regexp.new("^" + prefix + "$", true)
|
250
261
|
end
|
251
262
|
|
252
263
|
# Converts the given size into an integer number of bytes.
|
data/lib/net/ssh/known_hosts.rb
CHANGED
@@ -51,7 +51,7 @@ module Net; module SSH
|
|
51
51
|
class <<self
|
52
52
|
|
53
53
|
# Searches all known host files (see KnownHosts.hostfiles) for all keys
|
54
|
-
# of the given host. Returns an
|
54
|
+
# of the given host. Returns an enumerable of keys found.
|
55
55
|
def search_for(host, options={})
|
56
56
|
HostKeys.new(search_in(hostfiles(options), host), host, self, options)
|
57
57
|
end
|
@@ -91,6 +91,7 @@ module Net; module SSH; module Service
|
|
91
91
|
|
92
92
|
channel.on_open_failed do |ch, code, description|
|
93
93
|
channel.error { "could not establish direct channel: #{description} (#{code})" }
|
94
|
+
session.stop_listening_to(channel[:socket])
|
94
95
|
channel[:socket].close
|
95
96
|
end
|
96
97
|
end
|
@@ -273,7 +274,6 @@ module Net; module SSH; module Service
|
|
273
274
|
ch[:socket].enqueue(data)
|
274
275
|
end
|
275
276
|
|
276
|
-
# Handles server close on the sending side by Miklós Fazekas
|
277
277
|
channel.on_eof do |ch|
|
278
278
|
debug { "eof #{type} on #{type} forwarded channel" }
|
279
279
|
begin
|
data/lib/net/ssh/version.rb
CHANGED
@@ -55,7 +55,7 @@ module Net; module SSH
|
|
55
55
|
|
56
56
|
# The prerelease component of this version of the Net::SSH library
|
57
57
|
# nil allowed
|
58
|
-
PRE = "
|
58
|
+
PRE = "beta3"
|
59
59
|
|
60
60
|
# The current version of the Net::SSH library as a Version instance
|
61
61
|
CURRENT = new(*[MAJOR, MINOR, TINY, PRE].compact)
|
data/net-ssh.gemspec
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: net-ssh 3.1.0.
|
5
|
+
# stub: net-ssh 3.1.0.beta3 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "net-ssh"
|
9
|
-
s.version = "3.1.0.
|
9
|
+
s.version = "3.1.0.beta3"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Jamis Buck", "Delano Mandelbaum", "Mikl\u{f3}s Fazekas"]
|
14
14
|
s.cert_chain = ["net-ssh-public_cert.pem"]
|
15
|
-
s.date = "2016-03-
|
15
|
+
s.date = "2016-03-07"
|
16
16
|
s.description = "Net::SSH: a pure-Ruby implementation of the SSH2 client protocol. It allows you to write programs that invoke and interact with processes on remote servers, via SSH2."
|
17
17
|
s.email = "net-ssh@solutious.com"
|
18
18
|
s.extra_rdoc_files = [
|
@@ -287,8 +287,8 @@ class TestForward < Test::Unit::TestCase
|
|
287
287
|
end
|
288
288
|
end
|
289
289
|
|
290
|
-
def start_server
|
291
|
-
server
|
290
|
+
def start_server(server = nil, &block)
|
291
|
+
server ||= TCPServer.open(0)
|
292
292
|
Thread.start do
|
293
293
|
loop do
|
294
294
|
Thread.start(server.accept) do |client|
|
@@ -432,4 +432,101 @@ class TestForward < Test::Unit::TestCase
|
|
432
432
|
end
|
433
433
|
end
|
434
434
|
end
|
435
|
+
|
436
|
+
def _run_reading_client(client_done, local_port)
|
437
|
+
Thread.start do
|
438
|
+
begin
|
439
|
+
client = TCPSocket.new(localhost, local_port)
|
440
|
+
data = client.read(4096)
|
441
|
+
client.close
|
442
|
+
client_done << data
|
443
|
+
rescue
|
444
|
+
client_done << $!
|
445
|
+
end
|
446
|
+
end
|
447
|
+
end
|
448
|
+
|
449
|
+
def test_cannot_open_connection_should_allow_further_connections_on_different_forward
|
450
|
+
setup_ssh_env do
|
451
|
+
session = Net::SSH.start(*ssh_start_params)
|
452
|
+
server = start_server do |client|
|
453
|
+
data = client.write "hello"
|
454
|
+
client.close
|
455
|
+
end
|
456
|
+
# Forward to a non existing port
|
457
|
+
non_existing_port = 1234
|
458
|
+
local_port = session.forward.local(0, localhost, non_existing_port)
|
459
|
+
# should return connection refused
|
460
|
+
client_done = Queue.new
|
461
|
+
_run_reading_client(client_done, local_port)
|
462
|
+
timeout(5) do
|
463
|
+
session.loop(0.1) { client_done.empty? }
|
464
|
+
end
|
465
|
+
assert_equal nil, client_done.pop
|
466
|
+
assert client_done.empty?
|
467
|
+
# Forward to existing port
|
468
|
+
remote_port = server.addr[1]
|
469
|
+
local_port = session.forward.local(0, localhost, remote_port)
|
470
|
+
_run_reading_client(client_done, local_port)
|
471
|
+
timeout(5) do
|
472
|
+
session.loop(0.1) { client_done.empty? }
|
473
|
+
end
|
474
|
+
assert_equal "hello", client_done.pop
|
475
|
+
assert client_done.empty?
|
476
|
+
end
|
477
|
+
end
|
478
|
+
|
479
|
+
def test_cannot_open_connection_should_allow_further_connections_on_same
|
480
|
+
setup_ssh_env do
|
481
|
+
session = Net::SSH.start(*ssh_start_params)
|
482
|
+
server = TCPServer.open(0)
|
483
|
+
# Forward to a non existing port
|
484
|
+
remote_port = server.addr[1]
|
485
|
+
server.close
|
486
|
+
local_port = session.forward.local(0, localhost, remote_port)
|
487
|
+
# should return connection refused
|
488
|
+
client_done = Queue.new
|
489
|
+
_run_reading_client(client_done, local_port)
|
490
|
+
timeout(5) do
|
491
|
+
session.loop(0.1) { client_done.empty? }
|
492
|
+
end
|
493
|
+
assert_equal nil, client_done.pop
|
494
|
+
assert client_done.empty?
|
495
|
+
# start server
|
496
|
+
server = TCPServer.open(remote_port)
|
497
|
+
server = start_server(server) do |client|
|
498
|
+
data = client.write "hello"
|
499
|
+
client.close
|
500
|
+
end
|
501
|
+
_run_reading_client(client_done, local_port)
|
502
|
+
timeout(5) do
|
503
|
+
session.loop(0.1) { client_done.empty? }
|
504
|
+
end
|
505
|
+
assert_equal "hello", client_done.pop
|
506
|
+
assert client_done.empty?
|
507
|
+
end
|
508
|
+
end
|
509
|
+
|
510
|
+
def test_cancel_local
|
511
|
+
setup_ssh_env do
|
512
|
+
session = Net::SSH.start(*ssh_start_params)
|
513
|
+
server = start_server(server) do |client|
|
514
|
+
data = client.write "hello"
|
515
|
+
client.close
|
516
|
+
end
|
517
|
+
remote_port = server.addr[1]
|
518
|
+
local_port = session.forward.local(0, localhost, remote_port)
|
519
|
+
# run client
|
520
|
+
client_done = Queue.new
|
521
|
+
_run_reading_client(client_done, local_port)
|
522
|
+
timeout(5) do
|
523
|
+
session.loop(0.1) { client_done.empty? }
|
524
|
+
end
|
525
|
+
assert_equal "hello", client_done.pop
|
526
|
+
# cancel
|
527
|
+
session.forward.cancel_local(local_port)
|
528
|
+
session.loop(0.1)
|
529
|
+
assert_equal({}, session.channels)
|
530
|
+
end
|
531
|
+
end
|
435
532
|
end
|
data/test/test_config.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'common'
|
2
2
|
require 'net/ssh/config'
|
3
3
|
require 'pathname'
|
4
|
+
require 'tempfile'
|
4
5
|
|
5
6
|
class TestConfig < Test::Unit::TestCase
|
6
7
|
def test_home_should_be_absolute_path
|
@@ -41,6 +42,33 @@ class TestConfig < Test::Unit::TestCase
|
|
41
42
|
assert !config.key?('compression')
|
42
43
|
end
|
43
44
|
|
45
|
+
def test_load_with_pattern_does_match
|
46
|
+
data = %q{
|
47
|
+
Host test.*
|
48
|
+
Port 1234
|
49
|
+
Compression no
|
50
|
+
}
|
51
|
+
with_config_from_data data do |f|
|
52
|
+
config = Net::SSH::Config.load(f, "test.host")
|
53
|
+
assert_equal 1234, config['port']
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_load_with_regex_chars
|
58
|
+
data = %q{
|
59
|
+
Host |
|
60
|
+
Port 1234
|
61
|
+
Compression no
|
62
|
+
}
|
63
|
+
with_config_from_data data do |f|
|
64
|
+
config = Net::SSH::Config.load(f, "test.host")
|
65
|
+
assert_equal nil, config['port']
|
66
|
+
config = Net::SSH::Config.load(f, "|")
|
67
|
+
assert_equal 1234, config['port']
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
|
44
72
|
def test_for_should_load_all_files_and_translate_to_net_ssh_options
|
45
73
|
config = Net::SSH::Config.for("test.host", [config(:exact_match), config(:wild_cards)])
|
46
74
|
assert_equal 1234, config[:port]
|
@@ -229,4 +257,12 @@ class TestConfig < Test::Unit::TestCase
|
|
229
257
|
def config(name)
|
230
258
|
"test/configs/#{name}"
|
231
259
|
end
|
260
|
+
|
261
|
+
def with_config_from_data(data, &block)
|
262
|
+
Tempfile.open('config') do |f|
|
263
|
+
f.write(data)
|
264
|
+
f.close
|
265
|
+
yield(f.path)
|
266
|
+
end
|
267
|
+
end
|
232
268
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-ssh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.0.
|
4
|
+
version: 3.1.0.beta3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamis Buck
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
s/ZUKye79ELwFYKJOhjW5g725OL3hy+llhEleytwKRwgXFQBPTC4f5UkdxZVVWGH
|
32
32
|
e2C9M1m/2odPZo8h
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2016-03-
|
34
|
+
date: 2016-03-07 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: test-unit
|
metadata.gz.sig
CHANGED
Binary file
|