From e12c4379ff8de6145bab8c61a5150ac78ae25eb1 Mon Sep 17 00:00:00 2001 From: Toon Van den Bos Date: Thu, 13 Jun 2024 16:23:01 +0200 Subject: [PATCH 1/8] Updated composer.json --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 1bda6a3..4174dbe 100755 --- a/composer.json +++ b/composer.json @@ -19,12 +19,12 @@ ], "require": { "php": ">=7.2", - "illuminate/support": "^6.0|^7.0|^8.0", - "illuminate/filesystem": "^6.0|^7.0|^8.0", + "illuminate/support": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", + "illuminate/filesystem": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", "phpseclib/phpseclib": "^2.0" }, "require-dev": { - "illuminate/console": "^6.0|^7.0|^8.0", + "illuminate/console": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", "mockery/mockery": "~1.0", "phpunit/phpunit": "~5.5" }, From 97889a367bbfecf063290c11c56b2658997fffb2 Mon Sep 17 00:00:00 2001 From: Toon Van den Bos Date: Thu, 13 Jun 2024 16:26:01 +0200 Subject: [PATCH 2/8] Updated package name --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4174dbe..78d1f2d 100755 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "laravelcollective/remote", + "name": "whitecube/remote", "description": "Remote SSH access for The Laravel Framework.", "license": "MIT", "homepage": "http://laravelcollective.com", From e502dd9f8eb48cccc1a412a08f7fe2e5e7ad92d4 Mon Sep 17 00:00:00 2001 From: Toon Van den Bos Date: Thu, 13 Jun 2024 16:30:09 +0200 Subject: [PATCH 3/8] Bumped phpseclib version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 78d1f2d..374348d 100755 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "php": ">=7.2", "illuminate/support": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", "illuminate/filesystem": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", - "phpseclib/phpseclib": "^2.0" + "phpseclib/phpseclib": "^3.0" }, "require-dev": { "illuminate/console": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", From b6af6424c916efc0c6983dd0dff3f98b50074c08 Mon Sep 17 00:00:00 2001 From: Toon Van den Bos Date: Thu, 13 Jun 2024 16:44:32 +0200 Subject: [PATCH 4/8] Updated phpseclib3 namespaces --- src/SecLibGateway.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/SecLibGateway.php b/src/SecLibGateway.php index d25a044..3c935bc 100755 --- a/src/SecLibGateway.php +++ b/src/SecLibGateway.php @@ -2,12 +2,12 @@ namespace Collective\Remote; -use phpseclib\Net\SFTP; -use phpseclib\Net\SSH2; -use phpseclib\Crypt\RSA; +use phpseclib3\Net\SFTP; +use phpseclib3\Net\SSH2; +use phpseclib3\Crypt\RSA; use Illuminate\Support\Arr; use Illuminate\Support\Str; -use phpseclib\System\SSH\Agent; +use phpseclib3\System\SSH\Agent; use Illuminate\Filesystem\Filesystem; class SecLibGateway implements GatewayInterface From 0b5f598772b5c5a6a6bee2c4e5d7ae1f05e0f8c5 Mon Sep 17 00:00:00 2001 From: Toon Van den Bos Date: Thu, 13 Jun 2024 16:50:48 +0200 Subject: [PATCH 5/8] Fixed seclib typehinting --- src/SecLibGateway.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SecLibGateway.php b/src/SecLibGateway.php index 3c935bc..8f146a9 100755 --- a/src/SecLibGateway.php +++ b/src/SecLibGateway.php @@ -284,7 +284,7 @@ public function connected() */ public function run($command) { - $this->getConnection()->exec($command, false); + $this->getConnection()->exec($command, null); } /** From 6913dbeb8337dedf2b466386c88a98751b6eb042 Mon Sep 17 00:00:00 2001 From: Toon Van den Bos Date: Thu, 13 Jun 2024 16:59:27 +0200 Subject: [PATCH 6/8] Fixed seclib method call --- src/SecLibGateway.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SecLibGateway.php b/src/SecLibGateway.php index 8f146a9..c6c96ac 100755 --- a/src/SecLibGateway.php +++ b/src/SecLibGateway.php @@ -382,7 +382,7 @@ public function delete($remote) */ public function nextLine() { - $value = $this->getConnection()->_get_channel_packet(SSH2::CHANNEL_EXEC); + $value = $this->getConnection()->open_channel(SSH2::CHANNEL_EXEC); return $value === true ? null : $value; } From c0ef2ef6695f6d3178b0fbf6ce5b7f309c3b2573 Mon Sep 17 00:00:00 2001 From: Toon Van den Bos Date: Thu, 13 Jun 2024 17:24:05 +0200 Subject: [PATCH 7/8] Fixed command execution output callback --- src/Connection.php | 13 +------------ src/SecLibGateway.php | 6 ++---- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/Connection.php b/src/Connection.php index d6afd85..afbcf43 100755 --- a/src/Connection.php +++ b/src/Connection.php @@ -121,18 +121,7 @@ public function run($commands, Closure $callback = null, int $timeout = null) $callback = $this->getCallback($callback); - $gateway->run($this->formatCommands($commands)); - - // After running the commands against the server, we will continue to ask for - // the next line of output that is available, and write it them out using - // our callback. Once we hit the end of output, we'll bail out of here. - while (true) { - if (is_null($line = $gateway->nextLine())) { - break; - } - - call_user_func($callback, $line, $this); - } + $gateway->run($this->formatCommands($commands), $callback); } /** diff --git a/src/SecLibGateway.php b/src/SecLibGateway.php index c6c96ac..83b266a 100755 --- a/src/SecLibGateway.php +++ b/src/SecLibGateway.php @@ -280,7 +280,7 @@ public function connected() * * @param string $command * - * @return void + * @return string|bool */ public function run($command) { @@ -382,9 +382,7 @@ public function delete($remote) */ public function nextLine() { - $value = $this->getConnection()->open_channel(SSH2::CHANNEL_EXEC); - - return $value === true ? null : $value; + return null; } /** From b94cc72fd15247d56d37cccd6a19f7a9e97885cb Mon Sep 17 00:00:00 2001 From: Toon Van den Bos Date: Thu, 13 Jun 2024 17:59:37 +0200 Subject: [PATCH 8/8] Fixed exec result treatment --- src/Connection.php | 4 ++-- src/SecLibGateway.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Connection.php b/src/Connection.php index afbcf43..d0cb73f 100755 --- a/src/Connection.php +++ b/src/Connection.php @@ -119,9 +119,9 @@ public function run($commands, Closure $callback = null, int $timeout = null) $gateway->setTimeout($timeout); } - $callback = $this->getCallback($callback); + $result = $gateway->run($this->formatCommands($commands)); - $gateway->run($this->formatCommands($commands), $callback); + call_user_func($this->getCallback($callback), $result); } /** diff --git a/src/SecLibGateway.php b/src/SecLibGateway.php index 83b266a..d0f3c8f 100755 --- a/src/SecLibGateway.php +++ b/src/SecLibGateway.php @@ -284,7 +284,7 @@ public function connected() */ public function run($command) { - $this->getConnection()->exec($command, null); + return $this->getConnection()->exec($command, null); } /**