Merge pull request #1115 from StefanScherer/check-file-permission-unix-only

Skip file permission check on Windows
This commit is contained in:
Emile Vauge 2017-02-05 13:49:00 +01:00 committed by GitHub
commit 0d3b2ed230
3 changed files with 35 additions and 8 deletions

View file

@ -40,19 +40,15 @@ func (s *LocalStore) Load() (cluster.Object, error) {
defer s.storageLock.Unlock() defer s.storageLock.Unlock()
account := &Account{} account := &Account{}
err := checkPermissions(s.file)
if err != nil {
return nil, err
}
f, err := os.Open(s.file) f, err := os.Open(s.file)
if err != nil { if err != nil {
return nil, err return nil, err
} }
defer f.Close() 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) file, err := ioutil.ReadAll(f)
if err != nil { if err != nil {
return nil, err return nil, err

25
acme/localStore_unix.go Normal file
View file

@ -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
}

View file

@ -0,0 +1,6 @@
package acme
// Do not check file permissions on Windows right now
func checkPermissions(name string) error {
return nil
}