From cf0ac15ecccaad0fe55dce3e9a06fe80a424ff59 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 4 Nov 2013 14:26:18 -0800 Subject: [PATCH] builder/vmware: force LANG=C for ifconfig [GH-592] --- CHANGELOG.md | 1 + builder/vmware/host_ip_ifconfig.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e0a6f771..80ceceff6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ BUG FIXES: [GH-554] * builder/openstack: Properly scrub password from logs [GH-554] * builder/virtualbox: No panic if SSH host port min/max is the same. [GH-594] +* builder/vmware: Host IP lookup works for non-C locales. [GH-592] * common/uuid: Use cryptographically secure PRNG when generating UUIDs. [GH-552] * communicator/ssh: File uploads that exceed the size of memory no longer diff --git a/builder/vmware/host_ip_ifconfig.go b/builder/vmware/host_ip_ifconfig.go index 08606daf0..7c4204e17 100644 --- a/builder/vmware/host_ip_ifconfig.go +++ b/builder/vmware/host_ip_ifconfig.go @@ -21,6 +21,12 @@ func (f *IfconfigIPFinder) HostIP() (string, error) { stdout := new(bytes.Buffer) cmd := exec.Command(ifconfigPath, f.Device) + cmd.Env = append(cmd.Env, os.Environ()...) + + // Force LANG=C so that the output is what we expect it to be + // despite the locale. + cmd.Env = append(cmd.Env, "LANG=C") + cmd.Stdout = stdout cmd.Stderr = new(bytes.Buffer) if err := cmd.Run(); err != nil {