summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklós Fazekas <mfazekas@szemafor.com>2016-03-26 11:11:35 +0100
committerMiklós Fazekas <mfazekas@szemafor.com>2016-03-26 11:11:35 +0100
commitb82d4e965fdcd6d011b49ea7b2bdb0d285b62a63 (patch)
treeea44d20d6acf75a709b384198fbfcd81c6ac5e95
parent9f505d9f04c692d8e443912ed4a6b0fcc95619db (diff)
parentc1714d7512514fd2a09c9c7931451cd5ab1f159a (diff)
downloadnet-ssh-4.0.0.alpha2.tar.gz
Merge pull request #340 from mfazekas/close-chns-on-tr-closev4.0.0.alpha2
Close channels if trasport closed
-rw-r--r--CHANGES.txt4
-rw-r--r--Gemfile17
-rw-r--r--README.rdoc43
-rw-r--r--Rakefile62
-rw-r--r--lib/net/ssh/connection/session.rb13
-rw-r--r--lib/net/ssh/ruby_compat.rb26
-rw-r--r--lib/net/ssh/version.rb2
-rw-r--r--net-ssh.gemspec259
-rw-r--r--test/connection/test_session.rb1
-rw-r--r--test/integration/playbook.yml7
-rw-r--r--test/integration/test_forward.rb102
11 files changed, 173 insertions, 363 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index f7e7c0b..350a224 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,7 @@
+=== 4.0.0.alpha2
+
+* when transport closes we're cleaning up channels [Miklos Fazekas]
+
=== 4.0.0.alpha1
* ed25519 key support [Miklos Fazekas]
diff --git a/Gemfile b/Gemfile
index f83eecd..e5ce235 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,17 +1,4 @@
source 'https://rubygems.org'
-# Note: this is run at package time not install time so if you are
-# running on jruby, you need to install jruby-pageant manually.
-gem 'jruby-pageant', ">=1.1.1" if RUBY_PLATFORM == "java"
-
-gem 'rbnacl-libsodium', ">=1.0.2"
-gem 'rbnacl', ">=3.1.2"
-gem 'bcrypt_pbkdf', '1.0.0.alpha1' unless RUBY_PLATFORM == "java"
-
-
-group :development do
- gem 'rake'
- gem 'test-unit', ">= 0.8.5"
- gem 'mocha'
- gem 'jeweler'
-end
+# Specify your gem's dependencies in mygem.gemspec
+gemspec \ No newline at end of file
diff --git a/README.rdoc b/README.rdoc
index c12ca41..1fcd289 100644
--- a/README.rdoc
+++ b/README.rdoc
@@ -1,17 +1,12 @@
= Net::SSH 4.x
-<em><b>Please note: this project is in maintenance mode. It is not under active development but pull requests are very much welcome. Just be sure to include tests! -- delano</b></em>
-
-
* Docs: http://net-ssh.github.com/net-ssh
* Issues: https://github.com/net-ssh/net-ssh/issues
* Codes: https://github.com/net-ssh/net-ssh
* Email: net-ssh@solutious.com
-
<em>As of v2.6.4, all gem releases are signed. See INSTALL.</em>
-
== DESCRIPTION:
Net::SSH is 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.
@@ -86,18 +81,13 @@ If that spits out something like "OpenSSL 0.9.8g 19 Oct 2007", then you're set.
Additionally: if you are going to be having Net::SSH prompt you for things like passwords or certificate passphrases, you'll want to have either the Highline (recommended) or Termios (unix systems only) gem installed, so that the passwords don't echo in clear text.
-Lastly, if you want to run the tests or use any of the Rake tasks, you'll need:
-
-* Echoe (for the Rakefile)
-* Mocha (for the tests)
+Lastly, if you want to run the tests or use any of the Rake tasks, you'll need Mocha and other dependencies listed in Gemfile
== INSTALL:
* gem install net-ssh (might need sudo privileges)
-NOTE: If you are running on jruby you need to install jruby-pageant manually (gemspec doesn't allow for platform specific dependencies).
-
However, in order to be sure the code you're installing hasn't been tampered with, it's recommended that you verify the signature[http://docs.rubygems.org/read/chapter/21]. To do this, you need to add my public key as a trusted certificate (you only need to do this once):
# Add the public key as a trusted certificate
@@ -111,7 +101,7 @@ Then, when install the gem, do so with high security:
If you don't add the public key, you'll see an error like "Couldn't verify data signature". If you're still having trouble let me know and I'll give you a hand.
-== RUBY 1.x SUPPORT
+== RUBY SUPPORT
* Ruby 1.8.x is supported up until the net-ssh 2.5.1 release.
* Ruby 1.9.x is supported up until the net-ssh 2.9.x release.
@@ -121,40 +111,19 @@ If you don't add the public key, you'll see an error like "Couldn't verify data
Run the test suite from the net-ssh directory with the following command:
- bash -c 'unset HOME && ruby -Ilib -Itest -rrubygems test/test_all.rb'
+ bundle exec rake test
Run a single test file like this:
- ruby -Ilib -Itest -rrubygems test/transport/test_server_version.rb
+ ruby -Ilib -Itest test/transport/test_server_version.rb
To run integration tests see test/integration/README.txt
=== BUILDING GEM
-Since building the gem requires the private key if you want to build a .gem locally please use the NET_SSH_NOKEY=1 envirnoment variable:
-
- rake build NET_SSH_NOKEY=1
-
-=== PORT FORWARDING TESTS
-
- ruby -Ilib -Itest -rrubygems test/manual/test_forward.rb
-
-test_forward.rb must be run separately from the test suite because
-it requires authorizing your public SSH keys on you localhost.
-
-If you already have keys you can do this:
-
- cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
-
-If you don't have keys see:
-
- http://kimmo.suominen.com/docs/ssh/#ssh-keygen
-
-You should now be able to login to your localhost with out
-bring prompted for a password:
-
- ssh localhost
+Since building the gem requires the private key if you want to build a .gem locally please use the NET_SSH_BUILDGEM_UNSIGNED=1 envirnoment variable:
+ rake build NET_SSH_BUILDGEM_UNSIGNED=1
== LICENSE:
diff --git a/Rakefile b/Rakefile
index 8b3a552..bba07b8 100644
--- a/Rakefile
+++ b/Rakefile
@@ -8,7 +8,8 @@
require "rubygems"
require "rake"
require "rake/clean"
-if RUBY_VERSION >= '1.9.0'
+require "bundler/gem_tasks"
+
require "rdoc/task"
task :default => ["build"]
@@ -19,51 +20,6 @@ $:.unshift File.join(File.dirname(__FILE__), 'lib')
require "net/ssh"
version = Net::SSH::Version::CURRENT
-begin
- require "jeweler"
- Jeweler::Tasks.new do |s|
- s.version = version
- s.name = name
- s.rubyforge_project = s.name
- s.summary = "Net::SSH: a pure-Ruby implementation of the SSH2 client protocol."
- s.description = s.summary + " It allows you to write programs that invoke and interact with processes on remote servers, via SSH2."
- s.email = "net-ssh@solutious.com"
- s.homepage = "https://github.com/net-ssh/net-ssh"
- s.authors = ["Jamis Buck", "Delano Mandelbaum", "Miklós Fazekas"]
- s.required_ruby_version = '>= 2.0'
-
- # dependencies defined in Gemfile
- s.license = "MIT"
-
- unless ENV['NET_SSH_NOKEY']
- signing_key = File.join('/mnt/gem/', 'net-ssh-private_key.pem')
- s.signing_key = File.join('/mnt/gem/', 'net-ssh-private_key.pem')
- s.cert_chain = ['net-ssh-public_cert.pem']
- unless (Rake.application.top_level_tasks & ['build','install']).empty?
- raise "No key found at #{signing_key} for signing, use rake <taskname> NET_SSH_NOKEY=1 to build without key" unless File.exist?(signing_key)
- end
- end
- def s.to_ruby
- # see https://github.com/technicalpickles/jeweler/issues/170
- result = super
- result = result.chomp("\n").split("\n").map do |line|
- if line =~ /%q<bcrypt_pbkdf>/
- line += ' unless RUBY_PLATFORM == "java"'
- else
- line
- end
- end.join("\n") << "\n"
- fail "Unexpected gemspec:#{result.inspect}" unless result.chomp!("\nend\n")
- result << "\n s.add_dependency('jruby-pageant', ['>= 1.1.1']) if RUBY_PLATFORM == 'jruby'"
- result << "\nend\n"
- result
- end
- end
- Jeweler::RubygemsDotOrgTasks.new
-rescue LoadError
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
-end
-
extra_files = %w[LICENSE.txt THANKS.txt CHANGES.txt ]
RDoc::Task.new do |rdoc|
rdoc.rdoc_dir = "rdoc"
@@ -77,7 +33,6 @@ RDoc::Task.new do |rdoc|
rdoc.rdoc_files.include(file) if File.exists?(file)
}
end
-end
namespace :rdoc do
desc "Update gh-pages branch"
@@ -105,15 +60,8 @@ end
end
require 'rake/testtask'
-Rake::TestTask.new do |t|
- if ENV['NET_SSH_RUN_INTEGRATION_TESTS']
- t.libs = ["lib","test","test/integration"]
- else
- t.libs = ["lib", "test"]
- end
-end
-Rake::TestTask.new(:'integration-test') do |t|
- t.libs = ["lib", "test/integration"]
- t.pattern = 'test/integration/test_*.rb'
+Rake::TestTask.new do |t|
+ t.libs = ["lib", "test"]
+ t.libs << "test/integration" if ENV['NET_SSH_RUN_INTEGRATION_TESTS']
end
diff --git a/lib/net/ssh/connection/session.rb b/lib/net/ssh/connection/session.rb
index eac0721..de53766 100644
--- a/lib/net/ssh/connection/session.rb
+++ b/lib/net/ssh/connection/session.rb
@@ -475,6 +475,9 @@ module Net; module SSH; module Connection
send(MAP[packet.type], packet)
end
+ rescue
+ force_channel_cleanup_on_close if closed?
+ raise
end
# Returns the next available channel id to be assigned, and increments
@@ -483,6 +486,16 @@ module Net; module SSH; module Connection
@channel_id_counter += 1
end
+ def force_channel_cleanup_on_close
+ channels.each do |id, channel|
+ channel.remote_closed!
+ channel.close
+
+ cleanup_channel(channel)
+ channel.do_close
+ end
+ end
+
# Invoked when a global request is received. The registered global
# request callback will be invoked, if one exists, and the necessary
# reply returned.
diff --git a/lib/net/ssh/ruby_compat.rb b/lib/net/ssh/ruby_compat.rb
index 2e9ef4f..d4abeb4 100644
--- a/lib/net/ssh/ruby_compat.rb
+++ b/lib/net/ssh/ruby_compat.rb
@@ -16,31 +16,9 @@ module Net; module SSH
# This class contains miscellaneous patches and workarounds
# for different ruby implementations.
class Compat
-
- # A workaround for an IO#select threading bug in certain versions of MRI 1.8.
- # See: http://net-ssh.lighthouseapp.com/projects/36253/tickets/1-ioselect-threading-bug-in-ruby-18
- # The root issue is documented here: http://redmine.ruby-lang.org/issues/show/1993
- if RUBY_VERSION >= '1.9' || RUBY_PLATFORM == 'java'
- def self.io_select(*params)
- IO.select(*params)
- end
- else
- SELECT_MUTEX = Mutex.new
- def self.io_select(*params)
- # It should be safe to wrap calls in a mutex when the timeout is 0
- # (that is, the call is not supposed to block).
- # We leave blocking calls unprotected to avoid causing deadlocks.
- # This should still catch the main case for Capistrano users.
- if params[3] == 0
- SELECT_MUTEX.synchronize do
- IO.select(*params)
- end
- else
- IO.select(*params)
- end
- end
+ def self.io_select(*params)
+ IO.select(*params)
end
-
end
end; end
diff --git a/lib/net/ssh/version.rb b/lib/net/ssh/version.rb
index c1b1134..e4477f2 100644
--- a/lib/net/ssh/version.rb
+++ b/lib/net/ssh/version.rb
@@ -55,7 +55,7 @@ module Net; module SSH
# The prerelease component of this version of the Net::SSH library
# nil allowed
- PRE = "alpha1"
+ PRE = "alpha2"
# The current version of the Net::SSH library as a Version instance
CURRENT = new(*[MAJOR, MINOR, TINY, PRE].compact)
diff --git a/net-ssh.gemspec b/net-ssh.gemspec
index 64f8873..e2f7a87 100644
--- a/net-ssh.gemspec
+++ b/net-ssh.gemspec
@@ -1,233 +1,42 @@
-# Generated by jeweler
-# DO NOT EDIT THIS FILE DIRECTLY
-# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
-# -*- encoding: utf-8 -*-
-# stub: net-ssh 4.0.0.alpha1 ruby lib
+# coding: utf-8
+require_relative 'lib/net/ssh/version'
-Gem::Specification.new do |s|
- s.name = "net-ssh"
- s.version = "4.0.0.alpha1"
+Gem::Specification.new do |spec|
+ spec.name = "net-ssh"
+ spec.version = Net::SSH::Version::STRING
+ spec.authors = ["Jamis Buck", "Delano Mandelbaum", "Mikl\u{f3}s Fazekas"]
+ spec.email = ["net-ssh@solutious.com"]
- s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
- s.require_paths = ["lib"]
- s.authors = ["Jamis Buck", "Delano Mandelbaum", "Mikl\u{f3}s Fazekas"]
- s.cert_chain = ["net-ssh-public_cert.pem"]
- s.date = "2016-03-19"
- 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."
- s.email = "net-ssh@solutious.com"
- s.extra_rdoc_files = [
+ unless ENV['NET_SSH_BUILDGEM_UNSIGNED']
+ spec.cert_chain = ["net-ssh-public_cert.pem"]
+ spec.signing_key = "/mnt/gem/net-ssh-private_key.pem"
+ end
+
+ spec.summary = %q{Net::SSH: a pure-Ruby implementation of the SSH2 client protocol.}
+ spec.description = %q{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.}
+ spec.homepage = "https://github.com/net-ssh/net-ssh"
+ spec.license = "MIT"
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.0")
+
+ spec.extra_rdoc_files = [
"LICENSE.txt",
"README.rdoc"
]
- s.files = [
- ".travis.yml",
- "CHANGES.txt",
- "Gemfile",
- "LICENSE.txt",
- "Manifest",
- "README.rdoc",
- "Rakefile",
- "THANKS.txt",
- "lib/net/ssh.rb",
- "lib/net/ssh/authentication/agent.rb",
- "lib/net/ssh/authentication/agent/java_pageant.rb",
- "lib/net/ssh/authentication/agent/socket.rb",
- "lib/net/ssh/authentication/constants.rb",
- "lib/net/ssh/authentication/ed25519.rb",
- "lib/net/ssh/authentication/key_manager.rb",
- "lib/net/ssh/authentication/methods/abstract.rb",
- "lib/net/ssh/authentication/methods/hostbased.rb",
- "lib/net/ssh/authentication/methods/keyboard_interactive.rb",
- "lib/net/ssh/authentication/methods/none.rb",
- "lib/net/ssh/authentication/methods/password.rb",
- "lib/net/ssh/authentication/methods/publickey.rb",
- "lib/net/ssh/authentication/pageant.rb",
- "lib/net/ssh/authentication/session.rb",
- "lib/net/ssh/buffer.rb",
- "lib/net/ssh/buffered_io.rb",
- "lib/net/ssh/config.rb",
- "lib/net/ssh/connection/channel.rb",
- "lib/net/ssh/connection/constants.rb",
- "lib/net/ssh/connection/keepalive.rb",
- "lib/net/ssh/connection/session.rb",
- "lib/net/ssh/connection/term.rb",
- "lib/net/ssh/errors.rb",
- "lib/net/ssh/key_factory.rb",
- "lib/net/ssh/known_hosts.rb",
- "lib/net/ssh/loggable.rb",
- "lib/net/ssh/packet.rb",
- "lib/net/ssh/prompt.rb",
- "lib/net/ssh/proxy/command.rb",
- "lib/net/ssh/proxy/errors.rb",
- "lib/net/ssh/proxy/http.rb",
- "lib/net/ssh/proxy/socks4.rb",
- "lib/net/ssh/proxy/socks5.rb",
- "lib/net/ssh/ruby_compat.rb",
- "lib/net/ssh/service/forward.rb",
- "lib/net/ssh/test.rb",
- "lib/net/ssh/test/channel.rb",
- "lib/net/ssh/test/extensions.rb",
- "lib/net/ssh/test/kex.rb",
- "lib/net/ssh/test/local_packet.rb",
- "lib/net/ssh/test/packet.rb",
- "lib/net/ssh/test/remote_packet.rb",
- "lib/net/ssh/test/script.rb",
- "lib/net/ssh/test/socket.rb",
- "lib/net/ssh/transport/algorithms.rb",
- "lib/net/ssh/transport/cipher_factory.rb",
- "lib/net/ssh/transport/constants.rb",
- "lib/net/ssh/transport/ctr.rb",
- "lib/net/ssh/transport/hmac.rb",
- "lib/net/ssh/transport/hmac/abstract.rb",
- "lib/net/ssh/transport/hmac/md5.rb",
- "lib/net/ssh/transport/hmac/md5_96.rb",
- "lib/net/ssh/transport/hmac/none.rb",
- "lib/net/ssh/transport/hmac/ripemd160.rb",
- "lib/net/ssh/transport/hmac/sha1.rb",
- "lib/net/ssh/transport/hmac/sha1_96.rb",
- "lib/net/ssh/transport/hmac/sha2_256.rb",
- "lib/net/ssh/transport/hmac/sha2_256_96.rb",
- "lib/net/ssh/transport/hmac/sha2_512.rb",
- "lib/net/ssh/transport/hmac/sha2_512_96.rb",
- "lib/net/ssh/transport/identity_cipher.rb",
- "lib/net/ssh/transport/kex.rb",
- "lib/net/ssh/transport/kex/diffie_hellman_group14_sha1.rb",
- "lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb",
- "lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb",
- "lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha256.rb",
- "lib/net/ssh/transport/kex/ecdh_sha2_nistp256.rb",
- "lib/net/ssh/transport/kex/ecdh_sha2_nistp384.rb",
- "lib/net/ssh/transport/kex/ecdh_sha2_nistp521.rb",
- "lib/net/ssh/transport/key_expander.rb",
- "lib/net/ssh/transport/openssl.rb",
- "lib/net/ssh/transport/packet_stream.rb",
- "lib/net/ssh/transport/server_version.rb",
- "lib/net/ssh/transport/session.rb",
- "lib/net/ssh/transport/state.rb",
- "lib/net/ssh/verifiers/lenient.rb",
- "lib/net/ssh/verifiers/null.rb",
- "lib/net/ssh/verifiers/secure.rb",
- "lib/net/ssh/verifiers/strict.rb",
- "lib/net/ssh/version.rb",
- "net-ssh-public_cert.pem",
- "net-ssh.gemspec",
- "setup.rb",
- "support/arcfour_check.rb",
- "support/ssh_tunnel_bug.rb",
- "test/README.txt",
- "test/authentication/methods/common.rb",
- "test/authentication/methods/test_abstract.rb",
- "test/authentication/methods/test_hostbased.rb",
- "test/authentication/methods/test_keyboard_interactive.rb",
- "test/authentication/methods/test_none.rb",
- "test/authentication/methods/test_password.rb",
- "test/authentication/methods/test_publickey.rb",
- "test/authentication/test_agent.rb",
- "test/authentication/test_ed25519.rb",
- "test/authentication/test_key_manager.rb",
- "test/authentication/test_session.rb",
- "test/common.rb",
- "test/configs/auth_off",
- "test/configs/auth_on",
- "test/configs/empty",
- "test/configs/eqsign",
- "test/configs/exact_match",
- "test/configs/host_plus",
- "test/configs/multihost",
- "test/configs/negative_match",
- "test/configs/nohost",
- "test/configs/numeric_host",
- "test/configs/proxy_remote_user",
- "test/configs/send_env",
- "test/configs/substitutes",
- "test/configs/wild_cards",
- "test/connection/test_channel.rb",
- "test/connection/test_session.rb",
- "test/integration/README.md",
- "test/integration/Vagrantfile",
- "test/integration/common.rb",
- "test/integration/playbook.yml",
- "test/integration/test_ed25519_pkeys.rb",
- "test/integration/test_forward.rb",
- "test/integration/test_id_rsa_keys.rb",
- "test/integration/test_proxy.rb",
- "test/known_hosts/github",
- "test/known_hosts/github_hash",
- "test/manual/test_pageant.rb",
- "test/start/test_connection.rb",
- "test/start/test_options.rb",
- "test/start/test_transport.rb",
- "test/start/test_user_nil.rb",
- "test/test_all.rb",
- "test/test_buffer.rb",
- "test/test_buffered_io.rb",
- "test/test_config.rb",
- "test/test_key_factory.rb",
- "test/test_known_hosts.rb",
- "test/transport/hmac/test_md5.rb",
- "test/transport/hmac/test_md5_96.rb",
- "test/transport/hmac/test_none.rb",
- "test/transport/hmac/test_ripemd160.rb",
- "test/transport/hmac/test_sha1.rb",
- "test/transport/hmac/test_sha1_96.rb",
- "test/transport/hmac/test_sha2_256.rb",
- "test/transport/hmac/test_sha2_256_96.rb",
- "test/transport/hmac/test_sha2_512.rb",
- "test/transport/hmac/test_sha2_512_96.rb",
- "test/transport/kex/test_diffie_hellman_group14_sha1.rb",
- "test/transport/kex/test_diffie_hellman_group1_sha1.rb",
- "test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb",
- "test/transport/kex/test_diffie_hellman_group_exchange_sha256.rb",
- "test/transport/kex/test_ecdh_sha2_nistp256.rb",
- "test/transport/kex/test_ecdh_sha2_nistp384.rb",
- "test/transport/kex/test_ecdh_sha2_nistp521.rb",
- "test/transport/test_algorithms.rb",
- "test/transport/test_cipher_factory.rb",
- "test/transport/test_hmac.rb",
- "test/transport/test_identity_cipher.rb",
- "test/transport/test_packet_stream.rb",
- "test/transport/test_server_version.rb",
- "test/transport/test_session.rb",
- "test/transport/test_state.rb",
- "test/verifiers/test_secure.rb"
- ]
- s.homepage = "https://github.com/net-ssh/net-ssh"
- s.licenses = ["MIT"]
- s.required_ruby_version = Gem::Requirement.new(">= 2.0")
- s.rubyforge_project = "net-ssh"
- s.rubygems_version = "2.4.6"
- s.signing_key = "/mnt/gem/net-ssh-private_key.pem"
- s.summary = "Net::SSH: a pure-Ruby implementation of the SSH2 client protocol."
+
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ spec.bindir = "exe"
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
+ spec.require_paths = ["lib"]
- if s.respond_to? :specification_version then
- s.specification_version = 4
+ spec.add_runtime_dependency("rbnacl-libsodium", ">= 1.0.2")
+ spec.add_runtime_dependency("rbnacl", ">= 3.1.2")
+ spec.add_runtime_dependency("bcrypt_pbkdf", "= 1.0.0.alpha1") unless RUBY_PLATFORM == "java"
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<rbnacl-libsodium>, [">= 1.0.2"])
- s.add_runtime_dependency(%q<rbnacl>, [">= 3.1.2"])
- s.add_runtime_dependency(%q<bcrypt_pbkdf>, ["= 1.0.0.alpha1"]) unless RUBY_PLATFORM == "java"
- s.add_development_dependency(%q<rake>, [">= 0"])
- s.add_development_dependency(%q<test-unit>, [">= 0.8.5"])
- s.add_development_dependency(%q<mocha>, [">= 0"])
- s.add_development_dependency(%q<jeweler>, [">= 0"])
- else
- s.add_dependency(%q<rbnacl-libsodium>, [">= 1.0.2"])
- s.add_dependency(%q<rbnacl>, [">= 3.1.2"])
- s.add_dependency(%q<bcrypt_pbkdf>, ["= 1.0.0.alpha1"]) unless RUBY_PLATFORM == "java"
- s.add_dependency(%q<rake>, [">= 0"])
- s.add_dependency(%q<test-unit>, [">= 0.8.5"])
- s.add_dependency(%q<mocha>, [">= 0"])
- s.add_dependency(%q<jeweler>, [">= 0"])
- end
- else
- s.add_dependency(%q<rbnacl-libsodium>, [">= 1.0.2"])
- s.add_dependency(%q<rbnacl>, [">= 3.1.2"])
- s.add_dependency(%q<bcrypt_pbkdf>, ["= 1.0.0.alpha1"]) unless RUBY_PLATFORM == "java"
- s.add_dependency(%q<rake>, [">= 0"])
- s.add_dependency(%q<test-unit>, [">= 0.8.5"])
- s.add_dependency(%q<mocha>, [">= 0"])
- s.add_dependency(%q<jeweler>, [">= 0"])
- end
- s.add_dependency('jruby-pageant', ['>= 1.1.1']) if RUBY_PLATFORM == 'jruby'
-end
+ spec.add_development_dependency "bundler", "~> 1.11"
+ spec.add_development_dependency "rake", "~> 11.1"
+ spec.add_development_dependency "minitest", "~> 5.0"
+ spec.add_development_dependency("mocha", ">= 1.1.0")
+
+ spec.add_dependency('jruby-pageant', '>= 1.1.1') if RUBY_PLATFORM == 'jruby'
+end
diff --git a/test/connection/test_session.rb b/test/connection/test_session.rb
index 404d129..663a374 100644
--- a/test/connection/test_session.rb
+++ b/test/connection/test_session.rb
@@ -182,6 +182,7 @@ module Connection
end
def test_global_request_handler_returning_other_value_should_raise_error
+ socket.expects(:closed?).returns(false)
session.on_global_request("testing") { "bug" }
transport.return(GLOBAL_REQUEST, :string, "testing", :bool, true)
assert_raises(RuntimeError) { process_times(2) }
diff --git a/test/integration/playbook.yml b/test/integration/playbook.yml
index 50d76d0..40f7ec3 100644
--- a/test/integration/playbook.yml
+++ b/test/integration/playbook.yml
@@ -6,6 +6,8 @@
ruby_versions:
- '2.0.0-p598'
- '2.3.0'
+# - 'rbx-3.19'
+# - 'jruby-9.0.5.0'
rvm_install_path: '/usr/local/rvm'
foopwd: "$6$mhOzf/yapZwS$3RwDl4GfWZ5VcfcsHrK9xNNTxyzLOJBsmMttDNaegIbXxMahV86.v/5HsNtit16MEl0EFf5CSW8Dz2yXV.8GB0"
foo2pwd: "$6$JiB7y7.M0yI$Abt.ZGIc4DwkRWeI6nKxzzPUZcux7hLRXSdpoKoZvswJz1SZyg5GRQWn9pGID0dgC6e4wFglfW6ev/qZoTqGk/"
@@ -17,7 +19,7 @@
roles:
- { role: rvm_io.rvm1-ruby,
tags: ruby, sudo: True,
- rvm1_rubies: ["ruby-{{ruby_version}}","ruby-2.3.0"],
+ rvm1_rubies: "{{ ruby_versions }}",
rvm1_install_path: "{{rvm_install_path}}",
rvm1_gpg_key_server: pool.sks-keyservers.net,
when: "'{{current_ruby_version.stdout|default()}}' != '{{ruby_version}}'" }
@@ -46,10 +48,11 @@
with_items:
- pv
- libgmp3-dev
+ - git
- gem: name="{{ item[1] }}" state=present user_install=no executable=/usr/local/rvm/wrappers/ruby-{{ item[0] }}/gem
with_nested:
- "{{ruby_versions}}"
- - [ 'byebug', 'jeweler', 'mocha', 'rbnacl', 'rbnacl-libsodium' ]
+ - [ 'byebug', 'rake', 'jeweler', 'mocha', 'rbnacl', 'rbnacl-libsodium' ]
- copy: content='echo "cd /net-ssh ; rake integration-test"' dest=/etc/update-motd.d/99-net-ssh-tests mode=0755
handlers:
- name: restart sshd
diff --git a/test/integration/test_forward.rb b/test/integration/test_forward.rb
index bcef724..07f0866 100644
--- a/test/integration/test_forward.rb
+++ b/test/integration/test_forward.rb
@@ -17,6 +17,7 @@
require_relative './common'
require 'net/ssh/buffer'
require 'net/ssh'
+require 'net/ssh/proxy/command'
require 'timeout'
require 'tempfile'
@@ -31,8 +32,8 @@ class TestForward < Test::Unit::TestCase
'net_ssh_1'
end
- def ssh_start_params
- [localhost ,user , {:keys => @key_id_rsa}]
+ def ssh_start_params(options = {})
+ [localhost ,user , {:keys => @key_id_rsa}.merge(options)]
end
def setup_ssh_env(&block)
@@ -338,6 +339,103 @@ class TestForward < Test::Unit::TestCase
end
end
+ class TCPProxy
+ def initialize()
+ @sockets = []
+ end
+ attr_reader :sockets
+
+ def open(host, port, connection_options = nil)
+ socket = TCPSocket.new(host,port)
+ @sockets << socket
+ socket
+ end
+
+ def close_all
+ sockets.each do |socket|
+ socket.close
+ end
+ end
+ end
+
+ def test_transport_close_should_closes_channels_with_tcps
+ setup_ssh_env do
+ server = start_server do |client|
+ client.puts "Hello"
+ sleep(100)
+ client.puts "Hallo"
+ end
+ proxy = TCPProxy.new()
+ session = Net::SSH.start(*ssh_start_params(proxy: proxy))
+ remote_port = server.addr[1]
+ local_port = session.forward.local(0, localhost, remote_port)
+
+ # read on forwarded port
+ client_done = Queue.new
+ Thread.start do
+ begin
+ client = TCPSocket.new(localhost, local_port)
+ client.read(6)
+ proxy.close_all
+ client.read(7)
+ client.close
+ client_done << true
+ rescue
+ client_done << $!
+ end
+ end
+ Timeout.timeout(5) do
+ begin
+ session.loop(0.1) { true }
+ rescue EOFError, IOError
+ #puts "Error: #{$!} #{$!.backtrace.join("\n")}"
+ end
+ assert_equal true, client_done.pop
+ end
+ end
+ end
+
+ def todo_test_transport_close_should_closes_channels_with_proxy
+ setup_ssh_env do
+ server = start_server do |client|
+ client.puts "Hello"
+ sleep(100)
+ client.puts "Hallo"
+ end
+ proxy = Net::SSH::Proxy::Command.new("/bin/nc localhost 22")
+ session = Net::SSH.start(*ssh_start_params(proxy: proxy))
+ remote_port = server.addr[1]
+ local_port = session.forward.local(0, localhost, remote_port)
+
+ # read on forwarded port
+ client_done = Queue.new
+ Thread.start do
+ begin
+ client = TCPSocket.new(localhost, local_port)
+ client.read(6)
+ system("killall /bin/nc")
+ client.read(7)
+ client.close
+ client_done << true
+ rescue
+ client_done << $!
+ end
+ end
+ Timeout.timeout(5) do
+ begin
+ session.loop(0.1) { true }
+ rescue EOFError
+ begin
+ session.close
+ rescue
+ end
+ #puts "Error: #{$!} #{$!.backtrace.join("\n")}"
+ end
+ assert_equal true, client_done.pop
+ end
+ end
+ end
+
def test_client_close_should_be_handled
setup_ssh_env do
message = "This is a small message!"*1000