aboutsummaryrefslogtreecommitdiff
path: root/internal/fusefrontend_reverse/rpath.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-08-01 23:06:35 +0200
committerJakob Unterwurzacher2020-08-01 23:06:35 +0200
commit47d8f56b7f9a7dee760deeaeae3e044c0ab65d6a (patch)
treeea2ddbca8c0c5b755749ae762a74003a7878c805 /internal/fusefrontend_reverse/rpath.go
parent6c26cda53122df871befd0c1e08b892e0d56d31e (diff)
v2api/reverse: add missing decryptPath call openBackingDir
Diffstat (limited to 'internal/fusefrontend_reverse/rpath.go')
-rw-r--r--internal/fusefrontend_reverse/rpath.go20
1 files changed, 14 insertions, 6 deletions
diff --git a/internal/fusefrontend_reverse/rpath.go b/internal/fusefrontend_reverse/rpath.go
index ed37847..35b9361 100644
--- a/internal/fusefrontend_reverse/rpath.go
+++ b/internal/fusefrontend_reverse/rpath.go
@@ -64,11 +64,11 @@ func (rfs *RootNode) rDecryptName(cName string, dirIV []byte, pDir string) (pNam
// decryptPath decrypts a relative ciphertext path to a relative plaintext
// path.
-func (rn *RootNode) decryptPath(relPath string) (string, error) {
- if rn.args.PlaintextNames || relPath == "" {
- return relPath, nil
+func (rn *RootNode) decryptPath(cPath string) (string, error) {
+ if rn.args.PlaintextNames || cPath == "" {
+ return cPath, nil
}
- parts := strings.Split(relPath, "/")
+ parts := strings.Split(cPath, "/")
var transformedParts []string
for i := range parts {
// Start at the top and recurse
@@ -90,12 +90,20 @@ func (rn *RootNode) decryptPath(relPath string) (string, error) {
// and returns the fd to the directory and the decrypted name of the
// target file. The fd/name pair is intended for use with fchownat and
// friends.
-func (rn *RootNode) openBackingDir(pRelPath string) (dirfd int, pName string, err error) {
+func (rn *RootNode) openBackingDir(cPath string) (dirfd int, pName string, err error) {
+ defer func() {
+ tlog.Debug.Printf("openBackingDir %q -> %d %q %v\n", cPath, dirfd, pName, err)
+ }()
+ dirfd = -1
+ pRelPath, err := rn.decryptPath(cPath)
+ if err != nil {
+ return
+ }
// Open directory, safe against symlink races
pDir := filepath.Dir(pRelPath)
dirfd, err = syscallcompat.OpenDirNofollow(rn.args.Cipherdir, pDir)
if err != nil {
- return -1, "", err
+ return
}
pName = filepath.Base(pRelPath)
return dirfd, pName, nil