I get permission errors when I have a process running as root, spawning a subprocess as www-data, which then accesses a dir which is owned by root, with a subfolder which is owned by www-data, which has a symlink to a dir which is owned by a user in the group www-data, which then has.... you get the idea.
How the heck do I know where it fails in this impossibly complex chain? All I get is Permission Denied
Without getting bogged down in the details of this particular situation, how does one begin to debug a problem like this on Unix?
I want to just say
debug_permissions.sh www-data /my/long/symlink/chain
and I want it to go through the symlink chain and tell me where the terminal point is (where www-data fails to have permissions).
I know there is a tool
namei -l /path/
but that isn't very helpful because it doesn't let me run as another user (or at least I don't know how).
If I run sudo su www-data
, I get This account is currently not available.
I want to be able to "become" www-data and cd
around to the dirs and see where I fail to see things. But that's not letting me do this and I don't want to create a new user just to do this.