Skip to content

Commit

Permalink
fix(cosmovisor): fixed cosmovisor add-upgrade permissions (#20062)
Browse files Browse the repository at this point in the history
  • Loading branch information
freak12techno committed May 2, 2024
1 parent 2e39dcb commit 8f10576
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions tools/cosmovisor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions tools/cosmovisor/cmd/cosmovisor/add_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"os"
"path"
"path/filepath"
"strings"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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
Expand All @@ -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)
}

Expand Down

0 comments on commit 8f10576

Please sign in to comment.