winrm-elevated 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/winrm-elevated.rb +1 -1
- data/lib/winrm-elevated/scripts/elevated_shell.ps1 +11 -1
- data/lib/winrm/shells/elevated.rb +5 -17
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a697d6786acdc942c9144e8c726d3727ee22983bb21351f7a19be530873ec6a
|
4
|
+
data.tar.gz: cfa396d8c5a62a3a3174d996dc7f30347a4c8f9913468f3d27323067ac1f12e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c76b27bacedf07dd2f525cb98e04ddbb4a045b821eff0d97575e865ade5b980e28c062d5007c39201cd8cf1ed590f9cb6db5b8d4061b721617236afbfabe2f6c
|
7
|
+
data.tar.gz: 79a05661830ddb4b7bcf5423c67891368dc78cdd479278b30d56bd30493f9518e0fc92b3219f8d18ef5e45ece98d05af2595047b4b7f9006ab2f4256adebf1c7
|
data/lib/winrm-elevated.rb
CHANGED
@@ -119,7 +119,17 @@ try { Remove-Item $script_file -ErrorAction Stop } catch {}
|
|
119
119
|
|
120
120
|
$exit_code = $registered_task.LastTaskResult
|
121
121
|
|
122
|
-
try {
|
122
|
+
try {
|
123
|
+
# Clean current task
|
124
|
+
$folder.DeleteTask($task_name, 0)
|
125
|
+
# Clean old tasks if required
|
126
|
+
$old_tasks_filter_date = [datetime]::Now.AddSeconds(<%= -1 * execution_timeout %>)
|
127
|
+
$old_tasks_to_kill = $folder.GetTasks(0) | Select Name,LastRunTime | Where-Object {
|
128
|
+
($_.Name -like "WinRM_Elevated_Shell*") -and ($_.LastRunTime -le $old_tasks_filter_date) -and ($_.Name -ne $task_name)
|
129
|
+
}
|
130
|
+
$old_tasks_to_kill | ForEach-Object { try { $folder.DeleteTask($_.Name, 0) } catch {} }
|
131
|
+
}
|
132
|
+
catch {}
|
123
133
|
|
124
134
|
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($schedule) | Out-Null
|
125
135
|
|
@@ -14,9 +14,10 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
|
16
16
|
require 'erubi'
|
17
|
-
require 'winrm'
|
17
|
+
require 'winrm' unless defined?(WinRM::Connection)
|
18
18
|
require 'winrm-fs'
|
19
|
-
require 'securerandom'
|
19
|
+
require 'securerandom' unless defined?(SecureRandom)
|
20
|
+
require 'stringio'
|
20
21
|
|
21
22
|
module WinRM
|
22
23
|
module Shells
|
@@ -72,24 +73,11 @@ module WinRM
|
|
72
73
|
|
73
74
|
def upload_elevated_shell_script(script_text)
|
74
75
|
elevated_shell_path = 'c:/windows/temp/winrm-elevated-shell-' + SecureRandom.uuid + '.ps1'
|
75
|
-
|
76
|
-
|
77
|
-
end
|
76
|
+
script_text_with_exit = "#{script_text}\r\n$Host.SetShouldExit($LASTEXITCODE)"
|
77
|
+
@winrm_file_transporter.upload(StringIO.new(script_text_with_exit), elevated_shell_path)
|
78
78
|
elevated_shell_path
|
79
79
|
end
|
80
80
|
|
81
|
-
def with_temp_file(script_text)
|
82
|
-
file = Tempfile.new(%w[winrm-elevated-shell ps1])
|
83
|
-
file.write(script_text)
|
84
|
-
file.write("\r\n$Host.SetShouldExit($LASTEXITCODE)")
|
85
|
-
file.fsync
|
86
|
-
file.close
|
87
|
-
yield file.path
|
88
|
-
ensure
|
89
|
-
file.close
|
90
|
-
file.unlink
|
91
|
-
end
|
92
|
-
|
93
81
|
def elevated_shell_script_content
|
94
82
|
IO.read(File.expand_path('../../winrm-elevated/scripts/elevated_shell.ps1', __dir__))
|
95
83
|
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.
|
4
|
+
version: 1.2.2
|
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-
|
11
|
+
date: 2020-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: erubi
|
@@ -134,8 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
- !ruby/object:Gem::Version
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
|
-
|
138
|
-
rubygems_version: 2.7.8
|
137
|
+
rubygems_version: 3.1.2
|
139
138
|
signing_key:
|
140
139
|
specification_version: 4
|
141
140
|
summary: Ruby library for running commands as elevated
|