net-ssh 2.0.8 → 2.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,16 @@
1
+ === 2.0.9 / 1 Feb 2009
2
+
3
+ * Specifying non-nil user argument overrides user in .ssh/config [Jamis Buck]
4
+
5
+ * Ignore requests for non-existent channels (workaround ssh server bug) [Jamis Buck]
6
+
7
+ * Add terminate! method for hard shutdown scenarios [Jamis Buck]
8
+
9
+ * Revert to pre-2.0.7 key-loading behavior by default, but load private-key if public-key doesn't exist [Jamis Buck]
10
+
11
+ * Make sure :passphrase option gets passed to key manager [Bob Cotton]
12
+
13
+
1
14
  === 2.0.8 / 29 December 2008
2
15
 
3
16
  * Fix private key change from 2.0.7 so that keys are loaded just-in-time, avoiding unecessary prompts from encrypted keys. [Jamis Buck]
@@ -159,6 +159,7 @@ module Net
159
159
  else Array(options[:config])
160
160
  end
161
161
 
162
+ options[:user] = user if user
162
163
  options = Net::SSH::Config.for(host, files).merge(options)
163
164
  host = options.fetch(:host_name, host)
164
165
 
@@ -196,4 +197,4 @@ module Net
196
197
  end
197
198
  end
198
199
  end
199
- end
200
+ end
@@ -88,14 +88,23 @@ module Net
88
88
  end
89
89
 
90
90
  key_files.each do |file|
91
- if File.readable?(file)
91
+ public_key_file = file + ".pub"
92
+ if File.readable?(public_key_file)
92
93
  begin
93
- private_key = KeyFactory.load_private_key(file)
94
- key = private_key.send :public_key
94
+ key = KeyFactory.load_public_key(public_key_file)
95
95
  known_identities[key] = { :from => :file, :file => file }
96
96
  yield key
97
97
  rescue Exception => e
98
- error { "could not load public key file `#{file}.pub': #{e.class} (#{e.message})" }
98
+ error { "could not load public key file `#{public_key_file}': #{e.class} (#{e.message})" }
99
+ end
100
+ elsif File.readable?(file)
101
+ begin
102
+ private_key = KeyFactory.load_private_key(file, options[:passphrase])
103
+ key = private_key.send(:public_key)
104
+ known_identities[key] = { :from => :file, :file => file, :key => private_key }
105
+ yield key
106
+ rescue Exception => e
107
+ error { "could not load private key file `#{file}': #{e.class} (#{e.message})" }
99
108
  end
100
109
  end
101
110
  end
@@ -46,6 +46,16 @@ module Net; module SSH; module Connection
46
46
  # The list of callbacks for pending requests. See #send_global_request.
47
47
  attr_reader :pending_requests #:nodoc:
48
48
 
49
+ class NilChannel
50
+ def initialize(session)
51
+ @session = session
52
+ end
53
+
54
+ def method_missing(sym, *args)
55
+ @session.lwarn { "ignoring request #{sym.inspect} for non-existent (closed?) channel; probably ssh server bug" }
56
+ end
57
+ end
58
+
49
59
  # Create a new connection service instance atop the given transport
50
60
  # layer. Initializes the listeners to be only the underlying socket object.
51
61
  def initialize(transport, options={})
@@ -55,7 +65,7 @@ module Net; module SSH; module Connection
55
65
  @options = options
56
66
 
57
67
  @channel_id_counter = -1
58
- @channels = {}
68
+ @channels = Hash.new(NilChannel.new(self))
59
69
  @listeners = { transport.socket => nil }
60
70
  @pending_requests = []
61
71
  @channel_open_handlers = {}
@@ -100,6 +110,14 @@ module Net; module SSH; module Connection
100
110
  transport.close
101
111
  end
102
112
 
113
+ # Performs a "hard" shutdown of the connection. In general, this should
114
+ # never be done, but it might be necessary (in a rescue clause, for instance,
115
+ # when the connection needs to close but you don't know the status of the
116
+ # underlying protocol's state).
117
+ def shutdown!
118
+ transport.shutdown!
119
+ end
120
+
103
121
  # preserve a reference to Kernel#loop
104
122
  alias :loop_forever :loop
105
123
 
@@ -575,4 +593,4 @@ module Net; module SSH; module Connection
575
593
  end
576
594
  end
577
595
 
578
- end; end; end
596
+ end; end; end
@@ -104,6 +104,15 @@ module Net; module SSH; module Transport
104
104
  socket.close
105
105
  end
106
106
 
107
+ # Performs a "hard" shutdown of the connection. In general, this should
108
+ # never be done, but it might be necessary (in a rescue clause, for instance,
109
+ # when the connection needs to close but you don't know the status of the
110
+ # underlying protocol's state).
111
+ def shutdown!
112
+ error { "forcing connection closed" }
113
+ socket.close
114
+ end
115
+
107
116
  # Returns a new service_request packet for the given service name, ready
108
117
  # for sending to the server.
109
118
  def service_request(service)
@@ -264,4 +273,4 @@ module Net; module SSH; module Transport
264
273
  end
265
274
  end
266
275
  end
267
- end; end; end
276
+ end; end; end
@@ -51,7 +51,7 @@ module Net; module SSH
51
51
  MINOR = 0
52
52
 
53
53
  # The tiny component of this version of the Net::SSH library
54
- TINY = 8
54
+ TINY = 9
55
55
 
56
56
  # The current version of the Net::SSH library as a Version instance
57
57
  CURRENT = new(MAJOR, MINOR, TINY)
@@ -1,10 +1,10 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{net-ssh}
3
- s.version = "2.0.8"
3
+ s.version = "2.0.9"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Jamis Buck"]
7
- s.date = %q{2008-12-29}
7
+ s.date = %q{2009-02-01}
8
8
  s.description = %q{a pure-Ruby implementation of the SSH2 client protocol}
9
9
  s.email = %q{jamis@jamisbuck.org}
10
10
  s.extra_rdoc_files = ["CHANGELOG.rdoc", "lib/net/ssh/authentication/agent.rb", "lib/net/ssh/authentication/constants.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/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/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/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/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/test.rb", "lib/net/ssh/transport/algorithms.rb", "lib/net/ssh/transport/cipher_factory.rb", "lib/net/ssh/transport/constants.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/sha1.rb", "lib/net/ssh/transport/hmac/sha1_96.rb", "lib/net/ssh/transport/hmac.rb", "lib/net/ssh/transport/identity_cipher.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.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/strict.rb", "lib/net/ssh/version.rb", "lib/net/ssh.rb", "README.rdoc", "THANKS.rdoc"]
@@ -41,8 +41,8 @@ module Authentication
41
41
  assert_equal rsa.to_blob, identities.first.to_blob
42
42
  assert_equal dsa.to_blob, identities.last.to_blob
43
43
 
44
- assert_equal({:from => :file, :file => "/first"}, manager.known_identities[rsa])
45
- assert_equal({:from => :file, :file => "/second"}, manager.known_identities[dsa])
44
+ assert_equal({:from => :file, :file => "/first", :key => rsa}, manager.known_identities[rsa])
45
+ assert_equal({:from => :file, :file => "/second", :key => dsa}, manager.known_identities[dsa])
46
46
  end
47
47
 
48
48
  def test_identities_should_load_from_agent
@@ -78,7 +78,8 @@ module Authentication
78
78
 
79
79
  def stub_file_key(name, key, also_private=false)
80
80
  manager.add(name)
81
- File.expects(:readable?).returns(true)
81
+ File.expects(:readable?).with(name).returns(true)
82
+ File.expects(:readable?).with(name + ".pub").returns(false)
82
83
  Net::SSH::KeyFactory.expects(:load_private_key).with(name, nil).returns(key).at_least_once
83
84
  key.expects(:public_key).returns(key)
84
85
  end
@@ -257,6 +257,11 @@ module Connection
257
257
  process_times(2)
258
258
  end
259
259
 
260
+ def test_channel_request_for_nonexistant_channel_should_be_ignored
261
+ transport.return(CHANNEL_REQUEST, :long, 14, :string, "testing", :bool, false)
262
+ assert_nothing_raised { process_times(2) }
263
+ end
264
+
260
265
  def test_channel_request_packet_should_be_routed_to_corresponding_channel
261
266
  channel_at(14).expects(:do_request).with("testing", false, Net::SSH::Buffer.new)
262
267
  transport.return(CHANNEL_REQUEST, :long, 14, :string, "testing", :bool, false)
@@ -480,4 +485,4 @@ module Connection
480
485
  end
481
486
  end
482
487
 
483
- end
488
+ 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: 2.0.8
4
+ version: 2.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamis Buck
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-29 00:00:00 -07:00
12
+ date: 2009-02-01 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency