8000 Artisan::call fails with error with enabled open_basedir · Issue #42171 · laravel/framework · GitHub
[go: up one dir, main page]

Skip to content

Artisan::call fails with error with enabled open_basedir #42171

@rw4lll

Description

@rw4lll
  • Laravel Version: 8.83.9
  • PHP Version: 7.4.29
  • Database Driver & Version: -

Description:

If open_basedir is enabled on the server and Artisan:call() command called from the web, not from the console (e.g. in the controller),
the whole script fails with php error: realpath(): open_basedir restriction in effect. File(/) is not within the allowed path(s)

open_basedir_issue_example

I've investigated the problem from my side. It comes with the update of symfony/console package from 5.3 to 5.4.
Related issue: symfony/symfony#44457

Place in the code: https://github.com/symfony/symfony/blob/d11e41be6cb2301 672D 6894c564d5c2b9ef3357ecaa7/src/Symfony/Component/Console/Command/DumpCompletionCommand.php#L44

Since 5.4 version it calls realpath($_['PHP_SELF']) inside. Everything works well if it's called from console.
But if make Artisan:call from web, then PHP_SELF returns "/". It works also ok until open_basedir is disabled.
But when the restrictions are enabled, it fails with the error, because "/" path is not allowed.

Steps To Reproduce:

  1. Prepare server with php 7.4.29 and latest laravel 8.
  2. Enable open_basedir on the server with some directory enabled (e.g. /var/www).
  3. Add following code to the controller:
    \Artisan:call('cache:clear');
  4. Open the page with the controller and see the result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0