aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2018-09-08 13:04:33 +0200
committerJakob Unterwurzacher2018-09-08 13:04:33 +0200
commitca24c206945266d6397aa0e7d136d5bdcbda777f (patch)
tree3b9cebc661bcb788d6af175d86d03dd9d8a22e18 /main.go
parent2bdf7d5172d3540606f098030e8ede7a3ad1dfdd (diff)
main: don't read the config file twice (fix pipe bug)
Instead, first Load() the file, then DecryptMasterKey(). Fixes https://github.com/rfjakob/gocryptfs/issues/258
Diffstat (limited to 'main.go')
-rw-r--r--main.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/main.go b/main.go
index ac12d2e..fe38a87 100644
--- a/main.go
+++ b/main.go
@@ -33,10 +33,10 @@ var BuildDate = "0000-00-00"
var raceDetector bool
// loadConfig loads the config file "args.config", prompting the user for the password
-func loadConfig(args *argContainer) (masterkey []byte, confFile *configfile.ConfFile, err error) {
+func loadConfig(args *argContainer) (masterkey []byte, cf *configfile.ConfFile, err error) {
// First check if the file can be read at all, and find out if a Trezor should
// be used instead of a password.
- cf1, err := configfile.Load(args.config)
+ cf, err = configfile.Load(args.config)
if err != nil {
tlog.Fatal.Printf("Cannot open config file: %v", err)
return nil, nil, err
@@ -45,18 +45,18 @@ func loadConfig(args *argContainer) (masterkey []byte, confFile *configfile.Conf
// he forgot the password).
if args.masterkey != "" {
masterkey = parseMasterKey(args.masterkey, false)
- return masterkey, cf1, nil
+ return masterkey, cf, nil
}
var pw []byte
- if cf1.IsFeatureFlagSet(configfile.FlagTrezor) {
+ if cf.IsFeatureFlagSet(configfile.FlagTrezor) {
// Get binary data from from Trezor
- pw = readpassword.Trezor(cf1.TrezorPayload)
+ pw = readpassword.Trezor(cf.TrezorPayload)
} else {
// Normal password entry
pw = readpassword.Once(args.extpass, "")
}
tlog.Info.Println("Decrypting master key")
- masterkey, confFile, err = configfile.LoadAndDecrypt(args.config, pw)
+ masterkey, err = cf.DecryptMasterKey(pw)
for i := range pw {
pw[i] = 0
}
@@ -65,7 +65,7 @@ func loadConfig(args *argContainer) (masterkey []byte, confFile *configfile.Conf
tlog.Fatal.Println(err)
return nil, nil, err
}
- return masterkey, confFile, nil
+ return masterkey, cf, nil
}
// changePassword - change the password of config file "filename"