2

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.

Bart van Heukelom
  • 43,244
  • 59
  • 186
  • 301

1 Answers1

1

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
  • 22,776
  • 12
  • 65
  • 95