Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use a lower file permission in file creation #18206

Merged
merged 6 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@
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 {
Dismissed Show dismissed Hide dismissed
alexanderbez marked this conversation as resolved.
Show resolved Hide resolved
return nil, fmt.Errorf("failed to create snapshots directory: %w", err)
}

Expand Down
4 changes: 2 additions & 2 deletions store/storage/rocksdb/comparator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions x/upgrade/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ 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 {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@julienrbrt will anyone other than the sdk need to modify these files?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmh, cosmovisor needs to be able to read it and overwrite it if needed.

return "", fmt.Errorf("could not create directory %q: %w", upgradeInfoFileDir, err)
}
Expand Down
Loading