From 540f125f18d14f4aa55a2c88dfc3d17d8e7dcc1d Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 16 Oct 2016 16:19:12 +0200 Subject: [PATCH] main: move masterkey warnings into parseMasterKey This makes sure all callers of parseMasterKey warn the user. At the moment there is only one, but another one will be added soon for forcing a password change when only the master key is known. --- masterkey.go | 8 ++++++-- mount.go | 4 ---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/masterkey.go b/masterkey.go index 2e8ca4c..c933669 100644 --- a/masterkey.go +++ b/masterkey.go @@ -49,12 +49,16 @@ func parseMasterKey(masterkey string) []byte { masterkey = strings.Replace(masterkey, "-", "", -1) key, err := hex.DecodeString(masterkey) if err != nil { - tlog.Fatal.Printf("Could not parse master key: %v\n", err) + tlog.Fatal.Printf("Could not parse master key: %v", err) os.Exit(1) } if len(key) != cryptocore.KeyLen { - tlog.Fatal.Printf("Master key has length %d but we require length %d\n", len(key), cryptocore.KeyLen) + tlog.Fatal.Printf("Master key has length %d but we require length %d", len(key), cryptocore.KeyLen) os.Exit(1) } + tlog.Info.Printf("Using explicit master key.") + tlog.Info.Printf(tlog.ColorYellow + + "THE MASTER KEY IS VISIBLE VIA \"ps ax\" AND MAY BE STORED IN YOUR SHELL HISTORY!\n" + + "ONLY USE THIS MODE FOR EMERGENCIES." + tlog.ColorReset) return key } diff --git a/mount.go b/mount.go index 47dd192..c207bdd 100644 --- a/mount.go +++ b/mount.go @@ -53,11 +53,7 @@ func doMount(args *argContainer) int { var confFile *configfile.ConfFile if args.masterkey != "" { // "-masterkey" - tlog.Info.Printf("Using explicit master key.") masterkey = parseMasterKey(args.masterkey) - tlog.Info.Printf(tlog.ColorYellow + - "THE MASTER KEY IS VISIBLE VIA \"ps ax\" AND MAY BE STORED IN YOUR SHELL HISTORY!\n" + - "ONLY USE THIS MODE FOR EMERGENCIES." + tlog.ColorReset) } else if args.zerokey { // "-zerokey" tlog.Info.Printf("Using all-zero dummy master key.")