summaryrefslogtreecommitdiff
path: root/internal/nametransform/diriv.go
diff options
context:
space:
mode:
authorSebastian Lackner2017-11-30 20:53:38 +0100
committerrfjakob2017-12-01 09:41:52 +0100
commit9bcde0c09e96e17ed7092aa5fa5f6bfc89372a8d (patch)
tree645734db4d3959839ad013a7c9406c14e678403d /internal/nametransform/diriv.go
parente97c23e08383666117523cf3145f1213b41c2489 (diff)
fusefrontend: Improve documentation of mkdirWithIv and WriteDirIV
As requested in https://github.com/rfjakob/gocryptfs/pull/179
Diffstat (limited to 'internal/nametransform/diriv.go')
-rw-r--r--internal/nametransform/diriv.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/internal/nametransform/diriv.go b/internal/nametransform/diriv.go
index f980a04..527ccce 100644
--- a/internal/nametransform/diriv.go
+++ b/internal/nametransform/diriv.go
@@ -3,6 +3,7 @@ package nametransform
import (
"bytes"
"io"
+ "log"
"os"
"path/filepath"
"strings"
@@ -73,10 +74,16 @@ func fdReadDirIV(fd *os.File) (iv []byte, err error) {
return iv, nil
}
-// WriteDirIV - create diriv file inside "dir" (absolute ciphertext path)
-// This function is exported because it is used from pathfs_frontend, main,
-// and also the automated tests.
+// WriteDirIV - create diriv file inside of the specified directory. If dirfd
+// is nil "dir" should be the absolute path to the directory. If dirfd != nil
+// "dir" should be a path (without slashes) relative to the directory
+// described by "dirfd". This function is exported because it is used from
+// pathfs_frontend, main, and also the automated tests.
func WriteDirIV(dirfd *os.File, dir string) error {
+ // For relative paths we do not expect that "dir" contains slashes
+ if dirfd != nil && strings.Contains(dir, "/") {
+ log.Panicf("WriteDirIV: Relative path should not contain slashes: %v", dir)
+ }
iv := cryptocore.RandBytes(DirIVLen)
file := filepath.Join(dir, DirIVFilename)
// 0400 permissions: gocryptfs.diriv should never be modified after creation.