From f6db283def03e9c9911655e080b3ca152e1ee06f Mon Sep 17 00:00:00 2001 From: Stanimir Stoyanov Date: Tue, 8 Jun 2021 11:52:03 +0300 Subject: [PATCH] [php:core] Add cwd param to proc_open (#3281) --- php/elFinder.class.php | 5 +++-- php/elFinderVolumeDriver.class.php | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/php/elFinder.class.php b/php/elFinder.class.php index 59136326f..44b1a3a38 100644 --- a/php/elFinder.class.php +++ b/php/elFinder.class.php @@ -5111,12 +5111,13 @@ var go = function() { * @param string $output stdout strings * @param int $return_var process exit code * @param string $error_output stderr strings + * @param null $cwd cwd * * @return int exit code * @throws elFinderAbortException * @author Alexey Sukhotin */ - public static function procExec($command, &$output = '', &$return_var = -1, &$error_output = '') + public static function procExec($command, &$output = '', &$return_var = -1, &$error_output = '', $cwd = null) { static $allowed = null; @@ -5146,7 +5147,7 @@ var go = function() { 2 => array("pipe", "w") // stderr ); - $process = proc_open($command, $descriptorspec, $pipes, null, null); + $process = proc_open($command, $descriptorspec, $pipes, $cwd, null); if (is_resource($process)) { stream_set_blocking($pipes[1], 0); diff --git a/php/elFinderVolumeDriver.class.php b/php/elFinderVolumeDriver.class.php index 968a6d76d..eec594941 100644 --- a/php/elFinderVolumeDriver.class.php +++ b/php/elFinderVolumeDriver.class.php @@ -6356,7 +6356,7 @@ abstract class elFinderVolumeDriver * @throws elFinderAbortException * @author Alexey Sukhotin */ - protected function procExec($command, &$output = '', &$return_var = -1, &$error_output = '') + protected function procExec($command, &$output = '', &$return_var = -1, &$error_output = '', $cwd = null) { return elFinder::procExec($command, $output, $return_var, $error_output); } @@ -6863,7 +6863,8 @@ abstract class elFinderVolumeDriver $files = array_map('escapeshellarg', $files); $cmd = $arc['cmd'] . ' ' . $arc['argc'] . ' ' . escapeshellarg($name) . ' ' . implode(' ', $files); - $this->procExec($cmd, $o, $c); + $err_out = ''; + $this->procExec($cmd, $o, $c, $err_out, $dir); chdir($cwd); } else { return false;