Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open_basedir php warning restriction with shared hostings due to "closest" method #380

Open
SergiArias opened this issue Jun 8, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@SergiArias
Copy link
Contributor

Version

4.2.2

What did you expect to happen?

No php warning in shared hosting

What actually happens?

Warning: is_readable(): open_basedir restriction in effect.
File(/home) is not within the allowed path(s)

Origin: https://discourse.roots.io/t/open-basedir-restriction-in-effect-tried-everything/27183/10

The problem is the closest method in /vendor/roots/acorn/src/Roots/Acorn/Filesystem/Filesystem.php

It can be patched in line 32 (this is just a patch, it won't work for specific restrictions in every shared hosting):

        // -- while ($this->isReadable($currentDirectory)) {
        while ($currentDirectory !== '/home' && $this->isReadable($currentDirectory)) {

Steps to reproduce

Upload roots sage to any shared hosting with open_basedir restriction

System info

No response

Log output

No response

Please confirm this isn't a support request.

Yes

@SergiArias SergiArias added the bug Something isn't working label Jun 8, 2024
@Log1x
Copy link
Sponsor Member

Log1x commented Jun 8, 2024

Do you have logs from web/app/cache/acorn/logs that might better pinpoint where this issue is specifically happening?

@SergiArias
Copy link
Contributor Author

Of course, here you have. But the problem arises in closest() method in /vendor/roots/acorn/src/Roots/Acorn/Filesystem/Filesystem.php line 32 because it goes folder by folder searching for an env file until it reaches /home.

In my case I am not using bedrock.

[2024-06-07 21:17:03] development.ERROR: is_readable(): open_basedir restriction in effect. File(/home) is not within the allowed path(s): (/home/aestivum:/home2/aestivum:/usr/local/wepanel/filemanager:/usr/lib/php:/usr/local/lib/php:/tmp:/usr/local/bin/wp:/usr/local/bin/composer:/opt/alt/php82) {"userId":1,"exception":"[object] (ErrorException(code: 0): is_readable(): open_basedir restriction in effect. File(/home) is not within the allowed path(s): (/home/aestivum:/home2/aestivum:/usr/local/wepanel/filemanager:/usr/lib/php:/usr/local/lib/php:/tmp:/usr/local/bin/wp:/usr/local/bin/composer:/opt/alt/php82) at /home/aestivum/public_html/domain/wp-content/themes/sage-theme/vendor/illuminate/filesystem/Filesystem.php:523)
[stacktrace]
#0 /home/aestivum/public_html/domain/wp-content/themes/sage-theme/vendor/roots/acorn/src/Roots/Acorn/Bootstrap/HandleExceptions.php(49): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError()
#1 [internal function]: Roots\\Acorn\\Bootstrap\\HandleExceptions->handleError()
#2 /home/aestivum/public_html/domain/wp-content/themes/sage-theme/vendor/illuminate/filesystem/Filesystem.php(523): is_readable()
#3 /home/aestivum/public_html/domain/wp-content/themes/sage-theme/vendor/roots/acorn/src/Roots/Acorn/Filesystem/Filesystem.php(32): Illuminate\\Filesystem\\Filesystem->isReadable()
#4 /home/aestivum/public_html/domain/wp-content/themes/sage-theme/vendor/roots/acorn/src/Roots/Acorn/Bootloader.php(382): Roots\\Acorn\\Filesystem\\Filesystem->closest()
#5 /home/aestivum/public_html/domain/wp-content/themes/sage-theme/vendor/roots/acorn/src/Roots/Acorn/Bootloader.php(326): Roots\\Acorn\\Bootloader->environmentPath()
#6 /home/aestivum/public_html/domain/wp-content/themes/sage-theme/vendor/roots/acorn/src/Roots/helpers.php(46): Roots\\Acorn\\Bootloader->getApplication()
#7 /home/aestivum/public_html/domain/wp-includes/class-wp-hook.php(324): Roots\\{closure}()
#8 /home/aestivum/public_html/domain/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#9 /home/aestivum/public_html/domain/wp-includes/plugin.php(517): WP_Hook->do_action()
#10 /home/aestivum/public_html/domain/wp-settings.php(673): do_action()
#11 /home/aestivum/public_html/domain/wp-config.php(98): require_once('/home/aestivum/...')
#12 /home/aestivum/public_html/domain/wp-load.php(50): require_once('/home/aestivum/...')
#13 /home/aestivum/public_html/domain/wp-admin/admin-ajax.php(22): require_once('/home/aestivum/...')
#14 {main}
"} 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants