net-ssh 1.1.1 → 1.1.2

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.
@@ -122,7 +122,7 @@ module Net
122
122
  user = proxy_user
123
123
  passwd = proxy_password
124
124
 
125
- packet = [ SOCKS_VERSION,
125
+ packet = [ 0x01,
126
126
  user.length, user,
127
127
  passwd.length, passwd ].pack( "CCA*CA*" )
128
128
 
@@ -38,7 +38,7 @@ module Net
38
38
  end
39
39
 
40
40
  def do_open_channel( connection, channel, data )
41
- channel.on_data &method(:do_data)
41
+ channel.on_data(&method(:do_data))
42
42
  end
43
43
 
44
44
  # handle CHANNEL_DATA packets received on the agent-forward
@@ -127,8 +127,8 @@ module Net
127
127
  # server. This is where the command to execute will be sent to the
128
128
  # server.
129
129
  def do_confirm( channel )
130
- channel.on_success &method(:do_exec_success)
131
- channel.on_failure &method(:do_exec_failure)
130
+ channel.on_success(&method(:do_exec_success))
131
+ channel.on_failure(&method(:do_exec_failure))
132
132
  channel.exec @command, true
133
133
  end
134
134
 
@@ -136,10 +136,10 @@ module Net
136
136
  # This registers various callbacks, and then calls the +on_success+
137
137
  # callback (if registered).
138
138
  def do_exec_success( channel )
139
- channel.on_data &method(:do_data)
140
- channel.on_extended_data &method(:do_extended_data)
141
- channel.on_close &method(:do_close)
142
- channel.on_request &method(:do_request)
139
+ channel.on_data(&method(:do_data))
140
+ channel.on_extended_data(&method(:do_extended_data))
141
+ channel.on_close(&method(:do_close))
142
+ channel.on_request(&method(:do_request))
143
143
  @on_success.call( self ) if @on_success
144
144
  end
145
145
 
@@ -140,7 +140,7 @@ module Net
140
140
  # pipe should ever be associated with a channel.
141
141
  def initialize( channel )
142
142
  super( channel )
143
- channel.on_data &method(:do_data)
143
+ channel.on_data(&method(:do_data))
144
144
  end
145
145
 
146
146
  # Invoked when data is recieved from the channel. It simply
@@ -159,7 +159,7 @@ module Net
159
159
  # pipe should ever be associated with a channel.
160
160
  def initialize( channel )
161
161
  super( channel )
162
- channel.on_extended_data &method(:do_data)
162
+ channel.on_extended_data(&method(:do_data))
163
163
  end
164
164
 
165
165
  # Invoked when data is recieved from the channel. It simply
@@ -15,12 +15,15 @@
15
15
  #++
16
16
 
17
17
  require 'stringio'
18
+ require 'net/ssh/errors'
18
19
 
19
20
  module Net
20
21
  module SSH
21
22
  module Service
22
23
  module Shell
23
24
 
25
+ class OpenFailed < Net::SSH::Exception; end
26
+
24
27
  # A service class for interacting with a user's shell on a remote
25
28
  # machine. The shell may be interacted with either with or without a
26
29
  # pty.
@@ -128,6 +131,7 @@ module Net
128
131
  def on_confirm( channel )
129
132
  @channel = channel
130
133
 
134
+ @channel.on_confirm_failed( &method( :on_confirm_failed ) )
131
135
  @channel.on_close( &method( :on_close ) )
132
136
  @channel.on_data( &method( :on_data ) )
133
137
  @channel.on_eof( &method( :on_eof ) )
@@ -156,6 +160,11 @@ module Net
156
160
  @channel.send_request "shell", nil, true
157
161
  end
158
162
 
163
+ # Called when the channel could not be opened for some reason.
164
+ def on_confirm_failed( channel, reason, description, *args )
165
+ raise OpenFailed, "#{reason} (#{description})"
166
+ end
167
+
159
168
  # Invoked when the channel closes. Changes the shell's state to
160
169
  # closed.
161
170
  def on_close( channel )
@@ -282,7 +282,7 @@ module Net
282
282
  Net::SSH::NullHostKeyVerifier.new
283
283
  when :very then
284
284
  require 'net/ssh/host-key-verifier'
285
- Net::SS::HostKeyVerifier.new
285
+ Net::SSH::HostKeyVerifier.new
286
286
  else
287
287
  if paranoia.respond_to?(:verify)
288
288
  paranoia
@@ -16,6 +16,7 @@
16
16
 
17
17
  require 'net/ssh/errors'
18
18
  require 'net/ssh/transport/constants'
19
+ require 'net/ssh/known-hosts'
19
20
 
20
21
  module Net
21
22
  module SSH
@@ -68,9 +69,16 @@ module Net
68
69
 
69
70
  # Builds the @algorithms hash from the values specified in the
70
71
  # +options+ hash.
71
- def prepare_preferred_algorithms( options )
72
+ def prepare_preferred_algorithms( session, options )
72
73
  @algorithms = Hash.new
73
74
 
75
+ if !options.key?(:host_key)
76
+ keys = Net::SSH::KnownHosts.search_for(Net::SSH::KnownHosts.canonize(session.host, session.port))
77
+ preferred_order = []
78
+ preferred_order << keys.first.ssh_type if keys.any?
79
+ options = options.merge(:host_key => preferred_order)
80
+ end
81
+
74
82
  prepare_preferred_algorithm options, :host_key
75
83
  prepare_preferred_algorithm options, :kex
76
84
  prepare_preferred_algorithm options, :encryption
@@ -99,7 +107,7 @@ module Net
99
107
  # cannot be reached between what the client wants and what the server
100
108
  # can provide, this will fail.
101
109
  def negotiate( session, options )
102
- prepare_preferred_algorithms options
110
+ prepare_preferred_algorithms session, options
103
111
 
104
112
  # first, discover what the server can do
105
113
  type, buffer = session.wait_for_message
@@ -170,7 +170,7 @@ module Net
170
170
  # then validate it.
171
171
  hmac = @hmac.mac_length > 0 ? read( @hmac.mac_length ) : ""
172
172
 
173
- reader.append @cipher.update( data )
173
+ reader.append @cipher.update( data ) unless data.empty?
174
174
  reader.append @cipher.final
175
175
 
176
176
  padding_length = reader.read_byte
@@ -36,6 +36,12 @@ module Net
36
36
  # the collection of algorithms currently being used
37
37
  attr_reader :algorithms
38
38
 
39
+ # the hostname that was requested
40
+ attr_reader :host
41
+
42
+ # the port that was requested
43
+ attr_reader :port
44
+
39
45
  attr_writer :logger
40
46
  attr_writer :default_port
41
47
  attr_writer :version_negotiator
@@ -87,7 +87,7 @@ module Net
87
87
  msg = @buffers.writer
88
88
  msg.write_byte USERAUTH_INFO_RESPONSE
89
89
  msg.write_long responses.length
90
- msg.write_string *responses
90
+ msg.write_string(*responses)
91
91
  @messenger.send_message msg
92
92
  else
93
93
  raise Net::SSH::Exception,
@@ -126,7 +126,7 @@ module Net
126
126
  driver.set_host_key_files c[:userauth_host_keys]
127
127
  end
128
128
  if c.knows_key?(:userauth_method_order) && c[:userauth_method_order]
129
- driver.set_auth_method_order *c[:userauth_method_order]
129
+ driver.set_auth_method_order(*c[:userauth_method_order])
130
130
  end
131
131
 
132
132
  driver
@@ -20,7 +20,7 @@ module Net
20
20
 
21
21
  MAJOR = 1
22
22
  MINOR = 1
23
- TINY = 1
23
+ TINY = 2
24
24
 
25
25
  STRING = [ MAJOR, MINOR, TINY ].join( "." )
26
26
 
@@ -181,7 +181,7 @@ class TC_Proxy_SOCKS5 < Test::Unit::TestCase
181
181
 
182
182
  @server.wait
183
183
 
184
- assert_equal [ "\5\2\0\2", "\5\3foo\3bar" ], @server.events
184
+ assert_equal [ "\5\2\0\2", "\1\3foo\3bar" ], @server.events
185
185
  end
186
186
 
187
187
  [
@@ -206,7 +206,7 @@ class TC_Proxy_SOCKS5 < Test::Unit::TestCase
206
206
 
207
207
  @server.wait
208
208
 
209
- assert_equal [ "\5\2\0\2", "\5\3foo\3bar",
209
+ assert_equal [ "\5\2\0\2", "\1\3foo\3bar",
210
210
  "\5\1\0\3\11test.host\4\322" ], @server.events
211
211
  end
212
212
  end
@@ -126,7 +126,7 @@ class TC_Forward_Driver < Test::Unit::TestCase
126
126
  assert_equal 0, @driver.open_direct_channel_count
127
127
  assert @driver.active_locals.empty?
128
128
 
129
- @driver.local *args
129
+ @driver.local(*args)
130
130
 
131
131
  address = '127.0.0.1'
132
132
  address = args.shift if args.first.is_a? String
@@ -34,6 +34,7 @@ class TC_AlgorithmNegotiator < Test::Unit::TestCase
34
34
 
35
35
  class ScriptedSession
36
36
  attr_reader :messages
37
+ attr_reader :host, :port
37
38
 
38
39
  def initialize( *script )
39
40
  @script = script
@@ -98,7 +98,7 @@ class TC_Session < Test::Unit::TestCase
98
98
  @on_new_algos = block
99
99
  end
100
100
  def set_algorithms( *args )
101
- @on_new_algos.call *args if @on_new_algos
101
+ @on_new_algos.call(*args) if @on_new_algos
102
102
  end
103
103
  end
104
104
 
@@ -130,7 +130,7 @@ class TC_UserAuth_Driver < Test::Unit::TestCase
130
130
  @driver.order << "four"
131
131
  assert_equal [ "one", "two", "three" ], original
132
132
  assert_equal [ "one", "two", "three", "four" ], @driver.order
133
- @driver.set_auth_method_order *original
133
+ @driver.set_auth_method_order(*original)
134
134
  assert_equal [ "one", "two", "three" ], @driver.order
135
135
  end
136
136
 
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.2
2
+ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: net-ssh
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.1.1
7
- date: 2007-05-09 00:00:00 -06:00
6
+ version: 1.1.2
7
+ date: 2007-06-18 00:00:00 -06:00
8
8
  summary: Net::SSH is a pure-Ruby implementation of the SSH2 client protocol.
9
9
  require_paths:
10
10
  - lib
@@ -99,6 +99,7 @@ files:
99
99
  - lib/net/ssh/connection/term.rb
100
100
  - lib/net/ssh/errors.rb
101
101
  - lib/net/ssh/host-key-verifier.rb
102
+ - lib/net/ssh/known-hosts.rb
102
103
  - lib/net/ssh/lenient-host-key-verifier.rb
103
104
  - lib/net/ssh/null-host-key-verifier.rb
104
105
  - lib/net/ssh/proxy
@@ -268,6 +269,11 @@ files:
268
269
  - test/userauth/tc_userkeys.rb
269
270
  - test/util
270
271
  - test/util/tc_buffer.rb
272
+ - README
273
+ - LICENSE
274
+ - NEWS
275
+ - THANKS
276
+ - ChangeLog
271
277
  test_files:
272
278
  - test/ALL-TESTS.rb
273
279
  rdoc_options: []