From 4797e32ea12367918553152a821324231bb39249 Mon Sep 17 00:00:00 2001 From: Hendrik Wouters Date: Wed, 12 May 2021 10:31:26 +0200 Subject: [PATCH] Added --no-same-owner flag when extracting the NodeJs archive, so that it can behaves as expected when composer runs as root --- src/NodeJsInstaller.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/NodeJsInstaller.php b/src/NodeJsInstaller.php index f40e2e2..e681422 100644 --- a/src/NodeJsInstaller.php +++ b/src/NodeJsInstaller.php @@ -279,10 +279,11 @@ private function extractTo($tarGzFile, $targetDir) { // Note: we cannot use PharData class because it does not keeps symbolic links. // Also, --strip 1 allows us to remove the first directory. + // --no-same-owner is used to extract the files as the current user, even if the current user is root. $output = $return_var = null; - exec("tar -xvf ".$tarGzFile." -C ".escapeshellarg($targetDir)." --strip 1", $output, $return_var); + exec("tar -xvf ".$tarGzFile." -C ".escapeshellarg($targetDir)." --strip 1 --no-same-owner", $output, $return_var); if ($return_var !== 0) { throw new NodeJsInstallerException("An error occurred while untaring NodeJS ($tarGzFile) to $targetDir");