views:

50

answers:

1

Out of curiosity. I've been thinking about the different access models often seen in *nix and the one seen in windows nt based systems.

Is there any command or api to check if a file is readable, executable etc for a user different than the logged in user. For instance something like: http://www.php.net/manual/en/function.is-executable.php or http://stackoverflow.com/questions/1861836/checking-file-permissions-in-linux-with-python But for any user that the executing user has permission to see.

Is there any reason why such a function should not be found?

A: 

In *nix whether a user's permissions on a file can be determined by 2 attributes: the world and group permissions on a file. If the world permissions are set for r,w, or x than of course any user will have those rights on that file. Similarly if the user is a member of the group that is specified as the group owner of the file, and those permissions are set on the group level then again the user will have that right on the file. Of course you need to be sure the user the appropriate rights on all directories in the absolute path of the file. And, of course, root can access any file regardless of the permissions or ownerships.

So for any particular file it is relatively easy to determine whether a specific user has permissions on that file by looking at the file permissions and the group memberships of the user.

ennuikiller