Difference between EACCES and EPERM
EACCES
is almost always used when the system call was passed a path that was inaccessible by the current user.
EPERM
is used in various other situations where you need to be root to perform an action, e.g.
kill()
on a process that you don't ownlink()
on a directoryreboot()
The Linux capabilities(7)
figure into execve(2)
so that if the exec'ing process lacks the correct inheritance/bounding-set/ambient to set the file-capabilities:
"If the process did not obtain the full set of file permitted capabilities, then execve(2) fails with the error EPERM."