From 4b251f3ce1f0a0472ed10a00aeef70c69ba03a5d Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Mon, 3 Jan 2022 15:18:59 +0100 Subject: readpassword: bubble up errors instead of exiting the process This allows cleanups to happen in the caller, like removing the control socket. Fixes https://github.com/rfjakob/gocryptfs/issues/634 --- masterkey.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'masterkey.go') diff --git a/masterkey.go b/masterkey.go index 10009cb..d488441 100644 --- a/masterkey.go +++ b/masterkey.go @@ -39,8 +39,12 @@ func unhexMasterKey(masterkey string, fromStdin bool) []byte { func handleArgsMasterkey(args *argContainer) (masterkey []byte) { // "-masterkey=stdin" if args.masterkey == "stdin" { - in := string(readpassword.Once(nil, nil, "Masterkey")) - return unhexMasterKey(in, true) + in, err := readpassword.Once(nil, nil, "Masterkey") + if err != nil { + tlog.Fatal.Println(err) + os.Exit(exitcodes.ReadPassword) + } + return unhexMasterKey(string(in), true) } // "-masterkey=941a6029-3adc6a1c-..." if args.masterkey != "" { -- cgit v1.2.3