Signed-off-by: Robin Appelman <robin@icewind.nl>tags/v22.0.0beta1
}, | }, | ||||
"require": { | "require": { | ||||
"icewind/streams": "0.7.3", | "icewind/streams": "0.7.3", | ||||
"icewind/smb": "3.4.0" | |||||
"icewind/smb": "3.4.1" | |||||
} | } | ||||
} | } |
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", | ||||
"This file is @generated automatically" | "This file is @generated automatically" | ||||
], | ], | ||||
"content-hash": "9905ed45527f669a4165a8b83b6e4141", | |||||
"content-hash": "dacbb67c9e2d1d46204d5b1a7f5cebc2", | |||||
"packages": [ | "packages": [ | ||||
{ | { | ||||
"name": "icewind/smb", | "name": "icewind/smb", | ||||
"version": "v3.4.0", | |||||
"version": "v3.4.1", | |||||
"source": { | "source": { | ||||
"type": "git", | "type": "git", | ||||
"url": "https://github.com/icewind1991/SMB.git", | "url": "https://github.com/icewind1991/SMB.git", | ||||
"reference": "b5c6921f2e91229c9f71556a4713b4fac91fd394" | |||||
"reference": "9dba42ab2a3990de29e18cc62b0a8270aceb74e3" | |||||
}, | }, | ||||
"dist": { | "dist": { | ||||
"type": "zip", | "type": "zip", | ||||
"url": "https://api.github.com/repos/icewind1991/SMB/zipball/b5c6921f2e91229c9f71556a4713b4fac91fd394", | |||||
"reference": "b5c6921f2e91229c9f71556a4713b4fac91fd394", | |||||
"url": "https://api.github.com/repos/icewind1991/SMB/zipball/9dba42ab2a3990de29e18cc62b0a8270aceb74e3", | |||||
"reference": "9dba42ab2a3990de29e18cc62b0a8270aceb74e3", | |||||
"shasum": "" | "shasum": "" | ||||
}, | }, | ||||
"require": { | "require": { | ||||
"description": "php wrapper for smbclient and libsmbclient-php", | "description": "php wrapper for smbclient and libsmbclient-php", | ||||
"support": { | "support": { | ||||
"issues": "https://github.com/icewind1991/SMB/issues", | "issues": "https://github.com/icewind1991/SMB/issues", | ||||
"source": "https://github.com/icewind1991/SMB/tree/v3.4.0" | |||||
"source": "https://github.com/icewind1991/SMB/tree/v3.4.1" | |||||
}, | }, | ||||
"time": "2021-03-10T14:00:37+00:00" | |||||
"time": "2021-04-19T13:53:08+00:00" | |||||
}, | }, | ||||
{ | { | ||||
"name": "icewind/streams", | "name": "icewind/streams", |
'aliases' => | 'aliases' => | ||||
array ( | array ( | ||||
), | ), | ||||
'reference' => '62929cc646134fbd409cfb4eacb7039d15763b96', | |||||
'reference' => '9a69b8839389f133db55a41e1c2ba4435fd50c19', | |||||
'name' => 'files_external/3rdparty', | 'name' => 'files_external/3rdparty', | ||||
), | ), | ||||
'versions' => | 'versions' => | ||||
'aliases' => | 'aliases' => | ||||
array ( | array ( | ||||
), | ), | ||||
'reference' => '62929cc646134fbd409cfb4eacb7039d15763b96', | |||||
'reference' => '9a69b8839389f133db55a41e1c2ba4435fd50c19', | |||||
), | ), | ||||
'icewind/smb' => | 'icewind/smb' => | ||||
array ( | array ( | ||||
'pretty_version' => 'v3.4.0', | |||||
'version' => '3.4.0.0', | |||||
'pretty_version' => 'v3.4.1', | |||||
'version' => '3.4.1.0', | |||||
'aliases' => | 'aliases' => | ||||
array ( | array ( | ||||
), | ), | ||||
'reference' => 'b5c6921f2e91229c9f71556a4713b4fac91fd394', | |||||
'reference' => '9dba42ab2a3990de29e18cc62b0a8270aceb74e3', | |||||
), | ), | ||||
'icewind/streams' => | 'icewind/streams' => | ||||
array ( | array ( |
"packages": [ | "packages": [ | ||||
{ | { | ||||
"name": "icewind/smb", | "name": "icewind/smb", | ||||
"version": "v3.4.0", | |||||
"version_normalized": "3.4.0.0", | |||||
"version": "v3.4.1", | |||||
"version_normalized": "3.4.1.0", | |||||
"source": { | "source": { | ||||
"type": "git", | "type": "git", | ||||
"url": "https://github.com/icewind1991/SMB.git", | "url": "https://github.com/icewind1991/SMB.git", | ||||
"reference": "b5c6921f2e91229c9f71556a4713b4fac91fd394" | |||||
"reference": "9dba42ab2a3990de29e18cc62b0a8270aceb74e3" | |||||
}, | }, | ||||
"dist": { | "dist": { | ||||
"type": "zip", | "type": "zip", | ||||
"url": "https://api.github.com/repos/icewind1991/SMB/zipball/b5c6921f2e91229c9f71556a4713b4fac91fd394", | |||||
"reference": "b5c6921f2e91229c9f71556a4713b4fac91fd394", | |||||
"url": "https://api.github.com/repos/icewind1991/SMB/zipball/9dba42ab2a3990de29e18cc62b0a8270aceb74e3", | |||||
"reference": "9dba42ab2a3990de29e18cc62b0a8270aceb74e3", | |||||
"shasum": "" | "shasum": "" | ||||
}, | }, | ||||
"require": { | "require": { | ||||
"phpunit/phpunit": "^8.5|^9.3.8", | "phpunit/phpunit": "^8.5|^9.3.8", | ||||
"psalm/phar": "^4.3" | "psalm/phar": "^4.3" | ||||
}, | }, | ||||
"time": "2021-03-10T14:00:37+00:00", | |||||
"time": "2021-04-19T13:53:08+00:00", | |||||
"type": "library", | "type": "library", | ||||
"installation-source": "dist", | "installation-source": "dist", | ||||
"autoload": { | "autoload": { | ||||
"description": "php wrapper for smbclient and libsmbclient-php", | "description": "php wrapper for smbclient and libsmbclient-php", | ||||
"support": { | "support": { | ||||
"issues": "https://github.com/icewind1991/SMB/issues", | "issues": "https://github.com/icewind1991/SMB/issues", | ||||
"source": "https://github.com/icewind1991/SMB/tree/v3.4.0" | |||||
"source": "https://github.com/icewind1991/SMB/tree/v3.4.1" | |||||
}, | }, | ||||
"install-path": "../icewind/smb" | "install-path": "../icewind/smb" | ||||
}, | }, |
'aliases' => | 'aliases' => | ||||
array ( | array ( | ||||
), | ), | ||||
'reference' => '62929cc646134fbd409cfb4eacb7039d15763b96', | |||||
'reference' => '9a69b8839389f133db55a41e1c2ba4435fd50c19', | |||||
'name' => 'files_external/3rdparty', | 'name' => 'files_external/3rdparty', | ||||
), | ), | ||||
'versions' => | 'versions' => | ||||
'aliases' => | 'aliases' => | ||||
array ( | array ( | ||||
), | ), | ||||
'reference' => '62929cc646134fbd409cfb4eacb7039d15763b96', | |||||
'reference' => '9a69b8839389f133db55a41e1c2ba4435fd50c19', | |||||
), | ), | ||||
'icewind/smb' => | 'icewind/smb' => | ||||
array ( | array ( | ||||
'pretty_version' => 'v3.4.0', | |||||
'version' => '3.4.0.0', | |||||
'pretty_version' => 'v3.4.1', | |||||
'version' => '3.4.1.0', | |||||
'aliases' => | 'aliases' => | ||||
array ( | array ( | ||||
), | ), | ||||
'reference' => 'b5c6921f2e91229c9f71556a4713b4fac91fd394', | |||||
'reference' => '9dba42ab2a3990de29e18cc62b0a8270aceb74e3', | |||||
), | ), | ||||
'icewind/streams' => | 'icewind/streams' => | ||||
array ( | array ( |
namespace Icewind\SMB; | namespace Icewind\SMB; | ||||
use Icewind\SMB\Exception\Exception; | |||||
class AnonymousAuth implements IAuth { | class AnonymousAuth implements IAuth { | ||||
public function getUsername(): ?string { | public function getUsername(): ?string { | ||||
return null; | return null; | ||||
} | } | ||||
public function setExtraSmbClientOptions($smbClientState): void { | public function setExtraSmbClientOptions($smbClientState): void { | ||||
smbclient_option_set($smbClientState, SMBCLIENT_OPT_AUTO_ANONYMOUS_LOGIN, true); | |||||
if (smbclient_option_set($smbClientState, SMBCLIENT_OPT_AUTO_ANONYMOUS_LOGIN, true) === false) { | |||||
throw new Exception("Failed to set smbclient options for anonymous auth"); | |||||
} | |||||
} | } | ||||
} | } |
namespace Icewind\SMB; | namespace Icewind\SMB; | ||||
use Icewind\SMB\Exception\Exception; | |||||
/** | /** | ||||
* Use existing kerberos ticket to authenticate | * Use existing kerberos ticket to authenticate | ||||
*/ | */ | ||||
} | } | ||||
public function setExtraSmbClientOptions($smbClientState): void { | public function setExtraSmbClientOptions($smbClientState): void { | ||||
smbclient_option_set($smbClientState, SMBCLIENT_OPT_USE_KERBEROS, true); | |||||
smbclient_option_set($smbClientState, SMBCLIENT_OPT_FALLBACK_AFTER_KERBEROS, false); | |||||
$success = (bool)smbclient_option_set($smbClientState, SMBCLIENT_OPT_USE_KERBEROS, true); | |||||
$success = $success && smbclient_option_set($smbClientState, SMBCLIENT_OPT_FALLBACK_AFTER_KERBEROS, false); | |||||
if (!$success) { | |||||
throw new Exception("Failed to set smbclient options for kerberos auth"); | |||||
} | |||||
} | } | ||||
} | } |
/** @var resource $state */ | /** @var resource $state */ | ||||
$state = smbclient_state_new(); | $state = smbclient_state_new(); | ||||
$this->state = $state; | $this->state = $state; | ||||
/** @psalm-suppress UnusedFunctionCall */ | |||||
smbclient_option_set($this->state, SMBCLIENT_OPT_AUTO_ANONYMOUS_LOGIN, false); | smbclient_option_set($this->state, SMBCLIENT_OPT_AUTO_ANONYMOUS_LOGIN, false); | ||||
/** @psalm-suppress UnusedFunctionCall */ | |||||
smbclient_option_set($this->state, SMBCLIENT_OPT_TIMEOUT, $options->getTimeout() * 1000); | smbclient_option_set($this->state, SMBCLIENT_OPT_TIMEOUT, $options->getTimeout() * 1000); | ||||
if (function_exists('smbclient_client_protocols')) { | if (function_exists('smbclient_client_protocols')) { | ||||
$maxProtocol = $options->getMaxProtocol(); | |||||
$minProtocol = $options->getMinProtocol(); | |||||
smbclient_client_protocols($this->state, $minProtocol, $maxProtocol); | |||||
smbclient_client_protocols($this->state, $options->getMinProtocol(), $options->getMaxProtocol()); | |||||
} | } | ||||
$auth->setExtraSmbClientOptions($this->state); | $auth->setExtraSmbClientOptions($this->state); | ||||
public function __destruct() { | public function __destruct() { | ||||
if ($this->connected) { | if ($this->connected) { | ||||
smbclient_state_free($this->state); | |||||
if (smbclient_state_free($this->state) === false) { | |||||
throw new Exception("Failed to free smb state"); | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } |
* @return resource | * @return resource | ||||
*/ | */ | ||||
protected static function wrapClass(NativeState $state, $smbStream, string $mode, string $url, string $class) { | protected static function wrapClass(NativeState $state, $smbStream, string $mode, string $url, string $class) { | ||||
stream_wrapper_register('nativesmb', $class); | |||||
if (stream_wrapper_register('nativesmb', $class) === false) { | |||||
throw new Exception("Failed to register stream wrapper"); | |||||
} | |||||
$context = stream_context_create([ | $context = stream_context_create([ | ||||
'nativesmb' => [ | 'nativesmb' => [ | ||||
'state' => $state, | 'state' => $state, | ||||
] | ] | ||||
]); | ]); | ||||
$fh = fopen('nativesmb://', $mode, false, $context); | $fh = fopen('nativesmb://', $mode, false, $context); | ||||
stream_wrapper_unregister('nativesmb'); | |||||
if (stream_wrapper_unregister('nativesmb') === false) { | |||||
throw new Exception("Failed to unregister stream wrapper"); | |||||
} | |||||
return $fh; | return $fh; | ||||
} | } | ||||
} | } | ||||
public function read(int $count): string { | public function read(int $count): string { | ||||
$chunk = substr($this->buffer, $this->pos, $this->pos + $count); | |||||
$chunk = substr($this->buffer, $this->pos, $count); | |||||
$this->pos += strlen($chunk); | $this->pos += strlen($chunk); | ||||
return $chunk; | return $chunk; | ||||
} | } |
$shareNames = $parser->parseListShares($output); | $shareNames = $parser->parseListShares($output); | ||||
$shares = []; | $shares = []; | ||||
foreach ($shareNames as $name => $description) { | |||||
foreach ($shareNames as $name => $_description) { | |||||
$shares[] = $this->getShare($name); | $shares[] = $this->getShare($name); | ||||
} | } | ||||
return $shares; | return $shares; |