mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-28 16:24:39 +02:00
Fix tilde expand for Windows paths with backslashes (#768)
* add backslash support for Windows paths * add pester tests for tilde_expand * fix typo
This commit is contained in:
parent
0c3137f621
commit
cdcc8d34d8
9
misc.c
9
misc.c
@ -1261,6 +1261,15 @@ tilde_expand(const char *filename, uid_t uid, char **retp)
|
||||
path = NULL; /* ~/ */
|
||||
else
|
||||
path = copy; /* ~/path */
|
||||
#ifdef WINDOWS
|
||||
// also need to account for backward slashes on Windows
|
||||
} else if (*copy == '\\') {
|
||||
copy += strspn(copy, "\\");
|
||||
if (*copy == '\0')
|
||||
path = NULL; /* ~\ */
|
||||
else
|
||||
path = copy; /* ~\path */
|
||||
#endif /* WINDOWS */
|
||||
} else {
|
||||
user = copy;
|
||||
if ((path = strchr(copy, '/')) != NULL) {
|
||||
|
@ -27,7 +27,7 @@ Describe "E2E scenarios for ssh client" -Tags "CI" {
|
||||
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule($ssouser, $rights, "ContainerInherit,Objectinherit", "None", "Allow")
|
||||
$acl.SetAccessRule($accessRule)
|
||||
Set-Acl -Path $testDir -AclObject $acl
|
||||
#skip on ps 2 becase non-interactive cmd require a ENTER before it returns on ps2
|
||||
#skip on ps 2 because non-interactive cmd require a ENTER before it returns on ps2
|
||||
$skip = $IsWindows -and ($PSVersionTable.PSVersion.Major -le 2)
|
||||
|
||||
<#$testData = @(
|
||||
@ -349,6 +349,18 @@ Describe "E2E scenarios for ssh client" -Tags "CI" {
|
||||
$logFile | Should Contain "[::1]"
|
||||
}
|
||||
|
||||
It "$tC.$tI - tilde expand for path with forward slash" {
|
||||
$o = ssh -v -i ~/test/key/path -E $logFile test_target echo 1234
|
||||
$o | Should Be "1234"
|
||||
$logFile | Should Not Contain "tilde_expand: No such user"
|
||||
}
|
||||
|
||||
It "$tC.$tI - tilde expand for path with backslash" {
|
||||
$o = ssh -v -i ~\test\key\path -E $logFile test_target echo 1234
|
||||
$o | Should Be "1234"
|
||||
$logFile | Should Not Contain "tilde_expand: No such user"
|
||||
}
|
||||
|
||||
It "$tC.$tI - auto populate known hosts" {
|
||||
|
||||
$kh = Join-Path $testDir "$tC.$tI.known_hosts"
|
||||
|
Loading…
x
Reference in New Issue
Block a user