mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-04 01:34:07 +02:00
fix support for smbclient compiled without readline support
This commit is contained in:
parent
9f6b8f1c3f
commit
a8dc9ca75b
6 changed files with 60 additions and 43 deletions
|
|
@ -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
|
||||
|
|
@ -109,13 +110,30 @@ class RawConnection {
|
|||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue