safe_mode, sym-links and stat

From: Date: Mon, 06 Sep 2004 07:35:39 +0000
Subject: safe_mode, sym-links and stat
Groups: php.general 
Request: Send a blank email to php-general+get-195962@lists.php.net to get a copy of this message
Hi I'm running PHP in safe mode, and have symlinked executables to the execution_dir, that works great. With one exception, it is not possible to check the existence of the files, before executing them. It seems to me that stat / lstat resolves the ownership of the orig executables and safe_mode decides that I cannot have access, which is true, but I only want to know if the files that I'm about to execute, ie. the symlinks, exists. Is this a bug, or have I misunderstood something. Any suggestions on how I can solve this. Example: <?php $smed = ini_get('safe_mode_exec_dir'); $id = $smed.'identify'; var_dump(stat($id)); var_dump(lstat($id)); echo '<br />is_file: '; var_dump(is_file($id)); echo '<br />is_link: '; var_dump(is_link($id)); echo '<br />is_executable: '; var_dump(is_executable($id)); echo '<br />is_readable: '; var_dump(is_readable($id)); echo '<br /><br /><br />'; passthru($id.' -version'); ?> Result: Warning: stat() [function.stat]: SAFE MODE Restriction in effect. The script whose uid/gid is 33/33 is not allowed to access /var/lib/typo3/shared/smexec/identify owned by uid/gid 0/0 in /var/www/file_existence_check.php on line 6 Warning: stat() [function.stat]: stat failed for /var/lib/typo3/shared/smexec/identify in /var/www/file_existence_check.php on line 6 bool(false) Warning: lstat() [function.lstat]: SAFE MODE Restriction in effect. The script whose uid/gid is 33/33 is not allowed to access /var/lib/typo3/shared/smexec/identify owned by uid/gid 0/0 in /var/www/file_existence_check.php on line 7 Warning: lstat() [function.lstat]: Lstat failed for /var/lib/typo3/shared/smexec/identify in /var/www/file_existence_check.php on line 7 bool(false) is_file: bool(false) is_link: bool(false) is_executable: bool(false) is_readable: bool(false) Version: ImageMagick 6.0.6 08/31/04 Q16 http://www.imagemagick.org Copyright: Copyright (C) 1999-2004 ImageMagick Studio LLC -- ./Christian Jul Jensen

« previous php.general (#195962) next »