main: print actual error from LoadConfFile()

It may not have been a "Wrong password" after all.

Also, push down disabling the warning so LoadConfFile() can
warn about things that matter.
This commit is contained in:
Jakob Unterwurzacher 2016-06-05 13:44:22 +02:00
parent f2d208c464
commit ca54b665e3
2 changed files with 4 additions and 6 deletions

View File

@ -107,11 +107,12 @@ func LoadConfFile(filename string, password string) ([]byte, *ConfFile, error) {
cc := cryptocore.New(scryptHash, false, false)
ce := contentenc.New(cc, 4096)
toggledlog.Warn.Enabled = false // Silence DecryptBlock() error messages on incorrect password
key, err := ce.DecryptBlock(cf.EncryptedKey, 0, nil)
toggledlog.Warn.Enabled = true
if err != nil {
toggledlog.Warn.Printf("failed to unlock master key: %s", err.Error())
toggledlog.Warn.Printf("Password incorrect.")
return nil, nil, err
return nil, nil, fmt.Errorf("Password incorrect.")
}
return key, &cf, nil

View File

@ -123,12 +123,9 @@ func loadConfig(args *argContainer) (masterkey []byte, confFile *configfile.Conf
}
pw := readPassword(args.extpass)
toggledlog.Info.Printf("Decrypting master key... ")
toggledlog.Warn.Enabled = false // Silence DecryptBlock() error messages on incorrect password
masterkey, confFile, err = configfile.LoadConfFile(args.config, pw)
toggledlog.Warn.Enabled = true
if err != nil {
fmt.Println(err)
fmt.Println(colorRed + "Wrong password." + colorReset)
fmt.Println(os.Stderr, colorRed+err.Error()+colorReset)
os.Exit(ERREXIT_LOADCONF)
}
toggledlog.Info.Printf("done.")