From e6aa0cba4a2ff65e72345cf3052e5e972cc32d9b Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Fri, 2 Oct 2020 11:52:54 +0200 Subject: [PATCH 1/3] Write decrypted shares to stdout conditionally If the output file is specified, we should not write decrypted key shares to stdout. --- cmd/signing.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/cmd/signing.go b/cmd/signing.go index d44b0e71c..5209a36c5 100644 --- a/cmd/signing.go +++ b/cmd/signing.go @@ -110,17 +110,7 @@ func DecryptKeyShare(c *cli.Context) error { ) } - _, err = os.Stdout.Write(signerBytes) - if err != nil { - return fmt.Errorf( - "could not write signer bytes to stdout: [%v]", - err, - ) - } - - outputFilePath := c.String("output-file") - - if len(outputFilePath) > 0 { + if outputFilePath := c.String("output-file"); len(outputFilePath) > 0 { if _, err := os.Stat(outputFilePath); !os.IsNotExist(err) { return fmt.Errorf( "could not write shares to file; file [%s] already exists", @@ -136,6 +126,14 @@ func DecryptKeyShare(c *cli.Context) error { err, ) } + } else { + _, err = os.Stdout.Write(signerBytes) + if err != nil { + return fmt.Errorf( + "could not write signer bytes to stdout: [%v]", + err, + ) + } } return nil From 71a7aa83b7530eb8a8b3536d83e3930da3bd99dd Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Fri, 2 Oct 2020 12:05:33 +0200 Subject: [PATCH 2/3] Use keep-common logging in the signing `Before` fn --- cmd/signing.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/signing.go b/cmd/signing.go index 5209a36c5..ddeddfad0 100644 --- a/cmd/signing.go +++ b/cmd/signing.go @@ -9,8 +9,7 @@ import ( "sync" "time" - "github.com/ipfs/go-log" - + "github.com/keep-network/keep-common/pkg/logging" "github.com/keep-network/keep-core/pkg/net" "github.com/keep-network/keep-core/pkg/net/key" "github.com/keep-network/keep-core/pkg/net/local" @@ -33,7 +32,8 @@ func init() { Name: "signing", Usage: "Provides several tools useful for out-of-band signing", Before: func(c *cli.Context) error { - _ = log.SetLogLevel("*", "fatal") // disable the regular logger + // disable the regular logger + _ = logging.Configure("keep*=fatal") return nil }, Subcommands: []cli.Command{ From dec80cf3c8d58de372aef78d1a0a24d5cc988d4b Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Fri, 2 Oct 2020 12:11:10 +0200 Subject: [PATCH 3/3] Print the error from `app.Run` instead of logging --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 10baddf01..a8219ba20 100644 --- a/main.go +++ b/main.go @@ -65,6 +65,6 @@ func main() { err = app.Run(os.Args) if err != nil { - logger.Fatal(err) + fmt.Print(err) } }