From 4a7953f93a6c135f5c990c0a0deed62a18c336d0 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Fri, 22 Jun 2018 13:49:39 -0700 Subject: [PATCH] found a config validation bug where packer crashes instead of throwing a validation error if a windows-style path is provided to a provisioner on linux --- common/shell-local/config.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/common/shell-local/config.go b/common/shell-local/config.go index 82a41a192..ba2508120 100644 --- a/common/shell-local/config.go +++ b/common/shell-local/config.go @@ -215,6 +215,13 @@ func ConvertToLinuxPath(winAbsPath string) (string, error) { // get absolute path of script, and morph it into the bash path winAbsPath = strings.Replace(winAbsPath, "\\", "/", -1) splitPath := strings.SplitN(winAbsPath, ":/", 2) - winBashPath := fmt.Sprintf("/mnt/%s/%s", strings.ToLower(splitPath[0]), splitPath[1]) - return winBashPath, nil + if len(splitPath) == 2 { + winBashPath := fmt.Sprintf("/mnt/%s/%s", strings.ToLower(splitPath[0]), splitPath[1]) + return winBashPath, nil + } else { + err := fmt.Errorf("There was an error splitting your absolute path; expected "+ + "to find a drive following the format ':/' but did not: absolute "+ + "path: %s", winAbsPath) + return "", err + } }