Discard password prompts from smbclient's output

This commit is contained in:
Robin Appelman 2013-11-26 16:58:23 +01:00
commit bb92259b32
5 changed files with 23 additions and 6 deletions

View file

@ -21,20 +21,20 @@ class Connection extends RawConnection {
}
/**
* get all unprocessed output from smbclient untill the next prompt
* get all unprocessed output from smbclient until the next prompt
*
* @throws ConnectionError
* @return array
* @return string
*/
public function read() {
if (!$this->isValid()) {
throw new ConnectionError();
}
$line = parent::read(); //first line is prompt
$line = $this->readLine(); //first line is prompt
$this->checkConnectionError($line);
$output = array();
$line = parent::read();
$line = $this->readLine();
$length = strlen(self::DELIMITER);
while (substr($line, 0, $length) !== self::DELIMITER) { //next prompt functions as delimiter
$output[] .= $line;
@ -43,6 +43,15 @@ class Connection extends RawConnection {
return $output;
}
/**
* read a single line of unprocessed output
*
* @return string
*/
public function readLine() {
return parent::read();
}
/**
* check if the first line holds a connection failure
*