open-vault/vendor/github.com/lib/pq/ssl_permissions.go

21 lines
428 B
Go
Raw Normal View History

2017-01-04 21:47:38 +00:00
// +build !windows
package pq
import "os"
2017-03-31 00:03:13 +00:00
// sslKeyPermissions checks the permissions on user-supplied ssl key files.
// The key file should have very little access.
2017-01-04 21:47:38 +00:00
//
// libpq does not check key file permissions on Windows.
2017-03-31 00:03:13 +00:00
func sslKeyPermissions(sslkey string) error {
info, err := os.Stat(sslkey)
if err != nil {
return err
2017-01-04 21:47:38 +00:00
}
2017-03-31 00:03:13 +00:00
if info.Mode().Perm()&0077 != 0 {
return ErrSSLKeyHasWorldPermissions
}
return nil
2017-01-04 21:47:38 +00:00
}