@@ -1061,6 +1061,102 @@ jobs:
10611061 Remove-Item $batchPath -ErrorAction SilentlyContinue
10621062 Remove-Item $outputFile -ErrorAction SilentlyContinue
10631063
1064+ - name : Test wolfsshd config loading as LocalSystem
1065+ if : matrix.server_key_source == 'store'
1066+ working-directory : ${{ github.workspace }}\wolfssh
1067+ shell : pwsh
1068+ run : |
1069+ # Try to get more info by testing if wolfsshd can at least parse the config
1070+ # We'll create a small test that verifies LocalSystem can read all config-referenced files
1071+ Write-Host "=== Testing config file access as LocalSystem ==="
1072+
1073+ $configPath = (Resolve-Path "sshd_config_test").Path
1074+ $outputFile = "$env:TEMP\localsystem-config-test-output.txt"
1075+
1076+ # Create a PowerShell script to test file access as SYSTEM
1077+ $testScript = @'
1078+ $ErrorActionPreference = "Continue"
1079+ $configPath = $args[0]
1080+ $outputPath = $args[1]
1081+
1082+ $results = @()
1083+ $results += "Testing config access as: $([System.Security.Principal.WindowsIdentity]::GetCurrent().Name)"
1084+ $results += ""
1085+
1086+ # Test config file
1087+ $results += "Config file: $configPath"
1088+ if (Test-Path $configPath) {
1089+ $results += " Exists: YES"
1090+ try {
1091+ $content = Get-Content $configPath -Raw
1092+ $results += " Readable: YES"
1093+ $results += " Content:"
1094+ $content -split "`n" | ForEach-Object { $results += " $_" }
1095+ $results += ""
1096+
1097+ # Extract and test TrustedUserCAKeys
1098+ if ($content -match "TrustedUserCAKeys\s+([^\r\n]+)") {
1099+ $caPath = $matches[1].Trim()
1100+ $results += "TrustedUserCAKeys: $caPath"
1101+ if (Test-Path $caPath) {
1102+ $results += " Exists: YES"
1103+ try {
1104+ $caContent = Get-Content $caPath -Raw
1105+ $results += " Readable: YES ($($caContent.Length) bytes)"
1106+ } catch {
1107+ $results += " Readable: NO - $_"
1108+ }
1109+ } else {
1110+ $results += " Exists: NO"
1111+ }
1112+ }
1113+ } catch {
1114+ $results += " Readable: NO - $_"
1115+ }
1116+ } else {
1117+ $results += " Exists: NO"
1118+ }
1119+
1120+ $results | Out-File -FilePath $outputPath -Encoding UTF8
1121+ '@
1122+
1123+ $scriptPath = "$env:TEMP\test-config-access.ps1"
1124+ $testScript | Out-File -FilePath $scriptPath -Encoding UTF8
1125+
1126+ # Create scheduled task to run as SYSTEM
1127+ $taskName = "WolfSSH-ConfigAccessTest"
1128+ $action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-ExecutionPolicy Bypass -File `"$scriptPath`" `"$configPath`" `"$outputFile`""
1129+ $principal = New-ScheduledTaskPrincipal -UserId "NT AUTHORITY\SYSTEM" -LogonType ServiceAccount -RunLevel Highest
1130+ $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
1131+
1132+ Unregister-ScheduledTask -TaskName $taskName -Confirm:$false -ErrorAction SilentlyContinue
1133+ Register-ScheduledTask -TaskName $taskName -Action $action -Principal $principal -Settings $settings | Out-Null
1134+ Start-ScheduledTask -TaskName $taskName
1135+
1136+ # Wait for completion
1137+ $timeout = 30
1138+ $elapsed = 0
1139+ while ($elapsed -lt $timeout) {
1140+ Start-Sleep -Seconds 1
1141+ $elapsed++
1142+ $task = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue
1143+ if ($task.State -eq "Ready") { break }
1144+ }
1145+
1146+ # Show results
1147+ if (Test-Path $outputFile) {
1148+ Write-Host "=== LocalSystem config access test results ==="
1149+ Get-Content $outputFile
1150+ Write-Host "=== End results ==="
1151+ } else {
1152+ Write-Host "WARNING: No output file generated"
1153+ }
1154+
1155+ # Cleanup
1156+ Unregister-ScheduledTask -TaskName $taskName -Confirm:$false -ErrorAction SilentlyContinue
1157+ Remove-Item $scriptPath -ErrorAction SilentlyContinue
1158+ Remove-Item $outputFile -ErrorAction SilentlyContinue
1159+
10641160 - name : Start wolfSSHd as Windows service
10651161 working-directory : ${{ github.workspace }}\wolfssh
10661162 shell : pwsh
@@ -1070,14 +1166,14 @@ jobs:
10701166 Write-Host "ERROR: wolfsshd.exe not found at $sshdPath"
10711167 exit 1
10721168 }
1073-
1169+
10741170 # Get absolute path for service
10751171 $sshdPathFull = (Resolve-Path $sshdPath).Path
10761172 $configPathFull = (Resolve-Path "sshd_config_test").Path
1077-
1173+
10781174 # Service name
10791175 $serviceName = "wolfsshd"
1080-
1176+
10811177 # Remove service if it already exists
10821178 $existingService = Get-Service -Name $serviceName -ErrorAction SilentlyContinue
10831179 if ($existingService) {
@@ -1089,7 +1185,45 @@ jobs:
10891185 sc.exe delete $serviceName | Out-Null
10901186 Start-Sleep -Seconds 2
10911187 }
1092-
1188+
1189+ # Show config file content for debugging
1190+ Write-Host "=== Config file content ==="
1191+ Get-Content $configPathFull
1192+ Write-Host "=== End config ==="
1193+
1194+ # Verify all files referenced in config are accessible
1195+ Write-Host "=== Verifying config file references ==="
1196+ $configContent = Get-Content $configPathFull -Raw
1197+
1198+ # Check TrustedUserCAKeys
1199+ if ($configContent -match "TrustedUserCAKeys\s+([^\r\n]+)") {
1200+ $caPath = $matches[1].Trim()
1201+ Write-Host "TrustedUserCAKeys: $caPath"
1202+ if (Test-Path $caPath) {
1203+ Write-Host " File exists: YES"
1204+ $acl = Get-Acl $caPath
1205+ $systemAccess = $acl.Access | Where-Object { $_.IdentityReference -like "*SYSTEM*" }
1206+ if ($systemAccess) {
1207+ Write-Host " SYSTEM access: $($systemAccess.FileSystemRights)"
1208+ } else {
1209+ Write-Host " WARNING: No explicit SYSTEM access (may inherit)"
1210+ }
1211+ } else {
1212+ Write-Host " ERROR: File not found!"
1213+ }
1214+ }
1215+
1216+ # Check HostKeyStoreSubject
1217+ if ($configContent -match "HostKeyStoreSubject\s+([^\r\n]+)") {
1218+ $subject = $matches[1].Trim()
1219+ Write-Host "HostKeyStoreSubject: '$subject'"
1220+ Write-Host " Length: $($subject.Length) chars"
1221+ # Show hex dump for debugging
1222+ $bytes = [System.Text.Encoding]::UTF8.GetBytes($subject)
1223+ $hex = ($bytes | ForEach-Object { '{0:X2}' -f $_ }) -join ' '
1224+ Write-Host " UTF-8 hex: $hex"
1225+ }
1226+
10931227 # Pre-service checks
10941228 $sshdDir = Split-Path -Parent $sshdPathFull
10951229 $dllPath = Join-Path $sshdDir "wolfssl.dll"
0 commit comments