On Fri, Feb 28, 2014 at 11:46 AM, Cliff Nieuwenhuis < c.nieuwenhuis@xxxxxxxxxxxxxx> wrote: > In short, PHP isn't recognizing a folder I have that is a mount point to a > CIFS share. > > > Environment / Background information: > > PHP 5.3.3 on Apache/2.2.15 (centOS) 2.6.32-431.5.1.el6.i686. > SElinux disabled; firewall off during testing. > > Website document root is "/var/www/html" Within this directory I have a > folder called "projects", which is a mount point to a CIFS share on a > Windows 2003 server. It is mounted via fstab entry: > > //WIN01/Projects /var/www/html/projects cifs > rw,domain=XXX,credentials=/etc/samba/auth.support,uid=48,gid=48 0 0 > > (my UID 48 = apache) > > So far this works as expected -- the projects folder is mounted by the > Windows user identified in the credentials file (I've verified this on > the Windows server) but appears to be owned by apache.apache. If I do > this: > > #su - apache -s/bin/bash > > ..I can browse to the /var/www/html/projects folder and its sub-folders > and add / edit files as expected. > > When mounted, the /var/www/html/projects contains many levels of > subfolders, > for example project_1, project_2, etc. > > In addition to the projects folder, the website has a number of other > "normal" > folders: test_1, test_2. > > Finally, the PHP configuration file has this setting defined: > php_admin_value open_basedir > "/var/www/html/:/var/www/html/projects/:/tmp/" > ..although I've also tried: > php_admin_value open_basedir none > > > > The Problem: > > The web application needs to read and create files in the projects folder, > but > PHP doesn't recognize the projects folder as folder! I suspect a > permissions problem of some sort, but I can't figure our where. I see > nothing > in the HTTPD error logs. Also, I did have this same code working on an > older server > [PHP 5.3.28 Apache/2.2.3 (CentOS) 2.6.18-371.4.1.el5 ]-- the > trouble started when I set the project up on the newer CentOS system. > > > Here's some test code that shows the problem: > > $dirs = glob("$pat", GLOB_ONLYDIR ); > if ( is_array($dirs) ) { > foreach ( $dirs as $dirname ) { > echo "Folder -> $dirname <br />\n"; > } > } > > Output: > Folder -> test_1 > Folder -> test_2 > > (note -- no folder 'projects'!) > > > Tried the following: > > echo "projects " . ( is_dir('projects') ? 'is' : 'is not' ) . " a > directory<br />\n"; > echo "projects " . ( is_file('projects') ? 'is' : 'is not' ) . " a file<br > />\n"; > > Output: > projects is not a directory > projects is not a file > > echo "test_1 " . ( is_dir('test_1') ? 'is' : 'is not' ) . " a directory<br > />\n"; > echo "test_1 " . ( is_file('test_') ? 'is' : 'is not' ) . " a file<br > />\n"; > > test_1 is a directory > test_1 is not a file > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > You guessed right. PHP usually runs under a user with less permissions (www, user, etc..). You are probably logged in as a user with permissions to access that mounted drive while PHP isn't. Both fixes are ugly, but what I would recommend is giving permission to those files as opposed to giving PHP user more power.