From ff04b1d83ab120197add2fe4d6f6d3ff7a34f1ff Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sat, 9 May 2020 16:32:11 +0200 Subject: main: untangle `-masterkey` handling and config loading This was handled both in getMasterKey(). Split it apart. --- mount.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'mount.go') diff --git a/mount.go b/mount.go index 6d9dd8f..c0ef190 100644 --- a/mount.go +++ b/mount.go @@ -232,8 +232,22 @@ type ctlsockFs interface { // initFuseFrontend - initialize gocryptfs/fusefrontend // Calls os.Exit on errors func initFuseFrontend(args *argContainer) (pfs pathfs.FileSystem, wipeKeys func()) { - // Get master key (may prompt for the password) and read config file - masterkey, confFile := getMasterKey(args) + var err error + var confFile *configfile.ConfFile + // Get the masterkey from the command line if it was specified + masterkey := handleArgsMasterkey(args) + // Otherwise, load masterkey from config file (normal operation). + // Prompts the user for the password. + if masterkey == nil { + 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) + } + } // Reconciliate CLI and config file arguments into a fusefrontend.Args struct // that is passed to the filesystem implementation cryptoBackend := cryptocore.BackendGoGCM -- cgit v1.2.3