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.
This commit is contained in:
parent
fc23aba65b
commit
71b94828ed
@ -28,7 +28,7 @@ func NewScryptKdf(logN int) scryptKdf {
|
|||||||
s.N = 1 << SCRYPT_DEFAULT_LOGN
|
s.N = 1 << SCRYPT_DEFAULT_LOGN
|
||||||
} else {
|
} else {
|
||||||
if logN < 10 {
|
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)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
s.N = 1 << uint32(logN)
|
s.N = 1 << uint32(logN)
|
||||||
|
15
main.go
15
main.go
@ -52,13 +52,6 @@ func initDir(args *argContainer) {
|
|||||||
os.Exit(ERREXIT_INIT)
|
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
|
// Create gocryptfs.conf
|
||||||
cryptfs.Info.Printf("Choose a password for protecting your files.\n")
|
cryptfs.Info.Printf("Choose a password for protecting your files.\n")
|
||||||
password := readPasswordTwice(args.extpass)
|
password := readPasswordTwice(args.extpass)
|
||||||
@ -67,6 +60,14 @@ func initDir(args *argContainer) {
|
|||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(ERREXIT_INIT)
|
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")
|
cryptfs.Info.Printf("The filesystem is now ready for mounting.\n")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user