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

CacheClearCommand: open_basedir restriction warning #54402

Closed
kopfsalat opened this issue Mar 26, 2024 · 1 comment
Closed

CacheClearCommand: open_basedir restriction warning #54402

kopfsalat opened this issue Mar 26, 2024 · 1 comment

Comments

@kopfsalat
Copy link

Symfony version(s) affected

6.4.5

Description

Hi,
we're runnning our Symfony project in a php environment with open_basedir restrictions. Since upgrading to 6.4.5 the behavior of the cache:clear command changed. We now get a "Warning: is_readable(): open_basedir restriction in effect. File(/proc/mounts) is not within the allowed path(s): ..." warning. It gets triggered by the isNfs(string $dir) method in Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand.

I was able to narrow it down to this commit:
[FrameworkBundle] Prevent silenced warning by checking if /proc/mount… (349b3e7)

How to reproduce

To reproduce run symfony in an php environment with config
open_basedir = /var/www/
or likely and run the cache:clear command.

Possible Solution

Since is_readable() produces meaningful output even when restricted by open_basedir config, changing the if statement from

if ('/' === \DIRECTORY_SEPARATOR && is_readable('/proc/mounts') && $files = @file('/proc/mounts'))
to
if ('/' === \DIRECTORY_SEPARATOR && @is_readable('/proc/mounts') && $files = @file('/proc/mounts'))

would suppress the error without having any negative side effects.

Additional Context

No response

@derrabus
Copy link
Member

I was able to narrow it down to this commit: 349b3e7

For reference, that's #53785 by @shyim.

Please send a PR.

kopfsalat pushed a commit to kopfsalat/symfony that referenced this issue Mar 26, 2024
…eadable() tries to access dirs outside of open_basedir restrictions
xabbuh pushed a commit to kopfsalat/symfony that referenced this issue Apr 3, 2024
…eadable() tries to access dirs outside of open_basedir restrictions
xabbuh added a commit that referenced this issue Apr 3, 2024
…ng when is_readable() tries to access dirs outside of open_basedir restrictions (Jeldrik Geraedts)

This PR was submitted for the 6.4 branch but it was merged into the 5.4 branch instead.

Discussion
----------

[FrameworkBundle] [Command] Fix #54402: Suppress PHP warning when is_readable() tries to access dirs outside of open_basedir restrictions

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #54402
| License       | MIT

Suppress PHP warning in CacheClearCommand when is_readable() tries to access dirs outside of open_basedir restrictions

Commits
-------

d2ed4a3 [FrameworkBundle] fixes #54402: Suppress PHP warning when is_readable() tries to access dirs outside of open_basedir restrictions
@xabbuh xabbuh closed this as completed Apr 3, 2024
xabbuh added a commit that referenced this issue Apr 3, 2024
* 5.4:
  [FrameworkBundle] fixes #54402: Suppress PHP warning when is_readable() tries to access dirs outside of open_basedir restrictions
  return null when message with name is not set
  use local PHP web server to test HTTP stream wrappers
  Bump Symfony version to 5.4.39
  Update VERSION for 5.4.38
  Update CONTRIBUTORS for 5.4.38
  Update CHANGELOG for 5.4.38
xabbuh added a commit that referenced this issue Apr 3, 2024
* 6.4:
  [FrameworkBundle] fixes #54402: Suppress PHP warning when is_readable() tries to access dirs outside of open_basedir restrictions
  return null when message with name is not set
  use local PHP web server to test HTTP stream wrappers
  [Translation] Silence error when intl not loaded
  Bump Symfony version to 6.4.7
  Update VERSION for 6.4.6
  Update CHANGELOG for 6.4.6
  Bump Symfony version to 5.4.39
  Update VERSION for 5.4.38
  Update CONTRIBUTORS for 5.4.38
  Update CHANGELOG for 5.4.38
xabbuh added a commit that referenced this issue Apr 3, 2024
* 7.0:
  update constraint
  [FrameworkBundle] fixes #54402: Suppress PHP warning when is_readable() tries to access dirs outside of open_basedir restrictions
  return null when message with name is not set
  use local PHP web server to test HTTP stream wrappers
  [Translation] Silence error when intl not loaded
  Bump Symfony version to 7.0.7
  Update VERSION for 7.0.6
  Update CHANGELOG for 7.0.6
  Bump Symfony version to 6.4.7
  Update VERSION for 6.4.6
  Update CHANGELOG for 6.4.6
  Bump Symfony version to 5.4.39
  Update VERSION for 5.4.38
  Update CONTRIBUTORS for 5.4.38
  Update CHANGELOG for 5.4.38
This was referenced Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants