Skip to content

Commit 34222f4

Browse files
willemmWillem Monsuwe
authored andcommitted
Make winrm protocol options configurable
1 parent af235d3 commit 34222f4

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

parameters.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ type Parameters struct {
88
Timeout string
99
Locale string
1010
EnvelopeSize int
11+
RequestOptions map[string]string
1112
TransportDecorator func() Transporter
1213
Dial func(network, addr string) (net.Conn, error)
1314
}
@@ -23,5 +24,11 @@ func NewParameters(timeout, locale string, envelopeSize int) *Parameters {
2324
Timeout: timeout,
2425
Locale: locale,
2526
EnvelopeSize: envelopeSize,
27+
RequestOptions: map[string]string{
28+
"WINRS_NOPROFILE": "FALSE",
29+
"WINRS_CODEPAGE": "65001",
30+
"WINRS_CONSOLEMODE_STDIN": "TRUE",
31+
"WINRS_SKIP_CMD_SHELL": "FALSE",
32+
},
2633
}
2734
}

request.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ func NewOpenShellRequest(uri string, params *Parameters) *soap.SoapMessage {
3333
defaultHeaders(message, uri, params).
3434
Action("http://schemas.xmlsoap.org/ws/2004/09/transfer/Create").
3535
ResourceURI("http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd").
36-
AddOption(soap.NewHeaderOption("WINRS_NOPROFILE", "TRUE")).
37-
AddOption(soap.NewHeaderOption("WINRS_CODEPAGE", "65001")).
36+
AddOption(soap.NewHeaderOption("WINRS_NOPROFILE", params.RequestOptions["WINRS_NOPROFILE"])).
37+
AddOption(soap.NewHeaderOption("WINRS_CODEPAGE", params.RequestOptions["WINRS_CODEPAGE"])).
3838
Build()
3939

4040
body := message.CreateBodyElement("Shell", soap.DOM_NS_WIN_SHELL)
@@ -73,8 +73,8 @@ func NewExecuteCommandRequest(uri, shellID, command string, arguments []string,
7373
Action("http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Command").
7474
ResourceURI("http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd").
7575
ShellId(shellID).
76-
AddOption(soap.NewHeaderOption("WINRS_CONSOLEMODE_STDIN", "FALSE")).
77-
AddOption(soap.NewHeaderOption("WINRS_SKIP_CMD_SHELL", "FALSE")).
76+
AddOption(soap.NewHeaderOption("WINRS_CONSOLEMODE_STDIN", params.RequestOptions["WINRS_CONSOLEMODE_STDIN"])).
77+
AddOption(soap.NewHeaderOption("WINRS_SKIP_CMD_SHELL", params.RequestOptions["WINRS_SKIP_CMD_SHELL"])).
7878
Build()
7979

8080
body := message.CreateBodyElement("CommandLine", soap.DOM_NS_WIN_SHELL)

0 commit comments

Comments
 (0)