RawConnection.php: add workgroup to auth file

This commit is contained in:
Alfred Klomp 2015-08-23 18:27:27 +02:00
commit 98074eff7f
3 changed files with 17 additions and 11 deletions

View file

@ -131,12 +131,18 @@ class RawConnection {
return $this->pipes[5];
}
public function writeAuthentication($user, $password) {
$auth = ($password === false)
? "username=$user"
: "username=$user\npassword=$password";
if (fwrite($this->getAuthStream(), $auth) === false) {
public function writeAuthentication($workgroup, $user, $password) {
$auth = array();
if (is_string($workgroup)) {
$auth[] = "domain=$workgroup";
}
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());
return false;
}

View file

@ -118,7 +118,7 @@ class Server {
$command = Server::CLIENT . $workgroupArgument . ' --authentication-file=/proc/self/fd/3' .
' -gL ' . escapeshellarg($this->getHost());
$connection = new RawConnection($command);
$connection->writeAuthentication($this->getUser(), $this->getPassword());
$connection->writeAuthentication($this->getWorkgroup(), $this->getUser(), $this->getPassword());
$output = $connection->readAll();
$line = $output[0];

View file

@ -61,7 +61,7 @@ class Share extends AbstractShare {
escapeshellarg('//' . $this->server->getHost() . '/' . $this->name)
);
$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()) {
throw new ConnectionException();
}
@ -69,7 +69,7 @@ class Share extends AbstractShare {
protected function 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()) {
throw new ConnectionException();
}
@ -263,7 +263,7 @@ class Share extends AbstractShare {
escapeshellarg('//' . $this->server->getHost() . '/' . $this->name)
);
$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('exit');
$fh = $connection->getFileOutputStream();
@ -291,7 +291,7 @@ class Share extends AbstractShare {
escapeshellarg('//' . $this->server->getHost() . '/' . $this->name)
);
$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();
$connection->write('put /proc/self/fd/4 ' . $target);