Re: Still having lstat trouble
| From: | Rasmus Lerdorf | Date: | Wed, 23 May 2007 21:54:02 +0000 |
| Subject: | Re: Still having lstat trouble | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-29702@lists.php.net to get a copy of this message | ||
So, would this be Ubuntu 7.04? I happen to have one of those boxes
sitting here:
5:52pm ubuntu:~> mkdir /tmp/pear
5:52pm ubuntu:~> cat /etc/issue
Ubuntu 7.04 \n \l
5:52pm ubuntu:~> uname -a
Linux ubuntu 2.6.20-15-server #2 SMP Sun Apr 15 07:41:34 UTC 2007 i686
GNU/Linux
5:52pm ubuntu:~> php p
link
link
differ
5:52pm ubuntu:~> l /tmp | grep link
lrwxrwxrwx 1 rasmus rasmus 9 2007-05-23 17:52 link-test -> /tmp/pear/
The 'p' script is just a copy of paste of your script from this message.
-Rasmus
Arnold Daniels wrote:
> Hi,
>
> I've posted this problem some time ago, but never got a real answer and
> it is still bothering me a lot.
>
> My problem is that PHP does not recognize a symlink as a symlink. It
> seems to be dereferenced by functions like 'lstat', 'is_link' and
> 'filetype'. And that isn't supposed to happen.
>
> The bug http://bugs.php.net/bug.php?id=17128 describes my
> problem
> exactly, but is marked as bogus. Well this problem sure isn't bogus for
> me. I'm having this problem, since I've updated from Ubuntu Edgy to
> Feisty. Before that all worked fine.
> Please note that I've not installed PHP from a repository, but I build
> the latest CVS version of PHP 5 regularly myself. Also this problem only
> occurs in the Apache 2 SAPI, not in the CLI version.
>
> Let me give an example, to make the problem clear.
>
> ------------
> <?
> $symlink = '/tmp/link-test';
> $target = '/tmp/pear';
>
> if (!file_exists($target)) trigger_error("Target '$target' does not
> exist", E_USER_ERROR);
> if (file_exists($symlink) && !unlink($symlink)) trigger_error("Could
> not delete '$symlink'", E_USER_ERROR);
>
> symlink($target, $symlink);
> clearstatcache();
>
> /* This should output 'link' */
> echo filetype($symlink), "\n";
>
> /* This should output 'link' */
> echo is_link($symlink) ? 'link' : 'not a link', "\n";
>
> /* This should output 'differ' */
> echo lstat($symlink) === stat($target) ? 'same' : 'differ';
> ?>
>
> Expected:
> link
> link
> differ
>
> Actual:
> dir
> not a link
> same
>
> ------------
>
> I understand that if I post this as a bug, it is tested, can't be
> reproduced and marked as bogus. Therefore, I could appreciate it if
> someone could please point me towards a way to pinpoint the problem.
> I've run a strace already, but can't notice anything weird.
>
> Thanks for any help,
>
> Arnold
>