Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OVFTool password escaping space character #110

Open
carlhprime opened this issue May 18, 2020 · 1 comment
Open

OVFTool password escaping space character #110

carlhprime opened this issue May 18, 2020 · 1 comment

Comments

@carlhprime
Copy link

The url.QueryEscape parameter is used to escape the password provided to OVFTool in the locator string:

password := url.QueryEscape(c.esxiPassword)

password := url.QueryEscape(c.esxiPassword)

Unfortunately, the url.QueryEscape function escapes spaces as +, which OVFTool treats as a literal +. Consequently, providing a password containing spaces characters will cause authentication failure.

I just hit this issue, and I would be happy to submit a pull request to perform the additional escape of space manually.

I would personally rather modify the provider to pass credentials to OVFTool via stdin. This would avoid the need for escaping altogether, and would also be better practice in terms of security. If you are willing to go this way then I'll submit a pull request.

@josenk
Copy link
Owner

josenk commented May 18, 2020

I'm OK with either solution, but it must work cross-platform. Please make sure your solution works with Linux, Windows and Mac.

You'll notice that Windows requires a temporary batch file. I remember having a lot of trouble properly handling quotes and escaping on Windows.

if runtime.GOOS == "windows" {
osShellCmd = "cmd.exe"
osShellCmdOpt = "/c"
ovf_cmd = strings.Replace(ovf_cmd, "'", "\"", -1)
var ovf_bat = "ovf_cmd.bat"
_, err = os.Stat(ovf_bat)
// delete file if exists
if os.IsExist(err) {
err = os.Remove(ovf_bat)
if err != nil {
return "", fmt.Errorf("Unable to delete %s: %s\n", ovf_bat, err.Error())
}
}
// create new batch file
file, err := os.Create(ovf_bat)
if err != nil {
return "", fmt.Errorf("Unable to create %s: %s\n", ovf_bat, err.Error())
defer file.Close()
}
_, err = file.WriteString(strings.Replace(ovf_cmd, "%", "%%", -1))
if err != nil {
return "", fmt.Errorf("Unable to write to %s: %s\n", ovf_bat, err.Error())
defer file.Close()
}
err = file.Sync()
defer file.Close()
ovf_cmd = ovf_bat
} else {

If your solution can remove the requirement of the temp batch file, that would be a great fix!

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants