diff --git a/cmd/clef/main.go b/cmd/clef/main.go index 801c7e9efd..31a8e2fef9 100644 --- a/cmd/clef/main.go +++ b/cmd/clef/main.go @@ -82,6 +82,10 @@ var ( Name: "advanced", Usage: "If enabled, issues warnings instead of rejections for suspicious requests. Default off", } + acceptFlag = cli.BoolFlag{ + Name: "acceptWarn", + Usage: "If set, does not show the warning during boot", + } keystoreFlag = cli.StringFlag{ Name: "keystore", Value: filepath.Join(node.DefaultDataDir(), "keystore"), @@ -196,6 +200,7 @@ The delpw command removes a password for a given address (keyfile). logLevelFlag, keystoreFlag, utils.LightKDFFlag, + acceptFlag, }, Description: ` The newaccount command creates a new keystore-backed account. It is a convenience-method @@ -235,6 +240,7 @@ func init() { stdiouiFlag, testFlag, advancedMode, + acceptFlag, } app.Action = signer app.Commands = []cli.Command{initCommand, @@ -433,8 +439,10 @@ func initialize(c *cli.Context) error { if c.GlobalBool(stdiouiFlag.Name) { logOutput = os.Stderr // If using the stdioui, we can't do the 'confirm'-flow - fmt.Fprint(logOutput, legalWarning) - } else { + if !c.GlobalBool(acceptFlag.Name){ + fmt.Fprint(logOutput, legalWarning) + } + } else if !c.GlobalBool(acceptFlag.Name){ if !confirm(legalWarning) { return fmt.Errorf("aborted by user") } diff --git a/signer/core/cliui.go b/signer/core/cliui.go index 1e033299af..c7075a595c 100644 --- a/signer/core/cliui.go +++ b/signer/core/cliui.go @@ -25,9 +25,9 @@ import ( "sync" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/console" "github.com/ethereum/go-ethereum/internal/ethapi" "github.com/ethereum/go-ethereum/log" - "golang.org/x/crypto/ssh/terminal" ) type CommandlineUI struct { @@ -61,17 +61,16 @@ func (ui *CommandlineUI) readString() string { func (ui *CommandlineUI) OnInputRequired(info UserInputRequest) (UserInputResponse, error) { fmt.Printf("## %s\n\n%s\n", info.Title, info.Prompt) + defer fmt.Println("-----------------------") if info.IsPassword { - fmt.Printf("> ") - text, err := terminal.ReadPassword(int(os.Stdin.Fd())) + text, err := console.Stdin.PromptPassword("> ") if err != nil { - log.Error("Failed to read password", "err", err) + log.Error("Failed to read password", "error", err) + return UserInputResponse{}, err } - fmt.Println("-----------------------") - return UserInputResponse{string(text)}, err + return UserInputResponse{text}, nil } text := ui.readString() - fmt.Println("-----------------------") return UserInputResponse{text}, nil }