From 71b94828edb00d3a86bbe366f49295d81f91c28c Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 6 Dec 2015 14:24:45 +0100 Subject: [PATCH] init: create gocryptfs.diriv after creating gocryptfs.conf Creating the config file can fail easily, for example if the password is not entered the same twice. This would leave an orphaned gocryptfs.diriv behind. --- cryptfs/kdf.go | 2 +- main.go | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cryptfs/kdf.go b/cryptfs/kdf.go index db08500..9a1d81c 100644 --- a/cryptfs/kdf.go +++ b/cryptfs/kdf.go @@ -28,7 +28,7 @@ func NewScryptKdf(logN int) scryptKdf { s.N = 1 << SCRYPT_DEFAULT_LOGN } else { if logN < 10 { - fmt.Printf("Error: scryptn below 10 is too low to make sense. Aborting.") + fmt.Printf("Error: scryptn below 10 is too low to make sense. Aborting.\n") os.Exit(1) } s.N = 1 << uint32(logN) diff --git a/main.go b/main.go index c5c7f64..9da89ab 100644 --- a/main.go +++ b/main.go @@ -52,13 +52,6 @@ func initDir(args *argContainer) { os.Exit(ERREXIT_INIT) } - // Create gocryptfs.diriv in the root dir - err = cryptfs.WriteDirIV(args.cipherdir) - if err != nil { - fmt.Println(err) - os.Exit(ERREXIT_INIT) - } - // Create gocryptfs.conf cryptfs.Info.Printf("Choose a password for protecting your files.\n") password := readPasswordTwice(args.extpass) @@ -67,6 +60,14 @@ func initDir(args *argContainer) { fmt.Println(err) os.Exit(ERREXIT_INIT) } + + // Create gocryptfs.diriv in the root dir + err = cryptfs.WriteDirIV(args.cipherdir) + if err != nil { + fmt.Println(err) + os.Exit(ERREXIT_INIT) + } + cryptfs.Info.Printf("The filesystem is now ready for mounting.\n") os.Exit(0) }