aboutsummaryrefslogtreecommitdiff
path: root/internal/fusefrontend_reverse/rpath.go
diff options
context:
space:
mode:
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