Re: Problem with PHP and mounted folder

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Feb 28, 2014 at 3:50 PM, Aziz Saleh <azizsaleh@xxxxxxxxx> wrote:

>
>
>
> On Fri, Feb 28, 2014 at 3:43 PM, Cliff Nieuwenhuis <
> c.nieuwenhuis@xxxxxxxxxxxxxx> wrote:
>
>> From: Aziz Saleh [mailto:azizsaleh@xxxxxxxxx]
>> Sent: Friday, February 28, 2014 1:41 PM
>> To: Cliff Nieuwenhuis
>> Cc: php-general@xxxxxxxxxxxxx
>> Subject: Re:  Problem with PHP and mounted folder
>>
>> r
>>
>> On Fri, Feb 28, 2014 at 1:00 PM, Cliff Nieuwenhuis <
>> c.nieuwenhuis@xxxxxxxxxxxxxx> wrote:
>>
>> Cliff Nieuwenhuis wrote:
>> [snip]
>>
>> > 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 out where.
>>
>> [snip]
>>
>> Aziz Saleh wrote:
>>
>> > 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.
>>
>> Thanks for the reply.
>>
>> I thought that PHP runs under HTTPD as user 'apache'.  I know that the
>> Apache webserver runs as user 'apache' on my system -- does PHP run as a
>> different user?  Assuming that it does not, wouldn't my successful test of
>> traversing, reading, and writing files under the 'projects' folder by doing
>> 'su - apache -s/bin/bash' mean that the permissions are OK?  I guess not,
>> but I can't see why not.
>>
>> --
>> Cliff Nieuwenhuis
>>
>> You are correct, when I said PHP I meant through the server. Try using
>> runuser command instead. If you have exec enabled, try running an ls
>> command as a user with higher permissions and see if that works.
>>
>>
>> OK -- tried with runuser.  I can see all the projects in the projects
>> folder, and I can edit files that I should be able to edit (those files
>> that can be edited by the Windows user account given in the credentials
>> file that is used by mount.cifs).  But I can't descend into the projects
>> folder via PHP.
>>
>> If I browse to http://myserver/projects I see Apache's listing of all
>> the subfolders and files.  If I click on a test text (test.txt) file in
>> that list, I see the text file contents in the browser.
>>
>> If I write php code like this:
>>
>> $contents = file_get_contents('projects/test.txt');
>> echo "Contents: $contents";
>>
>> ..it works; the contents are displayed.  BUT is_file('projects/test.txt')
>> will return FALSE.
>>
>>
>>
> Does file_exists work? is_file will return false if the user doesn't have
> permission on the parent directory.
>

Another option which is a bit faster than file_exists:
stream_resolve_inlcude_path() !== false.

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux