I'm trying to set up a directory where a user can traverse a directory but not prove the existence of anything in the directory. I have tried setting permissions such that the user has execute but not read permissions. Unfortunately the error returned (either "No such file or directory" or "Permission denied") will confirm whether a given item exists in the directory.

For example, here is what I currently see:

$ sudo ls -l permTest/
total 4
drwxr-x--- 2 root root 4096 Aug 10 12:35 exists
$ ls -ld permTest
drwxr-x--x 3 root root 4096 Aug 10 12:35 permTest/
$ ls permTest
ls: cannot open directory 'permTest': Permission denied
$ ls permTest/doesnotexist
ls: cannot access 'permTest/doesnotexist': No such file or directory
$ ls permTest/exists
ls: cannot open directory 'permTest/exists': Permission denied

I would like the error messages in the final line to be identical.

I'm trying to set this up on MapRFS if that's relevant. It is broadly POSIX compliant.

I have read the answers at How does one create a directory that can't be seen and can only be accessed via its absolute path name?, but did not find a solution to my problem.


It is not possible to hide the existence of a file if the user could list it:

$ ls -l permTest/insidedir/doesexist
-rw-r--r-- 1 root root 0 Aug 10 01:55 permTest/insidedir/doesexist

even if both directories (permTest and insidedir) are own by root and have only x permissions:

$ sudo ls -la permTest/insidedir/
total 8
d--x--x--x 2 root root 4096 Aug 10 01:55 .
d--x--x--x 3 root root 4096 Aug 10 01:54 ..
-rw-r--r-- 1 root root    0 Aug 10 01:55 doesexist

$ ls -la permTest/
ls: cannot open directory permTest/: Permission denied

$ ls -la permTest/insidedir/
ls: cannot open directory permTest/insidedir/: Permission denied
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.