aboutsummaryrefslogtreecommitdiff
path: root/init_dir.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-05-07 22:15:01 +0200
committerJakob Unterwurzacher2017-05-07 22:16:22 +0200
commitd5adde1eeb13ba377f7c05b9f21893c01f61ec16 (patch)
tree011813ca5afd81ae6311bb007f5dc10ef69b2e7a /init_dir.go
parentad7942f434fea567f24458e67a0919291b5ec8dd (diff)
exitcodes: pull all exit code definitions into the package
This commit defines all exit codes in one place in the exitcodes package. Also, it adds a test to verify the exit code on incorrect password, which is what SiriKali cares about the most. Fixes https://github.com/rfjakob/gocryptfs/issues/77 .
Diffstat (limited to 'init_dir.go')
-rw-r--r--init_dir.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/init_dir.go b/init_dir.go
index 7b1dc7b..65b25d1 100644
--- a/init_dir.go
+++ b/init_dir.go
@@ -6,6 +6,7 @@ import (
"strings"
"github.com/rfjakob/gocryptfs/internal/configfile"
+ "github.com/rfjakob/gocryptfs/internal/exitcodes"
"github.com/rfjakob/gocryptfs/internal/nametransform"
"github.com/rfjakob/gocryptfs/internal/readpassword"
"github.com/rfjakob/gocryptfs/internal/tlog"
@@ -22,13 +23,13 @@ func initDir(args *argContainer) {
_, err = os.Stat(args.config)
if err == nil {
tlog.Fatal.Printf("Config file %q already exists", args.config)
- os.Exit(ErrExitInit)
+ os.Exit(exitcodes.Init)
}
} else {
err = checkDirEmpty(args.cipherdir)
if err != nil {
tlog.Fatal.Printf("Invalid cipherdir: %v", err)
- os.Exit(ErrExitInit)
+ os.Exit(exitcodes.Init)
}
}
// Choose password for config file
@@ -41,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(ErrExitInit)
+ os.Exit(exitcodes.Init)
}
// Forward mode with filename encryption enabled needs a gocryptfs.diriv
// in the root dir
@@ -49,7 +50,7 @@ func initDir(args *argContainer) {
err = nametransform.WriteDirIV(args.cipherdir)
if err != nil {
tlog.Fatal.Println(err)
- os.Exit(ErrExitInit)
+ os.Exit(exitcodes.Init)
}
}
mountArgs := ""