mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 21:38:05 -05:00
Relax file permissions check on existing directories (#13274)
This commit is contained in:
@@ -59,10 +59,9 @@ func HandleBackupDir(dirPath string, permissionOverride bool) error {
|
||||
return os.MkdirAll(expanded, params.BeaconIoConfig().ReadWriteExecutePermissions)
|
||||
}
|
||||
|
||||
// MkdirAll takes in a path, expands it if necessary, and looks through the
|
||||
// permissions of every directory along the path, ensuring we are not attempting
|
||||
// to overwrite any existing permissions. Finally, creates the directory accordingly
|
||||
// with standardized, Prysm project permissions. This is the static-analysis enforced
|
||||
// MkdirAll takes in a path, expands it if necessary, and creates the directory accordingly
|
||||
// with standardized, Prysm project permissions. If a directory already exists as this path,
|
||||
// then the method returns without making any changes. This is the static-analysis enforced
|
||||
// method for creating a directory programmatically in Prysm.
|
||||
func MkdirAll(dirPath string) error {
|
||||
expanded, err := ExpandPath(dirPath)
|
||||
@@ -74,13 +73,7 @@ func MkdirAll(dirPath string) error {
|
||||
return err
|
||||
}
|
||||
if exists {
|
||||
info, err := os.Stat(expanded)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if info.Mode().Perm() != params.BeaconIoConfig().ReadWriteExecutePermissions {
|
||||
return errors.New("dir already exists without proper 0700 permissions")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return os.MkdirAll(expanded, params.BeaconIoConfig().ReadWriteExecutePermissions)
|
||||
}
|
||||
|
||||
@@ -49,14 +49,6 @@ func TestPathExpansion(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMkdirAll_AlreadyExists_WrongPermissions(t *testing.T) {
|
||||
dirName := t.TempDir() + "somedir"
|
||||
err := os.MkdirAll(dirName, os.ModePerm)
|
||||
require.NoError(t, err)
|
||||
err = file.MkdirAll(dirName)
|
||||
assert.ErrorContains(t, "already exists without proper 0700 permissions", err)
|
||||
}
|
||||
|
||||
func TestMkdirAll_AlreadyExists_Override(t *testing.T) {
|
||||
dirName := t.TempDir() + "somedir"
|
||||
err := os.MkdirAll(dirName, params.BeaconIoConfig().ReadWriteExecutePermissions)
|
||||
|
||||
Reference in New Issue
Block a user