Question

I have a PHP process that:

  • starts as root
  • writes to and then closes a pid file in /var/run/
  • chown()s said pid file to another user
  • changes to that user via posix_setuid()
  • tries to delete pid file at end of process

Now, even though I am chown()ing the pid file to the current user, it is unable to delete the file claiming "Permission denied" on the unlink() call. That means that even though the effective user owns the file, and the file is NOT open in the current (or any) process, there is still insufficient permission.

On a hunch, I tried moving the pid file location to my home directory, and this works without a problem. Note that the user of the process is not MY personal user, so the effective user has no write permissions on my home directory, just the one specific file.

So, why can't I delete the pid file when it's in /var/run/?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top