Description
Symfony version(s) affected
>= 6.2
Description
In 007fa61 / #46971 the logic that checks if TTY is supported changed from checking /dev/tty
for reading / writing capabilities directly to checking stream_isatty(\STDOUT)
.
This causes an issue because the new way fails to take into account the open_basedir restrictions.
Related: wintercms/storm#175
How to reproduce
open_basedir
restriction not in effect, works fine:
php -r "require_once(__DIR__ . '/vendor/autoload.php'); (new \Symfony\Component\Process\Process(['ls', '-lsa']))->setTty(true)->run();"
open_basedir
restriction in effect, causes hard crash with PHP Fatal error: Uncaught Symfony\Component\Process\Exception\RuntimeException: Unable to launch a new process. in vendor/symfony/process/Process.php:350
:
php -d open_basedir="/path/to/cwd" -r "require_once(__DIR__ . '/vendor/autoload.php'); (new \Symfony\Component\Process\Process(['ls', '-lsa']))->setTty(true)->run();"
Possible Solution
Revert the linked commit or add an additional is_writable('/dev/tty')
check.
Additional Context
Side note, can we change the self::isTtySupported()
call to static::isTtySupported()
instead so that extending classes can override just the relevant method if needed in the future instead of having to override the setTty()
method entirely?