winrm-elevated 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a697d6786acdc942c9144e8c726d3727ee22983bb21351f7a19be530873ec6a
4
- data.tar.gz: cfa396d8c5a62a3a3174d996dc7f30347a4c8f9913468f3d27323067ac1f12e4
3
+ metadata.gz: ee0adbdb22c257558248a863ab41505ef63bbe664150084be3cd57ecc56eef3e
4
+ data.tar.gz: d3442d4883f6617827977d6c2538f8d4961a1bf45de3e45be4c249e34ec548c3
5
5
  SHA512:
6
- metadata.gz: c76b27bacedf07dd2f525cb98e04ddbb4a045b821eff0d97575e865ade5b980e28c062d5007c39201cd8cf1ed590f9cb6db5b8d4061b721617236afbfabe2f6c
7
- data.tar.gz: 79a05661830ddb4b7bcf5423c67891368dc78cdd479278b30d56bd30493f9518e0fc92b3219f8d18ef5e45ece98d05af2595047b4b7f9006ab2f4256adebf1c7
6
+ metadata.gz: 439dfd36cc9777886088dccb8172885844f319f3e808fb951b2eac31e115367e500f97b9d6fc2d0006588a7c1a8bedbb034d8af1678bc6d39d10647c6db2a958
7
+ data.tar.gz: 63935500fcb295b1359c2222cb1860788fbb2f7859c2f303c8928b61b478197c72e4fa2163070873e333e45d822a7164ea365947cdb5b7c3a6ca117ff20bdbc5
@@ -88,14 +88,28 @@ try {
88
88
 
89
89
  function SlurpOutput($file, $cur_line, $out_type) {
90
90
  if (Test-Path $file) {
91
- get-content $file | Select-Object -skip $cur_line | ForEach-Object {
92
- $cur_line += 1
93
- if ($out_type -eq 'err') {
94
- $host.ui.WriteErrorLine("$_")
95
- } else {
96
- $host.ui.WriteLine("$_")
91
+ $fs = New-Object -TypeName System.IO.FileStream -ArgumentList @(
92
+ $file,
93
+ [system.io.filemode]::Open,
94
+ [System.io.FileAccess]::Read,
95
+ [System.IO.FileShare]::ReadWrite
96
+ )
97
+ try {
98
+ $enc = [System.Text.Encoding]::GetEncoding($Host.CurrentCulture.TextInfo.OEMCodePage)
99
+ $bytes = [System.Byte[]]::CreateInstance([System.Byte], $fs.Length)
100
+ if ($fs.Read($bytes, 0, $fs.Length) -gt 0) {
101
+ $text = $enc.GetString($bytes)
102
+ $text.TrimEnd("`n").TrimEnd("`r").Split(@("`r`n", "`n"), [StringSplitOptions]::None) | Select-Object -skip $cur_line | ForEach-Object {
103
+ $cur_line += 1
104
+ if ($out_type -eq 'err') {
105
+ $host.ui.WriteErrorLine("$_")
106
+ } else {
107
+ $host.ui.WriteLine("$_")
108
+ }
109
+ }
97
110
  }
98
111
  }
112
+ finally { $fs.Close() }
99
113
  }
100
114
  return $cur_line
101
115
  }
@@ -73,7 +73,9 @@ module WinRM
73
73
 
74
74
  def upload_elevated_shell_script(script_text)
75
75
  elevated_shell_path = 'c:/windows/temp/winrm-elevated-shell-' + SecureRandom.uuid + '.ps1'
76
- script_text_with_exit = "#{script_text}\r\n$Host.SetShouldExit($LASTEXITCODE)"
76
+ # Prepend the content of the file with an UTF-8 BOM for Windows to read it as such instead of the default
77
+ # Windows-XXXX encoding, and convert script_text accordingly if needed.
78
+ script_text_with_exit = "\uFEFF#{script_text.encode(Encoding::UTF_8)}\r\n$Host.SetShouldExit($LASTEXITCODE)"
77
79
  @winrm_file_transporter.upload(StringIO.new(script_text_with_exit), elevated_shell_path)
78
80
  elevated_shell_path
79
81
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: winrm-elevated
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shawn Neal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-10 00:00:00.000000000 Z
11
+ date: 2020-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erubi