Fix php-proxying of binaries to avoid proxying phar files, fixes #9742
parent
e9d405ff18
commit
4bedd8379a
|
@ -192,7 +192,11 @@ class BinaryInstaller
|
|||
$binFile = basename($binPath);
|
||||
|
||||
$binContents = file_get_contents($bin);
|
||||
// For php files, we generate a PHP proxy instead of a shell one,
|
||||
// which allows calling the proxy with a custom php process
|
||||
if (preg_match('{^(?:#!(?:/usr)?/bin/env php|#!(?:/usr)?/bin/php|<?php)\r?\n}', $binContents, $match)) {
|
||||
// verify the file is not a phar file, because those do not support php-proxying
|
||||
if (false === ($pos = strpos($binContents, '__HALT_COMPILER')) || false === strpos(substr($binContents, 0, $pos), 'Phar::mapPhar')) {
|
||||
$proxyCode = trim($match[0]);
|
||||
// carry over the existing shebang if present, otherwise add our own
|
||||
if ($proxyCode === "<?php") {
|
||||
|
@ -226,6 +230,7 @@ include \$binPath;
|
|||
|
||||
PROXY;
|
||||
}
|
||||
}
|
||||
|
||||
$proxyCode = <<<PROXY
|
||||
#!/usr/bin/env sh
|
||||
|
|
Loading…
Reference in New Issue