From c498ce1d52eea943bbf1b9a4d980469ad59974c7 Mon Sep 17 00:00:00 2001 From: Zebreus Date: Sun, 25 Oct 2026 14:38:35 +0100 Subject: [PATCH] Copy MSYS2's default files into a recreated home MSYS2 only copies /etc/skel into a home directory that does not exist yet when the user logs in. The cleanup always creates the home first, so the default files never arrived. Co-Authored-By: Claude Opus 5.5 (1M context) --- server/scripts/install_restore_task.ps1 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/server/scripts/install_restore_task.ps1 b/server/scripts/install_restore_task.ps1 index e5f106c..5d8b122 100644 --- a/server/scripts/install_restore_task.ps1 +++ b/server/scripts/install_restore_task.ps1 @@ -59,23 +59,24 @@ function Restore-Keys($target, $source) { [IO.File]::WriteAllText($target, (($keys + $required) -join "`n") + "`n") } -# The home directory is the one from /etc/passwd, which the user cannot change, but which they can delete. The -# directories in it belong to the user, so that they can put their own keys in .ssh. -function New-Dir($path) { +# The home directory is the one from /etc/passwd, which the user cannot change, but which they can delete. A new one +# gets MSYS2's default files from /etc/skel, which MSYS2 itself only copies into a home that does not exist yet. +function New-Home($path) { New-Item -ItemType Directory -Path $path | Out-Null # The parent directory gives the users read access only, so the owner gets write access on their own home. if ($sid) { icacls $path /grant "*${sid}:(OI)(CI)F" | Out-Null icacls $path /setowner "*$sid" | Out-Null } + Get-ChildItem -LiteralPath 'C:\msys2\etc\skel' -Force | Copy-Item -Destination $path -Recurse -Force } if (-not (Test-Path -LiteralPath $HomeDir)) { - New-Dir $HomeDir + New-Home $HomeDir Write-Log "created $HomeDir" } elseif ((Get-Item -LiteralPath $HomeDir -Force).Attributes -band [IO.FileAttributes]::ReparsePoint) { Remove-Anything $HomeDir - New-Dir $HomeDir + New-Home $HomeDir Write-Log "replaced the link $HomeDir" }