aboutsummaryrefslogtreecommitdiff
path: root/mount.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-05-09 16:32:11 +0200
committerJakob Unterwurzacher2020-05-09 16:53:12 +0200
commitff04b1d83ab120197add2fe4d6f6d3ff7a34f1ff (patch)
tree202580b73b47b99b5ee81d9c2e2e9580e15a6520 /mount.go
parent7622c9f538d324ba4ed704ff836942af39d2b1f9 (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.go18
1 files changed, 16 insertions, 2 deletions
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