From a4f3a7dca2edd54ccc7941c73a33ba0ca0d34fdb Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 1 Apr 2018 14:51:53 +0200 Subject: main: move masterkey logic into new helper getMasterKey The new helper will also be used by fsck. --- mount.go | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) (limited to 'mount.go') diff --git a/mount.go b/mount.go index c5b1c05..c21fa01 100644 --- a/mount.go +++ b/mount.go @@ -29,7 +29,6 @@ import ( "github.com/rfjakob/gocryptfs/internal/fusefrontend" "github.com/rfjakob/gocryptfs/internal/fusefrontend_reverse" "github.com/rfjakob/gocryptfs/internal/nametransform" - "github.com/rfjakob/gocryptfs/internal/readpassword" "github.com/rfjakob/gocryptfs/internal/tlog" ) @@ -96,37 +95,9 @@ func doMount(args *argContainer) { var confFile *configfile.ConfFile var srv *fuse.Server { - // Get master key (may prompt for the password) var masterkey []byte - masterkeyFromStdin := false - if args.masterkey == "stdin" { - args.masterkey = string(readpassword.Once("", "Masterkey")) - masterkeyFromStdin = true - } - if args.masterkey != "" { - // "-masterkey" - masterkey = parseMasterKey(args.masterkey, masterkeyFromStdin) - } else if args.zerokey { - // "-zerokey" - tlog.Info.Printf("Using all-zero dummy master key.") - tlog.Info.Printf(tlog.ColorYellow + - "ZEROKEY MODE PROVIDES NO SECURITY AT ALL AND SHOULD ONLY BE USED FOR TESTING." + - tlog.ColorReset) - masterkey = make([]byte, cryptocore.KeyLen) - } else { - // Load master key from config file - // Prompts the user for the password - masterkey, confFile, err = loadConfig(args) - if err != nil { - if args._ctlsockFd != nil { - // Close the socket file (which also deletes it) - args._ctlsockFd.Close() - } - exitcodes.Exit(err) - } - readpassword.CheckTrailingGarbage() - printMasterKey(masterkey) - } + // Get master key (may prompt for the password) + masterkey, confFile = getMasterKey(args) // We cannot use JSON for pretty-printing as the fields are unexported tlog.Debug.Printf("cli args: %#v", args) // Initialize FUSE server -- cgit v1.2.3