From b3b0cf629e16c1fd7b9d80bf669a3d3ba25448e9 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 23 Feb 2021 10:49:34 +0100 Subject: [PATCH] Generate binary proxy in PHP if the target binary is detected as a PHP script, so custom PHP processes can be used to call them via the bin proxy path, fixes #9325 --- src/Composer/Installer/BinaryInstaller.php | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/Composer/Installer/BinaryInstaller.php b/src/Composer/Installer/BinaryInstaller.php index 0a7b97149..3ffbb50b3 100644 --- a/src/Composer/Installer/BinaryInstaller.php +++ b/src/Composer/Installer/BinaryInstaller.php @@ -191,6 +191,42 @@ class BinaryInstaller $binDir = ProcessExecutor::escape(dirname($binPath)); $binFile = basename($binPath); + $binContents = file_get_contents($bin); + if (preg_match('{^(?:#!(?:/usr)?/bin/env php|#!(?:/usr)?/bin/php| var_export(\$binPath, true), + '__DIR__' => var_export(dirname(\$binPath), true), + )); + + eval(\$contents); + exit(0); +} +include \$binPath; + +PROXY; + } + $proxyCode = <<