Sample Header Ad - 728x90

How to check if a user can access a given file?

109 votes
6 answers
215616 views
*nix user permissions are really simple, but things can get messy when you have to take in account all the parent directory access before reaching a given file. How can I check if the user has enough privileges? If not, then which directory is denying access? For example, suppose a user joe, and the file /long/path/to/file.txt. Even if file.txt was chmoded to 777, joe still has to be able to access /long/, and then /long/path/ and then /long/path/to/ before. What I need is a way to automatically check this. If joe does not have access, I would also like to know where he has been denied. Maybe he can access /long/, but not /long/path/.
Asked by Metalcoder (1235 rep)
Jul 9, 2013, 02:05 PM
Last activity: Jul 7, 2024, 03:20 AM