diff --git a/tools/cosmovisor/CHANGELOG.md b/tools/cosmovisor/CHANGELOG.md index e2d51a1106de..d3255d8d57db 100644 --- a/tools/cosmovisor/CHANGELOG.md +++ b/tools/cosmovisor/CHANGELOG.md @@ -35,6 +35,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Changelog ## [Unreleased] +* [#20062](https://github.com/cosmos/cosmos-sdk/pull/20062) Fixed cosmovisor add-upgrade permissions + ## v1.5.0 - 2023-07-17 diff --git a/tools/cosmovisor/cmd/cosmovisor/add_upgrade.go b/tools/cosmovisor/cmd/cosmovisor/add_upgrade.go index 24de3cd4899a..4e52d85728c5 100644 --- a/tools/cosmovisor/cmd/cosmovisor/add_upgrade.go +++ b/tools/cosmovisor/cmd/cosmovisor/add_upgrade.go @@ -5,7 +5,6 @@ import ( "fmt" "os" "path" - "path/filepath" "strings" "github.com/spf13/cobra" @@ -54,7 +53,7 @@ func AddUpgrade(cmd *cobra.Command, args []string) error { // create upgrade dir upgradeLocation := cfg.UpgradeDir(upgradeName) - if err := os.MkdirAll(path.Join(upgradeLocation, "bin"), 0o750); err != nil { + if err := os.MkdirAll(path.Join(upgradeLocation, "bin"), 0o755); err != nil { return fmt.Errorf("failed to create upgrade directory: %w", err) } @@ -94,7 +93,7 @@ func AddUpgrade(cmd *cobra.Command, args []string) error { return err } - logger.Info(fmt.Sprintf("%s created, %s upgrade binary will switch at height %d", filepath.Join(cfg.UpgradeInfoFilePath(), upgradetypes.UpgradeInfoFilename), upgradeName, upgradeHeight)) + logger.Info(fmt.Sprintf("%s created, %s upgrade binary will switch at height %d", cfg.UpgradeInfoFilePath(), upgradeName, upgradeHeight)) } return nil @@ -110,7 +109,8 @@ func saveOrAbort(path string, data []byte, force bool) error { return fmt.Errorf("failed to check if file exists: %w", err) } - if err := os.WriteFile(path, data, 0o600); err != nil { + //nolint:gosec // We need broader permissions to make it executable + if err := os.WriteFile(path, data, 0o755); err != nil { return fmt.Errorf("failed to write binary to location: %w", err) }