php - sys_get_temp_dir in shared hosting environment -


Note: this may also fit in the superuser.

I'm setting up to adopt PHP 5.3.10 on a shared host with Apes 2 MPM IKK and Open_Baseer, that each user can not see or change other user's files is. In apache2 vhost settings, I add the appropriate entries to restrict the user:

  AssignUserId USERA USERA php_admin_value open_basedir / home / USERA / www / php_admin_value upload_tmp_dir / home / USERA / www / tmp / php_admin_value session.save_path / home / USERA / www / tmp / setenv TMPDIR / home / USERA / www / tmp /   

now, Linux users set to use the first row apache2, next Define three lines, upload the directory and place the session passphrase in the user directory. I'll be back to the last line in a second.

Now for the problem: sys_get_temp_dir () for security reasons on a Linux system should give back to the temporary directory for PHP, which is / TMP default, this directory userA Should remain in open_basedir According to the php-source of 5.3.10, the sys_get_temp_dir () function uses the TMPDIR environment variable variable to get this directory:

  // php-src / Main / php_open_temporary_file.c: 217-219 / * Use TMPDIR environment variable on UNIX * / {char * s = getenv ("TMPDIR");   

What should the fifth line in the structure above should do. However, the sys_get_temp_dir () just global system directory (via viewable which was set entirely in $ _SERVER, also phpinfo () ), Environmental variables overlooked.

The sys_get_temp_dir the result of wrong bugs with various software-dependent (), because the directory open_basedir Settings. I tried to set the variable in straight $ _ENV and $ _SERVER without changing the behavior I have tried a putenv ('TMPDIR = / home / usera / www / tmp') without changes However, I am able to change the output by defining the variable in / etc / apache2 / envvars - which is useless for me because I want every VHOST to have its own temporary folder.

The only solution I have found so far is applying internal sys_get_temp_dir () through an extension and through its integration. But this solution is so dirty, I just can not believe that there is no better solution around it.

Then, my question: is a way to change the result of sys_get_temp_dir

Edit: Epa version 2.2 .22, which can be installed in app ache 2, and I am currently using mod_php as if I have to manually add all the users, an FCG or similar setup would also be possible. Running a putenv ('TMPDIR = / foo / bar')

inside php sys_get_temp_dir () is able to affect the result. You auto_prepend_file command TMPDIR to install could be a arranged to run a piece of PHP and sys_get_temp_dir () to a new definition Avoid messing with.

Edit: Additionally, you can easily use putenv ('TMPDIR =' .ini_get ('open_basedir'). '/ Tmp') to set

Strange, it also turns to work (Given that you keep SetEnv TMPDIR / foo / bar Apache configuration):

  putenv ('TMPDIR ='. Getenv ('tmpdir'));   

looks like a no-op, but in reality it does has an effect on sys_get_temp_dir () . I am starting to suspect that it should have some environmental-management bug in PHP.

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -