summaryrefslogtreecommitdiff
path: root/internal/fusefrontend
diff options
context:
space:
mode:
authorJakob Unterwurzacher2021-06-26 18:42:36 +0200
committerJakob Unterwurzacher2021-06-26 18:49:54 +0200
commit45648e567ae5e6d40bb42ae954406c8762fc577f (patch)
tree6f606c9a06d29e2a87446b02da3921ab978a921d /internal/fusefrontend
parentf9f4bd214f772b88233d55c2cf270726bfa603c6 (diff)
fusefrontend: ctlsock: get rid of unneccessary wrapper function
Diffstat (limited to 'internal/fusefrontend')
-rw-r--r--internal/fusefrontend/ctlsock_interface.go20
1 files changed, 6 insertions, 14 deletions
diff --git a/internal/fusefrontend/ctlsock_interface.go b/internal/fusefrontend/ctlsock_interface.go
index 07d742f..9e8cffc 100644
--- a/internal/fusefrontend/ctlsock_interface.go
+++ b/internal/fusefrontend/ctlsock_interface.go
@@ -18,11 +18,7 @@ var _ ctlsocksrv.Interface = &RootNode{} // Verify that interface is implemented
//
// Symlink-safe through openBackingDir().
func (rn *RootNode) EncryptPath(plainPath string) (cipherPath string, err error) {
- if plainPath == "" {
- // Empty string gets encrypted as empty string
- return plainPath, nil
- }
- if rn.args.PlaintextNames {
+ if rn.args.PlaintextNames || plainPath == "" {
return plainPath, nil
}
@@ -68,21 +64,17 @@ func (rn *RootNode) EncryptPath(plainPath string) (cipherPath string, err error)
// DecryptPath is symlink-safe because openBackingDir() and decryptPathAt()
// are symlink-safe.
func (rn *RootNode) DecryptPath(cipherPath string) (plainPath string, err error) {
+ if rn.args.PlaintextNames || cipherPath == "" {
+ return cipherPath, nil
+ }
+
dirfd, _, errno := rn.prepareAtSyscallMyself()
if errno != 0 {
return "", errno
}
defer syscall.Close(dirfd)
- return rn.decryptPathAt(dirfd, cipherPath)
-}
-// decryptPathAt decrypts a ciphertext path relative to dirfd.
-//
-// Symlink-safe through ReadDirIVAt() and ReadLongNameAt().
-func (rn *RootNode) decryptPathAt(dirfd int, cipherPath string) (plainPath string, err error) {
- if rn.args.PlaintextNames || cipherPath == "" {
- return cipherPath, nil
- }
+ // Decrypt path level by level
parts := strings.Split(cipherPath, "/")
wd := dirfd
for i, part := range parts {