1
0
Fork 0

Make sure that single files installed via file downloader get the executable bit set if they are a binary file, refs #9742

pull/9734/head
Jordi Boggiano 2021-03-09 14:13:19 +01:00
parent 4bedd8379a
commit 4a8e7daf56
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 11 additions and 0 deletions

View File

@ -27,6 +27,7 @@ use Composer\Plugin\PostFileDownloadEvent;
use Composer\Plugin\PreFileDownloadEvent; use Composer\Plugin\PreFileDownloadEvent;
use Composer\EventDispatcher\EventDispatcher; use Composer\EventDispatcher\EventDispatcher;
use Composer\Util\Filesystem; use Composer\Util\Filesystem;
use Composer\Util\Silencer;
use Composer\Util\HttpDownloader; use Composer\Util\HttpDownloader;
use Composer\Util\Url as UrlUtil; use Composer\Util\Url as UrlUtil;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;
@ -313,6 +314,16 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
$this->filesystem->emptyDirectory($path); $this->filesystem->emptyDirectory($path);
$this->filesystem->ensureDirectoryExists($path); $this->filesystem->ensureDirectoryExists($path);
$this->filesystem->rename($this->getFileName($package, $path), $path . '/' . pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_BASENAME)); $this->filesystem->rename($this->getFileName($package, $path), $path . '/' . pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_BASENAME));
if ($package->getBinaries()) {
// Single files can not have a mode set like files in archives
// so we make sure if the file is a binary that it is executable
foreach ($package->getBinaries() as $bin) {
if (file_exists($path . '/' . $bin) && !is_executable($path . '/' . $bin)) {
Silencer::call('chmod', $path . '/' . $bin, 0777 & ~umask());
}
}
}
} }
/** /**