@@ -162,6 +162,13 @@ jobs:
162162 "" | Out-File -FilePath $authKeysFile -Encoding ASCII -NoNewline
163163 icacls $authKeysFile /grant "testuser:R" /q
164164
165+ # Grant testuser full control of their home directory.
166+ # New-Item creates the directory owned by the runner account; Windows
167+ # only sets correct user ACLs during the normal profile-creation flow.
168+ # Without this, ImpersonateLoggedOnUser succeeds but CreateFile fails
169+ # with ACCESS_DENIED when wolfsshd tries to write files as testuser.
170+ icacls $homeDir /grant "testuser:(OI)(CI)F" /T /q
171+
165172 $sid = (New-Object System.Security.Principal.NTAccount("testuser")).Translate([System.Security.Principal.SecurityIdentifier]).Value
166173 $profKey = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$sid"
167174 if (-not (Test-Path $profKey)) { New-Item -Path $profKey -Force | Out-Null }
@@ -318,16 +325,15 @@ jobs:
318325 }
319326 Write-Host "Basic SFTP test passed"
320327
321- - name : Create 3GB test file and run SFTP get/put (large_rw)
322- if : matrix.test_type == 'large_rw'
328+ - name : Create 3GB test file and run SFTP get/put
323329 working-directory : ${{ github.workspace }}\wolfssh
324330 shell : pwsh
325331 timeout-minutes : 25
326332 run : |
327333 $sftpPath = $env:SFTP_PATH
328- $workDir = (Get-Location). Path
334+ $workDir = Join- Path $env:GITHUB_WORKSPACE "wolfssh"
329335 $largeFile = Join-Path $workDir "large_test.dat"
330- $getDest = Join-Path $workDir "large_test_copy.dat"
336+ $getDestPath = Join-Path $workDir "large_test_copy.dat"
331337
332338 # Create 3GB file: one random 10MB chunk repeated 307x + 2MB
333339 Write-Host "Creating 3GB test file..."
@@ -346,57 +352,68 @@ jobs:
346352 $fs.Close()
347353
348354 $hash = Get-FileHash -Path $largeFile -Algorithm SHA256
349- $hash.Hash | Out-File -FilePath large_test.dat.sha256
355+ $hash.Hash | Out-File -FilePath (Join-Path $workDir " large_test.dat.sha256")
350356 Write-Host "Created 3GB file, SHA256: $($hash.Hash)"
351357
352358 # SFTP PUT (upload)
359+ # Use a relative remote path (no leading /) so the server resolves it
360+ # under testuser's home directory. An absolute /large_test.dat maps to
361+ # the drive root (C:\) where testuser has no write permission; relative
362+ # large_test.dat is prefixed by workingDir (C:\Users\testuser) on the
363+ # client and becomes C:\Users\testuser\large_test.dat on the server.
353364 Write-Host "SFTP PUT 3GB file..."
354- $putCommands = "put $largeFile / large_test.dat`nquit"
355- $putCommands | Out-File -FilePath sftp_put_commands.txt -Encoding ASCII
365+ $putCommands = "put $largeFile large_test.dat`nquit"
366+ $putCommands | Out-File -FilePath (Join-Path $workDir " sftp_put_commands.txt") -Encoding ASCII
356367 $proc = Start-Process -FilePath $sftpPath `
357368 -ArgumentList "-u", "testuser", "-P", $env:TESTUSER_PASSWORD, "-h", "localhost", "-p", "${{env.TEST_PORT}}" `
358- -RedirectStandardInput "sftp_put_commands.txt" `
359- -RedirectStandardOutput "sftp_put_out.txt" `
360- -RedirectStandardError "sftp_put_err.txt" `
369+ -WorkingDirectory $workDir `
370+ -RedirectStandardInput (Join-Path $workDir "sftp_put_commands.txt") `
371+ -RedirectStandardOutput (Join-Path $workDir "sftp_put_out.txt") `
372+ -RedirectStandardError (Join-Path $workDir "sftp_put_err.txt") `
361373 -Wait -NoNewWindow -PassThru
362374
363- if ($proc.ExitCode -ne 0) {
364- Get-Content sftp_put_out.txt
365- Get-Content sftp_put_err.txt
375+ $putOut = Get-Content (Join-Path $workDir "sftp_put_out.txt") -Raw -ErrorAction SilentlyContinue
376+ Write-Host "=== SFTP PUT output ==="; Write-Host $putOut
377+ if ($proc.ExitCode -ne 0 -or $putOut -match "Error pushing file") {
378+ Get-Content (Join-Path $workDir "sftp_put_err.txt") -ErrorAction SilentlyContinue
366379 Write-Host "ERROR: SFTP PUT failed"
367380 exit 1
368381 }
369382 Write-Host "PUT succeeded"
370383
371- # SFTP GET (download)
384+ # SFTP GET (download) - relative remote and local paths.
385+ # Remote large_test.dat resolves to C:\Users\testuser\large_test.dat.
386+ # Local large_test_copy.dat is relative to wolfsftp's CWD ($workDir).
372387 Write-Host "SFTP GET 3GB file..."
373- $getCommands = "get / large_test.dat $getDest `nquit"
374- $getCommands | Out-File -FilePath sftp_get_commands.txt -Encoding ASCII
388+ $getCommands = "get large_test.dat large_test_copy.dat `nquit"
389+ $getCommands | Out-File -FilePath (Join-Path $workDir " sftp_get_commands.txt") -Encoding ASCII
375390 $proc2 = Start-Process -FilePath $sftpPath `
376391 -ArgumentList "-u", "testuser", "-P", $env:TESTUSER_PASSWORD, "-h", "localhost", "-p", "${{env.TEST_PORT}}" `
377- -RedirectStandardInput "sftp_get_commands.txt" `
378- -RedirectStandardOutput "sftp_get_out.txt" `
379- -RedirectStandardError "sftp_get_err.txt" `
392+ -WorkingDirectory $workDir `
393+ -RedirectStandardInput (Join-Path $workDir "sftp_get_commands.txt") `
394+ -RedirectStandardOutput (Join-Path $workDir "sftp_get_out.txt") `
395+ -RedirectStandardError (Join-Path $workDir "sftp_get_err.txt") `
380396 -Wait -NoNewWindow -PassThru
381397
382- if ($proc2.ExitCode -ne 0) {
383- Get-Content sftp_get_out.txt
384- Get-Content sftp_get_err.txt
398+ $getOut = Get-Content (Join-Path $workDir "sftp_get_out.txt") -Raw -ErrorAction SilentlyContinue
399+ Write-Host "=== SFTP GET output ==="; Write-Host $getOut
400+ if ($proc2.ExitCode -ne 0 -or $getOut -match "Error getting file") {
401+ Get-Content (Join-Path $workDir "sftp_get_err.txt") -ErrorAction SilentlyContinue
385402 Write-Host "ERROR: SFTP GET failed"
386403 exit 1
387404 }
388405 Write-Host "GET succeeded"
389406
390- # Verify integrity
391- $expectedHash = (Get-Content large_test.dat.sha256).Trim()
392- $actualHash = (Get-FileHash -Path $getDest -Algorithm SHA256).Hash
407+ # Verify integrity (file is in $workDir from GET with relative path)
408+ $expectedHash = (Get-Content (Join-Path $workDir " large_test.dat.sha256") ).Trim()
409+ $actualHash = (Get-FileHash -Path $getDestPath -Algorithm SHA256).Hash
393410 if ($expectedHash -ne $actualHash) {
394411 Write-Host "ERROR: SHA256 mismatch - PUT/GET corruption"
395412 Write-Host "Expected: $expectedHash"
396413 Write-Host "Actual: $actualHash"
397414 exit 1
398415 }
399- Write-Host "PASS: 3GB SFTP get/put with WOLFSSH_MAX_SFTP_RW=10485760 succeeded"
416+ Write-Host "PASS: 3GB SFTP get/put succeeded"
400417
401418 - name : Cleanup
402419 if : always()
0 commit comments