main: check if the config file can opened before prompting for password
This was frustrating: $ gocryptfs a b Password: Decrypting master key open a/gocryptfs.conf: permission denied
This commit is contained in:
parent
9b1a35174b
commit
89bcc50294
7
main.go
7
main.go
@ -64,12 +64,13 @@ Options:
|
|||||||
|
|
||||||
// loadConfig - load the config file "filename", prompting the user for the password
|
// loadConfig - load the config file "filename", prompting the user for the password
|
||||||
func loadConfig(args *argContainer) (masterkey []byte, confFile *configfile.ConfFile) {
|
func loadConfig(args *argContainer) (masterkey []byte, confFile *configfile.ConfFile) {
|
||||||
// Check if the file exists at all before prompting for a password
|
// Check if the file can be opened at all before prompting for a password
|
||||||
_, err := os.Stat(args.config)
|
fd, err := os.Open(args.config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tlog.Fatal.Printf("Config file not found: %v", err)
|
tlog.Fatal.Printf("Cannot open config file: %v", err)
|
||||||
os.Exit(ErrExitLoadConf)
|
os.Exit(ErrExitLoadConf)
|
||||||
}
|
}
|
||||||
|
fd.Close()
|
||||||
pw := readpassword.Once(args.extpass)
|
pw := readpassword.Once(args.extpass)
|
||||||
tlog.Info.Println("Decrypting master key")
|
tlog.Info.Println("Decrypting master key")
|
||||||
masterkey, confFile, err = configfile.LoadConfFile(args.config, pw)
|
masterkey, confFile, err = configfile.LoadConfFile(args.config, pw)
|
||||||
|
Loading…
Reference in New Issue
Block a user