From b93f392acd277a8cb63503c303e91c7fc9f873e6 Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Mon, 23 Oct 2023 13:06:16 +0200 Subject: [PATCH 1/4] use a lower file permission --- store/storage/rocksdb/comparator.go | 4 ++-- x/upgrade/keeper/keeper.go | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/store/storage/rocksdb/comparator.go b/store/storage/rocksdb/comparator.go index 3af816aba470..5da27d9121f9 100644 --- a/store/storage/rocksdb/comparator.go +++ b/store/storage/rocksdb/comparator.go @@ -27,7 +27,7 @@ func CreateTSComparator() *grocksdb.Comparator { // // NOTICE: The behavior must be identical to RocksDB builtin comparator // "leveldb.BytewiseComparator.u64ts". -func compareTS(bz1 []byte, bz2 []byte) int { +func compareTS(bz1, bz2 []byte) int { ts1 := binary.LittleEndian.Uint64(bz1) ts2 := binary.LittleEndian.Uint64(bz2) @@ -48,7 +48,7 @@ func compareTS(bz1 []byte, bz2 []byte) int { // // NOTICE: The behavior must be identical to RocksDB builtin comparator // "leveldb.BytewiseComparator.u64ts". -func compare(a []byte, b []byte) int { +func compare(a, b []byte) int { ret := compareWithoutTS(a, true, b, true) if ret != 0 { return ret diff --git a/x/upgrade/keeper/keeper.go b/x/upgrade/keeper/keeper.go index 4bc8590eeeb9..eab09c2a89e9 100644 --- a/x/upgrade/keeper/keeper.go +++ b/x/upgrade/keeper/keeper.go @@ -491,7 +491,8 @@ func (k Keeper) DumpUpgradeInfoToDisk(height int64, p types.Plan) error { // GetUpgradeInfoPath returns the upgrade info file path func (k Keeper) GetUpgradeInfoPath() (string, error) { upgradeInfoFileDir := path.Join(k.getHomeDir(), "data") - if err := os.MkdirAll(upgradeInfoFileDir, os.ModePerm); err != nil { + // Only the owner can read and write. Everyone else can only read. No one can execute the file. + if err := os.MkdirAll(upgradeInfoFileDir, 0o644); err != nil { return "", fmt.Errorf("could not create directory %q: %w", upgradeInfoFileDir, err) } From 80bcd9bf2bcd5d4bde41d05ada48adfbedd9923c Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Mon, 23 Oct 2023 13:08:57 +0200 Subject: [PATCH 2/4] change perms on snapshot store creation --- server/util.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/util.go b/server/util.go index dae0a21abb7e..32cd46d6b946 100644 --- a/server/util.go +++ b/server/util.go @@ -533,7 +533,7 @@ func DefaultBaseappOptions(appOpts types.AppOptions) []func(*baseapp.BaseApp) { func GetSnapshotStore(appOpts types.AppOptions) (*snapshots.Store, error) { homeDir := cast.ToString(appOpts.Get(flags.FlagHome)) snapshotDir := filepath.Join(homeDir, "data", "snapshots") - if err := os.MkdirAll(snapshotDir, os.ModePerm); err != nil { + if err := os.MkdirAll(snapshotDir, 0o644); err != nil { return nil, fmt.Errorf("failed to create snapshots directory: %w", err) } From bf89e1bd9b7ec96555eef20e2242081e03076080 Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Mon, 23 Oct 2023 14:53:27 +0200 Subject: [PATCH 3/4] revert perm --- x/upgrade/keeper/keeper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/upgrade/keeper/keeper.go b/x/upgrade/keeper/keeper.go index eab09c2a89e9..fee289180774 100644 --- a/x/upgrade/keeper/keeper.go +++ b/x/upgrade/keeper/keeper.go @@ -492,7 +492,7 @@ func (k Keeper) DumpUpgradeInfoToDisk(height int64, p types.Plan) error { func (k Keeper) GetUpgradeInfoPath() (string, error) { upgradeInfoFileDir := path.Join(k.getHomeDir(), "data") // Only the owner can read and write. Everyone else can only read. No one can execute the file. - if err := os.MkdirAll(upgradeInfoFileDir, 0o644); err != nil { + if err := os.MkdirAll(upgradeInfoFileDir, os.ModePerm); err != nil { return "", fmt.Errorf("could not create directory %q: %w", upgradeInfoFileDir, err) } From f2d1060bd01547648b7711714f7bbd47ea197cc0 Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Mon, 23 Oct 2023 14:54:42 +0200 Subject: [PATCH 4/4] remove comment --- x/upgrade/keeper/keeper.go | 1 - 1 file changed, 1 deletion(-) diff --git a/x/upgrade/keeper/keeper.go b/x/upgrade/keeper/keeper.go index fee289180774..4bc8590eeeb9 100644 --- a/x/upgrade/keeper/keeper.go +++ b/x/upgrade/keeper/keeper.go @@ -491,7 +491,6 @@ func (k Keeper) DumpUpgradeInfoToDisk(height int64, p types.Plan) error { // GetUpgradeInfoPath returns the upgrade info file path func (k Keeper) GetUpgradeInfoPath() (string, error) { upgradeInfoFileDir := path.Join(k.getHomeDir(), "data") - // Only the owner can read and write. Everyone else can only read. No one can execute the file. if err := os.MkdirAll(upgradeInfoFileDir, os.ModePerm); err != nil { return "", fmt.Errorf("could not create directory %q: %w", upgradeInfoFileDir, err) }