php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77474 open_basedir set to "." prevents me from running PHP
Submitted: 2019-01-16 19:29 UTC Modified: 2021-05-03 12:15 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: daniele dot testa at gmail dot com Assigned: cmb (profile)
Status: Duplicate Package: Safe Mode/open_basedir
PHP Version: 7.2.14 OS: Ubuntu 18.04
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: daniele dot testa at gmail dot com
New email:
PHP Version: OS:

 

 [2019-01-16 19:29 UTC] daniele dot testa at gmail dot com
Description:
------------
php.ini set to:
open_basedir = .

Nginx config:
    location / {
        root           /opt/www/test;
        fastcgi_pass   unix:/run/php/php7.2-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /opt/www/test/index.php;
        include        fastcgi_params;
    }

From documentation:
The special value . indicates that the working directory of the script will be used as the base-directory.

Trying to GET the PHP-file results in:
2019/01/16 19:06:39 [error] 3013#3013: *9 FastCGI sent in stderr: "PHP message: PHP Warning:  Unknown: open_basedir restriction in effect. File(/opt/www/test/index.php) is not within the allowed path(s): (.) in Unknown on line 0



Expected result:
----------------
I expect the file to be executed and result sent to client. According to documentation, setting open_basedir to "." should limit the current script to the current directory, but it does not even seem to allow the ACTUAL script to run at all.

If I turn off open_basedir and just print the getcwd(), I can clearly see that current dir is /opt/www/test and as the "." setting should allow access to "current dir", it should allow the execution of /opt/www/test/index.php, but it does not.

Actual result:
--------------
2019/01/16 19:06:39 [error] 3013#3013: *9 FastCGI sent in stderr: "PHP message: PHP Warning:  Unknown: open_basedir restriction in effect. File(/opt/www/test/index.php) is not within the allowed path(s): (.) in Unknown on line 0

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-01-16 19:38 UTC] daniele dot testa at gmail dot com
Ok, so it seems it is working if I specify "./" as value, but that is not what the documentation says I should use.
 [2021-05-03 12:15 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2021-05-03 12:15 UTC] cmb@php.net
Duplicate of bug #46925.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 22:01:28 2024 UTC