hrr_rb_ssh 0.3.0.pre1 → 0.3.0.pre2
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.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/hrr_rb_ssh.gemspec +4 -2
- data/lib/hrr_rb_ssh/authentication.rb +7 -1
- data/lib/hrr_rb_ssh/authentication/method/keyboard_interactive.rb +3 -2
- data/lib/hrr_rb_ssh/authentication/method/keyboard_interactive/context.rb +6 -2
- data/lib/hrr_rb_ssh/authentication/method/keyboard_interactive/info_request.rb +1 -1
- data/lib/hrr_rb_ssh/authentication/method/none.rb +3 -2
- data/lib/hrr_rb_ssh/authentication/method/none/context.rb +7 -2
- data/lib/hrr_rb_ssh/authentication/method/password.rb +3 -2
- data/lib/hrr_rb_ssh/authentication/method/password/context.rb +8 -2
- data/lib/hrr_rb_ssh/authentication/method/publickey.rb +3 -2
- data/lib/hrr_rb_ssh/authentication/method/publickey/context.rb +5 -1
- data/lib/hrr_rb_ssh/codable.rb +2 -2
- data/lib/hrr_rb_ssh/compat/ruby.rb +0 -1
- data/lib/hrr_rb_ssh/connection.rb +3 -0
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session.rb +1 -2
- data/lib/hrr_rb_ssh/message/098_ssh_msg_channel_request.rb +1 -1
- data/lib/hrr_rb_ssh/version.rb +1 -1
- metadata +4 -19
- data/lib/hrr_rb_ssh/compat/ruby/array.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a478983b765002a5277ac63e5ae06e4eccde19d35394b762c13760c33a9cf4b
|
4
|
+
data.tar.gz: d541edd1bd30026919fbf0b4d47369d6853a7ad9f9705b00a43054eaf85d41bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7c09c9e54fa096de5b2417490860e0e80f5ac3c73e2d8fda28b53bdf77fbc7233bede1ecc961bc31cdc817be39fc32bb2b72708d266a4fd46138bdae980e439
|
7
|
+
data.tar.gz: 536e9e52e0eaa7d88449f740ae379d9c2bb0a7c9e29bde06762da14d7220fcc89178cc8f835afc63e1bf9f28c23a7ca876826d219364f4fa7b7dab94a7d1f989
|
data/README.md
CHANGED
@@ -161,6 +161,8 @@ The `context` variable in password authentication context provides the following
|
|
161
161
|
|
162
162
|
- `#username` : The username that a remote user tries to authenticate
|
163
163
|
- `#password` : The password that a remote user tries to authenticate
|
164
|
+
- `#variables` : A hash instance that is shared in each authenticator and subsequent session channel request handlers
|
165
|
+
- `#vars` : The same object that `#variables` returns
|
164
166
|
- `#verify(username, password)` : Returns `true` when username and password arguments match with the context's username and password. Or returns `false` when username and password arguments don't match.
|
165
167
|
|
166
168
|
##### Publickey authentication
|
@@ -277,6 +279,8 @@ In `HrrRbSsh::Connection::RequestHandler.new` block, context variable basically
|
|
277
279
|
- `#io => [in, out, err]` : `in` is readable and read data is sent by remote. `out` and `err` are writable. `out` is for standard output and written data is sent as channel data. `err` is for standard error and written data is sent as channel extended data.
|
278
280
|
- `#chain_proc => {|chain| ... }` : When a session channel is opened, a background thread is started and is waitng for a chained block registered. This `#chain_proc` is used to define how to handle subsequent communications between local and remote. The `chain` variable provides `#call_next` method. In `#proc_chain` block, it is possible to call subsequent block that is defined in another request handler. For instance, shell request must called after pty-req request. The `chain` in pty-req request handler's `#chain_proc` calls `#next_proc` and then subsequent shell request handler's `#chain_proc` will be called.
|
279
281
|
- `#close_session` : In most cases, input and output between a client and the server is handled in `#chain_proc` and closing the `#chain_proc` block will lead closing the underlying session channel. This means that to close the underlying session channel it is required to write at least one `#chain_proc` block. If it is not required to use `#chain_proc` block or is required to close the underlying session channel from outside of `#chain_proc` block, `#close_session` can be used. The `#close_session` will close the background thread that calls `#chain_proc` blocks.
|
282
|
+
- `#variables => Hash` : A hash instance that is passed from authenticator and is shared in subsequent session channel request handlers
|
283
|
+
- `#vars` : The same object that `#variables` returns
|
280
284
|
|
281
285
|
And request handler's `context` variable also provides additional methods based on request type. See `lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/<request type>/context.rb`.
|
282
286
|
|
data/hrr_rb_ssh.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: et ts=2 sw=2
|
1
3
|
|
2
4
|
lib = File.expand_path("../lib", __FILE__)
|
3
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
@@ -21,8 +23,8 @@ Gem::Specification.new do |spec|
|
|
21
23
|
spec.required_ruby_version = '>= 2.0.0'
|
22
24
|
|
23
25
|
spec.add_dependency "ed25519", "~> 1.2"
|
24
|
-
|
26
|
+
|
25
27
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
28
|
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
-
spec.add_development_dependency "
|
29
|
+
spec.add_development_dependency "simplecov", "~> 0.16"
|
28
30
|
end
|
@@ -22,6 +22,7 @@ module HrrRbSsh
|
|
22
22
|
@closed = nil
|
23
23
|
|
24
24
|
@username = nil
|
25
|
+
@variables = {}
|
25
26
|
end
|
26
27
|
|
27
28
|
def send payload
|
@@ -62,6 +63,11 @@ module HrrRbSsh
|
|
62
63
|
@username
|
63
64
|
end
|
64
65
|
|
66
|
+
def variables
|
67
|
+
raise Error::ClosedAuthentication if @closed
|
68
|
+
@variables
|
69
|
+
end
|
70
|
+
|
65
71
|
def authenticate
|
66
72
|
loop do
|
67
73
|
payload = @transport.receive
|
@@ -69,7 +75,7 @@ module HrrRbSsh
|
|
69
75
|
when Message::SSH_MSG_USERAUTH_REQUEST::VALUE
|
70
76
|
userauth_request_message = Message::SSH_MSG_USERAUTH_REQUEST.decode payload
|
71
77
|
method_name = userauth_request_message[:'method name']
|
72
|
-
method = Method[method_name].new(@transport, {'session id' => @transport.session_id}.merge(@options))
|
78
|
+
method = Method[method_name].new(@transport, {'session id' => @transport.session_id}.merge(@options), @variables)
|
73
79
|
result = method.authenticate(userauth_request_message)
|
74
80
|
case result
|
75
81
|
when TrueClass
|
@@ -10,10 +10,11 @@ module HrrRbSsh
|
|
10
10
|
NAME = 'keyboard-interactive'
|
11
11
|
PREFERENCE = 30
|
12
12
|
|
13
|
-
def initialize transport, options
|
13
|
+
def initialize transport, options, variables
|
14
14
|
@logger = Logger.new(self.class.name)
|
15
15
|
@transport = transport
|
16
16
|
@authenticator = options.fetch( 'authentication_keyboard_interactive_authenticator', Authenticator.new { false } )
|
17
|
+
@variables = variables
|
17
18
|
end
|
18
19
|
|
19
20
|
def authenticate userauth_request_message
|
@@ -21,7 +22,7 @@ module HrrRbSsh
|
|
21
22
|
@logger.debug { "userauth request: " + userauth_request_message.inspect }
|
22
23
|
username = userauth_request_message[:'user name']
|
23
24
|
submethods = userauth_request_message[:'submethods']
|
24
|
-
context = Context.new(@transport, username, submethods)
|
25
|
+
context = Context.new(@transport, username, submethods, @variables)
|
25
26
|
@authenticator.authenticate context
|
26
27
|
end
|
27
28
|
end
|
@@ -13,12 +13,16 @@ module HrrRbSsh
|
|
13
13
|
attr_reader \
|
14
14
|
:username,
|
15
15
|
:submethods,
|
16
|
-
:info_response
|
16
|
+
:info_response,
|
17
|
+
:variables,
|
18
|
+
:vars
|
17
19
|
|
18
|
-
def initialize transport, username, submethods
|
20
|
+
def initialize transport, username, submethods, variables
|
19
21
|
@transport = transport
|
20
22
|
@username = username
|
21
23
|
@submethods = submethods
|
24
|
+
@variables = variables
|
25
|
+
@vars = variables
|
22
26
|
|
23
27
|
@logger = Logger.new self.class.name
|
24
28
|
end
|
@@ -10,15 +10,16 @@ module HrrRbSsh
|
|
10
10
|
NAME = 'none'
|
11
11
|
PREFERENCE = 0
|
12
12
|
|
13
|
-
def initialize transport, options
|
13
|
+
def initialize transport, options, variables
|
14
14
|
@logger = Logger.new(self.class.name)
|
15
15
|
@authenticator = options.fetch( 'authentication_none_authenticator', Authenticator.new { false } )
|
16
|
+
@variables = variables
|
16
17
|
end
|
17
18
|
|
18
19
|
def authenticate userauth_request_message
|
19
20
|
@logger.info { "authenticate" }
|
20
21
|
@logger.debug { "userauth request: " + userauth_request_message.inspect }
|
21
|
-
context = Context.new(userauth_request_message[:'user name'])
|
22
|
+
context = Context.new(userauth_request_message[:'user name'], @variables)
|
22
23
|
@authenticator.authenticate context
|
23
24
|
end
|
24
25
|
end
|
@@ -8,10 +8,15 @@ module HrrRbSsh
|
|
8
8
|
class Method
|
9
9
|
class None
|
10
10
|
class Context
|
11
|
-
attr_reader
|
11
|
+
attr_reader \
|
12
|
+
:username,
|
13
|
+
:variables,
|
14
|
+
:vars
|
12
15
|
|
13
|
-
def initialize username
|
16
|
+
def initialize username, variables
|
14
17
|
@username = username
|
18
|
+
@variables = variables
|
19
|
+
@vars = variables
|
15
20
|
|
16
21
|
@logger = Logger.new self.class.name
|
17
22
|
end
|
@@ -10,9 +10,10 @@ module HrrRbSsh
|
|
10
10
|
NAME = 'password'
|
11
11
|
PREFERENCE = 10
|
12
12
|
|
13
|
-
def initialize transport, options
|
13
|
+
def initialize transport, options, variables
|
14
14
|
@logger = Logger.new(self.class.name)
|
15
15
|
@authenticator = options.fetch( 'authentication_password_authenticator', Authenticator.new { false } )
|
16
|
+
@variables = variables
|
16
17
|
end
|
17
18
|
|
18
19
|
def authenticate userauth_request_message
|
@@ -20,7 +21,7 @@ module HrrRbSsh
|
|
20
21
|
@logger.debug { "userauth request: " + userauth_request_message.inspect }
|
21
22
|
username = userauth_request_message[:'user name']
|
22
23
|
password = userauth_request_message[:'plaintext password']
|
23
|
-
context = Context.new(username, password)
|
24
|
+
context = Context.new(username, password, @variables)
|
24
25
|
@authenticator.authenticate context
|
25
26
|
end
|
26
27
|
end
|
@@ -8,11 +8,17 @@ module HrrRbSsh
|
|
8
8
|
class Method
|
9
9
|
class Password
|
10
10
|
class Context
|
11
|
-
attr_reader
|
11
|
+
attr_reader \
|
12
|
+
:username,
|
13
|
+
:password,
|
14
|
+
:variables,
|
15
|
+
:vars
|
12
16
|
|
13
|
-
def initialize username, password
|
17
|
+
def initialize username, password, variables
|
14
18
|
@username = username
|
15
19
|
@password = password
|
20
|
+
@variables = variables
|
21
|
+
@vars = variables
|
16
22
|
|
17
23
|
@logger = Logger.new self.class.name
|
18
24
|
end
|
@@ -10,10 +10,11 @@ module HrrRbSsh
|
|
10
10
|
NAME = 'publickey'
|
11
11
|
PREFERENCE = 20
|
12
12
|
|
13
|
-
def initialize transport, options
|
13
|
+
def initialize transport, options, variables
|
14
14
|
@logger = Logger.new(self.class.name)
|
15
15
|
@session_id = options['session id']
|
16
16
|
@authenticator = options.fetch( 'authentication_publickey_authenticator', Authenticator.new { false } )
|
17
|
+
@variables = variables
|
17
18
|
end
|
18
19
|
|
19
20
|
def authenticate userauth_request_message
|
@@ -30,7 +31,7 @@ module HrrRbSsh
|
|
30
31
|
@logger.info { "verify signature" }
|
31
32
|
username = userauth_request_message[:'user name']
|
32
33
|
algorithm = Algorithm[public_key_algorithm_name].new
|
33
|
-
context = Context.new(username, algorithm, @session_id, userauth_request_message)
|
34
|
+
context = Context.new(username, algorithm, @session_id, userauth_request_message, @variables)
|
34
35
|
@authenticator.authenticate context
|
35
36
|
end
|
36
37
|
end
|
@@ -11,6 +11,8 @@ module HrrRbSsh
|
|
11
11
|
attr_reader \
|
12
12
|
:username,
|
13
13
|
:session_id,
|
14
|
+
:variables,
|
15
|
+
:vars,
|
14
16
|
:message_number,
|
15
17
|
:service_name,
|
16
18
|
:method_name,
|
@@ -19,11 +21,13 @@ module HrrRbSsh
|
|
19
21
|
:public_key_blob,
|
20
22
|
:signature
|
21
23
|
|
22
|
-
def initialize username, algorithm, session_id, message
|
24
|
+
def initialize username, algorithm, session_id, message, variables
|
23
25
|
@username = username
|
24
26
|
@algorithm = algorithm
|
25
27
|
@session_id = session_id
|
26
28
|
@message = message
|
29
|
+
@variables = variables
|
30
|
+
@vars = variables
|
27
31
|
|
28
32
|
@message_number = message[:'message number']
|
29
33
|
@service_name = message[:'service name']
|
data/lib/hrr_rb_ssh/codable.rb
CHANGED
@@ -58,9 +58,9 @@ module HrrRbSsh
|
|
58
58
|
|
59
59
|
def decode payload, complementary_message={}
|
60
60
|
payload_io = StringIO.new payload
|
61
|
-
decoded_message = decode_recursively(payload_io).
|
61
|
+
decoded_message = decode_recursively(payload_io).inject(Hash.new){ |h, (k, v)| h.update({k => v}) }
|
62
62
|
if complementary_message.any?
|
63
|
-
decoded_message.merge! decode_recursively(payload_io, complementary_message.to_a).
|
63
|
+
decoded_message.merge! decode_recursively(payload_io, complementary_message.to_a).inject(Hash.new){ |h, (k, v)| h.update({k => v}) }
|
64
64
|
end
|
65
65
|
logger.debug { 'decoded message: ' + decoded_message.inspect }
|
66
66
|
decoded_message
|
@@ -10,6 +10,7 @@ module HrrRbSsh
|
|
10
10
|
class Connection
|
11
11
|
attr_reader \
|
12
12
|
:username,
|
13
|
+
:variables,
|
13
14
|
:options
|
14
15
|
|
15
16
|
def initialize authentication, options={}
|
@@ -21,6 +22,7 @@ module HrrRbSsh
|
|
21
22
|
@global_request_handler = GlobalRequestHandler.new self
|
22
23
|
@channels = Hash.new
|
23
24
|
@username = nil
|
25
|
+
@variables = nil
|
24
26
|
@closed = nil
|
25
27
|
end
|
26
28
|
|
@@ -76,6 +78,7 @@ module HrrRbSsh
|
|
76
78
|
break
|
77
79
|
end
|
78
80
|
@username ||= @authentication.username
|
81
|
+
@variables ||= @authentication.variables
|
79
82
|
case payload[0,1].unpack("C")[0]
|
80
83
|
when Message::SSH_MSG_GLOBAL_REQUEST::VALUE
|
81
84
|
global_request payload
|
@@ -14,7 +14,6 @@ module HrrRbSsh
|
|
14
14
|
@logger = Logger.new self.class.name
|
15
15
|
@connection = connection
|
16
16
|
@channel = channel
|
17
|
-
@variables = {}
|
18
17
|
@proc_chain = ProcChain.new
|
19
18
|
end
|
20
19
|
|
@@ -30,7 +29,7 @@ module HrrRbSsh
|
|
30
29
|
|
31
30
|
def request message
|
32
31
|
request_type = message[:'request type']
|
33
|
-
RequestType[request_type].run @proc_chain, @connection.username, @channel.io, @variables, message, @connection.options, self
|
32
|
+
RequestType[request_type].run @proc_chain, @connection.username, @channel.io, @connection.variables, message, @connection.options, self
|
34
33
|
end
|
35
34
|
|
36
35
|
def proc_chain_thread
|
@@ -89,7 +89,7 @@ module HrrRbSsh
|
|
89
89
|
ID = self.name.split('::').last
|
90
90
|
VALUE = 98
|
91
91
|
|
92
|
-
TERMINAL_MODE_INV = TerminalMode.constants.map{|c| [TerminalMode.const_get(c), c.to_s]}.
|
92
|
+
TERMINAL_MODE_INV = TerminalMode.constants.map{|c| [TerminalMode.const_get(c), c.to_s]}.inject(Hash.new){ |h, (k, v)| h.update({k => v}) }
|
93
93
|
|
94
94
|
DEFINITION = [
|
95
95
|
#[DataType, Field Name]
|
data/lib/hrr_rb_ssh/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hrr_rb_ssh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.0.
|
4
|
+
version: 0.3.0.pre2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hirura
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.2'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.16'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.16'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: rake
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,19 +53,19 @@ dependencies:
|
|
67
53
|
- !ruby/object:Gem::Version
|
68
54
|
version: '3.0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
56
|
+
name: simplecov
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
59
|
- - "~>"
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
61
|
+
version: '0.16'
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
66
|
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
68
|
+
version: '0.16'
|
83
69
|
description: Pure Ruby SSH 2.0 server implementation
|
84
70
|
email:
|
85
71
|
- hirura@gmail.com
|
@@ -149,7 +135,6 @@ files:
|
|
149
135
|
- lib/hrr_rb_ssh/compat/openssh/authorized_keys.rb
|
150
136
|
- lib/hrr_rb_ssh/compat/openssh/public_key.rb
|
151
137
|
- lib/hrr_rb_ssh/compat/ruby.rb
|
152
|
-
- lib/hrr_rb_ssh/compat/ruby/array.rb
|
153
138
|
- lib/hrr_rb_ssh/compat/ruby/openssl.rb
|
154
139
|
- lib/hrr_rb_ssh/compat/ruby/openssl/bn.rb
|
155
140
|
- lib/hrr_rb_ssh/compat/ruby/queue.rb
|