Cant write across filesystem mounts?

Hi I dont think this is specific to nginx but I hope its a good
place to ask!

When running PHP script through Nginx it writes OK to files
on the same disk mount where the PHP file is located but
not to the other parts of the system that are on another mount.
(well i dont know if its a matter of “same mount” or not, but
that is how it is behaving)

Example, /tmp is on another mount than the web root.

<?php ini_set('display_errors', 'On'); file_put_contents('/tmp/test', 'hello world'); system('touch /tmp/test-touch'); file_put_contents('/webroot/tmp/test', 'hello world'); system('touch /webroot/tmp/test-touch'); ?>hello world

I run this script from CLI (sudo as ANY user including the php
user) and it always works fine (writes files in both places). If I
access it from a browser the write/touch commands to /tmp
fail silently.

No AVC from selinux, no PHP or Nginx errors or warnings.
/tmp permissions are usual 777. Can someone help me in
right direction?

Hello!

On Sat, May 30, 2015 at 02:20:05PM -0700, E.B. wrote:

access it from a browser the write/touch commands to /tmp
fail silently.

No AVC from selinux, no PHP or Nginx errors or warnings.
/tmp permissions are usual 777. Can someone help me in
right direction?

In this particular case I would recommend to look into PHP
configuration, open_basedir directive in particular:

http://php.net/manual/en/ini.core.php#ini.open-basedir

Either way this doesn’t looks like an nginx-related problem, you
may have better luck asking in more relevant lists.


Maxim D.
http://nginx.org/

Thank you very much for yours response!

file_put_contents(’/tmp/test’, ‘hello world’);
No AVC from selinux, no PHP or Nginx errors or warnings.
/tmp permissions are usual 777. Can someone help me in
right direction?

In this particular case I would recommend to look into PHP
configuration, open_basedir directive in particular:

http://php.net/manual/en/ini.core.php#ini.open-basedir

Nothing is set for that. Also note the “restriction” doesnt happen
when running the example script from the CLI. Issue may be
peculiar to the O/S but I no idea how or where to start looking
in this regard.

Other ideas anyone?

file_put_contents(’/tmp/test’, ‘hello world’);
No AVC from selinux, no PHP or Nginx errors or warnings.
/tmp permissions are usual 777. Can someone help me in
right direction?

The problem was the use of PrivateTmp in systemd for php-fpm.

Writes to /tmp (and apparently /var/tmp) go to nowhereland per
systemd (somewhere I don’t know about???)

But if I create a directory writable by php-fpm with another name,
it works.

Thanks for the comments.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs