Merge "veyron/services/mgmt/device/impl: fix shell expansion of TIMESTAMP"
diff --git a/services/mgmt/device/impl/device_installer.go b/services/mgmt/device/impl/device_installer.go
index cfa0015..1057bfe 100644
--- a/services/mgmt/device/impl/device_installer.go
+++ b/services/mgmt/device/impl/device_installer.go
@@ -221,7 +221,7 @@
}
// TODO(caprita): Switch all our generated bash scripts to use templates.
output := "#!/bin/bash\n"
- output += fmt.Sprintln("readonly TIMESTAMP=$(date +%s%N)")
+ output += fmt.Sprintf("readonly TIMESTAMP=$(%s)\n", dateCommand)
output += fmt.Sprintf("%s=%q ", consts.VeyronCredentials, principalDir)
// Escape the path to the binary; %q uses Go-syntax escaping, but it's
// close enough to Bash that we're using it as an approximation.
diff --git a/services/mgmt/device/impl/device_service.go b/services/mgmt/device/impl/device_service.go
index e8c9617..f976242 100644
--- a/services/mgmt/device/impl/device_service.go
+++ b/services/mgmt/device/impl/device_service.go
@@ -318,7 +318,7 @@
}
output := "#!/bin/bash\n"
- output += fmt.Sprintln("readonly TIMESTAMP=$(date +%s%N)")
+ output += fmt.Sprintf("readonly TIMESTAMP=$(%s)\n", dateCommand)
output += strings.Join(config.QuoteEnv(append(envelope.Env, configSettings...)), " ") + " "
// Escape the path to the binary; %q uses Go-syntax escaping, but it's
// close enough to Bash that we're using it as an approximation.
diff --git a/services/mgmt/device/impl/shell_darwin.go b/services/mgmt/device/impl/shell_darwin.go
new file mode 100644
index 0000000..02539ce
--- /dev/null
+++ b/services/mgmt/device/impl/shell_darwin.go
@@ -0,0 +1,5 @@
+package impl
+
+const (
+ dateCommand = "/bin/date +%s.$RANDOM"
+)
diff --git a/services/mgmt/device/impl/shell_linux.go b/services/mgmt/device/impl/shell_linux.go
new file mode 100644
index 0000000..530caa2
--- /dev/null
+++ b/services/mgmt/device/impl/shell_linux.go
@@ -0,0 +1,5 @@
+package impl
+
+const (
+ dateCommand = "/bin/date +%s%N"
+)