microsoft / K8s-Storage-Plugins

Storage plugins for Kubernetes
MIT License
42 stars 20 forks source link

Mapping error when mapping to a directory with spaces in the name #24

Open herao67 opened 2 years ago

herao67 commented 2 years ago

Hi, when we try to map to a directory with spaces in the name, e.g. \\servername.domain.com\folder1\some folder we got an error The specified network resource or device is no longer available.

The reason for that is that suddenly there are quotes around the directory name and the Trim functions in /flexvolume/windows/plugins/microsoft.com~smb.cmd/flexvolume.ps1 do not work correctly. The @json variable contains a beginning quote, but not ending one.

We fixed it with two edits. One in line 241, adding another Trim at the end:

$escapedJson = $all.Substring($command.Length).Trim().SubString($folder.Length).Trim('" ')

and secondly with adding quotes around the remotepath in line 128:

cmd /c "mklink /D $symlink `"$remotepath`"" 2>&1  | Out-Null