Standardize File Permissions in Accounts-V2 (#6934)

* standardize file permissions
* Gaz
* no petname
* Merge refs/heads/master into file-perms
This commit is contained in:
Raul Jordan 2020-08-07 17:14:07 -05:00 committed by GitHub
parent 3275a86ece
commit 10f38662e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 12 deletions

1
go.mod
View File

@ -17,7 +17,6 @@ require (
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
github.com/deckarep/golang-set v1.7.1 // indirect github.com/deckarep/golang-set v1.7.1 // indirect
github.com/dgraph-io/ristretto v0.0.3 github.com/dgraph-io/ristretto v0.0.3
github.com/dustinkirkland/golang-petname v0.0.0-20191129215211-8e5a1ed0cff0
github.com/edsrzf/mmap-go v1.0.0 // indirect github.com/edsrzf/mmap-go v1.0.0 // indirect
github.com/elastic/gosigar v0.10.5 // indirect github.com/elastic/gosigar v0.10.5 // indirect
github.com/emicklei/dot v0.11.0 github.com/emicklei/dot v0.11.0

2
go.sum
View File

@ -189,8 +189,6 @@ github.com/dop251/goja v0.0.0-20200219165308-d1232e640a87 h1:OMbqMXf9OAXzH1dDH82
github.com/dop251/goja v0.0.0-20200219165308-d1232e640a87/go.mod h1:Mw6PkjjMXWbTj+nnj4s3QPXq1jaT0s5pC0iFD4+BOAA= github.com/dop251/goja v0.0.0-20200219165308-d1232e640a87/go.mod h1:Mw6PkjjMXWbTj+nnj4s3QPXq1jaT0s5pC0iFD4+BOAA=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustinkirkland/golang-petname v0.0.0-20191129215211-8e5a1ed0cff0 h1:90Ly+6UfUypEF6vvvW5rQIv9opIL8CbmW9FT20LDQoY=
github.com/dustinkirkland/golang-petname v0.0.0-20191129215211-8e5a1ed0cff0/go.mod h1:V+Qd57rJe8gd4eiGzZyg4h54VLHmYVVw54iMnlAMrF8=
github.com/eapache/go-resiliency v1.2.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-resiliency v1.2.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=

View File

@ -33,7 +33,6 @@ go_library(
"//validator/keymanager/v2/derived:go_default_library", "//validator/keymanager/v2/derived:go_default_library",
"//validator/keymanager/v2/direct:go_default_library", "//validator/keymanager/v2/direct:go_default_library",
"//validator/keymanager/v2/remote:go_default_library", "//validator/keymanager/v2/remote:go_default_library",
"@com_github_dustinkirkland_golang_petname//:go_default_library",
"@com_github_k0kubun_go_ansi//:go_default_library", "@com_github_k0kubun_go_ansi//:go_default_library",
"@com_github_logrusorgru_aurora//:go_default_library", "@com_github_logrusorgru_aurora//:go_default_library",
"@com_github_manifoldco_promptui//:go_default_library", "@com_github_manifoldco_promptui//:go_default_library",

View File

@ -12,11 +12,11 @@ import (
"strings" "strings"
"time" "time"
petname "github.com/dustinkirkland/golang-petname"
"github.com/k0kubun/go-ansi" "github.com/k0kubun/go-ansi"
"github.com/logrusorgru/aurora" "github.com/logrusorgru/aurora"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/promptutil" "github.com/prysmaticlabs/prysm/shared/promptutil"
"github.com/prysmaticlabs/prysm/validator/flags" "github.com/prysmaticlabs/prysm/validator/flags"
v2keymanager "github.com/prysmaticlabs/prysm/validator/keymanager/v2" v2keymanager "github.com/prysmaticlabs/prysm/validator/keymanager/v2"
@ -63,10 +63,6 @@ type Wallet struct {
walletPassword string walletPassword string
} }
func init() {
petname.NonDeterministicMode() // Set random account name generation.
}
// NewWallet given a set of configuration options, will leverage // NewWallet given a set of configuration options, will leverage
// create and write a new wallet to disk for a Prysm validator. // create and write a new wallet to disk for a Prysm validator.
func NewWallet( func NewWallet(
@ -314,7 +310,7 @@ func (w *Wallet) WriteFileAtPath(ctx context.Context, filePath string, fileName
return errors.Wrapf(err, "could not create path: %s", accountPath) return errors.Wrapf(err, "could not create path: %s", accountPath)
} }
fullPath := filepath.Join(accountPath, fileName) fullPath := filepath.Join(accountPath, fileName)
if err := ioutil.WriteFile(fullPath, data, os.ModePerm); err != nil { if err := ioutil.WriteFile(fullPath, data, params.BeaconIoConfig().ReadWritePermissions); err != nil {
return errors.Wrapf(err, "could not write %s", filePath) return errors.Wrapf(err, "could not write %s", filePath)
} }
log.WithFields(logrus.Fields{ log.WithFields(logrus.Fields{
@ -395,7 +391,7 @@ func (w *Wallet) ReadKeymanagerConfigFromDisk(ctx context.Context) (io.ReadClose
func (w *Wallet) WriteKeymanagerConfigToDisk(ctx context.Context, encoded []byte) error { func (w *Wallet) WriteKeymanagerConfigToDisk(ctx context.Context, encoded []byte) error {
configFilePath := filepath.Join(w.accountsPath, KeymanagerConfigFileName) configFilePath := filepath.Join(w.accountsPath, KeymanagerConfigFileName)
// Write the config file to disk. // Write the config file to disk.
if err := ioutil.WriteFile(configFilePath, encoded, os.ModePerm); err != nil { if err := ioutil.WriteFile(configFilePath, encoded, params.BeaconIoConfig().ReadWritePermissions); err != nil {
return errors.Wrapf(err, "could not write %s", configFilePath) return errors.Wrapf(err, "could not write %s", configFilePath)
} }
log.WithField("configFilePath", configFilePath).Debug("Wrote keymanager config file to disk") log.WithField("configFilePath", configFilePath).Debug("Wrote keymanager config file to disk")
@ -417,7 +413,7 @@ func (w *Wallet) ReadEncryptedSeedFromDisk(ctx context.Context) (io.ReadCloser,
func (w *Wallet) WriteEncryptedSeedToDisk(ctx context.Context, encoded []byte) error { func (w *Wallet) WriteEncryptedSeedToDisk(ctx context.Context, encoded []byte) error {
seedFilePath := filepath.Join(w.accountsPath, derived.EncryptedSeedFileName) seedFilePath := filepath.Join(w.accountsPath, derived.EncryptedSeedFileName)
// Write the config file to disk. // Write the config file to disk.
if err := ioutil.WriteFile(seedFilePath, encoded, os.ModePerm); err != nil { if err := ioutil.WriteFile(seedFilePath, encoded, params.BeaconIoConfig().ReadWritePermissions); err != nil {
return errors.Wrapf(err, "could not write %s", seedFilePath) return errors.Wrapf(err, "could not write %s", seedFilePath)
} }
log.WithField("seedFilePath", seedFilePath).Debug("Wrote wallet encrypted seed file to disk") log.WithField("seedFilePath", seedFilePath).Debug("Wrote wallet encrypted seed file to disk")