From cb4d9e81a4d796acb51a5beea4959a2934804031 Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Wed, 14 May 2014 10:46:30 -0700 Subject: [PATCH] fix(coreos-cloudinit): Ensure /etc/coreos exists before writing to it --- initialize/locksmith.go | 3 +++ initialize/locksmith_test.go | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/initialize/locksmith.go b/initialize/locksmith.go index 2d383bf..d5578ba 100644 --- a/initialize/locksmith.go +++ b/initialize/locksmith.go @@ -20,6 +20,9 @@ func addStrategy(strategy string, root string) error { etcUpdate := path.Join(root, "etc", "coreos", "update.conf") usrUpdate := path.Join(root, "usr", "share", "coreos", "update.conf") + // Ensure /etc/coreos/ exists before attempting to write a file in it + os.MkdirAll(path.Join(root, "etc", "coreos"), 0755) + tmp, err := ioutil.TempFile(path.Join(root, "etc", "coreos"), ".update.conf") if err != nil { return err diff --git a/initialize/locksmith_test.go b/initialize/locksmith_test.go index c6bceae..2243ea3 100644 --- a/initialize/locksmith_test.go +++ b/initialize/locksmith_test.go @@ -22,7 +22,6 @@ REBOOT_STRATEGY=etcd-lock func setupFixtures(dir string) { os.MkdirAll(path.Join(dir, "usr", "share", "coreos"), 0755) - os.MkdirAll(path.Join(dir, "etc", "coreos"), 0755) os.MkdirAll(path.Join(dir, "run", "systemd", "system"), 0755) ioutil.WriteFile(path.Join(dir, "usr", "share", "coreos", "update.conf"), []byte(base), 0644)