From 0ed43e903e52bda84649cbbf04729477ea099af1 Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Fri, 21 Aug 2020 19:42:42 +0200 Subject: [PATCH] fix(key): dont allow backup key to be named 'self' docs: update the key rotate help docs to be clearer about the backup --- core/commands/keystore.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/commands/keystore.go b/core/commands/keystore.go index e79f6260b..844d77096 100644 --- a/core/commands/keystore.go +++ b/core/commands/keystore.go @@ -442,6 +442,7 @@ var keyRotateCmd = &cmds.Command{ Tagline: "Rotates the ipfs identity.", ShortDescription: ` Generates a new ipfs identity and saves it to the ipfs config file. +Your existing identity key will be backed up in the Keystore. The daemon must not be running when calling this command. ipfs uses a repository in the local file system. By default, the repo is @@ -453,7 +454,7 @@ environment variable: }, Arguments: []cmds.Argument{}, Options: []cmds.Option{ - cmds.StringOption(oldKeyOptionName, "o", "Keystore name for the old/rotated-out key."), + cmds.StringOption(oldKeyOptionName, "o", "Keystore name to use for backing up your existing identity"), cmds.StringOption(keyStoreTypeOptionName, "t", "type of the key to create: rsa, ed25519").WithDefault(keyStoreAlgorithmDefault), cmds.IntOption(keyStoreSizeOptionName, "s", "size of the key to generate"), }, @@ -482,6 +483,9 @@ environment variable: if !ok { return fmt.Errorf("keystore name for backing up old key must be provided") } + if oldKey == "self" { + return fmt.Errorf("keystore name for back up cannot be named 'self'") + } return doRotate(os.Stdout, cctx.ConfigRoot, oldKey, algorithm, nBitsForKeypair, nBitsGiven) }, }