0

I get false whenever I use the function is_readable on a file shared by my host on a VM, the expected result is true.

I am doing the setup of a local development environment for an existing projet. I don't want to use another function because it's a complex legacy system and I am afraid I would hide other potential problems I would stumble upon later in development.

The VM is set up using vagrant and virtualbox. The OS is a Windows Server 2008 machine with Zend Server with PHP 5.3 hosting code shared on the host, which is a Mac.

The shared folder is created as follow:

vmConfig.vm.synced_folder "/path/to/shared/folder/cms", '/cms', mount_options: ["dmode=775,fmode=664,type=smb"], owner: 'wcmadmin', group: 'wcmadmin'

A piece of code is trying to see if a file is readable. is_readable returns false. I run the script via command line with both users wcmadmin and Administrator and I get the same results.

function smarty_core_assemble_plugin_filepath($params, &$smarty)
{
    [...]
    // try relative to cwd (or absolute)
    if (is_readable($_plugin_filepath)) {
        $_return = $_plugin_filepath;
        break;
    }
    [...]

I did a test script to dig further:

echo 'is_readable: ';
var_export(is_readable('C:\cms\path\to\file\file.php'));
echo "\n";
echo 'require_once: ';
var_export(require_once('C:\cms\path\to\file\file.php'));

And I have the following results:

is_readable: false
require_once: true

Using file_get_contents on the file returns the content correctly.

Using cygwin, the permissions on the file are as follow:

$ ls -al C:\cms\path\to\file\file.php
-rw-r--r-- 1 wcmadmin None 1498 Apr 18 07:22 C:\cms\path\to\file\file.php

Files path have been changed for the purpose of this question. While they may have some discrepancies, they resolve correctly during real tests.

Stef
  • 523
  • 2
  • 7
  • 13
  • do `file_exists()` return true ? – Frederic Henri Apr 20 '16 at 15:36
  • did not notice at first you were using samba shared folder type, you might want to read http://stackoverflow.com/questions/10818770/php-is-readable-fails-on-readable-samba-directory - check with default sharing folder type if you still have issue – Frederic Henri Apr 20 '16 at 15:40
  • I don't understand why you're using two different file paths here. `C:\gesca\cms\backend....` appears to be entirely different than `C:\cms\path\to\file.php`, so it's not terribly surprising if one is readable and the other is not. – David White Apr 20 '16 at 15:40
  • @DavidWhite my bad, I fixed the path in the example. – Stef Apr 20 '16 at 17:20
  • @FrédéricHenri found this: https://www.virtualbox.org/ticket/11675 – Stef Apr 20 '16 at 17:21
  • Stef, I still don't understand. You're now running is_readable() on a URL, but running file_get_contents() on a local file? Why aren't you running is_readable() on `C:\cms\path\to\file\file.php` ? – David White Apr 20 '16 at 17:25
  • My bad again! Wrong copy and paste. But the matter is closed really, it's a bug in virtualbox. I will have to find a work around. – Stef Apr 20 '16 at 18:42

1 Answers1

0

It's a bug in virtual box and is still happening as of version 5.0.18.

See: https://www.virtualbox.org/ticket/11675

Stef
  • 523
  • 2
  • 7
  • 13