hrr_rb_ssh 0.3.0.pre1 → 0.4.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.
- checksums.yaml +4 -4
- data/.gitignore +0 -3
- data/.travis.yml +1 -0
- data/README.md +208 -46
- data/demo/client.rb +71 -0
- data/demo/echo_server.rb +8 -3
- data/demo/more_flexible_auth.rb +105 -0
- data/demo/multi_step_auth.rb +99 -0
- data/demo/server.rb +10 -4
- data/demo/subsystem_echo_server.rb +8 -3
- data/hrr_rb_ssh.gemspec +6 -6
- data/lib/hrr_rb_ssh.rb +1 -1
- data/lib/hrr_rb_ssh/algorithm/publickey.rb +0 -1
- data/lib/hrr_rb_ssh/algorithm/publickey/ecdsa_sha2.rb +12 -9
- data/lib/hrr_rb_ssh/algorithm/publickey/ecdsa_sha2/ecdsa_signature_blob.rb +2 -4
- data/lib/hrr_rb_ssh/algorithm/publickey/ecdsa_sha2/public_key_blob.rb +2 -4
- data/lib/hrr_rb_ssh/algorithm/publickey/ecdsa_sha2/signature.rb +2 -4
- data/lib/hrr_rb_ssh/algorithm/publickey/ssh_dss.rb +10 -7
- data/lib/hrr_rb_ssh/algorithm/publickey/ssh_dss/public_key_blob.rb +2 -4
- data/lib/hrr_rb_ssh/algorithm/publickey/ssh_dss/signature.rb +2 -4
- data/lib/hrr_rb_ssh/algorithm/publickey/ssh_rsa.rb +9 -6
- data/lib/hrr_rb_ssh/algorithm/publickey/ssh_rsa/public_key_blob.rb +2 -4
- data/lib/hrr_rb_ssh/algorithm/publickey/ssh_rsa/signature.rb +2 -4
- data/lib/hrr_rb_ssh/authentication.rb +103 -22
- data/lib/hrr_rb_ssh/authentication/constant.rb +14 -0
- data/lib/hrr_rb_ssh/authentication/method/keyboard_interactive.rb +44 -7
- data/lib/hrr_rb_ssh/authentication/method/keyboard_interactive/context.rb +16 -9
- data/lib/hrr_rb_ssh/authentication/method/keyboard_interactive/info_request.rb +7 -6
- data/lib/hrr_rb_ssh/authentication/method/keyboard_interactive/info_response.rb +5 -2
- data/lib/hrr_rb_ssh/authentication/method/none.rb +23 -7
- data/lib/hrr_rb_ssh/authentication/method/none/context.rb +15 -7
- data/lib/hrr_rb_ssh/authentication/method/password.rb +28 -7
- data/lib/hrr_rb_ssh/authentication/method/password/context.rb +16 -7
- data/lib/hrr_rb_ssh/authentication/method/publickey.rb +63 -10
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm.rb +0 -1
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/functionable.rb +32 -8
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/signature_blob.rb +2 -4
- data/lib/hrr_rb_ssh/authentication/method/publickey/context.rb +11 -2
- data/lib/hrr_rb_ssh/client.rb +234 -0
- data/lib/hrr_rb_ssh/codable.rb +15 -13
- data/lib/hrr_rb_ssh/compat/ruby.rb +0 -1
- data/lib/hrr_rb_ssh/connection.rb +145 -75
- data/lib/hrr_rb_ssh/connection/channel.rb +342 -109
- data/lib/hrr_rb_ssh/connection/channel/channel_type/direct_tcpip.rb +24 -19
- data/lib/hrr_rb_ssh/connection/channel/channel_type/forwarded_tcpip.rb +24 -19
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session.rb +19 -12
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/proc_chain.rb +0 -2
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/proc_chain/chain_context.rb +0 -3
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/env.rb +2 -5
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/env/context.rb +5 -4
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/exec.rb +2 -5
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/exec/context.rb +5 -4
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/pty_req.rb +2 -5
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/pty_req/context.rb +5 -4
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/shell.rb +2 -5
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/shell/context.rb +5 -4
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/subsystem.rb +2 -5
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/subsystem/context.rb +5 -4
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/window_change.rb +2 -5
- data/lib/hrr_rb_ssh/connection/channel/channel_type/session/request_type/window_change/context.rb +5 -4
- data/lib/hrr_rb_ssh/connection/global_request_handler.rb +14 -12
- data/lib/hrr_rb_ssh/connection/request_handler.rb +1 -3
- data/lib/hrr_rb_ssh/connection/request_handler/reference_env_request_handler.rb +0 -2
- data/lib/hrr_rb_ssh/connection/request_handler/reference_exec_request_handler.rb +4 -6
- data/lib/hrr_rb_ssh/connection/request_handler/reference_pty_req_request_handler.rb +10 -12
- data/lib/hrr_rb_ssh/connection/request_handler/reference_shell_request_handler.rb +4 -6
- data/lib/hrr_rb_ssh/connection/request_handler/reference_window_change_request_handler.rb +0 -2
- data/lib/hrr_rb_ssh/error/closed_authentication.rb +1 -1
- data/lib/hrr_rb_ssh/error/closed_connection.rb +1 -1
- data/lib/hrr_rb_ssh/error/closed_transport.rb +1 -1
- data/lib/hrr_rb_ssh/loggable.rb +42 -0
- data/lib/hrr_rb_ssh/message/001_ssh_msg_disconnect.rb +2 -4
- data/lib/hrr_rb_ssh/message/002_ssh_msg_ignore.rb +2 -4
- data/lib/hrr_rb_ssh/message/003_ssh_msg_unimplemented.rb +2 -4
- data/lib/hrr_rb_ssh/message/004_ssh_msg_debug.rb +2 -4
- data/lib/hrr_rb_ssh/message/005_ssh_msg_service_request.rb +2 -4
- data/lib/hrr_rb_ssh/message/006_ssh_msg_service_accept.rb +2 -4
- data/lib/hrr_rb_ssh/message/020_ssh_msg_kexinit.rb +2 -4
- data/lib/hrr_rb_ssh/message/021_ssh_msg_newkeys.rb +2 -4
- data/lib/hrr_rb_ssh/message/030_ssh_msg_kex_dh_gex_request_old.rb +2 -4
- data/lib/hrr_rb_ssh/message/030_ssh_msg_kexdh_init.rb +2 -4
- data/lib/hrr_rb_ssh/message/030_ssh_msg_kexecdh_init.rb +2 -4
- data/lib/hrr_rb_ssh/message/031_ssh_msg_kex_dh_gex_group.rb +2 -4
- data/lib/hrr_rb_ssh/message/031_ssh_msg_kexdh_reply.rb +2 -4
- data/lib/hrr_rb_ssh/message/031_ssh_msg_kexecdh_reply.rb +2 -4
- data/lib/hrr_rb_ssh/message/032_ssh_msg_kex_dh_gex_init.rb +2 -4
- data/lib/hrr_rb_ssh/message/033_ssh_msg_kex_dh_gex_reply.rb +2 -4
- data/lib/hrr_rb_ssh/message/034_ssh_msg_kex_dh_gex_request.rb +2 -4
- data/lib/hrr_rb_ssh/message/050_ssh_msg_userauth_request.rb +2 -4
- data/lib/hrr_rb_ssh/message/051_ssh_msg_userauth_failure.rb +2 -4
- data/lib/hrr_rb_ssh/message/052_ssh_msg_userauth_success.rb +2 -4
- data/lib/hrr_rb_ssh/message/060_ssh_msg_userauth_info_request.rb +2 -4
- data/lib/hrr_rb_ssh/message/060_ssh_msg_userauth_pk_ok.rb +2 -4
- data/lib/hrr_rb_ssh/message/061_ssh_msg_userauth_info_response.rb +2 -4
- data/lib/hrr_rb_ssh/message/080_ssh_msg_global_request.rb +2 -4
- data/lib/hrr_rb_ssh/message/081_ssh_msg_request_success.rb +2 -4
- data/lib/hrr_rb_ssh/message/082_ssh_msg_request_failure.rb +2 -4
- data/lib/hrr_rb_ssh/message/090_ssh_msg_channel_open.rb +2 -4
- data/lib/hrr_rb_ssh/message/091_ssh_msg_channel_open_confirmation.rb +2 -4
- data/lib/hrr_rb_ssh/message/092_ssh_msg_channel_open_failure.rb +2 -4
- data/lib/hrr_rb_ssh/message/093_ssh_msg_channel_window_adjust.rb +2 -4
- data/lib/hrr_rb_ssh/message/094_ssh_msg_channel_data.rb +2 -4
- data/lib/hrr_rb_ssh/message/095_ssh_msg_channel_extended_data.rb +2 -4
- data/lib/hrr_rb_ssh/message/096_ssh_msg_channel_eof.rb +2 -4
- data/lib/hrr_rb_ssh/message/097_ssh_msg_channel_close.rb +2 -4
- data/lib/hrr_rb_ssh/message/098_ssh_msg_channel_request.rb +3 -5
- data/lib/hrr_rb_ssh/message/099_ssh_msg_channel_success.rb +2 -4
- data/lib/hrr_rb_ssh/message/100_ssh_msg_channel_failure.rb +2 -4
- data/lib/hrr_rb_ssh/server.rb +16 -10
- data/lib/hrr_rb_ssh/transport.rb +113 -77
- data/lib/hrr_rb_ssh/transport/compression_algorithm/functionable.rb +5 -3
- data/lib/hrr_rb_ssh/transport/compression_algorithm/unfunctionable.rb +5 -3
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/functionable.rb +5 -3
- data/lib/hrr_rb_ssh/transport/encryption_algorithm/unfunctionable.rb +5 -3
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman.rb +43 -37
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman/h0.rb +2 -4
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group_exchange.rb +87 -52
- data/lib/hrr_rb_ssh/transport/kex_algorithm/diffie_hellman_group_exchange/h0.rb +2 -4
- data/lib/hrr_rb_ssh/transport/kex_algorithm/elliptic_curve_diffie_hellman.rb +43 -37
- data/lib/hrr_rb_ssh/transport/kex_algorithm/elliptic_curve_diffie_hellman/h0.rb +2 -4
- data/lib/hrr_rb_ssh/transport/mac_algorithm/functionable.rb +5 -3
- data/lib/hrr_rb_ssh/transport/mac_algorithm/unfunctionable.rb +5 -3
- data/lib/hrr_rb_ssh/transport/receiver.rb +8 -7
- data/lib/hrr_rb_ssh/transport/sender.rb +5 -3
- data/lib/hrr_rb_ssh/transport/sequence_number.rb +0 -4
- data/lib/hrr_rb_ssh/transport/server_host_key_algorithm.rb +0 -1
- data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/functionable.rb +5 -3
- data/lib/hrr_rb_ssh/version.rb +1 -1
- metadata +18 -51
- data/lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519.rb +0 -61
- data/lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/openssh_private_key.rb +0 -29
- data/lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/openssh_private_key_content.rb +0 -26
- data/lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/pkey.rb +0 -158
- data/lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/public_key_blob.rb +0 -23
- data/lib/hrr_rb_ssh/algorithm/publickey/ssh_ed25519/signature.rb +0 -23
- data/lib/hrr_rb_ssh/authentication/method/publickey/algorithm/ssh_ed25519.rb +0 -21
- data/lib/hrr_rb_ssh/compat/ruby/array.rb +0 -14
- data/lib/hrr_rb_ssh/logger.rb +0 -56
- data/lib/hrr_rb_ssh/transport/server_host_key_algorithm/ssh_ed25519.rb +0 -20
@@ -1,17 +1,19 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# vim: et ts=2 sw=2
|
3
3
|
|
4
|
-
require 'hrr_rb_ssh/
|
4
|
+
require 'hrr_rb_ssh/loggable'
|
5
5
|
|
6
6
|
module HrrRbSsh
|
7
7
|
class Connection
|
8
8
|
class Channel
|
9
9
|
class ChannelType
|
10
10
|
class DirectTcpip < ChannelType
|
11
|
+
include Loggable
|
12
|
+
|
11
13
|
NAME = 'direct-tcpip'
|
12
14
|
|
13
|
-
def initialize connection, channel, message, socket=nil
|
14
|
-
|
15
|
+
def initialize connection, channel, message, socket=nil, logger: nil
|
16
|
+
self.logger = logger
|
15
17
|
@connection = connection
|
16
18
|
@channel = channel
|
17
19
|
@host_to_connect = message[:'host to connect']
|
@@ -29,13 +31,16 @@ module HrrRbSsh
|
|
29
31
|
def close
|
30
32
|
begin
|
31
33
|
if @sender_thread_finished && @receiver_thread_finished
|
32
|
-
|
34
|
+
log_info { "closing direct-tcpip" }
|
33
35
|
@socket.close
|
36
|
+
log_info { "closing channel IOs" }
|
37
|
+
@channel.io.each{ |io| io.close rescue nil }
|
38
|
+
log_info { "channel IOs closed" }
|
34
39
|
@channel.close from=:channel_type_instance
|
35
|
-
|
40
|
+
log_info { "direct-tcpip closed" }
|
36
41
|
end
|
37
42
|
rescue => e
|
38
|
-
|
43
|
+
log_error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
|
39
44
|
end
|
40
45
|
end
|
41
46
|
|
@@ -46,24 +51,24 @@ module HrrRbSsh
|
|
46
51
|
begin
|
47
52
|
@channel.io[1].write s.readpartial(10240)
|
48
53
|
rescue EOFError
|
49
|
-
|
50
|
-
@channel.io[1].close
|
54
|
+
log_info { "socket is EOF" }
|
55
|
+
@channel.io[1].close rescue nil
|
51
56
|
break
|
52
57
|
rescue IOError
|
53
|
-
|
54
|
-
@channel.io[1].close
|
58
|
+
log_info { "socket is closed" }
|
59
|
+
@channel.io[1].close rescue nil
|
55
60
|
break
|
56
61
|
rescue => e
|
57
|
-
|
58
|
-
@channel.io[1].close
|
62
|
+
log_error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
|
63
|
+
@channel.io[1].close rescue nil
|
59
64
|
break
|
60
65
|
end
|
61
66
|
end
|
62
|
-
|
67
|
+
log_info { "finishing sender thread" }
|
63
68
|
@sender_thread_finished = true
|
64
69
|
close
|
65
70
|
ensure
|
66
|
-
|
71
|
+
log_info { "sender thread finished" }
|
67
72
|
end
|
68
73
|
}
|
69
74
|
end
|
@@ -75,23 +80,23 @@ module HrrRbSsh
|
|
75
80
|
begin
|
76
81
|
s.write @channel.io[0].readpartial(10240)
|
77
82
|
rescue EOFError
|
78
|
-
|
83
|
+
log_info { "io is EOF" }
|
79
84
|
s.close_write
|
80
85
|
break
|
81
86
|
rescue IOError
|
82
|
-
|
87
|
+
log_info { "socket is closed" }
|
83
88
|
break
|
84
89
|
rescue => e
|
85
|
-
|
90
|
+
log_error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
|
86
91
|
s.close_write
|
87
92
|
break
|
88
93
|
end
|
89
94
|
end
|
90
|
-
|
95
|
+
log_info { "finishing receiver thread" }
|
91
96
|
@receiver_thread_finished = true
|
92
97
|
close
|
93
98
|
ensure
|
94
|
-
|
99
|
+
log_info { "receiver thread finished" }
|
95
100
|
end
|
96
101
|
}
|
97
102
|
end
|
@@ -1,17 +1,19 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# vim: et ts=2 sw=2
|
3
3
|
|
4
|
-
require 'hrr_rb_ssh/
|
4
|
+
require 'hrr_rb_ssh/loggable'
|
5
5
|
|
6
6
|
module HrrRbSsh
|
7
7
|
class Connection
|
8
8
|
class Channel
|
9
9
|
class ChannelType
|
10
10
|
class ForwardedTcpip < ChannelType
|
11
|
+
include Loggable
|
12
|
+
|
11
13
|
NAME = 'forwarded-tcpip'
|
12
14
|
|
13
|
-
def initialize connection, channel, message, socket
|
14
|
-
|
15
|
+
def initialize connection, channel, message, socket, logger: nil
|
16
|
+
self.logger = logger
|
15
17
|
@connection = connection
|
16
18
|
@channel = channel
|
17
19
|
@socket = socket
|
@@ -25,13 +27,16 @@ module HrrRbSsh
|
|
25
27
|
def close
|
26
28
|
begin
|
27
29
|
if @sender_thread_finished && @receiver_thread_finished
|
28
|
-
|
30
|
+
log_info { "closing forwarded-tcpip" }
|
29
31
|
@socket.close
|
32
|
+
log_info { "closing channel IOs" }
|
33
|
+
@channel.io.each{ |io| io.close rescue nil }
|
34
|
+
log_info { "channel IOs closed" }
|
30
35
|
@channel.close from=:channel_type_instance
|
31
|
-
|
36
|
+
log_info { "forwarded-tcpip closed" }
|
32
37
|
end
|
33
38
|
rescue => e
|
34
|
-
|
39
|
+
log_error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
|
35
40
|
end
|
36
41
|
end
|
37
42
|
|
@@ -42,24 +47,24 @@ module HrrRbSsh
|
|
42
47
|
begin
|
43
48
|
@channel.io[1].write s.readpartial(10240)
|
44
49
|
rescue EOFError
|
45
|
-
|
46
|
-
@channel.io[1].close
|
50
|
+
log_info { "socket is EOF" }
|
51
|
+
@channel.io[1].close rescue nil
|
47
52
|
break
|
48
53
|
rescue IOError
|
49
|
-
|
50
|
-
@channel.io[1].close
|
54
|
+
log_info { "socket is closed" }
|
55
|
+
@channel.io[1].close rescue nil
|
51
56
|
break
|
52
57
|
rescue => e
|
53
|
-
|
54
|
-
@channel.io[1].close
|
58
|
+
log_error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
|
59
|
+
@channel.io[1].close rescue nil
|
55
60
|
break
|
56
61
|
end
|
57
62
|
end
|
58
|
-
|
63
|
+
log_info { "finishing sender thread" }
|
59
64
|
@sender_thread_finished = true
|
60
65
|
close
|
61
66
|
ensure
|
62
|
-
|
67
|
+
log_info { "sender thread finished" }
|
63
68
|
end
|
64
69
|
}
|
65
70
|
end
|
@@ -71,23 +76,23 @@ module HrrRbSsh
|
|
71
76
|
begin
|
72
77
|
s.write @channel.io[0].readpartial(10240)
|
73
78
|
rescue EOFError
|
74
|
-
|
79
|
+
log_info { "io is EOF" }
|
75
80
|
s.close_write
|
76
81
|
break
|
77
82
|
rescue IOError
|
78
|
-
|
83
|
+
log_info { "socket is closed" }
|
79
84
|
break
|
80
85
|
rescue => e
|
81
|
-
|
86
|
+
log_error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
|
82
87
|
s.close_write
|
83
88
|
break
|
84
89
|
end
|
85
90
|
end
|
86
|
-
|
91
|
+
log_info { "finishing receiver thread" }
|
87
92
|
@receiver_thread_finished = true
|
88
93
|
close
|
89
94
|
ensure
|
90
|
-
|
95
|
+
log_info { "receiver thread finished" }
|
91
96
|
end
|
92
97
|
}
|
93
98
|
end
|
@@ -1,25 +1,29 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# vim: et ts=2 sw=2
|
3
3
|
|
4
|
-
require 'hrr_rb_ssh/
|
4
|
+
require 'hrr_rb_ssh/loggable'
|
5
5
|
|
6
6
|
module HrrRbSsh
|
7
7
|
class Connection
|
8
8
|
class Channel
|
9
9
|
class ChannelType
|
10
10
|
class Session < ChannelType
|
11
|
+
include Loggable
|
12
|
+
|
11
13
|
NAME = 'session'
|
12
14
|
|
13
|
-
def initialize connection, channel, message, socket=nil
|
14
|
-
|
15
|
+
def initialize connection, channel, message, socket=nil, logger: nil
|
16
|
+
self.logger = logger
|
15
17
|
@connection = connection
|
16
18
|
@channel = channel
|
17
|
-
@variables = {}
|
18
19
|
@proc_chain = ProcChain.new
|
19
20
|
end
|
20
21
|
|
21
22
|
def start
|
22
|
-
@
|
23
|
+
case @connection.mode
|
24
|
+
when Mode::SERVER
|
25
|
+
@proc_chain_thread = proc_chain_thread
|
26
|
+
end
|
23
27
|
end
|
24
28
|
|
25
29
|
def close
|
@@ -30,24 +34,27 @@ module HrrRbSsh
|
|
30
34
|
|
31
35
|
def request message
|
32
36
|
request_type = message[:'request type']
|
33
|
-
RequestType[request_type].run @proc_chain, @connection.username, @channel.io, @variables, message, @connection.options, self
|
37
|
+
RequestType[request_type].run @proc_chain, @connection.username, @channel.io, @connection.variables, message, @connection.options, self, logger: logger
|
34
38
|
end
|
35
39
|
|
36
40
|
def proc_chain_thread
|
37
41
|
Thread.start {
|
38
|
-
|
42
|
+
log_info { "start proc chain thread" }
|
39
43
|
begin
|
40
44
|
exitstatus = @proc_chain.call_next
|
41
45
|
rescue => e
|
42
|
-
|
46
|
+
log_error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
|
43
47
|
exitstatus = 1
|
44
48
|
ensure
|
45
|
-
|
46
|
-
|
49
|
+
log_info { "closing proc chain thread" }
|
50
|
+
log_info { "closing channel IOs" }
|
51
|
+
@channel.io.each{ |io| io.close rescue nil }
|
52
|
+
log_info { "channel IOs closed" }
|
53
|
+
log_info { "wait for sending output" }
|
47
54
|
@channel.wait_until_senders_closed
|
48
|
-
|
55
|
+
log_info { "sending output finished" }
|
49
56
|
@channel.close from=:channel_type_instance, exitstatus=exitstatus
|
50
|
-
|
57
|
+
log_info { "proc chain thread closed" }
|
51
58
|
end
|
52
59
|
}
|
53
60
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# vim: et ts=2 sw=2
|
3
3
|
|
4
|
-
require 'hrr_rb_ssh/logger'
|
5
4
|
require 'hrr_rb_ssh/connection/channel/channel_type/session/proc_chain/chain_context'
|
6
5
|
|
7
6
|
module HrrRbSsh
|
@@ -11,7 +10,6 @@ module HrrRbSsh
|
|
11
10
|
class Session
|
12
11
|
class ProcChain
|
13
12
|
def initialize
|
14
|
-
@logger = Logger.new self.class.name
|
15
13
|
@q = Queue.new
|
16
14
|
end
|
17
15
|
def connect next_proc
|
@@ -1,8 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# vim: et ts=2 sw=2
|
3
3
|
|
4
|
-
require 'hrr_rb_ssh/logger'
|
5
|
-
|
6
4
|
module HrrRbSsh
|
7
5
|
class Connection
|
8
6
|
class Channel
|
@@ -11,7 +9,6 @@ module HrrRbSsh
|
|
11
9
|
class ProcChain
|
12
10
|
class ChainContext
|
13
11
|
def initialize proc_chain
|
14
|
-
@logger = Logger.new self.class.name
|
15
12
|
@proc_chain = proc_chain
|
16
13
|
end
|
17
14
|
def call_next *args
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# vim: et ts=2 sw=2
|
3
3
|
|
4
|
-
require 'hrr_rb_ssh/logger'
|
5
4
|
require 'hrr_rb_ssh/connection/request_handler'
|
6
5
|
|
7
6
|
module HrrRbSsh
|
@@ -13,10 +12,8 @@ module HrrRbSsh
|
|
13
12
|
class Env < RequestType
|
14
13
|
NAME = 'env'
|
15
14
|
|
16
|
-
def self.run proc_chain, username, io, variables, message, options, session
|
17
|
-
|
18
|
-
|
19
|
-
context = Context.new proc_chain, username, io, variables, message, session
|
15
|
+
def self.run proc_chain, username, io, variables, message, options, session, logger: nil
|
16
|
+
context = Context.new proc_chain, username, io, variables, message, session, logger: logger
|
20
17
|
handler = options.fetch('connection_channel_request_env', RequestHandler.new {})
|
21
18
|
handler.run context
|
22
19
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# vim: et ts=2 sw=2
|
3
3
|
|
4
|
-
require 'hrr_rb_ssh/
|
4
|
+
require 'hrr_rb_ssh/loggable'
|
5
5
|
|
6
6
|
module HrrRbSsh
|
7
7
|
class Connection
|
@@ -11,8 +11,9 @@ module HrrRbSsh
|
|
11
11
|
class RequestType
|
12
12
|
class Env
|
13
13
|
class Context
|
14
|
+
include Loggable
|
15
|
+
|
14
16
|
attr_reader \
|
15
|
-
:logger,
|
16
17
|
:username,
|
17
18
|
:io,
|
18
19
|
:variables,
|
@@ -20,8 +21,8 @@ module HrrRbSsh
|
|
20
21
|
:variable_name,
|
21
22
|
:variable_value
|
22
23
|
|
23
|
-
def initialize proc_chain, username, io, variables, message, session
|
24
|
-
|
24
|
+
def initialize proc_chain, username, io, variables, message, session, logger: nil
|
25
|
+
self.logger = logger
|
25
26
|
|
26
27
|
@proc_chain = proc_chain
|
27
28
|
@username = username
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# vim: et ts=2 sw=2
|
3
3
|
|
4
|
-
require 'hrr_rb_ssh/logger'
|
5
4
|
require 'hrr_rb_ssh/connection/request_handler'
|
6
5
|
|
7
6
|
module HrrRbSsh
|
@@ -13,10 +12,8 @@ module HrrRbSsh
|
|
13
12
|
class Exec < RequestType
|
14
13
|
NAME = 'exec'
|
15
14
|
|
16
|
-
def self.run proc_chain, username, io, variables, message, options, session
|
17
|
-
|
18
|
-
|
19
|
-
context = Context.new proc_chain, username, io, variables, message, session
|
15
|
+
def self.run proc_chain, username, io, variables, message, options, session, logger: nil
|
16
|
+
context = Context.new proc_chain, username, io, variables, message, session, logger: logger
|
20
17
|
handler = options.fetch('connection_channel_request_exec', RequestHandler.new {})
|
21
18
|
handler.run context
|
22
19
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# vim: et ts=2 sw=2
|
3
3
|
|
4
|
-
require 'hrr_rb_ssh/
|
4
|
+
require 'hrr_rb_ssh/loggable'
|
5
5
|
|
6
6
|
module HrrRbSsh
|
7
7
|
class Connection
|
@@ -11,16 +11,17 @@ module HrrRbSsh
|
|
11
11
|
class RequestType
|
12
12
|
class Exec
|
13
13
|
class Context
|
14
|
+
include Loggable
|
15
|
+
|
14
16
|
attr_reader \
|
15
|
-
:logger,
|
16
17
|
:username,
|
17
18
|
:io,
|
18
19
|
:variables,
|
19
20
|
:vars,
|
20
21
|
:command
|
21
22
|
|
22
|
-
def initialize proc_chain, username, io, variables, message, session
|
23
|
-
|
23
|
+
def initialize proc_chain, username, io, variables, message, session, logger: nil
|
24
|
+
self.logger = logger
|
24
25
|
|
25
26
|
@proc_chain = proc_chain
|
26
27
|
@username = username
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# vim: et ts=2 sw=2
|
3
3
|
|
4
|
-
require 'hrr_rb_ssh/logger'
|
5
4
|
require 'hrr_rb_ssh/connection/request_handler'
|
6
5
|
|
7
6
|
module HrrRbSsh
|
@@ -13,10 +12,8 @@ module HrrRbSsh
|
|
13
12
|
class PtyReq < RequestType
|
14
13
|
NAME = 'pty-req'
|
15
14
|
|
16
|
-
def self.run proc_chain, username, io, variables, message, options, session
|
17
|
-
|
18
|
-
|
19
|
-
context = Context.new proc_chain, username, io, variables, message, session
|
15
|
+
def self.run proc_chain, username, io, variables, message, options, session, logger: nil
|
16
|
+
context = Context.new proc_chain, username, io, variables, message, session, logger: logger
|
20
17
|
handler = options.fetch('connection_channel_request_pty_req', RequestHandler.new {})
|
21
18
|
handler.run context
|
22
19
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# vim: et ts=2 sw=2
|
3
3
|
|
4
|
-
require 'hrr_rb_ssh/
|
4
|
+
require 'hrr_rb_ssh/loggable'
|
5
5
|
|
6
6
|
module HrrRbSsh
|
7
7
|
class Connection
|
@@ -11,8 +11,9 @@ module HrrRbSsh
|
|
11
11
|
class RequestType
|
12
12
|
class PtyReq
|
13
13
|
class Context
|
14
|
+
include Loggable
|
15
|
+
|
14
16
|
attr_reader \
|
15
|
-
:logger,
|
16
17
|
:username,
|
17
18
|
:io,
|
18
19
|
:variables,
|
@@ -24,8 +25,8 @@ module HrrRbSsh
|
|
24
25
|
:terminal_height_pixels,
|
25
26
|
:encoded_terminal_modes
|
26
27
|
|
27
|
-
def initialize proc_chain, username, io, variables, message, session
|
28
|
-
|
28
|
+
def initialize proc_chain, username, io, variables, message, session, logger: nil
|
29
|
+
self.logger = logger
|
29
30
|
|
30
31
|
@proc_chain = proc_chain
|
31
32
|
@username = username
|