Qualify tenant-scoped bootstrap rotation and fresh Windows scripting
This commit is contained in:
@@ -123,7 +123,7 @@ try {
|
||||
Set-Text $ring ($meta.keyring | ConvertTo-Json -Depth 16 -Compress)
|
||||
Set-Text $envelope ($meta.release_envelope | ConvertTo-Json -Depth 16 -Compress)
|
||||
$updater = Join-Path $appStage 'rmm-updater-windows.exe'
|
||||
Get-Download ('/agent/v1/bootstrap/updater' + $query) $updater $meta.updater.bytes $true
|
||||
Get-Download ('/agent/v1/bootstrap/updater' + $query + '&sha256=' + $meta.updater.sha256) $updater $meta.updater.bytes $true
|
||||
if ((Get-Hash $updater) -cne $meta.updater.sha256) { throw 'Bootstrap updater digest mismatch.' }
|
||||
$roles = @('agent', 'helper')
|
||||
for ($i = 0; $i -lt $roles.Count; $i++) {
|
||||
@@ -145,6 +145,25 @@ try {
|
||||
$ca = Join-Path $data 'server-ca.pem'
|
||||
Set-Text (Join-Path $dataStage 'server-ca.pem') $meta.ca_pem
|
||||
$config = [ordered]@{server_name=$gateway.DnsSafeHost; connect_address=$endpoint.ToString(); ca_file=$ca; state_directory=$state; enrollment_token_file=$tokenPath; transport='https'}
|
||||
$localJobs = $verified.minimum_updater_version -ge 2
|
||||
if ($localJobs) {
|
||||
$features = & $agentPath --release-capabilities
|
||||
if ($LASTEXITCODE -ne 0 -or $features -cne 'enrolled-localservice/1') { throw 'Signed agent lacks its required LocalService profile.' }
|
||||
$features = & $updater --release-capabilities
|
||||
if ($LASTEXITCODE -ne 0 -or $features -cne 'release-job-lock/1') { throw 'Stable updater lacks coordinated job draining.' }
|
||||
$trust = $meta.windows_time_trust
|
||||
if (-not $trust -or $meta.job_signing_public_key_hex -cnotmatch '^[0-9a-f]{64}$' -or
|
||||
$trust.key_generation -lt 1 -or @($trust.public_keys_hex.PSObject.Properties).Count -notin (1..8)) { throw 'Missing enrolled Windows job trust.' }
|
||||
foreach ($key in $trust.public_keys_hex.PSObject.Properties) {
|
||||
if ($key.Value -cnotmatch '^[0-9a-f]{64}$' -or $key.Value -ceq $meta.job_signing_public_key_hex) { throw 'Invalid independent time signing key.' }
|
||||
}
|
||||
$policy = [ordered]@{schema_version=1; tenant_id=$tenant; job_signing_public_key_hex=$meta.job_signing_public_key_hex; key_generation=$trust.key_generation; server_instance=(Get-Id $trust.server_instance); public_keys_hex=$trust.public_keys_hex}
|
||||
Set-Text (Join-Path $dataStage 'job-time.json') ($policy | ConvertTo-Json -Depth 8 -Compress)
|
||||
Set-Text (Join-Path $dataStage 'release-job.lock') ''
|
||||
$config['enable_jobs'] = $true
|
||||
$config['localservice_time_policy'] = Join-Path $data 'job-time.json'
|
||||
$config['windows_execution_profile'] = 'powershell_51_remote_signed'
|
||||
}
|
||||
Set-Text (Join-Path $dataStage 'config.json') ($config | ConvertTo-Json -Compress)
|
||||
$baseline = [ordered]@{schema_version=1; tenant_id=$tenant; release_id=$releaseId; release_sequence=$verified.release_sequence; manifest_sha256=(Get-Hash (Join-Path $images 'manifest.json'))}
|
||||
Set-Text (Join-Path $dataStage 'installed-release.json') ($baseline | ConvertTo-Json -Compress)
|
||||
@@ -165,6 +184,7 @@ try {
|
||||
Set-Acl -LiteralPath $app -AclObject (Get-DirectoryAcl $sid 'ReadAndExecute')
|
||||
Set-Acl -LiteralPath $data -AclObject (Get-DirectoryAcl $sid 'ReadAndExecute')
|
||||
[void][IO.Directory]::CreateDirectory($state, (Get-DirectoryAcl $sid 'Modify'))
|
||||
if ($localJobs) { [void][IO.Directory]::CreateDirectory((Join-Path $state 'jobs'), (Get-DirectoryAcl $sid 'Modify')) }
|
||||
# Agent-side private-path checks authenticate the owner as well as the DACL.
|
||||
foreach ($root in @($app, $data)) {
|
||||
foreach ($item in @(Get-ChildItem -LiteralPath $root -Recurse -Force)) {
|
||||
|
||||
Reference in New Issue
Block a user