No Code Attached Yet
avatar Ars92
Ars92
23 Nov 2022

Steps to reproduce the issue

  1. Set PHP open_basedir restriction to JPATH_ROOT e.g. /var/www/html.
  2. Execute the CLI to update Joomla core: php cli/joomla.php core:update
  3. The command will fail on step "Extracting update package".

Expected result

A core update should be performed correctly.

Actual result

 6/8 -- Extracting update package ...
Warning: is_dir(): open_basedir restriction in effect. File(/var/www) is not within the allowed path(s): (/var/www/html:/tmp) in /var/www/html/libraries/src/Filesystem/Folder.php on line 484

Warning: is_dir(): open_basedir restriction in effect. File(/var) is not within the allowed path(s): (/var/www/html:/tmp) in /var/www/html/libraries/src/Filesystem/Folder.php on line 484

Warning: is_dir(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/var/www/html:/tmp) in /var/www/html/libraries/src/Filesystem/Folder.php on line 484

Warning: is_dir(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/var/www/html:/tmp) in /var/www/html/libraries/src/Filesystem/Folder.php on line 484

In Folder.php line 69:
                                    
  [RuntimeException (-1)]           
  Cannot create destination folder  
                                    

Exception trace:
  at /var/www/html/libraries/src/Filesystem/Folder.php:69
 Joomla\CMS\Filesystem\Folder::copy() at /var/www/html/libraries/src/Console/UpdateCoreCommand.php:385
 Joomla\CMS\Console\UpdateCoreCommand->copyFileTo() at /var/www/html/libraries/src/Console/UpdateCoreCommand.php:331
 Joomla\CMS\Console\UpdateCoreCommand->processUpdatePackage() at /var/www/html/libraries/src/Console/UpdateCoreCommand.php:216
 Joomla\CMS\Console\UpdateCoreCommand->updateJoomlaCore() at /var/www/html/libraries/src/Console/UpdateCoreCommand.php:168
 Joomla\CMS\Console\UpdateCoreCommand->doExecute() at /var/www/html/libraries/vendor/joomla/console/src/Command/AbstractCommand.php:235
 Joomla\Console\Command\AbstractCommand->execute() at /var/www/html/libraries/vendor/joomla/console/src/Application.php:1181
 Joomla\Console\Application->runCommand() at /var/www/html/libraries/vendor/joomla/console/src/Application.php:403
 Joomla\Console\Application->doExecute() at /var/www/html/libraries/src/Application/ConsoleApplication.php:191
 Joomla\CMS\Application\ConsoleApplication->doExecute() at /var/www/html/libraries/vendor/joomla/console/src/Application.php:448
 Joomla\Console\Application->execute() at /var/www/html/libraries/src/Application/ConsoleApplication.php:234
 Joomla\CMS\Application\ConsoleApplication->execute() at /var/www/html/cli/joomla.php:78

System information (as much as possible)

I tested with a couple of docker images:

  • joomla:4.2.3-php8.1-apache (joomla@sha256:ee81a0b756cab9d32f554f0053c181b3d478911ae366e9397b6aec0ccaac8c34)
  • joomla:4.1.3-php8.1-apache (joomla@sha256:a4ff5e24a1bcef799a545bd061bed5f7a295dea3e004e2d6721a1fa2910f3d32)

On both images I mounted a custom php.ini file into /usr/local/etc/php/conf.d/custom-php.ini containing only the open_basedir setting:

open_basedir = /var/www/html:/tmp

Additional comments

This issue is due to \Joomla\CMS\Filesystem\Folder::create that checks if the parent folder of the one we want to create exists or not but, since it cannot access it, it runs into an endless loop.
Note that after checking if the parent folder exist the function checks if the folder we want to create exist and, if that is the case, it returns true.
I think this issue can be solved by simply checking if the folder we want to create exists before checking for parent folders: I'm going to open a PR for that.

avatar Ars92 Ars92 - open - 23 Nov 2022
avatar joomla-cms-bot joomla-cms-bot - change - 23 Nov 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 23 Nov 2022
avatar richard67 richard67 - close - 23 Nov 2022
avatar richard67
richard67 - comment - 23 Nov 2022

Closing as having a pull request.

avatar richard67 richard67 - change - 23 Nov 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-11-23 19:48:43
Closed_By richard67

Add a Comment

Login with GitHub to post a comment