From fa4226c742bc076ea2c0981c74e64776c6a04d42 Mon Sep 17 00:00:00 2001 From: Stefan Scherer Date: Sat, 4 Feb 2017 21:21:17 +0100 Subject: [PATCH] Skip file permission check on Windows --- acme/localStore.go | 12 ++++-------- acme/localStore_unix.go | 25 +++++++++++++++++++++++++ acme/localStore_windows.go | 6 ++++++ 3 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 acme/localStore_unix.go create mode 100644 acme/localStore_windows.go diff --git a/acme/localStore.go b/acme/localStore.go index ac74bc531..b65bf50a8 100644 --- a/acme/localStore.go +++ b/acme/localStore.go @@ -40,19 +40,15 @@ func (s *LocalStore) Load() (cluster.Object, error) { defer s.storageLock.Unlock() account := &Account{} + err := checkPermissions(s.file) + if err != nil { + return nil, err + } f, err := os.Open(s.file) if err != nil { return nil, err } defer f.Close() - fi, err := f.Stat() - if err != nil { - return nil, err - } - if fi.Mode().Perm()&0077 != 0 { - return nil, fmt.Errorf("permissions %o for %s are too open, please use 600", fi.Mode().Perm(), s.file) - } - file, err := ioutil.ReadAll(f) if err != nil { return nil, err diff --git a/acme/localStore_unix.go b/acme/localStore_unix.go new file mode 100644 index 000000000..e53592e5d --- /dev/null +++ b/acme/localStore_unix.go @@ -0,0 +1,25 @@ +// +build !windows + +package acme + +import ( + "fmt" + "os" +) + +// Check file permissions +func checkPermissions(name string) error { + f, err := os.Open(name) + if err != nil { + return err + } + defer f.Close() + fi, err := f.Stat() + if err != nil { + return err + } + if fi.Mode().Perm()&0077 != 0 { + return fmt.Errorf("permissions %o for %s are too open, please use 600", fi.Mode().Perm(), name) + } + return nil +} diff --git a/acme/localStore_windows.go b/acme/localStore_windows.go new file mode 100644 index 000000000..131896371 --- /dev/null +++ b/acme/localStore_windows.go @@ -0,0 +1,6 @@ +package acme + +// Do not check file permissions on Windows right now +func checkPermissions(name string) error { + return nil +}