mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 17:24:07 +02:00
use authentication files
This commit is contained in:
parent
1a3640e25b
commit
d18b9db9c0
3 changed files with 28 additions and 21 deletions
|
|
@ -81,19 +81,14 @@ class Server {
|
|||
* @throws \Icewind\SMB\InvalidHostException
|
||||
*/
|
||||
public function listShares() {
|
||||
$user = escapeshellarg($this->getUser());
|
||||
$command = self::CLIENT . ' -U ' . $user . ' ' . '-gL ' . escapeshellarg($this->getHost());
|
||||
$command = Server::CLIENT . ' --authentication-file=/proc/self/fd/3' .
|
||||
' -gL ' . escapeshellarg($this->getHost());
|
||||
$connection = new RawConnection($command);
|
||||
$connection->write($this->getPassword() . PHP_EOL);
|
||||
$connection->writeAuthentication($this->getUser(), $this->getPassword());
|
||||
$output = $connection->readAll();
|
||||
|
||||
$line = $output[0];
|
||||
|
||||
// disregard password prompt
|
||||
if (substr($line, 0, 6) == 'Enter ' and count($output) > 1) {
|
||||
$line = $output[1];
|
||||
}
|
||||
|
||||
$line = rtrim($line, ')');
|
||||
if (substr($line, -23) === ErrorCodes::LogonFailure) {
|
||||
throw new AuthenticationException();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue