Jump to content

opendir cannot follow soft link


SonnyKo

Recommended Posts

I recently installed Fedora C5 ( 2.6.18-1.2239.fc5 ) with php (v 5.1.6), mysql and Apache. I am having a problem with this code segment:

    .....
    .....
    $dirval = "/var/www/html/softlink";  // softlink is a soft link to  another directory (hard)
    if ( !($handle = @opendir ($dirval))) {
        ......
        ......  this code always gets executed
        ......  owner and file permissions are not a problem. I have double and triple checked it
        ......
    }
    ...
    ...

In my previous installation - Fedora C5 ( 2.6.17-1.2174_FC5 ) with php (v 5.1.4), mysql and Apache
the exact same code passes through without any problems.  Just for info - the directory that softlink links to sits on another hard disk that has to be mounted. This is the same in both installations.

Is this a PHP bug?  Please help.

Link to comment
https://forums.phpfreaks.com/topic/29474-opendir-cannot-follow-soft-link/
Share on other sites

Try using php's [url=http://us3.php.net/manual/en/function.is-link.php]is_link()[/url] and [url=http://us3.php.net/manual/en/function.readlink.php]readlink()[/url] functions:

[code]
$dirval = "/var/www/html/softlink";
if (is_link($dirval))
{
  $dirval = readlink($dirval);
}
if ( !($handle = @opendir ($dirval))) {
}
[/code]
It didn't work.  :(

What did work was that I created a directory onto the same physical hard disk as the Apache files and moved the data to it. The link now points to this directory - no problems.  The link was previously pointed to data kept on a USB drive.  That still works in the previous installation.

I dont understand the difference.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.