diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2022-01-20 23:25:58 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-20 23:25:58 +0300 |
commit | c0b03000a507f7bdce57eb91deaf4e7d2d67a3b4 (patch) | |
tree | 86019acc692b5e207a2c2efa226620e611b0dfa1 /apps/files_external/3rdparty/icewind/smb/src/Wrapped/RawConnection.php | |
parent | 4466eb1f42c037ed3a71e4a0d549fbe7c7295703 (diff) | |
parent | 13b8179912630acede43aff844f2d302f552cb80 (diff) |
Merge pull request #30782 from nextcloud/backport/29349/stable23v23.0.1rc3
Diffstat (limited to 'apps/files_external/3rdparty/icewind/smb/src/Wrapped/RawConnection.php')
-rw-r--r-- | apps/files_external/3rdparty/icewind/smb/src/Wrapped/RawConnection.php | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/RawConnection.php b/apps/files_external/3rdparty/icewind/smb/src/Wrapped/RawConnection.php index 26a17cc584b..4aec674c3da 100644 --- a/apps/files_external/3rdparty/icewind/smb/src/Wrapped/RawConnection.php +++ b/apps/files_external/3rdparty/icewind/smb/src/Wrapped/RawConnection.php @@ -71,7 +71,8 @@ class RawConnection { setlocale(LC_ALL, Server::LOCALE); $env = array_merge($this->env, [ - 'CLI_FORCE_INTERACTIVE' => 'y', // Needed or the prompt isn't displayed!! + 'CLI_FORCE_INTERACTIVE' => 'y', // Make sure the prompt is displayed + 'CLI_NO_READLINE' => 1, // Not all distros build smbclient with readline, disable it to get consistent behaviour 'LC_ALL' => Server::LOCALE, 'LANG' => Server::LOCALE, 'COLUMNS' => 8192 // prevent smbclient from line-wrapping it's output @@ -91,7 +92,7 @@ class RawConnection { public function isValid(): bool { if (is_resource($this->process)) { $status = proc_get_status($this->process); - return (bool)$status['running']; + return $status['running']; } else { return false; } @@ -110,12 +111,29 @@ class RawConnection { } /** + * read output till the next prompt + * + * @return string|false + */ + public function readTillPrompt() { + $output = ""; + do { + $chunk = $this->readLine('\> '); + if ($chunk === false) { + return false; + } + $output .= $chunk; + } while (strlen($chunk) == 4096 && strpos($chunk, "smb:") === false); + return $output; + } + + /** * read a line of output * * @return string|false */ - public function readLine() { - return stream_get_line($this->getOutputStream(), 4086, "\n"); + public function readLine(string $end = "\n") { + return stream_get_line($this->getOutputStream(), 4096, $end); } /** @@ -202,6 +220,14 @@ class RawConnection { * @psalm-assert null $this->process */ public function close(bool $terminate = true): void { + $this->close_process($terminate); + } + + /** + * @param bool $terminate + * @psalm-assert null $this->process + */ + protected function close_process(bool $terminate = true): void { if (!is_resource($this->process)) { return; } |