commit
722724c2c3
|
@ -65,6 +65,7 @@ class Compiler
|
||||||
}
|
}
|
||||||
$this->addFile($phar, new \SplFileInfo(__DIR__.'/Autoload/ClassLoader.php'), false);
|
$this->addFile($phar, new \SplFileInfo(__DIR__.'/Autoload/ClassLoader.php'), false);
|
||||||
$this->addFile($phar, new \SplFileInfo(__DIR__.'/../../res/composer-schema.json'), false);
|
$this->addFile($phar, new \SplFileInfo(__DIR__.'/../../res/composer-schema.json'), false);
|
||||||
|
$this->addFile($phar, new \SplFileInfo(__DIR__.'/../../src/Composer/IO/hiddeninput.exe'), false);
|
||||||
|
|
||||||
$finder = new Finder();
|
$finder = new Finder();
|
||||||
$finder->files()
|
$finder->files()
|
||||||
|
|
|
@ -134,44 +134,40 @@ class ConsoleIO implements IOInterface
|
||||||
*/
|
*/
|
||||||
public function askAndHideAnswer($question)
|
public function askAndHideAnswer($question)
|
||||||
{
|
{
|
||||||
// for windows OS (does not hide the answer in the popup, but it never appears in the STDIN history)
|
// handle windows
|
||||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||||
$vbscript = sys_get_temp_dir() . '/prompt_password.vbs';
|
$exe = __DIR__.'\\hiddeninput.exe';
|
||||||
file_put_contents($vbscript,
|
|
||||||
'wscript.echo(Inputbox("' . addslashes($question) . '","'
|
// handle code running from a phar
|
||||||
. addslashes($question) . '", ""))');
|
if ('phar:' === substr(__FILE__, 0, 5)) {
|
||||||
$command = "cscript //nologo " . escapeshellarg($vbscript);
|
$tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
|
||||||
|
copy($exe, $tmpExe);
|
||||||
|
$exe = $tmpExe;
|
||||||
|
}
|
||||||
|
|
||||||
$this->write($question, false);
|
$this->write($question, false);
|
||||||
|
$value = rtrim(shell_exec($exe));
|
||||||
|
$this->write('');
|
||||||
|
|
||||||
$value = rtrim(shell_exec($command));
|
// clean up
|
||||||
unlink($vbscript);
|
if (isset($tmpExe)) {
|
||||||
|
unlink($tmpExe);
|
||||||
$this->write('***');
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// for other OS with shell_exec (hide the answer)
|
// handle other OSs with bash if available to hide the answer
|
||||||
$command = "/usr/bin/env bash -c 'echo OK'";
|
if ('OK' === rtrim(shell_exec("/usr/bin/env bash -c 'echo OK'"))) {
|
||||||
if (rtrim(shell_exec($command)) === 'OK') {
|
|
||||||
$this->write($question, false);
|
$this->write($question, false);
|
||||||
|
|
||||||
$command = "/usr/bin/env bash -c 'read -s mypassword && echo \$mypassword'";
|
$command = "/usr/bin/env bash -c 'read -s mypassword && echo \$mypassword'";
|
||||||
$value = rtrim(shell_exec($command));
|
$value = rtrim(shell_exec($command));
|
||||||
|
|
||||||
for ($i = 0; $i < strlen($value); ++$i) {
|
|
||||||
$this->write('*', false);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->write('');
|
$this->write('');
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// for other OS without shell_exec (does not hide the answer)
|
// not able to hide the answer, proceed with normal question handling
|
||||||
$this->write('');
|
|
||||||
|
|
||||||
return $this->ask($question);
|
return $this->ask($question);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue