Get user id in PHP setuid script

I have a PHP script on Linux that has the sticky bit set so it runs as the owner of the file. How can I get the user id of the calling process for authorization purposes?

Context: I have two applications on a server and you want someone to request information from the other. For this reason, another suggests a script with setuid, but I want to make sure it can only be called by that.

+2


a source to share


1 answer


You can use one of the posix functions to get the parent process, for example: http://www.php.net/manual/en/function.posix-getppid.php

From this, you can look into / proc / PROCESSID / to hopefully what you are looking for.



I'm not on a Linux machine to test this, but it seems possible.

+1


a source







All Articles