mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 17:24:07 +02:00
RawConnection.php: add workgroup to auth file
This commit is contained in:
parent
9277bd2026
commit
98074eff7f
3 changed files with 17 additions and 11 deletions
|
|
@ -131,12 +131,18 @@ class RawConnection {
|
||||||
return $this->pipes[5];
|
return $this->pipes[5];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function writeAuthentication($user, $password) {
|
public function writeAuthentication($workgroup, $user, $password) {
|
||||||
$auth = ($password === false)
|
$auth = array();
|
||||||
? "username=$user"
|
if (is_string($workgroup)) {
|
||||||
: "username=$user\npassword=$password";
|
$auth[] = "domain=$workgroup";
|
||||||
|
}
|
||||||
if (fwrite($this->getAuthStream(), $auth) === false) {
|
if (is_string($user)) {
|
||||||
|
$auth[] = "username=$user";
|
||||||
|
}
|
||||||
|
if (is_string($password)) {
|
||||||
|
$auth[] = "password=$password";
|
||||||
|
}
|
||||||
|
if (fwrite($this->getAuthStream(), implode("\n", $auth)) === false) {
|
||||||
fclose($this->getAuthStream());
|
fclose($this->getAuthStream());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ class Server {
|
||||||
$command = Server::CLIENT . $workgroupArgument . ' --authentication-file=/proc/self/fd/3' .
|
$command = Server::CLIENT . $workgroupArgument . ' --authentication-file=/proc/self/fd/3' .
|
||||||
' -gL ' . escapeshellarg($this->getHost());
|
' -gL ' . escapeshellarg($this->getHost());
|
||||||
$connection = new RawConnection($command);
|
$connection = new RawConnection($command);
|
||||||
$connection->writeAuthentication($this->getUser(), $this->getPassword());
|
$connection->writeAuthentication($this->getWorkgroup(), $this->getUser(), $this->getPassword());
|
||||||
$output = $connection->readAll();
|
$output = $connection->readAll();
|
||||||
|
|
||||||
$line = $output[0];
|
$line = $output[0];
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ class Share extends AbstractShare {
|
||||||
escapeshellarg('//' . $this->server->getHost() . '/' . $this->name)
|
escapeshellarg('//' . $this->server->getHost() . '/' . $this->name)
|
||||||
);
|
);
|
||||||
$this->connection = new Connection($command);
|
$this->connection = new Connection($command);
|
||||||
$this->connection->writeAuthentication($this->server->getUser(), $this->server->getPassword());
|
$this->connection->writeAuthentication($this->server->getWorkgroup(), $this->server->getUser(), $this->server->getPassword());
|
||||||
if (!$this->connection->isValid()) {
|
if (!$this->connection->isValid()) {
|
||||||
throw new ConnectionException();
|
throw new ConnectionException();
|
||||||
}
|
}
|
||||||
|
|
@ -69,7 +69,7 @@ class Share extends AbstractShare {
|
||||||
|
|
||||||
protected function reconnect() {
|
protected function reconnect() {
|
||||||
$this->connection->reconnect();
|
$this->connection->reconnect();
|
||||||
$this->connection->writeAuthentication($this->server->getUser(), $this->server->getPassword());
|
$this->connection->writeAuthentication($this->server->getWorkgroup(), $this->server->getUser(), $this->server->getPassword());
|
||||||
if (!$this->connection->isValid()) {
|
if (!$this->connection->isValid()) {
|
||||||
throw new ConnectionException();
|
throw new ConnectionException();
|
||||||
}
|
}
|
||||||
|
|
@ -263,7 +263,7 @@ class Share extends AbstractShare {
|
||||||
escapeshellarg('//' . $this->server->getHost() . '/' . $this->name)
|
escapeshellarg('//' . $this->server->getHost() . '/' . $this->name)
|
||||||
);
|
);
|
||||||
$connection = new Connection($command);
|
$connection = new Connection($command);
|
||||||
$connection->writeAuthentication($this->server->getUser(), $this->server->getPassword());
|
$connection->writeAuthentication($this->server->getWorkgroup(), $this->server->getUser(), $this->server->getPassword());
|
||||||
$connection->write('get ' . $source . ' /proc/self/fd/5');
|
$connection->write('get ' . $source . ' /proc/self/fd/5');
|
||||||
$connection->write('exit');
|
$connection->write('exit');
|
||||||
$fh = $connection->getFileOutputStream();
|
$fh = $connection->getFileOutputStream();
|
||||||
|
|
@ -291,7 +291,7 @@ class Share extends AbstractShare {
|
||||||
escapeshellarg('//' . $this->server->getHost() . '/' . $this->name)
|
escapeshellarg('//' . $this->server->getHost() . '/' . $this->name)
|
||||||
);
|
);
|
||||||
$connection = new Connection($command);
|
$connection = new Connection($command);
|
||||||
$connection->writeAuthentication($this->server->getUser(), $this->server->getPassword());
|
$connection->writeAuthentication($this->server->getWorkgroup(), $this->server->getUser(), $this->server->getPassword());
|
||||||
$fh = $connection->getFileInputStream();
|
$fh = $connection->getFileInputStream();
|
||||||
|
|
||||||
$connection->write('put /proc/self/fd/4 ' . $target);
|
$connection->write('put /proc/self/fd/4 ' . $target);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue