Skip to content

Commit

Permalink
Make sure that single files installed via file downloader get the exe…
Browse files Browse the repository at this point in the history
…cutable bit set if they are a binary file, refs #9742
  • Loading branch information
Seldaek committed Mar 9, 2021
1 parent 4bedd83 commit 4a8e7da
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Composer/Downloader/FileDownloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Composer\Plugin\PreFileDownloadEvent;
use Composer\EventDispatcher\EventDispatcher;
use Composer\Util\Filesystem;
use Composer\Util\Silencer;
use Composer\Util\HttpDownloader;
use Composer\Util\Url as UrlUtil;
use Composer\Util\ProcessExecutor;
Expand Down Expand Up @@ -313,6 +314,16 @@ public function install(PackageInterface $package, $path, $output = true)
$this->filesystem->emptyDirectory($path);
$this->filesystem->ensureDirectoryExists($path);
$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());
}
}
}
}

/**
Expand Down

0 comments on commit 4a8e7da

Please sign in to comment.