Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f21b753ed | ||
|
|
00717e4283 | ||
|
|
aa36b178aa | ||
|
|
d37160ba41 | ||
|
|
577132fb42 | ||
|
|
ca588abce4 | ||
|
|
53d17757ab | ||
|
|
27bb6a1257 | ||
|
|
81d78aaf8f | ||
|
|
0ecfb98204 | ||
|
|
cd44bdb735 | ||
|
|
b0076d14be |
@@ -0,0 +1,268 @@
|
||||
#requires -Version 5.1
|
||||
#requires -RunAsAdministrator
|
||||
# Finish the single, console-verified public-file publication on the test VM.
|
||||
# Run in a fresh Windows PowerShell process. No SSH or RMM job is involved.
|
||||
[CmdletBinding()]
|
||||
param([switch]$InitialCreate)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$caseId = 'ad9fd154-b2be-4f5d-9e17-65abb721ceaf'
|
||||
$controllerHash = 'd8b4fd4fd9ca5310cc1591ce3c2ccae5bd72a2ade43b21a8187cfdfb960b3427'
|
||||
$configHash = '2b4a8a7080770304b80e2a665fa5f5ee1ebbd9182e7c80b184e75b114575b42b'
|
||||
$bootstrap = 'C:\ProgramData\RustDiscoveryBootstrap'
|
||||
$casePath = Join-Path $bootstrap "time-profile-$caseId"
|
||||
$original = Join-Path (Join-Path $bootstrap $controllerHash) 'InstallPublicTimeProfile.ps1'
|
||||
$originalBytes = [IO.File]::ReadAllBytes($original)
|
||||
$sha = [Security.Cryptography.SHA256]::Create()
|
||||
try {
|
||||
$digest = [BitConverter]::ToString($sha.ComputeHash($originalBytes)).Replace('-', '')
|
||||
} finally { $sha.Dispose() }
|
||||
if ($digest -ne $controllerHash) { throw 'Unexpected original controller' }
|
||||
|
||||
# Import the verified definitions (including native FileID/SCM checks) from the
|
||||
# installed original. Its first top-level preflight and install body are excluded.
|
||||
$source = [Text.Encoding]::UTF8.GetString($originalBytes)
|
||||
$boundary = "`nCheckControl `$boot `$true`n"
|
||||
$index = $source.IndexOf($boundary, [StringComparison]::Ordinal)
|
||||
if ($index -lt 1 -or $index -ne $source.LastIndexOf($boundary, [StringComparison]::Ordinal)) {
|
||||
throw 'Original controller definition boundary missing'
|
||||
}
|
||||
$intent = Get-Content -LiteralPath (Join-Path $casePath 'intent.json') -Raw | ConvertFrom-Json
|
||||
if ($intent.id -cne $caseId -or $intent.request.id -cne $caseId -or
|
||||
$intent.request.script_sha256 -cne $controllerHash -or $intent.request.config_sha256 -cne $configHash) {
|
||||
throw 'Unexpected original intent'
|
||||
}
|
||||
$global:RmmTimeProfilePayload = $intent.request
|
||||
. ([scriptblock]::Create($source.Substring(0, $index)))
|
||||
|
||||
CheckControl $boot $true
|
||||
CheckControl $folder $true
|
||||
foreach ($leaf in 'intent.json','publish-intent.json','directory-acl-intent.json','directory-acl-done.json') {
|
||||
CheckControl (Join-Path $folder $leaf) $false
|
||||
}
|
||||
CheckControl $active $false
|
||||
$activeRecord = Get-Content -LiteralPath $active -Raw | ConvertFrom-Json
|
||||
if ($activeRecord.id -cne $caseId -or $activeRecord.script_sha256 -cne $controllerHash -or
|
||||
$activeRecord.config_sha256 -cne $configHash -or $activeRecord.no_retry -ne $true) {
|
||||
throw 'Unexpected active publication record'
|
||||
}
|
||||
$bytes = ConfigBytes
|
||||
$publish = Get-Content -LiteralPath (Join-Path $folder 'publish-intent.json') -Raw | ConvertFrom-Json
|
||||
$aclDone = Get-Content -LiteralPath (Join-Path $folder 'directory-acl-done.json') -Raw | ConvertFrom-Json
|
||||
$staged = Join-Path $folder 'time-attestation.candidate.json'
|
||||
$resultPath = Join-Path $folder 'result.json'
|
||||
$reservation = Join-Path $folder 'console-finalization-intent.json'
|
||||
$initialReservation = Join-Path $folder 'console-initial-create-intent.json'
|
||||
$initialResult = Join-Path $folder 'console-initial-create-result.json'
|
||||
$initialError = Join-Path $folder 'console-initial-create-error.json'
|
||||
$absent = @($target,$resultPath,$initialReservation,$initialResult,$initialError)
|
||||
if ($InitialCreate) {
|
||||
$priorError = Join-Path $folder 'console-finalization-error.json'
|
||||
CheckControl $reservation $false
|
||||
CheckControl $priorError $false
|
||||
$priorReservation = Get-Content -LiteralPath $reservation -Raw | ConvertFrom-Json
|
||||
$priorFailure = Get-Content -LiteralPath $priorError -Raw | ConvertFrom-Json
|
||||
if ($priorReservation.id -cne $caseId -or $priorReservation.config_sha256 -cne $configHash -or
|
||||
$priorFailure.id -cne $caseId -or $priorFailure.phase -cne 'File.Move' -or
|
||||
$priorFailure.hresult -cne '0x80070020' -or $priorFailure.exception -cne 'System.IO.IOException') {
|
||||
throw 'Expected the recorded sharing violation from the original single finalization attempt'
|
||||
}
|
||||
} else {
|
||||
$absent += $reservation
|
||||
}
|
||||
foreach ($path in $absent) {
|
||||
if (Test-Path -LiteralPath $path) { throw 'Existing target or finalization record: read original case' }
|
||||
}
|
||||
$stagedAcl = ReadAcl $staged $false
|
||||
$rootAcl = ReadAcl $helperRoot $true
|
||||
$expected = @{
|
||||
volume_serial = '9815088561147542064'
|
||||
file_id = '6d990300000003000000000000000000'
|
||||
bytes = 1177
|
||||
acl_sha256 = '3a426f649cd6ff4e82bf70205c8ecc7d5b2c0775fa1e10fc30ce35de9bb12493'
|
||||
sha256 = $configHash
|
||||
}
|
||||
if ($publish.create_once -ne $true -or $publish.config_sha256 -cne $configHash -or
|
||||
!(JsonEqual $expected $publish.staged) -or !(JsonEqual $expected (FileIdentity $staged)) -or
|
||||
(FileVolume $helperRoot) -cne $expected.volume_serial -or $rootAcl.Sddl -cne $aclDone.sddl -or
|
||||
(AclHash $helperRoot) -cne '186d85132cf0e16cbb9623ad9636b7777741939a8cae3d689a2af1eb267a7f49') {
|
||||
throw 'Original file identity or permissions changed'
|
||||
}
|
||||
if ($p.probe_sha256 -cne '727732fb4b38ac5431a330527bd52a3ab80af8f189ae75a7b48eceb1d4b69cac' -or
|
||||
$p.system_probe_sha256 -cne '77a344912c61b7ac4a92152ae1b534ca7c36fe6f7dc4675783f20558c3a7f434') {
|
||||
throw 'Unexpected native status probes'
|
||||
}
|
||||
$before = ActualState $true
|
||||
SameLive $request.expected_native $before
|
||||
SameLive $intent.before $before
|
||||
if ($before.agent_kernel.creation_filetime -cne '134392294174782153' -or
|
||||
$before.helper_kernel.creation_filetime -cne '134392294130218261') { throw 'Service generation changed' }
|
||||
|
||||
# FileStandardInfo supplies the hard-link count and directory/delete-pending state
|
||||
# from the same exclusive handle used to write, flush, hash and publish the DACL.
|
||||
function Initialize-InitialProfileNative {
|
||||
Add-Type -TypeDefinition @'
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
|
||||
public static class RmmInitialProfileFile {
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct StandardInfo {
|
||||
public long AllocationSize, EndOfFile;
|
||||
public uint NumberOfLinks;
|
||||
public byte DeletePending, Directory;
|
||||
}
|
||||
[DllImport("kernel32.dll", SetLastError=true)]
|
||||
private static extern bool GetFileInformationByHandleEx(
|
||||
SafeFileHandle handle, int infoClass, out StandardInfo info, uint size);
|
||||
public static void CheckSingleFile(SafeFileHandle handle, long expectedLength) {
|
||||
StandardInfo info;
|
||||
if (!GetFileInformationByHandleEx(handle, 1, out info, (uint)Marshal.SizeOf(typeof(StandardInfo))))
|
||||
throw new Win32Exception(Marshal.GetLastWin32Error());
|
||||
if (info.NumberOfLinks != 1 || info.DeletePending != 0 || info.Directory != 0 ||
|
||||
info.EndOfFile != expectedLength)
|
||||
throw new InvalidOperationException("Expected one regular file of the exact size");
|
||||
}
|
||||
}
|
||||
'@
|
||||
}
|
||||
|
||||
function Get-HeldProfileIdentity([IO.FileStream]$Stream) {
|
||||
[RmmInitialProfileFile]::CheckSingleFile($Stream.SafeFileHandle, 1177)
|
||||
$id = New-Object RmmPipeNative+FileId
|
||||
if (![RmmPipeNative]::GetFileInformationByHandleEx($Stream.SafeFileHandle, 18, [ref]$id, 24)) {
|
||||
throw 'New file identity unavailable'
|
||||
}
|
||||
$Stream.Position = 0
|
||||
$algorithm = [Security.Cryptography.SHA256]::Create()
|
||||
try { $digest = [BitConverter]::ToString($algorithm.ComputeHash($Stream)).Replace('-','').ToLowerInvariant() }
|
||||
finally { $algorithm.Dispose() }
|
||||
$sddl = $Stream.GetAccessControl().GetSecurityDescriptorSddlForm($aclSections)
|
||||
return @{
|
||||
volume_serial=$id.Volume.ToString([Globalization.CultureInfo]::InvariantCulture)
|
||||
file_id=([BitConverter]::ToString($id.Id)).Replace('-','').ToLowerInvariant()
|
||||
bytes=$Stream.Length; sha256=$digest; acl_sha256=(BytesHash ([Text.Encoding]::UTF8.GetBytes($sddl)))
|
||||
}
|
||||
}
|
||||
|
||||
function New-OriginalPublicProfile {
|
||||
Initialize-InitialProfileNative
|
||||
$aclSections = [Security.AccessControl.AccessControlSections]'Owner,Group,Access'
|
||||
$accessOnly = [Security.AccessControl.AccessControlSections]::Access
|
||||
$draftAcl = [Security.AccessControl.FileSecurity]::new()
|
||||
$draftAcl.SetSecurityDescriptorSddlForm($stagedAcl.Sddl, $aclSections)
|
||||
foreach ($sid in @($agentSid,$helperSid)) {
|
||||
$deny = [Security.AccessControl.FileSystemAccessRule]::new(
|
||||
[Security.Principal.SecurityIdentifier]::new($sid),
|
||||
[Security.AccessControl.FileSystemRights]::ReadData, [Security.AccessControl.AccessControlType]::Deny)
|
||||
$draftAcl.AddAccessRule($deny)
|
||||
}
|
||||
$draftSddl = $draftAcl.GetSecurityDescriptorSddlForm($aclSections)
|
||||
if (!$draftAcl.AreAccessRulesProtected -or $draftSddl -ceq $stagedAcl.Sddl) { throw 'Initial protected DACL required' }
|
||||
|
||||
# Record the lower bound immediately before the only possible first creation.
|
||||
$since = [DateTime]::UtcNow.ToString('o')
|
||||
WriteNew $initialReservation @{id=$caseId; config_sha256=$configHash; utc=$since; staged=$expected; create_new=$true}
|
||||
$phase = 'CreateNew'
|
||||
try {
|
||||
$rights = [Security.AccessControl.FileSystemRights]'ReadData,WriteData,ReadAttributes,ReadPermissions,ChangePermissions,Synchronize'
|
||||
$stream = [IO.FileStream]::new($target, [IO.FileMode]::CreateNew,
|
||||
$rights, [IO.FileShare]::None, 4096,
|
||||
[IO.FileOptions]::WriteThrough, $draftAcl)
|
||||
try {
|
||||
$phase = 'verify_creation'
|
||||
if ($stream.GetAccessControl().GetSecurityDescriptorSddlForm($aclSections) -cne $draftSddl) {
|
||||
throw 'Unexpected security descriptor on new file'
|
||||
}
|
||||
[RmmInitialProfileFile]::CheckSingleFile($stream.SafeFileHandle, 0)
|
||||
$phase = 'write_verify'
|
||||
$stream.Write($bytes, 0, $bytes.Length)
|
||||
$stream.Flush($true)
|
||||
$new = Get-HeldProfileIdentity $stream
|
||||
if ($new.volume_serial -cne $expected.volume_serial -or $new.file_id -ceq $expected.file_id -or
|
||||
$new.file_id -ceq ('0' * 32) -or $new.sha256 -cne $configHash -or
|
||||
$new.acl_sha256 -cne (BytesHash ([Text.Encoding]::UTF8.GetBytes($draftSddl)))) {
|
||||
throw 'New held bytes, identity or staging permissions differ'
|
||||
}
|
||||
SameLive $before (ActualState $true)
|
||||
$null = Kernel 'agent' $before.service $heldAgent
|
||||
$null = Kernel 'helper' $before.helper_service $heldHelper
|
||||
if (!(JsonEqual $expected (FileIdentity $staged)) -or (AclHash $helperRoot) -cne $rootAclHash) {
|
||||
throw 'Original source or target directory changed before publication'
|
||||
}
|
||||
WriteNew (Join-Path $folder 'console-initial-create-verified.json') @{
|
||||
id=$caseId; utc=$since; original_candidate=$expected; held_target=$new
|
||||
}
|
||||
# Change only the DACL by handle after the verified bytes and FileID
|
||||
# are durable. A crash before this point leaves service reads denied.
|
||||
$phase = 'publish_dacl'
|
||||
$final = $stream.GetAccessControl()
|
||||
$final.SetSecurityDescriptorSddlForm($stagedAcl.Sddl, $accessOnly)
|
||||
$stream.SetAccessControl($final)
|
||||
$stream.Flush($true)
|
||||
$new.acl_sha256 = $expected.acl_sha256
|
||||
if (!(JsonEqual $new (Get-HeldProfileIdentity $stream))) { throw 'Held publication readback failed' }
|
||||
} finally { $stream.Dispose() }
|
||||
|
||||
$phase = 'readback'
|
||||
$null = ReadAcl $target $false
|
||||
$published = FileIdentity $target
|
||||
if (!(JsonEqual $new $published) -or !(JsonEqual $expected (FileIdentity $staged)) -or
|
||||
(AclHash $helperRoot) -cne $rootAclHash) { throw 'Final source/target binding failed' }
|
||||
$after = ActualState $true
|
||||
SameLive $before $after
|
||||
$null = Kernel 'agent' $before.service $heldAgent
|
||||
$null = Kernel 'helper' $before.helper_service $heldHelper
|
||||
WriteNew $initialResult @{
|
||||
id=$caseId; installed=$true; publication_since=$since; configuration=$published
|
||||
original_candidate=$expected; source_candidate_preserved=$true; initial_create=$true
|
||||
native=$after; clock_runtime_qualified=$false; services_changed=$false; private_key_read=$false
|
||||
no_jobs=$true; original_move_failed=$true
|
||||
}
|
||||
} catch {
|
||||
$cause = $_.Exception.GetBaseException()
|
||||
WriteNew $initialError @{id=$caseId; phase=$phase; hresult=('0x{0:X8}' -f $cause.HResult); exception=$cause.GetType().FullName}
|
||||
throw
|
||||
}
|
||||
}
|
||||
|
||||
$heldAgent = [RmmPipeNative]::Open([int]$before.service.pid)
|
||||
try {
|
||||
$heldHelper = [RmmPipeNative]::Open([int]$before.helper_service.pid)
|
||||
try {
|
||||
$null = Kernel 'agent' $before.service $heldAgent
|
||||
$null = Kernel 'helper' $before.helper_service $heldHelper
|
||||
if ($InitialCreate) {
|
||||
$rootAclHash = '186d85132cf0e16cbb9623ad9636b7777741939a8cae3d689a2af1eb267a7f49'
|
||||
New-OriginalPublicProfile
|
||||
'Zeitprofil erstmalig erstellt und anhand seiner neuen Dateiidentitaet geprueft.'
|
||||
return
|
||||
}
|
||||
# WriteNew uses CreateNew. Concurrent or later invocations cannot republish.
|
||||
WriteNew $reservation @{id=$caseId; config_sha256=$configHash; utc=[DateTime]::UtcNow.ToString('o')}
|
||||
try {
|
||||
[IO.File]::Move($staged, $target)
|
||||
} catch {
|
||||
$cause = $_.Exception.GetBaseException()
|
||||
$failure = @{id=$caseId; phase='File.Move'; hresult=('0x{0:X8}' -f $cause.HResult); exception=$cause.GetType().FullName}
|
||||
WriteNew (Join-Path $folder 'console-finalization-error.json') $failure
|
||||
throw ("File.Move: {0} ({1})." -f $failure.exception, $failure.hresult)
|
||||
}
|
||||
$null = ReadAcl $target $false
|
||||
$published = FileIdentity $target
|
||||
if (!(JsonEqual $expected $published) -or (Test-Path -LiteralPath $staged)) { throw 'Publication postcheck failed' }
|
||||
$after = ActualState $true
|
||||
SameLive $before $after
|
||||
$null = Kernel 'agent' $before.service $heldAgent
|
||||
$null = Kernel 'helper' $before.helper_service $heldHelper
|
||||
WriteNew $resultPath @{
|
||||
id=$caseId; installed=$true; install_not_before=$intent.install_not_before
|
||||
configuration=$published; native=$after; original_root_sddl=$intent.original_root_sddl
|
||||
root_sddl=(Get-Acl -LiteralPath $helperRoot).Sddl; no_jobs=$true
|
||||
clock_runtime_qualified=$false; services_changed=$false; private_key_read=$false
|
||||
console_finalized=$true; original_move_failed=$true
|
||||
}
|
||||
'Zeitprofil veroeffentlicht; Dateiidentitaet und Dienstgenerationen geprueft.'
|
||||
} finally { $heldHelper.Dispose() }
|
||||
} finally { $heldAgent.Dispose() }
|
||||
@@ -0,0 +1,105 @@
|
||||
#requires -Version 5.1
|
||||
#requires -RunAsAdministrator
|
||||
# The relay receives a fixed public receipt. There is no command reader.
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$until = [DateTimeOffset]::Parse('2026-11-15T17:00:00+00:00')
|
||||
$deadline = [DateTimeOffset]::UtcNow.AddMinutes(12)
|
||||
if ($deadline -gt $until) { $deadline = $until }
|
||||
if ($deadline -le [DateTimeOffset]::UtcNow) { throw 'Das Wartungsfenster ist abgelaufen.' }
|
||||
|
||||
$base = 'https://gitea.incoso.eu/kevin_janssen/rust-discovery/raw/commit/577132fb422bf854276b3afb5bafdb12d2c08427/deploy/windows'
|
||||
$bootstrap = 'C:\ProgramData\RustDiscoveryBootstrap'
|
||||
$caseId = 'ad9fd154-b2be-4f5d-9e17-65abb721ceaf'
|
||||
$case = Join-Path $bootstrap "time-profile-$caseId"
|
||||
$access = 'C:\ProgramData\RmmDevAccess'
|
||||
$sshBin = Join-Path $env:WINDIR 'System32\OpenSSH'
|
||||
$known = Join-Path $access 'known_hosts'
|
||||
$key = Join-Path $access 'tunnel_ed25519'
|
||||
$fp = & "$sshBin\ssh-keygen.exe" -lf $known
|
||||
if ($LASTEXITCODE -ne 0 -or @($fp).Count -ne 1 -or
|
||||
$fp.Split(' ')[1] -cne 'SHA256:+NEin4XJc3CbhjQi7/ZpMIgxOrXn8AT2tlpTaXW5quw') { throw 'Server-Hostpin stimmt nicht.' }
|
||||
$session = [guid]::NewGuid().ToString()
|
||||
$work = Join-Path $bootstrap "time-receipt-$session"
|
||||
$null = New-Item -ItemType Directory -Path $work
|
||||
$listener = $null
|
||||
$ssh = $null
|
||||
$scripts = [ordered]@{
|
||||
'Complete-OriginalTimeProfile.ps1' = '5ad85ae7a3a513d3cc2f5f5dca3e48eb42fd863522c3384f9c64cdcf0273ef1a'
|
||||
'Read-PassiveTimeSamples.ps1' = 'd9e2b9344c19af1296b86ec70ba754ef820f369ac5ec897979bd4233e0722d04'
|
||||
}
|
||||
try {
|
||||
foreach ($name in $scripts.Keys) {
|
||||
$path = Join-Path $work $name
|
||||
Invoke-WebRequest -UseBasicParsing -Uri "$base/$name" -OutFile $path -TimeoutSec 30
|
||||
if ((Get-FileHash -LiteralPath $path).Hash -ne $scripts[$name]) { throw "Downloadhash: $name" }
|
||||
Unblock-File -LiteralPath $path
|
||||
}
|
||||
$listener = [Net.Sockets.TcpListener]::new([Net.IPAddress]::Loopback, 0)
|
||||
$listener.Start(4)
|
||||
$port = $listener.LocalEndpoint.Port
|
||||
$options = @('-F','NUL','-N','-T','-o','BatchMode=yes','-o','IdentitiesOnly=yes',
|
||||
'-o','ForwardAgent=no','-o','StrictHostKeyChecking=yes','-o','GlobalKnownHostsFile=NUL',
|
||||
'-o',"UserKnownHostsFile=$known",'-o','ExitOnForwardFailure=yes','-o','ConnectTimeout=10',
|
||||
'-o','ServerAliveInterval=15','-o','ServerAliveCountMax=2','-i',$key,
|
||||
'-R',"127.0.0.1:22240:127.0.0.1:$port",'rmm-win-tunnel@discovery.ease-technologies.de')
|
||||
$ssh = Start-Process -FilePath "$sshBin\ssh.exe" -ArgumentList $options -PassThru -NoNewWindow
|
||||
if ($ssh.WaitForExit(1800)) { throw "SSH Exit $($ssh.ExitCode)" }
|
||||
Write-Host 'Wartungsfenster aktiv. Dieses Fenster offen lassen. Strg+C beendet es.'
|
||||
$receipt = [ordered]@{session=$session; case_id=$caseId; phase='preflight'; read_only_channel=$true}
|
||||
$result = Join-Path $case 'result.json'
|
||||
try {
|
||||
if (!(Test-Path -LiteralPath $result)) {
|
||||
$null = & (Join-Path $work 'Complete-OriginalTimeProfile.ps1')
|
||||
}
|
||||
$record = Get-Content -LiteralPath $result -Raw | ConvertFrom-Json
|
||||
$actual = Get-FileHash -LiteralPath 'C:\ProgramData\RustDiscoverySystem\time-attestation.json'
|
||||
if ($record.id -cne $caseId -or $record.installed -ne $true -or
|
||||
$record.console_finalized -ne $true -or $record.clock_runtime_qualified -ne $false -or
|
||||
$actual.Hash -ne '2b4a8a7080770304b80e2a665fa5f5ee1ebbd9182e7c80b184e75b114575b42b') { throw 'Unexpected publication result' }
|
||||
$marker = Get-Content -LiteralPath (Join-Path $case 'console-finalization-intent.json') -Raw | ConvertFrom-Json
|
||||
if ($marker.id -cne $caseId -or $marker.config_sha256 -ne $actual.Hash) { throw 'Unexpected finalization intent' }
|
||||
$receipt.phase = 'published'
|
||||
$receipt.publication_since = $marker.utc
|
||||
$receipt.result_sha256 = (Get-FileHash -LiteralPath $result).Hash
|
||||
} catch {
|
||||
$receipt.phase = 'finalization_failed'
|
||||
$receipt.exception_type = $_.Exception.GetBaseException().GetType().FullName
|
||||
$receipt.line = $_.InvocationInfo.ScriptLineNumber
|
||||
$receipt.file = [IO.Path]::GetFileName($_.InvocationInfo.ScriptName)
|
||||
Write-Warning $_.Exception.Message
|
||||
$failurePath = Join-Path $case 'console-finalization-error.json'
|
||||
if (Test-Path -LiteralPath $failurePath) {
|
||||
$failure = Get-Content -LiteralPath $failurePath -Raw | ConvertFrom-Json
|
||||
if ($failure.id -ceq $caseId -and $failure.hresult -cmatch '^0x[0-9A-Fa-f]{8}$') { $receipt.move_hresult = $failure.hresult }
|
||||
}
|
||||
}
|
||||
$readScript = Join-Path $work 'Read-PassiveTimeSamples.ps1'
|
||||
$readInput = @{id=$session; agent_sha256='0549d9ebea73cff996938f859b92192cc333de194128d7c6859a3f1d2e85893c'; helper_sha256='59675a3cbb3a5d213fc764f38379d6b81baaf9d47a7124470cc2767d4985763e'} | ConvertTo-Json -Compress
|
||||
while ([DateTimeOffset]::UtcNow -lt $deadline -and !$ssh.HasExited) {
|
||||
if (!$listener.Pending()) { Start-Sleep -Milliseconds 250; continue }
|
||||
$client = $listener.AcceptTcpClient()
|
||||
try {
|
||||
if ($receipt.phase -eq 'published') {
|
||||
$receipt.native = $null
|
||||
try {
|
||||
$json = $readInput | & "$env:WINDIR\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy RemoteSigned -File $readScript
|
||||
if ($LASTEXITCODE -eq 0) { $receipt.native = ($json -join "`n") | ConvertFrom-Json }
|
||||
} catch { Write-Warning 'Passive Zeitbelege aktuell nicht lesbar.' }
|
||||
}
|
||||
$client.SendTimeout = 3000
|
||||
$body = [Text.Encoding]::UTF8.GetBytes(($receipt | ConvertTo-Json -Depth 16 -Compress))
|
||||
if ($body.Length -gt 65536) { throw 'Ergebnis zu gross.' }
|
||||
$client.GetStream().Write($body,0,$body.Length)
|
||||
} catch { Write-Warning $_.Exception.Message } finally { $client.Dispose() }
|
||||
}
|
||||
} finally {
|
||||
if ($null -ne $ssh) {
|
||||
try { if (!$ssh.HasExited) { $ssh.Kill(); $ssh.WaitForExit() } } finally { $ssh.Dispose() }
|
||||
}
|
||||
if ($null -ne $listener) { $listener.Stop() }
|
||||
foreach ($name in $scripts.Keys) {
|
||||
$path = Join-Path $work $name
|
||||
if (Test-Path -LiteralPath $path) { Remove-Item -LiteralPath $path }
|
||||
}
|
||||
if ((Get-ChildItem -LiteralPath $work -Force | Measure-Object).Count -eq 0) { [IO.Directory]::Delete($work) }
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
$ErrorActionPreference='Stop';$p=([Console]::In.ReadLine()|ConvertFrom-Json)
|
||||
if((($p.PSObject.Properties.Name|Sort-Object)-join',')-cne'agent_sha256,helper_sha256,id'-or[guid]::ParseExact($p.id,'D').ToString()-cne$p.id-or$p.agent_sha256-cnotmatch'^[0-9a-f]{64}$'-or$p.helper_sha256-cnotmatch'^[0-9a-f]{64}$'){throw 'Fixed public sample read'}
|
||||
$state='C:\ProgramData\RustDiscovery\state';$agent='RmmDiscoveryWindows';$helper='RmmDiscoverySystemHelper'
|
||||
$agentSid=(New-Object Security.Principal.NTAccount('NT SERVICE',$agent)).Translate([Security.Principal.SecurityIdentifier]).Value
|
||||
$allowed=@('S-1-5-18','S-1-5-32-544',$agentSid)
|
||||
function Check($path,[bool]$directory){
|
||||
$i=Get-Item -LiteralPath $path -Force
|
||||
if($i.PSIsContainer-ne$directory-or($i.Attributes-band[IO.FileAttributes]::ReparsePoint)){throw 'Regular public report path'}
|
||||
$ancestor=$i.Directory;if($directory){$ancestor=$i.Parent};while($null-ne$ancestor){if($ancestor.Attributes-band[IO.FileAttributes]::ReparsePoint){throw 'Public report reparse ancestry'};$ancestor=$ancestor.Parent}
|
||||
$acl=Get-Acl -LiteralPath $path;$owner=$acl.GetOwner([Security.Principal.SecurityIdentifier]).Value
|
||||
if($owner-cnotin$allowed-and!(!$directory-and$owner-ceq'S-1-5-19')){throw 'Public report owner'}
|
||||
$rules=@($acl.GetAccessRules($true,$true,[Security.Principal.SecurityIdentifier]));if(!$rules.Count){throw 'Public report empty DACL'}
|
||||
foreach($r in $rules){if($r.AccessControlType-ne'Allow'-or$r.IdentityReference.Value-cnotin$allowed){throw 'Public report broad DACL'}}
|
||||
if($directory-and!$acl.AreAccessRulesProtected){throw 'Protected public report directory'}
|
||||
return @{owner_sid=$owner;sddl=$acl.Sddl;dacl_checked=$true}
|
||||
}
|
||||
Add-Type -TypeDefinition @'
|
||||
using System; using System.Text; using System.Runtime.InteropServices; using Microsoft.Win32.SafeHandles;
|
||||
public static class RmmPassiveTimeRead {
|
||||
[StructLayout(LayoutKind.Sequential)] public struct Info {public uint Attr,CL,CH,AL,AH,WL,WH,Volume,SizeH,SizeL,Links,IndexH,IndexL;}
|
||||
[DllImport("kernel32.dll",SetLastError=true)] public static extern bool GetFileInformationByHandle(SafeFileHandle h,out Info i);
|
||||
[DllImport("kernel32.dll",SetLastError=true)] static extern IntPtr OpenProcess(uint access,bool inherit,int pid);
|
||||
[DllImport("kernel32.dll",SetLastError=true,CharSet=CharSet.Unicode)] static extern bool QueryFullProcessImageName(IntPtr h,uint flags,StringBuilder text,ref uint size);
|
||||
[DllImport("kernel32.dll",SetLastError=true)] static extern bool GetProcessTimes(IntPtr h,out long creation,out long exit,out long kernel,out long user);
|
||||
[DllImport("kernel32.dll",SetLastError=true)] static extern bool GetExitCodeProcess(IntPtr h,out uint code);
|
||||
[DllImport("kernel32.dll")] static extern bool CloseHandle(IntPtr h);
|
||||
public static string[] Process(int pid){IntPtr h=OpenProcess(0x1000,false,pid);if(h==IntPtr.Zero)throw new InvalidOperationException("QUERY_PROCESS");try{long c,e,k,u;uint code,size=32768;StringBuilder image=new StringBuilder((int)size);if(!GetProcessTimes(h,out c,out e,out k,out u)||!QueryFullProcessImageName(h,0,image,ref size)||!GetExitCodeProcess(h,out code)||code!=259)throw new InvalidOperationException("LIVE_PROCESS");return new string[]{c.ToString(System.Globalization.CultureInfo.InvariantCulture),image.ToString()};}finally{CloseHandle(h);}}
|
||||
}
|
||||
'@
|
||||
function Hash([byte[]]$bytes){$h=[Security.Cryptography.SHA256]::Create();try{return([BitConverter]::ToString($h.ComputeHash($bytes))).Replace('-','').ToLowerInvariant()}finally{$h.Dispose()}}
|
||||
function Runtime($role){
|
||||
$name=$agent;$image='C:\Program Files\RustDiscovery\rmm-agent-windows.exe';$owner='NT AUTHORITY\LocalService';$mode='Auto';$sha=$p.agent_sha256
|
||||
if($role-ceq'helper'){$name=$helper;$image='C:\Program Files\RustDiscovery\rmm-helper-windows.exe';$owner='LocalSystem';$mode='Manual';$sha=$p.helper_sha256}
|
||||
$s=Get-CimInstance Win32_Service -Filter ("Name='"+$name+"'") -OperationTimeoutSec 5
|
||||
if(!$s-or$s.State-cne'Running'-or$s.StartName-cne$owner-or$s.StartMode-cne$mode-or$s.ProcessId-le0-or$s.ServiceType-cne'Own Process'){throw 'Current fixed service role'}
|
||||
$expected='"'+$image+'" --service';if($role-ceq'agent'){$expected+=' --config "C:\ProgramData\RustDiscovery\config.json"'}
|
||||
if($s.PathName-cne$expected){throw 'Current fixed service command'}
|
||||
$native=[RmmPassiveTimeRead]::Process([int]$s.ProcessId)
|
||||
if($native[1]-cne$image-or(Get-FileHash -LiteralPath $image -Algorithm SHA256).Hash.ToLowerInvariant()-cne$sha){throw 'Current fixed service image'}
|
||||
return [ordered]@{pid=[uint32]$s.ProcessId;birth_filetime=$native[0];image=$native[1];sha256=$sha;start_name=$s.StartName;start_mode=$s.StartMode;command=$s.PathName}
|
||||
}
|
||||
function Boot{return (Get-CimInstance Win32_OperatingSystem -Property LastBootUpTime -OperationTimeoutSec 5).LastBootUpTime.ToUniversalTime().Ticks.ToString([Globalization.CultureInfo]::InvariantCulture)}
|
||||
$null=Check 'C:\ProgramData\RustDiscovery' $true;$directory=Check $state $true
|
||||
$boot=Boot;$before=[ordered]@{agent=(Runtime 'agent');helper=(Runtime 'helper')};$reports=[ordered]@{}
|
||||
foreach($name in @('agent-time-sample.json','helper-time-sample.json')){
|
||||
$path=Join-Path $state $name
|
||||
if(!(Test-Path -LiteralPath $path)){$reports[$name]=$null;continue}
|
||||
$stream=[IO.File]::Open($path,[IO.FileMode]::Open,[IO.FileAccess]::Read,[IO.FileShare]::Read)
|
||||
try{
|
||||
$meta=Check $path $false;$info=New-Object RmmPassiveTimeRead+Info
|
||||
if(![RmmPassiveTimeRead]::GetFileInformationByHandle($stream.SafeFileHandle,[ref]$info)-or$info.Links-ne1-or($info.Attr-band0x410)-ne0-or$info.SizeH-ne0-or$info.SizeL-lt1-or$info.SizeL-gt8192-or$stream.Length-ne$info.SizeL){throw 'Single-link bounded public report'}
|
||||
$raw=New-Object byte[] $info.SizeL;$offset=0;while($offset-lt$raw.Length){$count=$stream.Read($raw,$offset,$raw.Length-$offset);if($count-le0){throw 'Complete held public report'};$offset+=$count}
|
||||
$after=New-Object RmmPassiveTimeRead+Info
|
||||
if(![RmmPassiveTimeRead]::GetFileInformationByHandle($stream.SafeFileHandle,[ref]$after)-or$after.IndexH-ne$info.IndexH-or$after.IndexL-ne$info.IndexL-or$after.WH-ne$info.WH-or$after.WL-ne$info.WL-or$after.SizeL-ne$info.SizeL-or$after.Links-ne1){throw 'Stable held public report'}
|
||||
$again=Check $path $false;if($again.sddl-cne$meta.sddl-or$again.owner_sid-cne$meta.owner_sid){throw 'Stable public report security'}
|
||||
$meta['volume']=$info.Volume;$meta['index_high']=$info.IndexH;$meta['index_low']=$info.IndexL;$meta['last_write_filetime']=(([uint64]$info.WH-shl32)-bor$info.WL).ToString([Globalization.CultureInfo]::InvariantCulture)
|
||||
$reports[$name]=@{raw_base64=[Convert]::ToBase64String($raw);sha256=(Hash $raw);metadata=$meta}
|
||||
}finally{$stream.Dispose()}
|
||||
}
|
||||
$after=[ordered]@{agent=(Runtime 'agent');helper=(Runtime 'helper')}
|
||||
$directoryAfter=Check $state $true
|
||||
if(($before|ConvertTo-Json -Depth 8 -Compress)-cne($after|ConvertTo-Json -Depth 8 -Compress)-or(Boot)-cne$boot-or$directory.sddl-cne$directoryAfter.sddl){throw 'Stable process, directory and boot during public read'}
|
||||
@{id=$p.id;read_only=$true;boot_ticks=$boot;runtime=$after;state_metadata=$directory;reports=$reports;observed_at=[DateTime]::UtcNow.ToString('o')}|ConvertTo-Json -Depth 12 -Compress
|
||||
@@ -27,70 +27,7 @@ SECOND_NS = 1_000_000_000
|
||||
# No report is requested from a service. The only content reads on the guest
|
||||
# are these two public JSONs and public executable hashes. CIM/process queries
|
||||
# obtain current boot/SCM/image/birth metadata without starting another binary.
|
||||
SCRIPT = r'''$ErrorActionPreference='Stop';$p=([Console]::In.ReadLine()|ConvertFrom-Json)
|
||||
if((($p.PSObject.Properties.Name|Sort-Object)-join',')-cne'agent_sha256,helper_sha256,id'-or[guid]::ParseExact($p.id,'D').ToString()-cne$p.id-or$p.agent_sha256-cnotmatch'^[0-9a-f]{64}$'-or$p.helper_sha256-cnotmatch'^[0-9a-f]{64}$'){throw 'Fixed public sample read'}
|
||||
$state='C:\ProgramData\RustDiscovery\state';$agent='RmmDiscoveryWindows';$helper='RmmDiscoverySystemHelper'
|
||||
$agentSid=(New-Object Security.Principal.NTAccount('NT SERVICE',$agent)).Translate([Security.Principal.SecurityIdentifier]).Value
|
||||
$allowed=@('S-1-5-18','S-1-5-32-544',$agentSid)
|
||||
function Check($path,[bool]$directory){
|
||||
$i=Get-Item -LiteralPath $path -Force
|
||||
if($i.PSIsContainer-ne$directory-or($i.Attributes-band[IO.FileAttributes]::ReparsePoint)){throw 'Regular public report path'}
|
||||
$ancestor=$i.Directory;if($directory){$ancestor=$i.Parent};while($null-ne$ancestor){if($ancestor.Attributes-band[IO.FileAttributes]::ReparsePoint){throw 'Public report reparse ancestry'};$ancestor=$ancestor.Parent}
|
||||
$acl=Get-Acl -LiteralPath $path;$owner=$acl.GetOwner([Security.Principal.SecurityIdentifier]).Value
|
||||
if($owner-cnotin$allowed-and!(!$directory-and$owner-ceq'S-1-5-19')){throw 'Public report owner'}
|
||||
$rules=@($acl.GetAccessRules($true,$true,[Security.Principal.SecurityIdentifier]));if(!$rules.Count){throw 'Public report empty DACL'}
|
||||
foreach($r in $rules){if($r.AccessControlType-ne'Allow'-or$r.IdentityReference.Value-cnotin$allowed){throw 'Public report broad DACL'}}
|
||||
if($directory-and!$acl.AreAccessRulesProtected){throw 'Protected public report directory'}
|
||||
return @{owner_sid=$owner;sddl=$acl.Sddl;dacl_checked=$true}
|
||||
}
|
||||
Add-Type -TypeDefinition @'
|
||||
using System; using System.Text; using System.Runtime.InteropServices; using Microsoft.Win32.SafeHandles;
|
||||
public static class RmmPassiveTimeRead {
|
||||
[StructLayout(LayoutKind.Sequential)] public struct Info {public uint Attr,CL,CH,AL,AH,WL,WH,Volume,SizeH,SizeL,Links,IndexH,IndexL;}
|
||||
[DllImport("kernel32.dll",SetLastError=true)] public static extern bool GetFileInformationByHandle(SafeFileHandle h,out Info i);
|
||||
[DllImport("kernel32.dll",SetLastError=true)] static extern IntPtr OpenProcess(uint access,bool inherit,int pid);
|
||||
[DllImport("kernel32.dll",SetLastError=true,CharSet=CharSet.Unicode)] static extern bool QueryFullProcessImageName(IntPtr h,uint flags,StringBuilder text,ref uint size);
|
||||
[DllImport("kernel32.dll",SetLastError=true)] static extern bool GetProcessTimes(IntPtr h,out long creation,out long exit,out long kernel,out long user);
|
||||
[DllImport("kernel32.dll",SetLastError=true)] static extern bool GetExitCodeProcess(IntPtr h,out uint code);
|
||||
[DllImport("kernel32.dll")] static extern bool CloseHandle(IntPtr h);
|
||||
public static string[] Process(int pid){IntPtr h=OpenProcess(0x1000,false,pid);if(h==IntPtr.Zero)throw new InvalidOperationException("QUERY_PROCESS");try{long c,e,k,u;uint code,size=32768;StringBuilder image=new StringBuilder((int)size);if(!GetProcessTimes(h,out c,out e,out k,out u)||!QueryFullProcessImageName(h,0,image,ref size)||!GetExitCodeProcess(h,out code)||code!=259)throw new InvalidOperationException("LIVE_PROCESS");return new string[]{c.ToString(System.Globalization.CultureInfo.InvariantCulture),image.ToString()};}finally{CloseHandle(h);}}
|
||||
}
|
||||
'@
|
||||
function Hash([byte[]]$bytes){$h=[Security.Cryptography.SHA256]::Create();try{return([BitConverter]::ToString($h.ComputeHash($bytes))).Replace('-','').ToLowerInvariant()}finally{$h.Dispose()}}
|
||||
function Runtime($role){
|
||||
$name=$agent;$image='C:\Program Files\RustDiscovery\rmm-agent-windows.exe';$owner='NT AUTHORITY\LocalService';$mode='Auto';$sha=$p.agent_sha256
|
||||
if($role-ceq'helper'){$name=$helper;$image='C:\Program Files\RustDiscovery\rmm-helper-windows.exe';$owner='LocalSystem';$mode='Manual';$sha=$p.helper_sha256}
|
||||
$s=Get-CimInstance Win32_Service -Filter ("Name='"+$name+"'") -OperationTimeoutSec 5
|
||||
if(!$s-or$s.State-cne'Running'-or$s.StartName-cne$owner-or$s.StartMode-cne$mode-or$s.ProcessId-le0-or$s.ServiceType-cne'Own Process'){throw 'Current fixed service role'}
|
||||
$expected='"'+$image+'" --service';if($role-ceq'agent'){$expected+=' --config "C:\ProgramData\RustDiscovery\config.json"'}
|
||||
if($s.PathName-cne$expected){throw 'Current fixed service command'}
|
||||
$native=[RmmPassiveTimeRead]::Process([int]$s.ProcessId)
|
||||
if($native[1]-cne$image-or(Get-FileHash -LiteralPath $image -Algorithm SHA256).Hash.ToLowerInvariant()-cne$sha){throw 'Current fixed service image'}
|
||||
return [ordered]@{pid=[uint32]$s.ProcessId;birth_filetime=$native[0];image=$native[1];sha256=$sha;start_name=$s.StartName;start_mode=$s.StartMode;command=$s.PathName}
|
||||
}
|
||||
function Boot{return (Get-CimInstance Win32_OperatingSystem -Property LastBootUpTime -OperationTimeoutSec 5).LastBootUpTime.ToUniversalTime().Ticks.ToString([Globalization.CultureInfo]::InvariantCulture)}
|
||||
$null=Check 'C:\ProgramData\RustDiscovery' $true;$directory=Check $state $true
|
||||
$boot=Boot;$before=[ordered]@{agent=(Runtime 'agent');helper=(Runtime 'helper')};$reports=[ordered]@{}
|
||||
foreach($name in @('agent-time-sample.json','helper-time-sample.json')){
|
||||
$path=Join-Path $state $name
|
||||
if(!(Test-Path -LiteralPath $path)){$reports[$name]=$null;continue}
|
||||
$stream=[IO.File]::Open($path,[IO.FileMode]::Open,[IO.FileAccess]::Read,[IO.FileShare]::Read)
|
||||
try{
|
||||
$meta=Check $path $false;$info=New-Object RmmPassiveTimeRead+Info
|
||||
if(![RmmPassiveTimeRead]::GetFileInformationByHandle($stream.SafeFileHandle,[ref]$info)-or$info.Links-ne1-or($info.Attr-band0x410)-ne0-or$info.SizeH-ne0-or$info.SizeL-lt1-or$info.SizeL-gt8192-or$stream.Length-ne$info.SizeL){throw 'Single-link bounded public report'}
|
||||
$raw=New-Object byte[] $info.SizeL;$offset=0;while($offset-lt$raw.Length){$count=$stream.Read($raw,$offset,$raw.Length-$offset);if($count-le0){throw 'Complete held public report'};$offset+=$count}
|
||||
$after=New-Object RmmPassiveTimeRead+Info
|
||||
if(![RmmPassiveTimeRead]::GetFileInformationByHandle($stream.SafeFileHandle,[ref]$after)-or$after.IndexH-ne$info.IndexH-or$after.IndexL-ne$info.IndexL-or$after.WH-ne$info.WH-or$after.WL-ne$info.WL-or$after.SizeL-ne$info.SizeL-or$after.Links-ne1){throw 'Stable held public report'}
|
||||
$again=Check $path $false;if($again.sddl-cne$meta.sddl-or$again.owner_sid-cne$meta.owner_sid){throw 'Stable public report security'}
|
||||
$meta['volume']=$info.Volume;$meta['index_high']=$info.IndexH;$meta['index_low']=$info.IndexL;$meta['last_write_filetime']=(([uint64]$info.WH-shl32)-bor$info.WL).ToString([Globalization.CultureInfo]::InvariantCulture)
|
||||
$reports[$name]=@{raw_base64=[Convert]::ToBase64String($raw);sha256=(Hash $raw);metadata=$meta}
|
||||
}finally{$stream.Dispose()}
|
||||
}
|
||||
$after=[ordered]@{agent=(Runtime 'agent');helper=(Runtime 'helper')}
|
||||
$directoryAfter=Check $state $true
|
||||
if(($before|ConvertTo-Json -Depth 8 -Compress)-cne($after|ConvertTo-Json -Depth 8 -Compress)-or(Boot)-cne$boot-or$directory.sddl-cne$directoryAfter.sddl){throw 'Stable process, directory and boot during public read'}
|
||||
@{id=$p.id;read_only=$true;boot_ticks=$boot;runtime=$after;state_metadata=$directory;reports=$reports;observed_at=[DateTime]::UtcNow.ToString('o')}|ConvertTo-Json -Depth 12 -Compress
|
||||
'''
|
||||
SCRIPT = Path(__file__).with_name('Read-PassiveTimeSamples.ps1').read_text(encoding='utf-8')
|
||||
|
||||
|
||||
def need(value, tag):
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
# Migration0016: passives Updateinventar annehmen
|
||||
|
||||
Am2026-11-15 ist Migration0016 tatsächlich auf dem permanenten Server mit dem
|
||||
regulären SQLx-Migrationspfad ausgeführt und separat nachgelesen worden. Der
|
||||
bisherige Check `observations_source_id_check` ließ nur `linux.base` und
|
||||
`windows.base` zu. Die laufende Gatewayversion kannte bereits die passive
|
||||
`agent.update`-Beobachtung; der Datenbankcheck verweigerte deren Speicherung.
|
||||
Nach dem neuen Windowsagentenwechsel waren15 entsprechende Fehler beobachtet
|
||||
worden. Diese verweigerten Nachrichten werden nicht nachträglich als gespeichert
|
||||
ausgegeben.
|
||||
|
||||
Die additive Datei `migrations/0016_agent_update_observation_scope.sql` erweitert
|
||||
ausschließlich diese feste Dreiermenge. Freie Scopes bleiben verboten. Im
|
||||
normalen SQLx-Transactionrahmen wird der alte Check ersetzt und der neue Check
|
||||
validiert; ein Fehler rollt die Transaktion zurück. `lock_timeout=3s` begrenzt
|
||||
das Warten auf Tabellenlocks, `statement_timeout=15s` jedes DDL-Statement.
|
||||
Keine DML-, RLS-, FK-, PK-, Tenant-/Geräte-/Zertifikats-, Job-, Grant- oder
|
||||
Policyänderung gehört zur Migration.
|
||||
|
||||
Tatsächlicher Fall: `cc3ea56d-6186-425a-8ef3-90562212fb1b`. Verwendet wurde das
|
||||
bereits vom Orchestrator nativ ARM64 gebaute Image
|
||||
`sha256:6a76343bf65c126458244f5540d4cb740988144fc77877b409f790251e7ddcc7`.
|
||||
Es enthält den vorhandenen `rmm-server migrate`-Entrypoint und die echte
|
||||
SQLx-`migrate!`-Migrationseinbettung. Es wurde kein zusätzlicher Builderlauf
|
||||
gestartet und keine SQLx-Tabellenzeile manuell angelegt oder geändert.
|
||||
|
||||
Ein eigenes privates Compose-Overlay wählte ausschließlich für den temporären
|
||||
`migrate`-Container dieses bereits vorhandene Image (`pull_policy: never`,
|
||||
read-only RootFS, CapDropALL, NoNewPrivileges). Die vorhandene Migration-URL
|
||||
blieb im normalen Compose-/Prozesskontext; sie wurde nicht ausgegeben. Der
|
||||
unterstützte `docker compose … run --no-deps … migrate` führte genau einen
|
||||
wirklichen SQLx-Lauf aus, Exit0. Der eigene gestoppte Container wurde nach
|
||||
seinem Exit-/Image-/Falllabelbeleg entfernt. Kein API-, Gateway- oder
|
||||
PostgreSQLdienst wurde durch diesen Agenten ersetzt oder neu gestartet.
|
||||
API-Filterung und API-only-Deployment sind ein eigener Orchestratorschnitt.
|
||||
|
||||
Die tatsächliche SQLx-Historie besitzt danach Versionen1–16 jeweils mit
|
||||
`success=true`; die alten15 Checksums stimmen unverändert mit den Quellinputs
|
||||
überein. Version16 heißt `agent update observation scope` und besitzt SHA384
|
||||
`e66ec49233c210555b5107d20b925ca6715925871aa2bf94dfb86bd5cfb39c6dc769fdf0049b615fcad503332e1cd8fc`.
|
||||
Die SQL-Datei hat SHA256
|
||||
`fa0953262e3a8da7f3f0366db6f3fa77ad7976ec04327b126036739eea46eebb`.
|
||||
|
||||
Vor dem echten SQLx-Start wurden3127 bestehende Observationzeilen serverseitig
|
||||
über ihre vollständige JSON-Zeilendarstellung gehasht; unmittelbar danach waren alle
|
||||
unverändert. Der ursprüngliche Fallbaseline enthielt3123Zeilen. Deren
|
||||
unveränderte Fingerprints und die vollständige RLS-/Owner-/ACL-/Policy-,
|
||||
FK-/PK-/sonstige Check- und Job-/Plan-/Authorization-/Outbox-/Permit-/Receipt-
|
||||
Zeugen wurden nochmals in einem getrennten Read-only-SQL-Aufruf bestätigt.
|
||||
Neue passive Zeilen durften parallel regulär hinzukommen. Die neue Constraint
|
||||
war tatsächlich `VALIDATED` und enthielt genau
|
||||
`linux.base`, `windows.base`, `agent.update`. API und Gateway liefen während
|
||||
dieser Migration unverändert mit Image422c2c28; PostgreSQL behielt seine
|
||||
ursprüngliche Container-/Imageidentität.
|
||||
|
||||
Ein weiterer lesender Serverabgleich fand bereits drei angenommene
|
||||
`agent.update`-Zeilen, zuletzt15:40:50UTC. Das beweist die normale Speicherung
|
||||
dieses Scopes nach der Migration, keinen separat geprüften Windows-ACK,
|
||||
keine neue Basisinventarabnahme und keine Zeit-/Jobbereitschaft.
|
||||
|
||||
Die Vorherarchive enthalten Katalog-/Migrations-/Policyzeugen und
|
||||
Zeilenfingerprints; ein vollständiger **Vorher-`pg_dump` wurde nicht angelegt**.
|
||||
Ein vollständiger privater Customformat-Dump wurde ausdrücklich **nach** der
|
||||
Migration archiviert: `after-migration-0016.pg_dump`,49,455,447Bytes, SHA256
|
||||
`b89e74eaaea7ec2faa17a44358acca3aead1db0fcf9ccf673e2c5808b3259398`.
|
||||
Er bleibt ausschließlich im Root0700-Fall auf dem Server, Datei0600, und wurde
|
||||
nicht heruntergeladen oder als Vorherbackup bezeichnet. Ein Restoretest wurde
|
||||
hier nicht ausgeführt.
|
||||
|
||||
Zwei harmlose Vorbedingungen scheiterten vor dem eigentlichen SQLx-Lauf und
|
||||
bleiben erhalten: zunächst die Annahme eines vollständigen Buildkontexts
|
||||
statt des tatsächlichen Minimal-Kontexts; danach ein hier nicht unterstütztes
|
||||
Compose-Flag `--no-build`. Für letzteren Fall waren Exit1, Ledger15 und die
|
||||
Abwesenheit eines eigenen Containers belegt. Nach Roots konkreter Korrektur
|
||||
wurde derselbe Originalfall mit einem neuen Create-only-Fortsetzungsintent
|
||||
verwendet; alte Fehler-/Vorherdateien wurden nicht überschrieben. Ein weiterer
|
||||
reiner Absenzmatcher wurde an die tatsächliche Kleinschreibung der Docker-
|
||||
Fehlermeldung angepasst, ebenfalls vor jedem Container-/SQLx-Start. Keine
|
||||
verlorene SQLx-Wirkung wurde blind wiederholt.
|
||||
|
||||
Geschütztes Serverarchiv:
|
||||
`/opt/rust-discovery/devstate/observation-scope-migration-cc3ea56d-6186-425a-8ef3-90562212fb1b/`.
|
||||
Lokaler Belegordner im eigenen Worktree:
|
||||
`devstate/observation-scope-migration/cc3ea56d-6186-425a-8ef3-90562212fb1b/`.
|
||||
Die separate lokale `receipt.json` bindet Originalintent, Fehler, tatsächlichen
|
||||
SQLx-Erfolg, getrennten Read und Nachbackup; SHA256
|
||||
`00ff8f8ffa689bf3917937ce14ae23457e464b921ae7793e9091eab9a83d76c7`.
|
||||
Private Zugangsdaten und
|
||||
Datenbankinhalte wurden weder veröffentlicht noch in Git aufgenommen.
|
||||
+5
-1
@@ -16,7 +16,11 @@ nach dem Wechsel gelang. Danach wies PostgreSQL den passiven Updatestatus
|
||||
gefilterte Basisinventarabfrage und Migration 16 aus dem zum laufenden
|
||||
ARM64-Image passenden Builder offline gebaut. Docker meldete Exit 0 für
|
||||
Image `6a76343bf65c` (Buildfall `5ad7c74c-67a1-40b8-8960-d3ba016565af`).
|
||||
[Dienstwechsel und Inventarabfrage](windows-signed-clock-upgrade-plan.md)
|
||||
Die Migration lief anschließend erfolgreich. Die API arbeitet mit diesem
|
||||
Image. MCP bestätigte zwei neue Windows-Heartbeats um **16:39:46 und
|
||||
16:40:17 Uhr MEZ**, jeweils mit derselben Geräte- und Zertifikatsidentität wie
|
||||
vor dem Dienstwechsel. Die Cloud-Linux-VM meldete sich weiterhin als online.
|
||||
[Dienstwechsel und Telemetrienachweis](windows-signed-clock-upgrade-plan.md)
|
||||
|
||||
Die Zeitprofilinstallation scheiterte beim Veröffentlichen der Datei mit einer
|
||||
`IOException`. Eine separate Abfrage auf der VM bestätigte, dass die Zieldatei
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
# Tatsächlicher Implementierungsstand
|
||||
|
||||
## Agent-Update-Telemetrie: Migration0016 tatsächlich angewendet — 2026-11-15
|
||||
|
||||
Der permanente Server akzeptiert nun zusätzlich den festen passiven Scope
|
||||
`agent.update`. Regulärer SQLx-Runner aus dem vorhandenen ARM64-Kandidaten6a7634,
|
||||
Exit0 und separate Read-only-Nachprüfung von Version16/Checksum/VALIDATED-Check
|
||||
bestanden. Ursprüngliche Zeilen, RLS/FKs/PK/ACL und Corezeugen erhalten; keine
|
||||
laufenden Dienste durch diesen Schnitt ersetzt. Erste drei regulär angenommene
|
||||
Updatebeobachtungen belegt. API-Basisfilterung ist getrennt. Vorherfingerprints
|
||||
und ausdrücklich erst nachher angelegter privater pg_dump sind dokumentiert;
|
||||
kein vorgetäuschter Vorherbackup-/Restoretest. [Beleg](agent-update-observation-scope.md).
|
||||
|
||||
## Passiver Windows-Zeitabschluss vorbereitet — 2026-11-15
|
||||
|
||||
Ein kleiner rein lesender Collector für die beiden historischen Rollenbelege
|
||||
|
||||
@@ -423,3 +423,39 @@ bleiben im Resultat ausdrücklich **nicht bewiesen**. Windows-MVP damit nicht
|
||||
vollständig abgenommen. Wichtige spätere Werkzeugverbesserung: erwartete additive
|
||||
Schemaentwicklung vor Wartung aus dem qualifizierten Quellstand planen; hierfür
|
||||
jetzt keinen allgemeinen Migrations-/Resumeframework bauen.
|
||||
|
||||
## Serverkorrektur für die passive Telemetrie am 15. November 2026
|
||||
|
||||
Nach SQLx-Migration 16 wurde um 16:39:24 Uhr MEZ ausschließlich der
|
||||
API-Container auf dem permanenten Server neu gestartet. Sein ARM64-Image
|
||||
`6a76343bf65c126458244f5540d4cb740988144fc77877b409f790251e7ddcc7`
|
||||
enthält die Änderung an der Basisinventarabfrage und die Migration.
|
||||
Gateway und PostgreSQL behielten Container-ID und Startzeit.
|
||||
|
||||
Der erste Nachvergleich schlug beim direkten Listenvergleich der
|
||||
Containerkonfiguration fehl. Eine separate lesende Prüfung verglich die Mounts
|
||||
nach Zielpfad. Docker lieferte sie in anderer Reihenfolge. Quelle, Ziel,
|
||||
Modus und übrige Mountattribute stimmten vollständig mit dem vorherigen
|
||||
Container überein. API-Umgebung und Startkonfiguration entsprachen Compose
|
||||
und Image. Verifiziert wurden zudem die Loopback-Bindung, UID/GID 10001,
|
||||
Read-only-Rootfs, CapDrop ALL und no-new-privileges. Es gab genau einen
|
||||
API-Wechsel. Die weitere Prüfung erfolgte am laufenden Container.
|
||||
|
||||
### Erneute Abnahme über MCP
|
||||
|
||||
Zwei getrennte, nach Beginn der Prüfung eingegangene Kontakte des Windows-11-
|
||||
Agenten wurden am 15. November um 16:39:46 und 16:40:17 Uhr MEZ aus
|
||||
`inventory.get_device` gelesen. Beide hatten Präsenz `online`, dasselbe
|
||||
Gerät, dieselbe Agent-ID, Zuordnung, Enrollmentgeneration und dasselbe
|
||||
authentifizierte Zertifikat wie vor dem Paarwechsel. Der Agent meldet
|
||||
`heartbeat/1`, `windows.base/1` und `agent.update/1`.
|
||||
Beleg-SHA-256 `837c7580b9e7cd68de09533f50d91622272c2f2bc288da70d8b4624d2f6a747e`.
|
||||
|
||||
Die MCP-Geräteansicht lieferte das gespeicherte Windows-Basisinventar mit fünf
|
||||
Bereichen und für die Cloud-Linux-VM den Datensatz `linux.base`. Das
|
||||
Windows-Basisinventar stammte von 16:16:59 Uhr MEZ. Die Kontaktzeiten wurden
|
||||
unabhängig davon aktualisiert. PostgreSQL speicherte die separaten
|
||||
Updatemeldungen des Windowsagenten um 16:38:43, 16:39:45 und 16:40:50 Uhr MEZ.
|
||||
Der zuletzt gelesene Updatezustand war `not_configured`. Die Windows-Jobtabelle
|
||||
enthielt für dieses Gerät null Aufträge. Die Prüfung las gespeicherte
|
||||
Telemetrie über den permanenten Server nach Ablauf des SSH-Fensters.
|
||||
|
||||
@@ -260,3 +260,125 @@ Source-/Intent-/Receiptbindung ohne Legacy-Hashadoption. Der Transport ist dabei
|
||||
vollständig gemockt; dies ist kein nativer Befund. Die Kontrollbelege des alten
|
||||
fehlgeschlagenen Installationsfalls bleiben bytegleich erhalten. Ein konkreter
|
||||
Publikationsfix wurde mangels belegter nativer Fehlerursache nicht erfunden.
|
||||
|
||||
## Nachlese durch die Bedienperson auf der Windows-VM
|
||||
|
||||
In der administrativen VM-Konsole konnte die Bedienperson den Kandidaten
|
||||
`time-attestation.candidate.json` lesen. SHA-256 stimmte mit dem im
|
||||
Publish-Intent hinterlegten Wert `2b4a8a7080770304b80e2a665fa5f5ee1ebbd9182e7c80b184e75b114575b42b`
|
||||
überein. Für den festen Zielpfad unter `RustDiscoverySystem` meldete
|
||||
PowerShell `ObjectNotFound`. Dieser Konsolenbefund ergänzt den früheren
|
||||
Readback um den Inhalt des verbliebenen Kandidaten. FileID, DACL und
|
||||
Dienstgeneration wurden bei dieser Konsolenabfrage nicht erfasst.
|
||||
|
||||
Für die Fortsetzung an derselben VM-Konsole liegt
|
||||
[`Complete-OriginalTimeProfile.ps1`](../deploy/windows/Complete-OriginalTimeProfile.ps1)
|
||||
bereit. Der Befehl übernimmt die Prüffunktionen aus den SHA-256-geprüften
|
||||
Bytes des bereits installierten Controllers. Vor der Veröffentlichung prüft er
|
||||
die ursprüngliche Datei-ID und das Volume, den Inhalt, die DACL, die
|
||||
ursprünglichen Marker und beide laufenden Dienstgenerationen. Er hält die
|
||||
beiden Prozesshandles während der Veröffentlichung offen. Ein exklusiv
|
||||
erstellter zusätzlicher Marker verhindert eine doppelte Ausführung.
|
||||
|
||||
Nach der Verschiebung an den festen Zielpfad vergleicht das Skript die
|
||||
Dateiidentität und die Dienstzustände erneut. Bei einem neuen Move-Fehler erfasst
|
||||
es Fehlerklasse und HRESULT für diesen Aufruf. Ein erneuter Start trifft auf
|
||||
den Abschlussmarker oder den vorhandenen Zielpfad und beendet sich. Das
|
||||
Ergebnis einer erfolgreichen Veröffentlichung hält die separate
|
||||
Laufzeitprüfung der beiden Dienstrollen ausdrücklich offen.
|
||||
|
||||
Lokal geprüft wurden die PowerShell-Syntax, die Bindung an die gespeicherten
|
||||
Originalbelege und der Vergleich mit der tatsächlichen Kandidatenidentität.
|
||||
Eine veränderte FileID wurde im lokalen Vergleich abgewiesen. Die Ausführung
|
||||
des Abschlussbefehls auf der VM und die anschließende Zeitprüfung stehen aus.
|
||||
|
||||
## Ergebnis vom Konsolenschritt automatisch abholen
|
||||
|
||||
Für den vorbereiteten Profilabschluss steht `Open-TimeProfileReceiptWindow.ps1`
|
||||
zur Verfügung. Die Bedienperson startet es auf der Windows-VM. Das Skript prüft
|
||||
die beiden Downloads gegen feste SHA-256-Werte, öffnet den vorhandenen
|
||||
Reverse-SSH-Transport und führt den festen Abschluss lokal aus. Die
|
||||
Weiterleitung auf dem Server ist an `127.0.0.1:22240` gebunden. Auf der VM
|
||||
endet sie an einem temporären Loopback-Port. Der Prozess sendet dort den
|
||||
Abschlussstatus und die öffentlichen Belege der beiden Zeitdienstrollen.
|
||||
Er liest keine Befehle vom Socket. Die Gast-Kontofrist und die Aufgabenplanung
|
||||
werden nicht geändert. Strg+C oder zwölf Minuten beenden das Vordergrundfenster.
|
||||
|
||||
Die serverseitige Frist für den vorhandenen Transportschlüssel und der aktive
|
||||
Abschalttimer wurden für den 15. November 2026, 18:00 Uhr MEZ, geprüft.
|
||||
Beim Bereitstellen wurden der PowerShell-Parser, die Downloadhashes, die
|
||||
bestehenden Quellprüfungen und die sechs lokalen Prüffälle für die Zeitbelege
|
||||
ausgeführt. Ein Ergebnis von der VM liegt bei Bereitstellung noch nicht vor.
|
||||
|
||||
Der Ergebnisempfänger auf dem permanenten Server wurde anschließend gestartet.
|
||||
Seine Anfangsprüfung des laufenden Gateways und der gespeicherten
|
||||
Windows-Gerätebindung war erfolgreich. Der Server fragt den Loopback-Port
|
||||
nur bei vorhandenem SSH-Listener ab und legt eingehende Belege im privaten
|
||||
Fall `time-profile-receipt-f7f56e9f` ab. Für Zeitbelege verwendet er die
|
||||
bestehende Rollen-, Boot-, Generations- und Altersprüfung mit je einer
|
||||
Datenbanklesung vor und nach dem Empfang. Die Bereitstellung des Empfängers
|
||||
belegt noch keine Profilveröffentlichung auf dem Gast.
|
||||
|
||||
## Rückmeldung der Windows-VM am 15. November um 17:05:36 Uhr MEZ
|
||||
|
||||
Der Empfänger hat im Fall `time-profile-receipt-f7f56e9f` die Antwort
|
||||
`finalization_failed` gespeichert. Der Abschlussbefehl bestand die Prüfungen
|
||||
auf Kandidat, Berechtigungen und Dienstgenerationen bis zur Veröffentlichung.
|
||||
Der Aufruf von `File.Move` meldete HRESULT **0x80070020**
|
||||
(`ERROR_SHARING_VIOLATION`). Zeile 94 gibt diesen Fehler an den Aufrufer
|
||||
weiter. Empfangsbeleg SHA-256
|
||||
`7cc51d44abfbe7949b0896053a463f3bd140b1844229e9ba206683db34d6f2ba`,
|
||||
Ergebnis `172edeaf54ca08f4e5b1ad3662884da6ec217636ca30bbd8274e73140f6ef35b`.
|
||||
|
||||
Der Code des installierten Helpers öffnet das öffentliche Stammverzeichnis
|
||||
mit Lesezugriff und ausschließlich `FILE_SHARE_READ` und hält diesen Handle
|
||||
im laufenden Dienst. Ein Rename aus einem anderen Verzeichnis benötigt am
|
||||
Zielverzeichnis `FILE_ADD_FILE`. Das erklärt einen konkreten Konflikt.
|
||||
Die VM-Rückmeldung enthält keine Liste der tatsächlich offenen Handles.
|
||||
Für den älteren Installationsaufruf ohne HRESULT bleibt der Fehlercode
|
||||
unbekannt. Das laufende Konsolenskript hat keine weitere Veröffentlichung
|
||||
versucht. Für diesen Lauf liegt keine erfolgreiche Zeitprüfung vor.
|
||||
[Windows-Dateisystemregeln für Rename](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fsa/87f86c9b-6c2a-4803-84b7-131a74a434fa)
|
||||
|
||||
### Erstprovisionierung nach dem belegten Sharingkonflikt
|
||||
|
||||
`Complete-OriginalTimeProfile.ps1 -InitialCreate` ist eine eigene Reparatur
|
||||
für das bislang fehlende Ziel. Sie setzt den vorhandenen Abschlussintent und
|
||||
den gespeicherten Fehler `File.Move / System.IO.IOException / 0x80070020`
|
||||
voraus. Die ursprünglichen Quell-, ACL-, Dienst-, Geräte- und
|
||||
Kandidatenbindungen gelten weiter. Der ursprüngliche Kandidat bleibt als
|
||||
Referenz erhalten. Der alte Move-Erfolg und dessen `result.json` werden durch
|
||||
diesen Pfad nicht nachträglich erzeugt.
|
||||
|
||||
Der feste neue Name wird genau einmal mit `CreateNew` angelegt. Windows
|
||||
erhält dabei bereits eine geschützte DACL mit explizitem Leseverbot für die
|
||||
beiden Service-SIDs. Der kontrollierende Prozess besitzt den einzigen
|
||||
Datenhandle. Er schreibt und flusht die 1177 qualifizierten Bytes und liest sie
|
||||
über denselben Handle vollständig zurück. Er prüft Hash, Volume, neue FileID,
|
||||
einzigen Hardlink, Länge und DACL. Dann prüft er die ursprüngliche
|
||||
Kandidatenidentität und die laufenden Dienste noch einmal und schreibt einen
|
||||
Prüfbeleg. Erst jetzt setzt er die bereits gebundene endgültige DACL auf dem
|
||||
gehaltenen Handle und prüft Identität, Hash und DACL erneut. Nach Schließen
|
||||
folgt eine separate Prüfung beider Pfade und Dienste. Damit wird eine neue
|
||||
Ziel-FileID dokumentiert. Die DACL des öffentlichen Ordners bleibt unverändert.
|
||||
[Windows-Dateierstellung](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fsa/498a5eeb-afc9-445f-99ed-a7e4b73c648b)
|
||||
[.NET-Framework-Konstruktor mit Erstellungs-DACL](https://learn.microsoft.com/en-us/dotnet/api/system.io.filestream.-ctor?view=netframework-4.8)
|
||||
|
||||
Eine vor der DACL-Freigabe unterbrochene Erstellung kann eine vorhandene
|
||||
Teildatei mit gesperrtem Dienstzugriff hinterlassen. Nach erfolgter
|
||||
DACL-Freigabe ist die Datei lesbar, auch wenn der Prozess vor dem
|
||||
abschließenden Ergebnis ausfällt. Ein neuer Versuch wird in beiden Fällen
|
||||
verweigert. Die getrennten `console-initial-create-*`-Dateien dokumentieren
|
||||
Intent, verifizierte neue Zielidentität und tatsächlichen Abschluss oder
|
||||
Fehlerphase. Das Ergebnis weist `clock_runtime_qualified=false` aus. Für
|
||||
dessen positive Bewertung sind weiterhin die unabhängigen Zeitbelege der
|
||||
installierten Dienste erforderlich.
|
||||
|
||||
Lokal bestanden Parserprüfung, Kompilierung des kleinen nativen
|
||||
Handle-Readers, Prüfung seines Strukturlayouts und drei simulierte
|
||||
Entscheidungsfälle mit echtem beziehungsweise verändertem Fehlerbeleg.
|
||||
Der frühere lokale Prüfharness wählte beim ersten Strukturlayoutaufruf die
|
||||
falsche .NET-Überladung; nach Angabe des Typs bestand die Prüfung. Der
|
||||
Original-Kandidaten-/FileID-Vergleich und die acht bisherigen Profilfixtures
|
||||
bestanden ebenfalls. Dieser Stand wurde auf der Windows-VM noch nicht
|
||||
ausgeführt.
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
-- Passive agent-update observations share the existing tenant/device-bound
|
||||
-- ingest path. Preserve both base scopes and every existing row/RLS/FK.
|
||||
-- SQLx applies this file transactionally and records its normal checksum.
|
||||
SET LOCAL lock_timeout = '3s';
|
||||
SET LOCAL statement_timeout = '15s';
|
||||
ALTER TABLE observations DROP CONSTRAINT observations_source_id_check;
|
||||
ALTER TABLE observations ADD CONSTRAINT observations_source_id_check
|
||||
CHECK (source_id IN ('linux.base', 'windows.base', 'agent.update')) NOT VALID;
|
||||
ALTER TABLE observations VALIDATE CONSTRAINT observations_source_id_check;
|
||||
Reference in New Issue
Block a user