aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-10-08 17:19:06 +0200
committerJakob Unterwurzacher2016-10-08 17:19:55 +0200
commit89bcc50294c765315fafa0d2201edfc59438ff8f (patch)
tree812d9492226220072e20fbeef0d39fc28bd7c7e5 /main.go
parent9b1a35174b11b321271f7cefb6af3ced90ebc2bb (diff)
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
Diffstat (limited to 'main.go')
-rw-r--r--main.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/main.go b/main.go
index ac412a6..9fc9b6b 100644
--- a/main.go
+++ b/main.go
@@ -64,12 +64,13 @@ Options:
// loadConfig - load the config file "filename", prompting the user for the password
func loadConfig(args *argContainer) (masterkey []byte, confFile *configfile.ConfFile) {
- // Check if the file exists at all before prompting for a password
- _, err := os.Stat(args.config)
+ // Check if the file can be opened at all before prompting for a password
+ fd, err := os.Open(args.config)
if err != nil {
- tlog.Fatal.Printf("Config file not found: %v", err)
+ tlog.Fatal.Printf("Cannot open config file: %v", err)
os.Exit(ErrExitLoadConf)
}
+ fd.Close()
pw := readpassword.Once(args.extpass)
tlog.Info.Println("Decrypting master key")
masterkey, confFile, err = configfile.LoadConfFile(args.config, pw)