Capture both security descriptors at the exclusive profile creation handle
Rust development slice / linux (push) Failing after 7s
Rust development slice / linux (push) Failing after 7s
This commit is contained in:
@@ -128,22 +128,29 @@ public static class RmmInitialProfileFile {
|
||||
'@
|
||||
}
|
||||
|
||||
function Get-HeldProfileIdentity([IO.FileStream]$Stream) {
|
||||
[RmmInitialProfileFile]::CheckSingleFile($Stream.SafeFileHandle, 1177)
|
||||
function Get-HeldProfileFileId([IO.FileStream]$Stream) {
|
||||
$id = New-Object RmmPipeNative+FileId
|
||||
if (![RmmPipeNative]::GetFileInformationByHandleEx($Stream.SafeFileHandle, 18, [ref]$id, 24)) {
|
||||
throw 'New file identity unavailable'
|
||||
}
|
||||
return @{
|
||||
volume_serial=$id.Volume.ToString([Globalization.CultureInfo]::InvariantCulture)
|
||||
file_id=([BitConverter]::ToString($id.Id)).Replace('-','').ToLowerInvariant()
|
||||
}
|
||||
}
|
||||
|
||||
function Get-HeldProfileIdentity([IO.FileStream]$Stream) {
|
||||
[RmmInitialProfileFile]::CheckSingleFile($Stream.SafeFileHandle, 1177)
|
||||
$identity = Get-HeldProfileFileId $Stream
|
||||
$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)))
|
||||
}
|
||||
$identity.bytes = $Stream.Length
|
||||
$identity.sha256 = $digest
|
||||
$identity.acl_sha256 = BytesHash ([Text.Encoding]::UTF8.GetBytes($sddl))
|
||||
return $identity
|
||||
}
|
||||
|
||||
function New-OriginalPublicProfile {
|
||||
@@ -165,6 +172,7 @@ function New-OriginalPublicProfile {
|
||||
$since = [DateTime]::UtcNow.ToString('o')
|
||||
WriteNew $initialReservation @{id=$caseId; config_sha256=$configHash; utc=$since; staged=$expected; create_new=$true}
|
||||
$phase = 'CreateNew'
|
||||
$descriptorFailure = $null
|
||||
try {
|
||||
$rights = [Security.AccessControl.FileSystemRights]'ReadData,WriteData,ReadAttributes,ReadPermissions,ChangePermissions,Synchronize'
|
||||
$stream = [IO.FileStream]::new($target, [IO.FileMode]::CreateNew,
|
||||
@@ -172,7 +180,17 @@ function New-OriginalPublicProfile {
|
||||
[IO.FileOptions]::WriteThrough, $draftAcl)
|
||||
try {
|
||||
$phase = 'verify_creation'
|
||||
if ($stream.GetAccessControl().GetSecurityDescriptorSddlForm($aclSections) -cne $draftSddl) {
|
||||
$actualSddl = $stream.GetAccessControl().GetSecurityDescriptorSddlForm($aclSections)
|
||||
if ($actualSddl -cne $draftSddl) {
|
||||
$descriptorFailure = @{expected_sddl=$draftSddl; actual_sddl=$actualSddl; bytes=$null}
|
||||
try {
|
||||
$descriptorFailure.bytes = $stream.Length
|
||||
$fileId = Get-HeldProfileFileId $stream
|
||||
$descriptorFailure.file_id = $fileId.file_id
|
||||
$descriptorFailure.volume_serial = $fileId.volume_serial
|
||||
} catch {
|
||||
$descriptorFailure.metadata_hresult = '0x{0:X8}' -f $_.Exception.GetBaseException().HResult
|
||||
}
|
||||
throw 'Unexpected security descriptor on new file'
|
||||
}
|
||||
[RmmInitialProfileFile]::CheckSingleFile($stream.SafeFileHandle, 0)
|
||||
@@ -222,7 +240,9 @@ function New-OriginalPublicProfile {
|
||||
}
|
||||
} catch {
|
||||
$cause = $_.Exception.GetBaseException()
|
||||
WriteNew $initialError @{id=$caseId; phase=$phase; hresult=('0x{0:X8}' -f $cause.HResult); exception=$cause.GetType().FullName}
|
||||
$failure = @{id=$caseId; phase=$phase; hresult=('0x{0:X8}' -f $cause.HResult); exception=$cause.GetType().FullName}
|
||||
if ($null -ne $descriptorFailure) { $failure.creation_descriptor = $descriptorFailure }
|
||||
WriteNew $initialError $failure
|
||||
throw
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,3 +488,21 @@ um 20:25:35 Uhr MEZ. Präsenz war `online`, die Quelle `windows.base`.
|
||||
Gerät, Agent, Assignment, Enrollmentgeneration und authentifiziertes Zertifikat
|
||||
stimmten mit dem früheren Abnahmebeleg überein. Beleg-SHA-256
|
||||
`7ea828b42b3c7948956aad56845502ffa52192ce6ca14728203f8574d70a28ec`.
|
||||
|
||||
### Fehlerbeleg beim ersten Vergleich des Sicherheitsdeskriptors
|
||||
|
||||
Unterscheiden sich Soll- und Ist-SDDL an der neu angelegten Datei, erfasst der
|
||||
Controller beide Werte für Besitzer, Gruppe und DACL am exklusiv gehaltenen
|
||||
Dateihandle. Der private Fehlerbeleg enthält dazu das optionale Feld
|
||||
`creation_descriptor` mit `expected_sddl`, `actual_sddl` und `bytes`.
|
||||
Bei erfolgreicher nativer Identitätsabfrage kommen `file_id` und
|
||||
`volume_serial` hinzu. Scheitert das Lesen der Zusatzmetadaten, hält
|
||||
`metadata_hresult` dessen Fehlercode fest. Die ursprüngliche Abweichung
|
||||
bricht den Aufruf vor dem Schreiben der Profilbytes und der Rechtefreigabe ab.
|
||||
Der ältere Gastbeleg enthält diese neuen Felder noch nicht.
|
||||
|
||||
Lokal bestanden die Parserprüfung, vier PowerShell-Fälle für Vergleich und
|
||||
Fehlerbeleg sowie die acht vorhandenen Profiltests. Die vier Fälle umfassten
|
||||
ungleiche Deskriptoren mit lesbarer beziehungsweise fehlender FileID, einen
|
||||
gleichen Deskriptor und einen unabhängigen Folgefehler. Die FileID-Abfrage war
|
||||
simuliert. Eine native Abnahme dieser Belegerweiterung steht aus.
|
||||
|
||||
Reference in New Issue
Block a user