views:

151

answers:

1

I have a PHP script on Linux in which the sticky bit is set, so it gets executed as the file owner. How can I get the user id of the calling process, for authorization purposes?

Context: I have two applications on a server, and want one to request some info from the other. For this reason the other offers a script with setuid, but I want to make sure it can only be called by the one.

A: 

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

From this you can peek into /proc/PROCESSID/ to find hopefully what you seek.

I'm not on a linux machine to test it out but this looks to be possible.

zaf