Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP is_readable() fails on readable samba directory

Tags:

php

samba

cifs

Calls to PHP's is_readable() function are returning false on a directory that is readable from the command prompt. I have changed permissions to most-permissible and still no luck.

ls -lad /remote/samba_share
drwxrwxr-x 13 me users 0 May 29 15:49 /remote/samba_share

ls -la /remote/samba_share
drwxr-xr-x  4 me users 0 May  8 14:19 /remote/samba_share/local_dir
drwxr-xr-x 16 me users 0 May 14 19:49 /remote/samba_share/second_drive
drwxrwxrwx 12 me users 0 May 30 09:42 /remote/samba_share/ext_raid

Running the following code...

if (is_readable('/remote/samba_share'              )){ echo "share ok\n";  } else { echo "share BAD\n";  }
if (is_readable('/remote/samba_share/local_dir'    )){ echo "local ok\n";  } else { echo "local BAD\n";  }
if (is_readable('/remote/samba_share/second_drive' )){ echo "second ok\n"; } else { echo "second BAD\n"; }
if (is_readable('/remote/samba_share/ext_raid'     )){ echo "raid ok\n";   } else { echo "raid BAD\n";   }

...results in...

share ok
local ok
second BAD
raid BAD

Any directory under the samba share that is not on the physical primary partition seems to fail.

Config details of machine where is_readable() is called:

php -v
PHP 5.3.11-pl0-gentoo (cli) (built: May  5 2012 16:48:35)

php.ini:
    safe_mode = Off
    safe_mode_gid = On # (tried either way, shouldn't matter)
    ;open_basedir =

/etc/fstab entry:
    //remote_machine/samba_share /remote/samba_share cifs iocharset=utf8,credentials=/blahblah/samba_credentials,uid=me,gid=users,file_mode=0777,dir_mode=0777,auto   0 0

eix samba
[I] net-fs/samba
     Installed versions:  3.5.15!t

Config details of remote machine:

eix samba
[I] net-fs/samba
     Installed versions:  3.5.15!t

/etc/samba/smb.conf:

    [samba_share]
       path = /samba_share/
       public = yes
       writable = yes
    ;  printable = yes
       browseable = yes
       create mask = 0777
       create mode = 0777
       directory mode = 0777

I have tried everything I can think of to get this working, and now I feel dumb. :-) I can provide kernel config too if that seems relevant to anyone. THANKS for any help!

like image 626
moodboom Avatar asked Nov 04 '22 23:11

moodboom


1 Answers

is_readable() just wraps the access system call to determine the file permission, so it´s very likely not a php issue.

According to the samba configuration and file permissions a very likely reason could be SELINUX. PHP is probably running as different user (no matter if CLI wether apache mod), so it could be that selinux denies access for this user.

So check if selinux is enabled and disabled it or configure it appropriate.

like image 90
Sebastian Keßler Avatar answered Nov 15 '22 05:11

Sebastian Keßler