I get permissions 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 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.

Aha, this does it:

sudo -H -u www-data namei /my/long/symlink/chain

where www-data is the user I'm trying to debug

  • 2
    Strictly speaking that is the answer how to solve your particular problem, not how to debug permissions... (I'd have used strace for that to find the call that actually gives problems). – dirkt Jul 7 '17 at 6:36
  • Please post an example of how to use strace -- I have never used it – Jonathan Jul 8 '17 at 0:53
  • 1
    E.g. here, or google for lots more. – dirkt Jul 8 '17 at 6:51

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.