diff options
author | Jakob Unterwurzacher | 2022-01-03 15:18:59 +0100 |
---|---|---|
committer | Jakob Unterwurzacher | 2022-01-03 15:18:59 +0100 |
commit | 4b251f3ce1f0a0472ed10a00aeef70c69ba03a5d (patch) | |
tree | a93b7b37d5b3118decd8a52f2db2e76d09d82b70 /main.go | |
parent | 1eaf1211a259a38cdf3e7dad2e00e140409bef9a (diff) |
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
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -55,11 +55,15 @@ func loadConfig(args *argContainer) (masterkey []byte, cf *configfile.ConfFile, if cf.IsFeatureFlagSet(configfile.FlagFIDO2) { if args.fido2 == "" { tlog.Fatal.Printf("Masterkey encrypted using FIDO2 token; need to use the --fido2 option.") - os.Exit(exitcodes.Usage) + return nil, nil, exitcodes.NewErr("", exitcodes.Usage) } pw = fido2.Secret(args.fido2, cf.FIDO2.CredentialID, cf.FIDO2.HMACSalt) } else { - pw = readpassword.Once([]string(args.extpass), []string(args.passfile), "") + pw, err = readpassword.Once([]string(args.extpass), []string(args.passfile), "") + if err != nil { + tlog.Fatal.Println(err) + return nil, nil, exitcodes.NewErr("", exitcodes.ReadPassword) + } } tlog.Info.Println("Decrypting master key") masterkey, err = cf.DecryptMasterKey(pw) @@ -93,7 +97,11 @@ func changePassword(args *argContainer) { os.Exit(exitcodes.Usage) } tlog.Info.Println("Please enter your new password.") - newPw := readpassword.Twice([]string(args.extpass), []string(args.passfile)) + newPw, err := readpassword.Twice([]string(args.extpass), []string(args.passfile)) + if err != nil { + tlog.Fatal.Println(err) + os.Exit(exitcodes.ReadPassword) + } logN := confFile.ScryptObject.LogN() if args._explicitScryptn { logN = args.scryptn |