php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68280 scuzzy@gmail.com
Submitted: 2014-10-21 23:00 UTC Modified: 2014-10-21 23:39 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: scuzzy at gmail dot com Assigned:
Status: Closed Package: PHAR related
PHP Version: 5.5.18 OS: Windows 7 Version 6.1.7601
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: scuzzy at gmail dot com
New email:
PHP Version: OS:

 

 [2014-10-21 23:00 UTC] scuzzy at gmail dot com
Description:
------------
I have two websites, both with their own sys_temp_dir and open_basedir settings.
I am then trying to load an amazon aws.phar file (each site has it's own copy of the archive)
When executed, the first website (PharA) will function and behave normally.
The second website when executed (PharB) will get open_basedir errors trying to access a temporary file outside of its path that was generated/cached by the first website (PharA)

I have this simple apache config to create two websites "PharA" and "PharB"

<VirtualHost *:80>
  DocumentRoot "C:/WebRoot/PharA/web"
  ServerName PharA
  <Directory "C:/WebRoot/PharA/web">
    php_admin_value open_basedir "C:/WebRoot/PharA/web;C:/WebRoot/PharA/tmp;"
    php_admin_value upload_tmp_dir "C:/WebRoot/PharA/tmp"
    php_admin_value sys_temp_dir "C:/WebRoot/PharA/tmp"
  </Directory>
</VirtualHost>

<VirtualHost *:80>
  DocumentRoot "C:/WebRoot/PharB/web"
  ServerName PharB
  <Directory "C:/WebRoot/PharB/web">
    php_admin_value open_basedir "C:/WebRoot/PharB/web;C:/WebRoot/PharB/tmp"
    php_admin_value upload_tmp_dir "C:/WebRoot/PharB/tmp"
    php_admin_value sys_temp_dir "C:/WebRoot/PharB/tmp"
  </Directory>
</VirtualHost>

I then had this as a hosts entry

    127.0.0.1 phara
    127.0.0.1 pharb

Test script:
---------------
<?php
// Phar downloaded from https://github.com/aws/aws-sdk-php/releases/tag/2.7.1
require('aws.phar');
use Aws\S3\S3Client;
use Aws\Common\Enum\Region;
$client = S3Client::factory(array(
  'key'    => '[KEY]',
  'secret' => '[SECRET]',
  'region' => Region::AP_SOUTHEAST_2
));

Actual result:
--------------
After browsing http://phara/ first followed by browsing to http://pharb/ afterwards, I see this error and incorrect temp path in http://pharb/

 Warning: file_exists(): open_basedir restriction in effect. File(C:/WebRoot/PharA/tmp/guzzle-cacert.pem) is not within the allowed path(s): (C:/WebRoot/PharB/web;C:/WebRoot/PharB/tmp) in phar://C:/WebRoot/PharB/web/aws.phar/Guzzle/Http/Client.php on line 511

Likewise if I restart apache, then browse http://pharb/ first the error will then occur under http://phara/ switching positions depending on which site was executed first (almost as if PHP keeps a index of paths for the phar file it processes)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-10-21 23:25 UTC] ragdata73 at gmail dot com
I've encountered the same problem with PHP 5.5.17, Apache 2.4.10, Amazon Linux AMI (Red Hat 3.10.34).  When multiple copies of the same .phar are hosted under different virtual hosts on the same server instance, it seems whichever virtual host is first to access the .phar sets the '/tmp' dir for all copies on that server.  Don't know about other directories - but the '/tmp' dir is the one causing issues for me.
 [2014-10-21 23:39 UTC] scuzzy at gmail dot com
-Summary: PHAR temp path being shared across virtualhosts with open_basedir +Summary: scuzzy@gmail.com -Status: Open +Status: Closed
 [2014-10-21 23:39 UTC] scuzzy at gmail dot com
I'm closing this myself as I no longer believe my problem is "PHAR" specific, but revolves around how Apache/PHP manage the sys_temp_dir configuration.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 05:01:29 2024 UTC