how to debug "Permission denied" errors in Linux (lstat() = -1 EACCES)
Asked Answered
T

0

6

Is there a way to debug why I get

lstat("/path/to/file", 0x...) = -1 EACCES (permission denied)

error when accessing a file/directory? whether it is because of selinux issues or because of user/group permission or NFS or any ACLs that might be coming into play?

I was having the correct permissions set on a directory for a user and I was able to create a file in that directory after logging in as the user. However when PHP is running under the Apache scope with the same user and group, it fails to create the file.

I understand Apache is using suid to change from "root" to the required user but still when PHP executes under Apache, the file is not created. Also, PHP prints out correct and expected real and effective user IDs (instead of root).

For those interested, the /path/to/file is on an NFSv4 mount, but I would like to investigate, due to what reasons, the permission is being denied.

Would it be possible to know!?

Teena answered 3/7, 2013 at 12:5 Comment(1)
It turned out to be selinux related. Unfortunately and strangely, the avc "denied" errors for this issue are not thrown in audit.log. However, the question still remains open as to how to debug the permissioning issues to find out the root cause for permission denied.Teena

© 2022 - 2024 — McMap. All rights reserved.