diff options
author | Jakob Unterwurzacher | 2021-06-26 18:42:36 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2021-06-26 18:49:54 +0200 |
commit | 45648e567ae5e6d40bb42ae954406c8762fc577f (patch) | |
tree | 6f606c9a06d29e2a87446b02da3921ab978a921d /internal/fusefrontend | |
parent | f9f4bd214f772b88233d55c2cf270726bfa603c6 (diff) |
fusefrontend: ctlsock: get rid of unneccessary wrapper function
Diffstat (limited to 'internal/fusefrontend')
-rw-r--r-- | internal/fusefrontend/ctlsock_interface.go | 20 |
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 { |