From 3a2610a141b3afb96050b8dc4f7262939d563133 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Wed, 16 Sep 2015 18:43:07 +0200 Subject: symlink encryption: pass ".." and "." through unchanged This fixes relative symlinks: $ tar xf linux-4.2.tar.gz tar: linux-4.2/tools/testing/selftests/powerpc/vphn/vphn.h: Cannot utime: No such file or directory tar: linux-4.2/tools/testing/selftests/powerpc/vphn/vphn.c: Cannot utime: No such file or directory tar: linux-4.2/tools/testing/selftests/powerpc/stringloops/memcmp_64.S: Cannot utime: No such file or directory tar: linux-4.2/tools/testing/selftests/powerpc/primitives/word-at-a-time.h: Cannot utime: No such file or directory tar: linux-4.2/tools/testing/selftests/powerpc/primitives/asm/asm-compat.h: Cannot utime: No such file or directory tar: linux-4.2/tools/testing/selftests/powerpc/copyloops/memcpy_power7.S: Cannot utime: No such file or directory tar: linux-4.2/tools/testing/selftests/powerpc/copyloops/memcpy_64.S: Cannot utime: No such file or directory tar: linux-4.2/tools/testing/selftests/powerpc/copyloops/copyuser_power7.S: Cannot utime: No such file or directory tar: linux-4.2/tools/testing/selftests/powerpc/copyloops/copyuser_64.S: Cannot utime: No such file or directory tar: linux-4.2/arch/powerpc/boot/dts/include/dt-bindings: Cannot utime: No such file or directory tar: linux-4.2/arch/mips/boot/dts/include/dt-bindings: Cannot utime: No such file or directory tar: linux-4.2/arch/metag/boot/dts/include/dt-bindings: Cannot utime: No such file or directory tar: linux-4.2/arch/arm64/boot/dts/include/dt-bindings: Cannot utime: No such file or directory tar: linux-4.2/arch/arm/boot/dts/include/dt-bindings: Cannot utime: No such file or directory tar: Exiting with failure status due to previous errors --- cryptfs/cryptfs_names.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cryptfs/cryptfs_names.go b/cryptfs/cryptfs_names.go index c4f2a36..f694fa5 100644 --- a/cryptfs/cryptfs_names.go +++ b/cryptfs/cryptfs_names.go @@ -19,6 +19,12 @@ const ( // DecryptName - decrypt filename func (be *CryptFS) decryptName(cipherName string) (string, error) { + // Make sure relative symlinks still work after encryption + // by passing these trough unchanged + if cipherName == "." || cipherName == ".." { + return cipherName, nil + } + bin, err := base64.URLEncoding.DecodeString(cipherName) if err != nil { return "", err @@ -44,6 +50,12 @@ func (be *CryptFS) decryptName(cipherName string) (string, error) { // EncryptName - encrypt filename func (be *CryptFS) encryptName(plainName string) string { + // Make sure relative symlinks still work after encryption + // by passing these trough unchanged + if plainName == "." || plainName == ".." { + return plainName + } + bin := []byte(plainName) bin = be.pad16(bin) -- cgit v1.2.3