Skip to content

Commit b6600ee

Browse files
fix SeSecurityPrivilege error (#1747)
1 parent 48ae5a3 commit b6600ee

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

‎scripts/ingest.ps1‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -458,9 +458,7 @@ function Setup-Collector {
458458

459459
$configContent = ($configLines -join [Environment]::NewLine) + [Environment]::NewLine
460460
$utf8NoBom = New-Object System.Text.UTF8Encoding $false
461-
$configUpdateId = [guid]::NewGuid().ToString('N')
462-
$tempConfigFile = "$CONFIG_FILE.$configUpdateId.tmp"
463-
$backupConfigFile = "$CONFIG_FILE.$configUpdateId.bak"
461+
$tempConfigFile = "$CONFIG_FILE.$([guid]::NewGuid().ToString('N')).tmp"
464462

465463
try {
466464
$tempConfigStream = [System.IO.File]::Create($tempConfigFile)
@@ -488,22 +486,14 @@ function Setup-Collector {
488486
exit 1
489487
}
490488

491-
if (Test-Path $CONFIG_FILE) {
492-
Set-Acl -Path $CONFIG_FILE -AclObject $acl -ErrorAction Stop
493-
[System.IO.File]::Replace($tempConfigFile, $CONFIG_FILE, $backupConfigFile)
494-
}
495-
else {
496-
[System.IO.File]::Move($tempConfigFile, $CONFIG_FILE)
497-
}
498-
Set-Acl -Path $CONFIG_FILE -AclObject $acl -ErrorAction Stop
489+
Move-Item -LiteralPath $tempConfigFile -Destination $CONFIG_FILE -Force -ErrorAction Stop
499490
}
500491
catch {
501492
Write-ErrorMsg "Failed to update OpenTelemetry Collector configuration: $_"
502493
exit 1
503494
}
504495
finally {
505496
Remove-Item $tempConfigFile -Force -ErrorAction SilentlyContinue
506-
Remove-Item $backupConfigFile -Force -ErrorAction SilentlyContinue
507497
}
508498

509499
if (Test-CollectorRunning) {

0 commit comments

Comments
 (0)