diff options
author | Jakob Unterwurzacher | 2020-05-09 16:32:11 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2020-05-09 16:53:12 +0200 |
commit | ff04b1d83ab120197add2fe4d6f6d3ff7a34f1ff (patch) | |
tree | 202580b73b47b99b5ee81d9c2e2e9580e15a6520 /mount.go | |
parent | 7622c9f538d324ba4ed704ff836942af39d2b1f9 (diff) |
main: untangle `-masterkey` handling and config loading
This was handled both in getMasterKey(). Split it apart.
Diffstat (limited to 'mount.go')
-rw-r--r-- | mount.go | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -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 |