rfjakob/gocryptfs

Excluding files/directories from directory listing does not work when using "-plaintextnames" switch

slackner opened this issue · 3 comments

Steps to reproduce:

mkdir local remote
gocryptfs -init -plaintextnames -reverse local
touch local/abcd
gocryptfs -reverse -exclude abcd local remote

In this example, the file abcd should not appear in any directory listing - however, it still appears (but without being able to access it):

drwxr-xr-x 2 sebastian sebastian 4,0K Dez 17 14:48 .
drwxr-xr-x 7 sebastian sebastian 4,0K Dez 17 14:45 ..
-????????? ? ?         ?            ?            ? abcd
-r-------- 1 sebastian sebastian  366 Dez 17 14:45 gocryptfs.conf

The problem seems to be that exclude handling was never implemented in openDirPlaintextnames, which is used as shortcut when using plaintext names:

        [...]
	if rfs.args.PlaintextNames {
		return rfs.openDirPlaintextnames(cipherPath, entries)
	}
        [...]

And they are. The tests used ioutil.ReadDir, which tries to stat all files and filters out those it cannot.

Fixed the tests and fixed the bug, thanks