aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--init_dir.go2
-rw-r--r--internal/configfile/config_file.go1
-rw-r--r--internal/exitcodes/exitcodes.go4
-rw-r--r--main.go4
4 files changed, 8 insertions, 3 deletions
diff --git a/init_dir.go b/init_dir.go
index 65b25d1..20c9fd9 100644
--- a/init_dir.go
+++ b/init_dir.go
@@ -42,7 +42,7 @@ func initDir(args *argContainer) {
err = configfile.CreateConfFile(args.config, password, args.plaintextnames, args.scryptn, creator, args.aessiv)
if err != nil {
tlog.Fatal.Println(err)
- os.Exit(exitcodes.Init)
+ os.Exit(exitcodes.WriteConf)
}
// Forward mode with filename encryption enabled needs a gocryptfs.diriv
// in the root dir
diff --git a/internal/configfile/config_file.go b/internal/configfile/config_file.go
index 5605e1d..fea4a84 100644
--- a/internal/configfile/config_file.go
+++ b/internal/configfile/config_file.go
@@ -96,6 +96,7 @@ func LoadConfFile(filename string, password string) ([]byte, *ConfFile, error) {
// Read from disk
js, err := ioutil.ReadFile(filename)
if err != nil {
+ fmt.Printf("LoadConfFile: ReadFile: %#v\n", err)
return nil, nil, err
}
diff --git a/internal/exitcodes/exitcodes.go b/internal/exitcodes/exitcodes.go
index 3e78b64..ae7824d 100644
--- a/internal/exitcodes/exitcodes.go
+++ b/internal/exitcodes/exitcodes.go
@@ -53,6 +53,10 @@ const (
PanicLogCreate = 21
// PasswordEmpty - we received an empty password
PasswordEmpty = 22
+ // OpenConf - the was an error opening the gocryptfs.conf file for reading
+ OpenConf = 23
+ // WriteConf - could not write the gocryptfs.conf
+ WriteConf = 24
)
// Err wraps an error with an associated numeric exit code
diff --git a/main.go b/main.go
index 27cbf1f..77d25f4 100644
--- a/main.go
+++ b/main.go
@@ -52,7 +52,7 @@ func loadConfig(args *argContainer) (masterkey []byte, confFile *configfile.Conf
fd, err := os.Open(args.config)
if err != nil {
tlog.Fatal.Printf("Cannot open config file: %v", err)
- return nil, nil, err
+ return nil, nil, exitcodes.NewErr(err.Error(), exitcodes.OpenConf)
}
fd.Close()
// The user has passed the master key (probably because he forgot the
@@ -97,7 +97,7 @@ func changePassword(args *argContainer) {
err = confFile.WriteFile()
if err != nil {
tlog.Fatal.Println(err)
- os.Exit(exitcodes.Init)
+ os.Exit(exitcodes.WriteConf)
}
tlog.Info.Printf(tlog.ColorGreen + "Password changed." + tlog.ColorReset)
os.Exit(0)