From 12471a8b0697b5263502db86d3b5903a64d5c62f Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Wed, 26 Jun 2019 13:21:49 -0700 Subject: [PATCH 1/2] use file getter for smb shares --- common/step_download.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/step_download.go b/common/step_download.go index af7708e6e..3e1429608 100644 --- a/common/step_download.go +++ b/common/step_download.go @@ -101,6 +101,9 @@ func init() { // can leave the source file where it is & tell us where it is. Copy: true, } + getters["smb"] = &getter.FileGetter{ + Copy: true, + } } } From 88d589cc888c2adc5cc4858d414474cdfb3741e7 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Wed, 26 Jun 2019 13:43:05 -0700 Subject: [PATCH 2/2] enable smb share double backslash pathing too --- common/step_download.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common/step_download.go b/common/step_download.go index 3e1429608..cc076a182 100644 --- a/common/step_download.go +++ b/common/step_download.go @@ -7,6 +7,7 @@ import ( "fmt" "log" "os" + "path/filepath" "runtime" "strings" @@ -108,6 +109,14 @@ func init() { } func (s *StepDownload) download(ctx context.Context, ui packer.Ui, source string) (string, error) { + if runtime.GOOS == "windows" { + // Check that the user specified a UNC path, and promote it to an smb:// uri. + if strings.HasPrefix(source, "\\\\") && len(source) > 2 && source[2] != '?' { + source = filepath.ToSlash(source[2:]) + source = fmt.Sprintf("smb://%s", source) + } + } + u, err := urlhelper.Parse(source) if err != nil { return "", fmt.Errorf("url parse: %s", err)