Bind Windows script contexts to the installed signed helper
This commit is contained in:
@@ -51,12 +51,29 @@ if ($managed) {
|
||||
$settingsPath = Join-Path $policyRoot 'helper.json'
|
||||
$settings = Get-Content -LiteralPath $settingsPath -Raw | ConvertFrom-Json
|
||||
if ($settings.schema_version -ne 5) { throw 'Managed helper settings required.' }
|
||||
# Old renderers require this input; the successor preserves the complete
|
||||
# existing scope, including an absent long Windows Update permission.
|
||||
$longRuntime = 3600
|
||||
if ($settings.PSObject.Properties['windows_update_max_runtime_seconds']) { $longRuntime = $settings.windows_update_max_runtime_seconds }
|
||||
$rendered = ([ordered]@{binding=$settings.binding; release_id='TO_UUID'
|
||||
agent_sha256='SELECTED_AGENT_SHA256'; helper_sha256='SELECTED_HELPER_SHA256'
|
||||
max_runtime_seconds=$settings.windows_update_max_runtime_seconds; managed_scripts=$true} | ConvertTo-Json -Depth 6 -Compress) |
|
||||
max_runtime_seconds=$longRuntime; managed_scripts=$true} | ConvertTo-Json -Depth 6 -Compress) |
|
||||
& $helperExe --prepare-enrolled-windows-update
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Signed successor helper could not render its pins.' }
|
||||
$pins = $rendered | ConvertFrom-Json
|
||||
# Rollback may select an earlier renderer. Compare the complete protected
|
||||
# policy, allowing only the two release image paths and digests to change.
|
||||
$scope = $pins.helper_settings | ConvertFrom-Json
|
||||
if ($scope.agent.binary -cne (Join-Path (Split-Path $helperExe) 'rmm-agent-windows.exe') -or
|
||||
$scope.helper.binary -cne $helperExe -or $scope.agent.binary_sha256 -cne 'SELECTED_AGENT_SHA256' -or
|
||||
$scope.helper.binary_sha256 -cne 'SELECTED_HELPER_SHA256') { throw 'Rendered helper image pins differ from the selected release.' }
|
||||
foreach ($role in @('agent','helper')) {
|
||||
$scope.$role.binary = $settings.$role.binary
|
||||
$scope.$role.binary_sha256 = $settings.$role.binary_sha256
|
||||
}
|
||||
if (($scope | ConvertTo-Json -Depth 12 -Compress) -cne ($settings | ConvertTo-Json -Depth 12 -Compress)) {
|
||||
throw 'Agent release cannot change the managed script authorization.'
|
||||
}
|
||||
Wait-Stopped 'RmmDiscoveryWindows'
|
||||
Wait-Stopped 'RmmDiscoverySystemHelper'
|
||||
Replace-Pin $settingsPath $pins.helper_settings
|
||||
|
||||
Reference in New Issue
Block a user