Open_basedir and fopen()

software development


One of my PHP scripts needs to create a few files under my “home” directory (/home/beaconte). The full path for one such file, for example, is /home/beaconte/BeAContender_v3/RLHTemp/LOCKFILE. However, I’m getting open_basedir warnings when trying to do so with a regular .php script:

2003-10-30 05:32:14 (/home/.mayelene/beaconte/UltraStats_v1/libs/php/UltraStats/UltraStatsManager.php:471) fopen("/home/beaconte/BeAContender_v3/RLHTemp/LOCKFILE", “w”) - Operation not permitted
2003-10-30 05:32:14 (/home/.mayelene/beaconte/UltraStats_v1/libs/php/UltraStats/UltraStatsManager.php:492) open_basedir restriction in effect. File is in wrong directory

That doesn’t make any sense since I have full permissions (777) on the RLHTemp dir, and it is under my home directory!!??

I tried symlinking a .pcgi file to the same .php script to get around this. However, then I have other issues, relating to the fact that I can’t seem to retrieve any of the environment variables through ($_SERVER or $_ENV) that I need to reference common library paths.

AARGH!! Does anyone have any idea how I can make this work?

–Brad Barkhouse
Be a Contender!


Just figured out a work-around.

It appears as though the path I’m using (/home/beaconte) really maps to some other magic DreamHost path (/home/.mayelene/beaonte or something like that). And the fopen call isn’t properly evaluating the directory properly. I basically wrapped all my paths with a call to realpath() and now it works fine as a .php script.

–Brad Barkhouse
Be a Contender!