Hi all. Currently I'm webmaster of a site where there are only a few users other than myself.
We're about to enable PHP (finally) and I've written the following in an attempt to restrict the use of PHP to only my user account.
$f = $HTTP_SERVER_VARS["PATH_TRANSLATED"];
define("u","webmstr");
define("owner",implode("",array_slice(posix_getpwuid(fileowner($f)),0,1)));define("group",implode("",array_slice(posix_getgrgid(filegroup($f)),0,1)));owner != u || group != u ? die("illegally accessed. please go away.") : "";
I'm going to put this in a file outside of the webroot and then use that file as the value of auto_prepend_file in php.ini. Then whenever a php file is executed, it will check to see who it belongs to. If group and owner are both 'webmstr' it's okay, if not, the script will die.
Can anyone see any weakness in this, or have any other suggestions for achieving the same thing?
Thanks in advance,
Pablo