aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-11-25 19:30:32 +0100
committerJakob Unterwurzacher2015-11-25 20:57:16 +0100
commit4d466c3412918346144dff609d8f706c6f002581 (patch)
tree2624a1b9573295e6f70df6eb74be5d0f241436e7 /main.go
parentd8bf6e7836a22c755fa0881f89d482b5e8f47e29 (diff)
diriv: Create gocryptfs.diriv in every directory
Diffstat (limited to 'main.go')
-rw-r--r--main.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/main.go b/main.go
index 8d8ef08..77b722a 100644
--- a/main.go
+++ b/main.go
@@ -1,6 +1,7 @@
package main
import (
+ "io/ioutil"
"flag"
"fmt"
"os"
@@ -43,6 +44,18 @@ func initDir(args *argContainer) {
os.Exit(ERREXIT_INIT)
}
+ // Create gocryptfs.diriv in the root dir
+ diriv := cryptfs.RandBytes(cryptfs.DIRIV_LEN)
+ dirivPath := filepath.Join(args.cipherdir, cryptfs.DIRIV_FILENAME)
+ cryptfs.Debug.Printf("Creating %s\n", dirivPath)
+ // 0444 permissions: the file is not secret but should not be written to
+ err = ioutil.WriteFile(dirivPath, diriv, 0444)
+ 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)
err = cryptfs.CreateConfFile(args.config, password, args.plaintextnames)