winrm-elevated 1.1.2 → 1.2.0
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/winrm-elevated/scripts/elevated_shell.ps1 +7 -2
- data/lib/winrm/shells/elevated.rb +6 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e5c9bfe856756ffb48cf79dc0607bf52d9adccb9dd310220337b8410740b8993
|
|
4
|
+
data.tar.gz: 4c12a53e2641725ce24e95c60d5efed248477f6176151ec4920d9d080284d13d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 642b27dfba98db6686b52869737ea9876ed6c4e002e878484277851a793d07ddd00193430f946d8141d8d90a1bbd16dd61b8eae51a183f8bb7b5cb8391853376
|
|
7
|
+
data.tar.gz: 46040a6e7f2d8004b76c4f442628776949003d718a46c41f3916ba75942a8a478ce018ab69171e3a885db00aedadb30b9b3789158026a9cb7dea7b47850a65c4
|
|
@@ -16,7 +16,7 @@ if($interactive -eq 'true') {
|
|
|
16
16
|
$logon_type_xml = "<LogonType>InteractiveTokenOrPassword</LogonType>"
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
$task_name = "
|
|
19
|
+
$task_name = "WinRM_Elevated_Shell_" + (New-Guid).Guid
|
|
20
20
|
$out_file = [System.IO.Path]::GetTempFileName()
|
|
21
21
|
$err_file = [System.IO.Path]::GetTempFileName()
|
|
22
22
|
|
|
@@ -97,11 +97,13 @@ function SlurpOutput($file, $cur_line, $out_type) {
|
|
|
97
97
|
|
|
98
98
|
$err_cur_line = 0
|
|
99
99
|
$out_cur_line = 0
|
|
100
|
+
$timeout = <%= execution_timeout %>
|
|
101
|
+
$startDate = Get-Date
|
|
100
102
|
do {
|
|
101
103
|
Start-Sleep -m 100
|
|
102
104
|
$out_cur_line = SlurpOutput $out_file $out_cur_line 'out'
|
|
103
105
|
$err_cur_line = SlurpOutput $err_file $err_cur_line 'err'
|
|
104
|
-
} while (!($registered_task.state -eq 3))
|
|
106
|
+
} while( (!($registered_task.state -eq 3)) -and ($startDate.AddSeconds($timeout) -gt (Get-Date)) )
|
|
105
107
|
|
|
106
108
|
# We'll make a best effort to clean these files
|
|
107
109
|
# But a reboot could possibly end the task while the process
|
|
@@ -111,6 +113,9 @@ try { Remove-Item $err_file -ErrorAction Stop } catch {}
|
|
|
111
113
|
try { Remove-Item $script_file -ErrorAction Stop } catch {}
|
|
112
114
|
|
|
113
115
|
$exit_code = $registered_task.LastTaskResult
|
|
116
|
+
|
|
117
|
+
try { Unregister-ScheduledTask -TaskName $task_name -Confirm:$false } catch {}
|
|
118
|
+
|
|
114
119
|
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($schedule) | Out-Null
|
|
115
120
|
|
|
116
121
|
exit $exit_code
|
|
@@ -33,6 +33,7 @@ module WinRM
|
|
|
33
33
|
@interactive_logon = false
|
|
34
34
|
@shell = Powershell.new(connection_opts, transport, logger)
|
|
35
35
|
@winrm_file_transporter = WinRM::FS::Core::FileTransporter.new(@shell)
|
|
36
|
+
@execution_timeout = 86_400
|
|
36
37
|
end
|
|
37
38
|
|
|
38
39
|
# @return [String] The admin user name to execute the scheduled task as
|
|
@@ -44,6 +45,9 @@ module WinRM
|
|
|
44
45
|
# @return [Bool] Using an interactive logon
|
|
45
46
|
attr_accessor :interactive_logon
|
|
46
47
|
|
|
48
|
+
# @return [Integer] Timeout for the task to be executed
|
|
49
|
+
attr_accessor :execution_timeout
|
|
50
|
+
|
|
47
51
|
# Run a command or PowerShell script elevated without any of the
|
|
48
52
|
# restrictions that WinRM puts in place.
|
|
49
53
|
#
|
|
@@ -95,7 +99,8 @@ module WinRM
|
|
|
95
99
|
username: username,
|
|
96
100
|
password: password,
|
|
97
101
|
script_path: script_path,
|
|
98
|
-
interactive_logon: interactive_logon
|
|
102
|
+
interactive_logon: interactive_logon,
|
|
103
|
+
execution_timeout: execution_timeout
|
|
99
104
|
}
|
|
100
105
|
|
|
101
106
|
b = binding
|
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.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shawn Neal
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-01-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: erubi
|