Skip to content

Commit

Permalink
cmd: include case where PrivKey is stored in lower case
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
  • Loading branch information
Kubuxu committed Jul 13, 2016
1 parent f7e6590 commit 6b97588
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/commands/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io/ioutil"
"os"
"os/exec"
"strings"

cmds "github.com/ipfs/go-ipfs/commands"
repo "github.com/ipfs/go-ipfs/repo"
Expand Down Expand Up @@ -59,8 +60,8 @@ Set the value of the 'datastore.path' key:
key := args[0]

// This is a temporary fix until we move the private key out of the config file
switch key {
case "Identity", "Identity.PrivKey":
switch strings.ToLower(key) {
case "identity", "identity.privkey":
res.SetError(fmt.Errorf("cannot show or change private key through API"), cmds.ErrNormal)
return
default:
Expand Down
9 changes: 9 additions & 0 deletions test/sharness/t0021-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,19 @@ test_config_cmd() {
test_expect_code 1 ipfs config Identity.PrivKey 2> ident_out
'

test_expect_success "lower cased PrivKey" '
sed -i -e '\''s/PrivKey/privkey/'\'' "$IPFS_PATH/config" &&
test_expect_code 1 ipfs config Identity.privkey 2> ident_out
'

test_expect_success "output looks good" '
test_cmp ident_exp ident_out
'

test_expect_success "fix it back" '
sed -i -e '\''s/privkey/PrivKey/'\'' "$IPFS_PATH/config"
'

test_expect_success "'ipfs config show' doesn't include privkey" '
ipfs config show > show_config &&
test_expect_code 1 grep PrivKey show_config
Expand Down

0 comments on commit 6b97588

Please sign in to comment.