diff --git a/src/Model/Build.php b/src/Model/Build.php index 166ad6c4..23c975ff 100644 --- a/src/Model/Build.php +++ b/src/Model/Build.php @@ -472,13 +472,11 @@ class Build extends BaseBuild */ protected function writeSshKey($cloneTo) { - $keyPath = $cloneTo . 'temp'; - $keyFile = $keyPath . '.key'; + $tempKeyFile = tempnam(sys_get_temp_dir(), 'key_'); - file_put_contents($keyFile, $this->getProject()->getSshPrivateKey()); - chmod($keyFile, 0600); + file_put_contents($tempKeyFile, $this->getProject()->getSshPrivateKey()); - return $keyFile; + return $tempKeyFile; } /** @@ -491,9 +489,6 @@ class Build extends BaseBuild */ protected function writeSshWrapper($cloneTo, $keyFile) { - $path = $cloneTo . 'temp'; - $wrapperFile = $path . '.sh'; - $sshFlags = '-o CheckHostIP=no -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o PasswordAuthentication=no'; // Write out the wrapper script for this build: @@ -502,11 +497,12 @@ class Build extends BaseBuild ssh {$sshFlags} -o IdentityFile={$keyFile} $* OUT; + $tempShFile = tempnam(sys_get_temp_dir(), 'sh_'); - file_put_contents($wrapperFile, $script); - shell_exec('chmod +x "' . $wrapperFile . '"'); + file_put_contents($tempShFile, $script); + shell_exec('chmod +x "' . $tempShFile . '"'); - return $wrapperFile; + return $tempShFile; } /** diff --git a/src/Plugin/PhpCpd.php b/src/Plugin/PhpCpd.php index e4189856..a7e7f7eb 100644 --- a/src/Plugin/PhpCpd.php +++ b/src/Plugin/PhpCpd.php @@ -99,7 +99,7 @@ class PhpCpd extends Plugin implements ZeroConfigPluginInterface $phpcpd = $this->findBinary('phpcpd'); - $tmpFileName = tempnam('/tmp', 'phpcpd'); + $tmpFileName = tempnam(sys_get_temp_dir(), 'phpcpd_'); $cmd = $phpcpd . ' --log-pmd "%s" %s "%s"'; $success = $this->builder->executeCommand($cmd, $tmpFileName, $ignore, $this->path); diff --git a/src/Plugin/PhpUnit.php b/src/Plugin/PhpUnit.php index 3f61f7f0..f7988b2e 100644 --- a/src/Plugin/PhpUnit.php +++ b/src/Plugin/PhpUnit.php @@ -161,7 +161,7 @@ class PhpUnit extends Plugin implements ZeroConfigPluginInterface $buildPath = $this->build->getBuildPath(); // Save the results into a log file - $logFile = @tempnam($buildPath, 'jLog_'); + $logFile = tempnam(sys_get_temp_dir(), 'jlog_'); $options->addArgument('log-' . $logFormat, $logFile); // Removes any current configurations files @@ -258,7 +258,7 @@ class PhpUnit extends Plugin implements ZeroConfigPluginInterface $this->builder, 'php_unit', $error['message'], $severity, $error['file'], $error['line'] ); } - @unlink($logFile); + unlink($logFile); } else { throw new \Exception('log output file does not exist: ' . $logFile); }