diff options
author | Jakob Unterwurzacher | 2019-01-03 13:32:13 +0100 |
---|---|---|
committer | Jakob Unterwurzacher | 2019-01-03 15:31:13 +0100 |
commit | f6dad8d0fae25b5d88ad036b841fea10b7296ccb (patch) | |
tree | 6fd3ebb0e8114445027cb36b340925e275f82a84 /init_dir.go | |
parent | 0fd7637624c6994ce50be8a374648352f3f52501 (diff) |
nametransform: simplify WriteDirIV to WriteDirIVAt
Un-spaghettify the function and let the callers open
the directory.
Diffstat (limited to 'init_dir.go')
-rw-r--r-- | init_dir.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/init_dir.go b/init_dir.go index 5d5cbc9..1f5a7fc 100644 --- a/init_dir.go +++ b/init_dir.go @@ -6,12 +6,14 @@ import ( "os" "path/filepath" "strings" + "syscall" "github.com/rfjakob/gocryptfs/internal/configfile" "github.com/rfjakob/gocryptfs/internal/cryptocore" "github.com/rfjakob/gocryptfs/internal/exitcodes" "github.com/rfjakob/gocryptfs/internal/nametransform" "github.com/rfjakob/gocryptfs/internal/readpassword" + "github.com/rfjakob/gocryptfs/internal/syscallcompat" "github.com/rfjakob/gocryptfs/internal/tlog" ) @@ -96,7 +98,12 @@ func initDir(args *argContainer) { // Forward mode with filename encryption enabled needs a gocryptfs.diriv file // in the root dir if !args.plaintextnames && !args.reverse { - err = nametransform.WriteDirIV(-1, args.cipherdir) + // Open cipherdir (following symlinks) + dirfd, err := syscall.Open(args.cipherdir, syscall.O_RDONLY|syscall.O_DIRECTORY|syscallcompat.O_PATH, 0) + if err == nil { + err = nametransform.WriteDirIVAt(dirfd) + syscall.Close(dirfd) + } if err != nil { tlog.Fatal.Println(err) os.Exit(exitcodes.Init) |