From 47d8f56b7f9a7dee760deeaeae3e044c0ab65d6a Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sat, 1 Aug 2020 23:06:35 +0200 Subject: v2api/reverse: add missing decryptPath call openBackingDir --- internal/fusefrontend_reverse/rpath.go | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'internal/fusefrontend_reverse/rpath.go') 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 -- cgit v1.2.3