chef-winrm 2.3.11 → 2.3.12
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/lib/chef-winrm/connection.rb +6 -6
- data/lib/chef-winrm/connection_opts.rb +7 -7
- data/lib/chef-winrm/exceptions.rb +1 -1
- data/lib/chef-winrm/http/response_handler.rb +3 -3
- data/lib/chef-winrm/http/transport.rb +47 -47
- data/lib/chef-winrm/http/transport_factory.rb +4 -4
- data/lib/chef-winrm/psrp/fragment.rb +10 -9
- data/lib/chef-winrm/psrp/message.rb +7 -7
- data/lib/chef-winrm/psrp/message_data/base.rb +1 -1
- data/lib/chef-winrm/psrp/message_data/error_record.rb +10 -10
- data/lib/chef-winrm/psrp/message_data/pipeline_output.rb +6 -6
- data/lib/chef-winrm/psrp/message_data/session_capability.rb +3 -3
- data/lib/chef-winrm/psrp/message_data.rb +9 -9
- data/lib/chef-winrm/psrp/message_defragmenter.rb +13 -13
- data/lib/chef-winrm/psrp/message_factory.rb +5 -5
- data/lib/chef-winrm/psrp/message_fragmenter.rb +9 -6
- data/lib/chef-winrm/psrp/powershell_output_decoder.rb +25 -29
- data/lib/chef-winrm/psrp/receive_response_reader.rb +5 -5
- data/lib/chef-winrm/shells/base.rb +17 -16
- data/lib/chef-winrm/shells/cmd.rb +2 -2
- data/lib/chef-winrm/shells/power_shell.rb +18 -18
- data/lib/chef-winrm/shells/retryable.rb +1 -1
- data/lib/chef-winrm/shells/shell_factory.rb +5 -5
- data/lib/chef-winrm/version.rb +1 -1
- data/lib/chef-winrm/wsmv/base.rb +7 -7
- data/lib/chef-winrm/wsmv/cleanup_command.rb +8 -8
- data/lib/chef-winrm/wsmv/close_shell.rb +5 -5
- data/lib/chef-winrm/wsmv/command.rb +15 -15
- data/lib/chef-winrm/wsmv/command_output.rb +15 -15
- data/lib/chef-winrm/wsmv/command_output_decoder.rb +4 -4
- data/lib/chef-winrm/wsmv/configuration.rb +3 -3
- data/lib/chef-winrm/wsmv/create_pipeline.rb +8 -8
- data/lib/chef-winrm/wsmv/create_shell.rb +19 -19
- data/lib/chef-winrm/wsmv/header.rb +56 -56
- data/lib/chef-winrm/wsmv/init_runspace_pool.rb +22 -22
- data/lib/chef-winrm/wsmv/iso8601_duration.rb +2 -2
- data/lib/chef-winrm/wsmv/keep_alive.rb +11 -11
- data/lib/chef-winrm/wsmv/receive_response_reader.rb +9 -9
- data/lib/chef-winrm/wsmv/send_data.rb +5 -5
- data/lib/chef-winrm/wsmv/soap.rb +22 -22
- data/lib/chef-winrm/wsmv/wql_pull.rb +4 -4
- data/lib/chef-winrm/wsmv/wql_query.rb +6 -6
- data/lib/chef-winrm/wsmv/write_stdin.rb +18 -18
- data/lib/chef-winrm.rb +10 -10
- metadata +96 -14
@@ -12,7 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
require_relative
|
15
|
+
require_relative "base"
|
16
16
|
|
17
17
|
module WinRM
|
18
18
|
module WSMV
|
@@ -38,7 +38,7 @@ module WinRM
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def create_body(body)
|
41
|
-
body.tag!("#{NS_WIN_SHELL}:CommandLine",
|
41
|
+
body.tag!("#{NS_WIN_SHELL}:CommandLine", "CommandId" => @command_id) do |cl|
|
42
42
|
cl << Gyoku.xml(command_body)
|
43
43
|
end
|
44
44
|
end
|
@@ -51,19 +51,19 @@ module WinRM
|
|
51
51
|
@command = cmd_opts[:command]
|
52
52
|
@arguments = cmd_opts[:arguments] || []
|
53
53
|
@shell_uri = cmd_opts[:shell_uri] || RESOURCE_URI_CMD
|
54
|
-
@consolemode = cmd_opts.key?(:console_mode_stdin) ? cmd_opts[:console_mode_stdin] :
|
55
|
-
@skipcmd = cmd_opts.key?(:skip_cmd_shell) ? cmd_opts[:skip_cmd_shell] :
|
54
|
+
@consolemode = cmd_opts.key?(:console_mode_stdin) ? cmd_opts[:console_mode_stdin] : "TRUE"
|
55
|
+
@skipcmd = cmd_opts.key?(:skip_cmd_shell) ? cmd_opts[:skip_cmd_shell] : "FALSE"
|
56
56
|
end
|
57
57
|
|
58
58
|
def validate_opts(session_opts, cmd_opts)
|
59
|
-
raise
|
60
|
-
raise
|
61
|
-
raise
|
59
|
+
raise "session_opts is required" unless session_opts
|
60
|
+
raise "cmd_opts[:shell_id] is required" unless cmd_opts[:shell_id]
|
61
|
+
raise "cmd_opts[:command] is required" unless cmd_opts[:command]
|
62
62
|
end
|
63
63
|
|
64
64
|
def issue69_unescape_single_quotes(xml)
|
65
65
|
escaped_cmd = %r{<#{NS_WIN_SHELL}:Command>(.+)<\/#{NS_WIN_SHELL}:Command>}m.match(xml)[1]
|
66
|
-
xml[escaped_cmd] = escaped_cmd.gsub(
|
66
|
+
xml[escaped_cmd] = escaped_cmd.gsub("'", "'")
|
67
67
|
xml
|
68
68
|
end
|
69
69
|
|
@@ -75,10 +75,10 @@ module WinRM
|
|
75
75
|
|
76
76
|
def command_headers
|
77
77
|
merge_headers(shared_headers(@session_opts),
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
78
|
+
resource_uri_shell(@shell_uri),
|
79
|
+
action_command,
|
80
|
+
command_header_opts,
|
81
|
+
selector_shell_id(@shell_id))
|
82
82
|
end
|
83
83
|
|
84
84
|
def command_header_opts
|
@@ -89,10 +89,10 @@ module WinRM
|
|
89
89
|
"#{NS_WSMAN_DMTF}:OptionSet" => {
|
90
90
|
"#{NS_WSMAN_DMTF}:Option" => [@consolemode, @skipcmd], :attributes! => {
|
91
91
|
"#{NS_WSMAN_DMTF}:Option" => {
|
92
|
-
|
93
|
-
}
|
92
|
+
"Name" => %w{WINRS_CONSOLEMODE_STDIN WINRS_SKIP_CMD_SHELL},
|
93
|
+
},
|
94
94
|
}
|
95
|
-
}
|
95
|
+
},
|
96
96
|
}
|
97
97
|
end
|
98
98
|
end
|
@@ -12,21 +12,21 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
require_relative
|
15
|
+
require_relative "base"
|
16
16
|
|
17
17
|
module WinRM
|
18
18
|
module WSMV
|
19
19
|
# WSMV message to get output from a remote shell
|
20
20
|
class CommandOutput < Base
|
21
21
|
def initialize(session_opts, command_out_opts)
|
22
|
-
raise
|
23
|
-
raise
|
22
|
+
raise "command_out_opts[:shell_id] is required" unless command_out_opts[:shell_id]
|
23
|
+
raise "command_out_opts[:command_id] is required" unless command_out_opts[:command_id]
|
24
24
|
|
25
25
|
@session_opts = session_opts
|
26
26
|
@shell_id = command_out_opts[:shell_id]
|
27
27
|
@command_id = command_out_opts[:command_id]
|
28
28
|
@shell_uri = command_out_opts[:shell_uri] || RESOURCE_URI_CMD
|
29
|
-
@out_streams = command_out_opts[:out_streams] || %w
|
29
|
+
@out_streams = command_out_opts[:out_streams] || %w{stdout stderr}
|
30
30
|
end
|
31
31
|
|
32
32
|
protected
|
@@ -43,30 +43,30 @@ module WinRM
|
|
43
43
|
|
44
44
|
def output_header
|
45
45
|
merge_headers(shared_headers(@session_opts),
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
resource_uri_shell(@shell_uri),
|
47
|
+
action_receive,
|
48
|
+
header_opts,
|
49
|
+
selector_shell_id(@shell_id))
|
50
50
|
end
|
51
51
|
|
52
52
|
def header_opts
|
53
53
|
{
|
54
54
|
"#{NS_WSMAN_DMTF}:OptionSet" => {
|
55
|
-
"#{NS_WSMAN_DMTF}:Option" =>
|
55
|
+
"#{NS_WSMAN_DMTF}:Option" => "TRUE", :attributes! => {
|
56
56
|
"#{NS_WSMAN_DMTF}:Option" => {
|
57
|
-
|
58
|
-
}
|
57
|
+
"Name" => "WSMAN_CMDSHELL_OPTION_KEEPALIVE",
|
58
|
+
},
|
59
59
|
}
|
60
|
-
}
|
60
|
+
},
|
61
61
|
}
|
62
62
|
end
|
63
63
|
|
64
64
|
def output_body
|
65
65
|
{
|
66
|
-
"#{NS_WIN_SHELL}:DesiredStream" => @out_streams.join(
|
66
|
+
"#{NS_WIN_SHELL}:DesiredStream" => @out_streams.join(" "), :attributes! => {
|
67
67
|
"#{NS_WIN_SHELL}:DesiredStream" => {
|
68
|
-
|
69
|
-
}
|
68
|
+
"CommandId" => @command_id,
|
69
|
+
},
|
70
70
|
}
|
71
71
|
}
|
72
72
|
end
|
@@ -12,7 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
require
|
15
|
+
require "base64" unless defined?(Base64)
|
16
16
|
|
17
17
|
module WinRM
|
18
18
|
module WSMV
|
@@ -32,7 +32,7 @@ module WinRM
|
|
32
32
|
private
|
33
33
|
|
34
34
|
def decode_raw_output(raw_output)
|
35
|
-
Base64.decode64(raw_output).force_encoding(
|
35
|
+
Base64.decode64(raw_output).force_encoding("utf-8")
|
36
36
|
end
|
37
37
|
|
38
38
|
def handle_invalid_encoding(decoded_text)
|
@@ -41,13 +41,13 @@ module WinRM
|
|
41
41
|
if decoded_text.respond_to?(:scrub)
|
42
42
|
decoded_text.scrub
|
43
43
|
else
|
44
|
-
decoded_text.encode(
|
44
|
+
decoded_text.encode("utf-16", invalid: :replace, undef: :replace).encode("utf-8")
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
def remove_bom(decoded_text)
|
49
49
|
# remove BOM which 2008R2 applies
|
50
|
-
decoded_text.sub("\xEF\xBB\xBF",
|
50
|
+
decoded_text.sub("\xEF\xBB\xBF", "")
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -12,7 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
require_relative
|
15
|
+
require_relative "base"
|
16
16
|
|
17
17
|
module WinRM
|
18
18
|
module WSMV
|
@@ -36,8 +36,8 @@ module WinRM
|
|
36
36
|
|
37
37
|
def configuration_headers
|
38
38
|
merge_headers(shared_headers(@session_opts),
|
39
|
-
|
40
|
-
|
39
|
+
resource_uri_shell("http://schemas.microsoft.com/wbem/wsman/1/config"),
|
40
|
+
action_get)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -12,8 +12,8 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
require_relative
|
16
|
-
require_relative
|
15
|
+
require_relative "base"
|
16
|
+
require_relative "../psrp/message_factory"
|
17
17
|
|
18
18
|
module WinRM
|
19
19
|
module WSMV
|
@@ -35,7 +35,7 @@ module WinRM
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def create_body(body)
|
38
|
-
body.tag!("#{NS_WIN_SHELL}:CommandLine",
|
38
|
+
body.tag!("#{NS_WIN_SHELL}:CommandLine", "CommandId" => command_id) do |cl|
|
39
39
|
cl << Gyoku.xml(command_body)
|
40
40
|
end
|
41
41
|
end
|
@@ -44,16 +44,16 @@ module WinRM
|
|
44
44
|
|
45
45
|
def command_body
|
46
46
|
{
|
47
|
-
"#{NS_WIN_SHELL}:Command" =>
|
48
|
-
"#{NS_WIN_SHELL}:Arguments" => arguments
|
47
|
+
"#{NS_WIN_SHELL}:Command" => "Invoke-Expression",
|
48
|
+
"#{NS_WIN_SHELL}:Arguments" => arguments,
|
49
49
|
}
|
50
50
|
end
|
51
51
|
|
52
52
|
def command_headers
|
53
53
|
merge_headers(shared_headers(@session_opts),
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
resource_uri_shell(RESOURCE_URI_POWERSHELL),
|
55
|
+
action_command,
|
56
|
+
selector_shell_id(shell_id))
|
57
57
|
end
|
58
58
|
|
59
59
|
def arguments
|
@@ -12,8 +12,8 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
require_relative
|
16
|
-
require_relative
|
15
|
+
require_relative "base"
|
16
|
+
require_relative "iso8601_duration"
|
17
17
|
|
18
18
|
module WinRM
|
19
19
|
module WSMV
|
@@ -29,10 +29,10 @@ module WinRM
|
|
29
29
|
def initialize(session_opts, shell_opts = {})
|
30
30
|
@session_opts = session_opts
|
31
31
|
@shell_uri = opt_or_default(shell_opts, :shell_uri, RESOURCE_URI_CMD)
|
32
|
-
@i_stream = opt_or_default(shell_opts, :i_stream,
|
33
|
-
@o_stream = opt_or_default(shell_opts, :o_stream,
|
32
|
+
@i_stream = opt_or_default(shell_opts, :i_stream, "stdin")
|
33
|
+
@o_stream = opt_or_default(shell_opts, :o_stream, "stdout stderr")
|
34
34
|
@codepage = opt_or_default(shell_opts, :codepage, UTF8_CODE_PAGE)
|
35
|
-
@noprofile = opt_or_default(shell_opts, :noprofile,
|
35
|
+
@noprofile = opt_or_default(shell_opts, :noprofile, "FALSE")
|
36
36
|
@working_directory = opt_or_default(shell_opts, :working_directory)
|
37
37
|
@idle_timeout = opt_or_default(shell_opts, :idle_timeout)
|
38
38
|
@env_vars = opt_or_default(shell_opts, :env_vars)
|
@@ -57,7 +57,7 @@ module WinRM
|
|
57
57
|
def shell_body
|
58
58
|
body = {
|
59
59
|
"#{NS_WIN_SHELL}:InputStreams" => @i_stream,
|
60
|
-
"#{NS_WIN_SHELL}:OutputStreams" => @o_stream
|
60
|
+
"#{NS_WIN_SHELL}:OutputStreams" => @o_stream,
|
61
61
|
}
|
62
62
|
body["#{NS_WIN_SHELL}:WorkingDirectory"] = @working_directory if @working_directory
|
63
63
|
body["#{NS_WIN_SHELL}:IdleTimeOut"] = format_idle_timeout(@idle_timeout) if @idle_timeout
|
@@ -75,27 +75,27 @@ module WinRM
|
|
75
75
|
"#{NS_WIN_SHELL}:Variable" => @env_vars.values,
|
76
76
|
:attributes! => {
|
77
77
|
"#{NS_WIN_SHELL}:Variable" => {
|
78
|
-
|
79
|
-
}
|
80
|
-
}
|
78
|
+
"Name" => @env_vars.keys,
|
79
|
+
},
|
80
|
+
},
|
81
81
|
}
|
82
82
|
end
|
83
83
|
|
84
84
|
def shell_headers
|
85
85
|
merge_headers(shared_headers(@session_opts),
|
86
|
-
|
87
|
-
|
88
|
-
|
86
|
+
resource_uri_shell(@shell_uri),
|
87
|
+
action_create,
|
88
|
+
header_opts)
|
89
89
|
end
|
90
90
|
|
91
91
|
def action_create
|
92
92
|
{
|
93
|
-
"#{NS_ADDRESSING}:Action" =>
|
93
|
+
"#{NS_ADDRESSING}:Action" => "http://schemas.xmlsoap.org/ws/2004/09/transfer/Create",
|
94
94
|
:attributes! => {
|
95
95
|
"#{NS_ADDRESSING}:Action" => {
|
96
|
-
|
97
|
-
}
|
98
|
-
}
|
96
|
+
"mustUnderstand" => true,
|
97
|
+
},
|
98
|
+
},
|
99
99
|
}
|
100
100
|
end
|
101
101
|
|
@@ -104,10 +104,10 @@ module WinRM
|
|
104
104
|
"#{NS_WSMAN_DMTF}:OptionSet" => {
|
105
105
|
"#{NS_WSMAN_DMTF}:Option" => [@noprofile, @codepage], :attributes! => {
|
106
106
|
"#{NS_WSMAN_DMTF}:Option" => {
|
107
|
-
|
108
|
-
}
|
107
|
+
"Name" => %w{WINRS_NOPROFILE WINRS_CODEPAGE},
|
108
|
+
},
|
109
109
|
}
|
110
|
-
}
|
110
|
+
},
|
111
111
|
}
|
112
112
|
end
|
113
113
|
end
|
@@ -14,18 +14,18 @@
|
|
14
14
|
|
15
15
|
# rubocop:disable Metrics/MethodLength
|
16
16
|
|
17
|
-
require_relative
|
18
|
-
require_relative
|
17
|
+
require_relative "soap"
|
18
|
+
require_relative "iso8601_duration"
|
19
19
|
|
20
20
|
module WinRM
|
21
21
|
module WSMV
|
22
22
|
# SOAP header utility mixin
|
23
23
|
module Header
|
24
24
|
# WSMan URI of the regular Windows cmd shell
|
25
|
-
RESOURCE_URI_CMD =
|
25
|
+
RESOURCE_URI_CMD = "http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd".freeze
|
26
26
|
|
27
27
|
# WSMan URI for PowerShell
|
28
|
-
RESOURCE_URI_POWERSHELL =
|
28
|
+
RESOURCE_URI_POWERSHELL = "http://schemas.microsoft.com/powershell/Microsoft.PowerShell".freeze
|
29
29
|
|
30
30
|
# Merge the various header hashes and make sure we carry all of the attributes
|
31
31
|
# through instead of overwriting them.
|
@@ -44,30 +44,30 @@ module WinRM
|
|
44
44
|
"#{SOAP::NS_ADDRESSING}:To" => session_opts[:endpoint],
|
45
45
|
"#{SOAP::NS_ADDRESSING}:ReplyTo" => {
|
46
46
|
"#{SOAP::NS_ADDRESSING}:Address" =>
|
47
|
-
|
47
|
+
"http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
|
48
48
|
:attributes! => {
|
49
49
|
"#{SOAP::NS_ADDRESSING}:Address" => {
|
50
|
-
|
51
|
-
}
|
52
|
-
}
|
50
|
+
"mustUnderstand" => true,
|
51
|
+
},
|
52
|
+
},
|
53
53
|
},
|
54
54
|
"#{SOAP::NS_WSMAN_DMTF}:MaxEnvelopeSize" => session_opts[:max_envelope_size],
|
55
55
|
"#{SOAP::NS_ADDRESSING}:MessageID" => "uuid:#{SecureRandom.uuid.to_s.upcase}",
|
56
56
|
"#{SOAP::NS_WSMAN_MSFT}:SessionId" => "uuid:#{session_opts[:session_id]}",
|
57
|
-
"#{SOAP::NS_WSMAN_DMTF}:Locale/" =>
|
58
|
-
"#{SOAP::NS_WSMAN_MSFT}:DataLocale/" =>
|
57
|
+
"#{SOAP::NS_WSMAN_DMTF}:Locale/" => "",
|
58
|
+
"#{SOAP::NS_WSMAN_MSFT}:DataLocale/" => "",
|
59
59
|
"#{SOAP::NS_WSMAN_DMTF}:OperationTimeout" =>
|
60
60
|
Iso8601Duration.sec_to_dur(session_opts[:operation_timeout]),
|
61
61
|
:attributes! => {
|
62
|
-
"#{SOAP::NS_WSMAN_DMTF}:MaxEnvelopeSize" => {
|
62
|
+
"#{SOAP::NS_WSMAN_DMTF}:MaxEnvelopeSize" => { "mustUnderstand" => true },
|
63
63
|
"#{SOAP::NS_WSMAN_DMTF}:Locale/" => {
|
64
|
-
|
64
|
+
"xml:lang" => session_opts[:locale], "mustUnderstand" => false
|
65
65
|
},
|
66
66
|
"#{SOAP::NS_WSMAN_MSFT}:DataLocale/" => {
|
67
|
-
|
67
|
+
"xml:lang" => session_opts[:locale], "mustUnderstand" => false
|
68
68
|
},
|
69
|
-
"#{SOAP::NS_WSMAN_MSFT}:SessionId" => {
|
70
|
-
}
|
69
|
+
"#{SOAP::NS_WSMAN_MSFT}:SessionId" => { "mustUnderstand" => false },
|
70
|
+
},
|
71
71
|
}
|
72
72
|
end
|
73
73
|
|
@@ -77,8 +77,8 @@ module WinRM
|
|
77
77
|
{
|
78
78
|
"#{SOAP::NS_WSMAN_DMTF}:ResourceURI" => shell_uri, :attributes! => {
|
79
79
|
"#{SOAP::NS_WSMAN_DMTF}:ResourceURI" => {
|
80
|
-
|
81
|
-
}
|
80
|
+
"mustUnderstand" => true,
|
81
|
+
},
|
82
82
|
}
|
83
83
|
}
|
84
84
|
end
|
@@ -87,111 +87,111 @@ module WinRM
|
|
87
87
|
resource_uri_shell(RESOURCE_URI_CMD)
|
88
88
|
end
|
89
89
|
|
90
|
-
def resource_uri_wmi(namespace =
|
90
|
+
def resource_uri_wmi(namespace = "root/cimv2/*")
|
91
91
|
{
|
92
92
|
"#{SOAP::NS_WSMAN_DMTF}:ResourceURI" =>
|
93
93
|
"http://schemas.microsoft.com/wbem/wsman/1/wmi/#{namespace}",
|
94
94
|
:attributes! => {
|
95
95
|
"#{SOAP::NS_WSMAN_DMTF}:ResourceURI" => {
|
96
|
-
|
97
|
-
}
|
98
|
-
}
|
96
|
+
"mustUnderstand" => true,
|
97
|
+
},
|
98
|
+
},
|
99
99
|
}
|
100
100
|
end
|
101
101
|
|
102
102
|
def action_get
|
103
103
|
{
|
104
104
|
"#{SOAP::NS_ADDRESSING}:Action" =>
|
105
|
-
|
105
|
+
"http://schemas.xmlsoap.org/ws/2004/09/transfer/Get",
|
106
106
|
:attributes! => {
|
107
107
|
"#{SOAP::NS_ADDRESSING}:Action" => {
|
108
|
-
|
109
|
-
}
|
110
|
-
}
|
108
|
+
"mustUnderstand" => true,
|
109
|
+
},
|
110
|
+
},
|
111
111
|
}
|
112
112
|
end
|
113
113
|
|
114
114
|
def action_delete
|
115
115
|
{
|
116
116
|
"#{SOAP::NS_ADDRESSING}:Action" =>
|
117
|
-
|
117
|
+
"http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete",
|
118
118
|
:attributes! => {
|
119
119
|
"#{SOAP::NS_ADDRESSING}:Action" => {
|
120
|
-
|
121
|
-
}
|
122
|
-
}
|
120
|
+
"mustUnderstand" => true,
|
121
|
+
},
|
122
|
+
},
|
123
123
|
}
|
124
124
|
end
|
125
125
|
|
126
126
|
def action_command
|
127
127
|
{
|
128
128
|
"#{SOAP::NS_ADDRESSING}:Action" =>
|
129
|
-
|
129
|
+
"http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Command",
|
130
130
|
:attributes! => {
|
131
131
|
"#{SOAP::NS_ADDRESSING}:Action" => {
|
132
|
-
|
133
|
-
}
|
134
|
-
}
|
132
|
+
"mustUnderstand" => true,
|
133
|
+
},
|
134
|
+
},
|
135
135
|
}
|
136
136
|
end
|
137
137
|
|
138
138
|
def action_receive
|
139
139
|
{
|
140
140
|
"#{SOAP::NS_ADDRESSING}:Action" =>
|
141
|
-
|
141
|
+
"http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Receive",
|
142
142
|
:attributes! => {
|
143
143
|
"#{SOAP::NS_ADDRESSING}:Action" => {
|
144
|
-
|
145
|
-
}
|
146
|
-
}
|
144
|
+
"mustUnderstand" => true,
|
145
|
+
},
|
146
|
+
},
|
147
147
|
}
|
148
148
|
end
|
149
149
|
|
150
150
|
def action_send
|
151
151
|
{
|
152
152
|
"#{SOAP::NS_ADDRESSING}:Action" =>
|
153
|
-
|
153
|
+
"http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Send",
|
154
154
|
:attributes! => {
|
155
155
|
"#{SOAP::NS_ADDRESSING}:Action" => {
|
156
|
-
|
157
|
-
}
|
158
|
-
}
|
156
|
+
"mustUnderstand" => true,
|
157
|
+
},
|
158
|
+
},
|
159
159
|
}
|
160
160
|
end
|
161
161
|
|
162
162
|
def action_signal
|
163
163
|
{
|
164
164
|
"#{SOAP::NS_ADDRESSING}:Action" =>
|
165
|
-
|
165
|
+
"http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Signal",
|
166
166
|
:attributes! => {
|
167
167
|
"#{SOAP::NS_ADDRESSING}:Action" => {
|
168
|
-
|
169
|
-
}
|
170
|
-
}
|
168
|
+
"mustUnderstand" => true,
|
169
|
+
},
|
170
|
+
},
|
171
171
|
}
|
172
172
|
end
|
173
173
|
|
174
174
|
def action_enumerate
|
175
175
|
{
|
176
176
|
"#{SOAP::NS_ADDRESSING}:Action" =>
|
177
|
-
|
177
|
+
"http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate",
|
178
178
|
:attributes! => {
|
179
179
|
"#{SOAP::NS_ADDRESSING}:Action" => {
|
180
|
-
|
181
|
-
}
|
182
|
-
}
|
180
|
+
"mustUnderstand" => true,
|
181
|
+
},
|
182
|
+
},
|
183
183
|
}
|
184
184
|
end
|
185
185
|
|
186
186
|
def action_enumerate_pull
|
187
187
|
{
|
188
188
|
"#{SOAP::NS_ADDRESSING}:Action" =>
|
189
|
-
|
189
|
+
"http://schemas.xmlsoap.org/ws/2004/09/enumeration/Pull",
|
190
190
|
:attributes! => {
|
191
191
|
"#{SOAP::NS_ADDRESSING}:Action" => {
|
192
|
-
|
193
|
-
}
|
194
|
-
}
|
192
|
+
"mustUnderstand" => true,
|
193
|
+
},
|
194
|
+
},
|
195
195
|
}
|
196
196
|
end
|
197
197
|
|
@@ -200,10 +200,10 @@ module WinRM
|
|
200
200
|
"#{SOAP::NS_WSMAN_DMTF}:SelectorSet" => {
|
201
201
|
"#{SOAP::NS_WSMAN_DMTF}:Selector" => shell_id, :attributes! => {
|
202
202
|
"#{SOAP::NS_WSMAN_DMTF}:Selector" => {
|
203
|
-
|
204
|
-
}
|
203
|
+
"Name" => "ShellId",
|
204
|
+
},
|
205
205
|
}
|
206
|
-
}
|
206
|
+
},
|
207
207
|
}
|
208
208
|
end
|
209
209
|
end
|
@@ -12,7 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
require_relative
|
15
|
+
require_relative "base"
|
16
16
|
|
17
17
|
module WinRM
|
18
18
|
module WSMV
|
@@ -34,7 +34,7 @@ module WinRM
|
|
34
34
|
|
35
35
|
def create_body(body)
|
36
36
|
# OMI server requires a Name for the Shell
|
37
|
-
body.tag!("#{NS_WIN_SHELL}:Shell",
|
37
|
+
body.tag!("#{NS_WIN_SHELL}:Shell", "ShellId" => shell_id, "Name" => "Runspace") do |s|
|
38
38
|
s << Gyoku.xml(shell_body)
|
39
39
|
end
|
40
40
|
end
|
@@ -43,33 +43,33 @@ module WinRM
|
|
43
43
|
|
44
44
|
def shell_body
|
45
45
|
body = {
|
46
|
-
"#{NS_WIN_SHELL}:InputStreams" =>
|
47
|
-
"#{NS_WIN_SHELL}:OutputStreams" =>
|
46
|
+
"#{NS_WIN_SHELL}:InputStreams" => "stdin pr",
|
47
|
+
"#{NS_WIN_SHELL}:OutputStreams" => "stdout",
|
48
48
|
}
|
49
|
-
body[
|
49
|
+
body["creationXml"] = encode_bytes(@payload)
|
50
50
|
body[:attributes!] = {
|
51
|
-
|
52
|
-
|
53
|
-
}
|
51
|
+
"creationXml" => {
|
52
|
+
"xmlns" => "http://schemas.microsoft.com/powershell",
|
53
|
+
},
|
54
54
|
}
|
55
55
|
body
|
56
56
|
end
|
57
57
|
|
58
58
|
def shell_headers
|
59
59
|
merge_headers(shared_headers(@session_opts),
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
resource_uri_shell(RESOURCE_URI_POWERSHELL),
|
61
|
+
action_create,
|
62
|
+
header_opts)
|
63
63
|
end
|
64
64
|
|
65
65
|
def action_create
|
66
66
|
{
|
67
|
-
"#{NS_ADDRESSING}:Action" =>
|
67
|
+
"#{NS_ADDRESSING}:Action" => "http://schemas.xmlsoap.org/ws/2004/09/transfer/Create",
|
68
68
|
:attributes! => {
|
69
69
|
"#{NS_ADDRESSING}:Action" => {
|
70
|
-
|
71
|
-
}
|
72
|
-
}
|
70
|
+
"mustUnderstand" => true,
|
71
|
+
},
|
72
|
+
},
|
73
73
|
}
|
74
74
|
end
|
75
75
|
|
@@ -79,16 +79,16 @@ module WinRM
|
|
79
79
|
"#{NS_WSMAN_DMTF}:Option" => 2.3,
|
80
80
|
:attributes! => {
|
81
81
|
"#{NS_WSMAN_DMTF}:Option" => {
|
82
|
-
|
83
|
-
|
84
|
-
}
|
85
|
-
}
|
82
|
+
"Name" => "protocolversion",
|
83
|
+
"MustComply" => "true",
|
84
|
+
},
|
85
|
+
},
|
86
86
|
},
|
87
87
|
:attributes! => {
|
88
88
|
"#{NS_WSMAN_DMTF}:OptionSet" => {
|
89
|
-
|
90
|
-
}
|
91
|
-
}
|
89
|
+
"env:mustUnderstand" => "true",
|
90
|
+
},
|
91
|
+
},
|
92
92
|
}
|
93
93
|
end
|
94
94
|
end
|