diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-04-20 11:04:32 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2016-04-20 11:04:32 +0200 |
commit | b54faa994b63c8732fc952586fb5200d7c1feb58 (patch) | |
tree | 643f6ba55e092a6af2199064ba72271746937881 /apps/files_external | |
parent | 2d59027064ed2121f11c580910244d5906f335a9 (diff) | |
parent | b88acd51d20ee1b820d9deb1cf556f37f73b715b (diff) | |
download | nextcloud-server-b54faa994b63c8732fc952586fb5200d7c1feb58.tar.gz nextcloud-server-b54faa994b63c8732fc952586fb5200d7c1feb58.zip |
Merge pull request #23363 from owncloud/smb-1.0.8-82
[8.2] update icewind/smb to 1.0.8
Diffstat (limited to 'apps/files_external')
19 files changed, 236 insertions, 58 deletions
diff --git a/apps/files_external/3rdparty/composer.json b/apps/files_external/3rdparty/composer.json index ad007df23de..13b5766f215 100644 --- a/apps/files_external/3rdparty/composer.json +++ b/apps/files_external/3rdparty/composer.json @@ -6,7 +6,7 @@ "vendor-dir": "." }, "require": { - "icewind/smb": "1.0.4", + "icewind/smb": "1.0.8", "icewind/streams": "0.2" } } diff --git a/apps/files_external/3rdparty/composer.lock b/apps/files_external/3rdparty/composer.lock index 033a5a17a13..51acd1dc4d1 100644 --- a/apps/files_external/3rdparty/composer.lock +++ b/apps/files_external/3rdparty/composer.lock @@ -4,28 +4,30 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "5c612406bc1235075305b09a5d6996a9", + "hash": "44a8cfa909a9a5273db4fea4a2d9bd69", + "content-hash": "9bd1a06cb9a4ee6cc48af41325383693", "packages": [ { "name": "icewind/smb", - "version": "v1.0.4", + "version": "v1.0.8", "source": { "type": "git", "url": "https://github.com/icewind1991/SMB.git", - "reference": "9277bd20262a01b38a33cc7356e98055f2262d32" + "reference": "764f3fc793a904eb937d619ad097fb076ff199cd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/icewind1991/SMB/zipball/9277bd20262a01b38a33cc7356e98055f2262d32", - "reference": "9277bd20262a01b38a33cc7356e98055f2262d32", + "url": "https://api.github.com/repos/icewind1991/SMB/zipball/764f3fc793a904eb937d619ad097fb076ff199cd", + "reference": "764f3fc793a904eb937d619ad097fb076ff199cd", "shasum": "" }, "require": { - "icewind/streams": "0.2.*", + "icewind/streams": ">=0.2.0", "php": ">=5.3" }, "require-dev": { - "satooshi/php-coveralls": "dev-master" + "phpunit/phpunit": "^4.8", + "satooshi/php-coveralls": "v1.0.0" }, "type": "library", "autoload": { @@ -45,7 +47,7 @@ } ], "description": "php wrapper for smbclient and libsmbclient-php", - "time": "2015-08-17 14:20:38" + "time": "2016-03-17 13:29:58" }, { "name": "icewind/streams", diff --git a/apps/files_external/3rdparty/composer/ClassLoader.php b/apps/files_external/3rdparty/composer/ClassLoader.php index 5e1469e8307..ff6ecfb822f 100644 --- a/apps/files_external/3rdparty/composer/ClassLoader.php +++ b/apps/files_external/3rdparty/composer/ClassLoader.php @@ -13,9 +13,7 @@ namespace Composer\Autoload; /** - * ClassLoader implements a PSR-0 class loader - * - * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. * * $loader = new \Composer\Autoload\ClassLoader(); * @@ -39,6 +37,8 @@ namespace Composer\Autoload; * * @author Fabien Potencier <fabien@symfony.com> * @author Jordi Boggiano <j.boggiano@seld.be> + * @see http://www.php-fig.org/psr/psr-0/ + * @see http://www.php-fig.org/psr/psr-4/ */ class ClassLoader { @@ -147,7 +147,7 @@ class ClassLoader * appending or prepending to the ones previously set for this namespace. * * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-0 base directories + * @param array|string $paths The PSR-4 base directories * @param bool $prepend Whether to prepend the directories * * @throws \InvalidArgumentException diff --git a/apps/files_external/3rdparty/composer/LICENSE b/apps/files_external/3rdparty/composer/LICENSE new file mode 100644 index 00000000000..c8d57af8b27 --- /dev/null +++ b/apps/files_external/3rdparty/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) 2015 Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/apps/files_external/3rdparty/composer/autoload_real.php b/apps/files_external/3rdparty/composer/autoload_real.php index 3391b322be0..d462110b1f2 100644 --- a/apps/files_external/3rdparty/composer/autoload_real.php +++ b/apps/files_external/3rdparty/composer/autoload_real.php @@ -43,8 +43,3 @@ class ComposerAutoloaderInit98fe9b281934250b3a93f69a5ce843b3 return $loader; } } - -function composerRequire98fe9b281934250b3a93f69a5ce843b3($file) -{ - require $file; -} diff --git a/apps/files_external/3rdparty/composer/installed.json b/apps/files_external/3rdparty/composer/installed.json index 89c8ed56529..613ee63f31a 100644 --- a/apps/files_external/3rdparty/composer/installed.json +++ b/apps/files_external/3rdparty/composer/installed.json @@ -43,27 +43,28 @@ }, { "name": "icewind/smb", - "version": "v1.0.4", - "version_normalized": "1.0.4.0", + "version": "v1.0.8", + "version_normalized": "1.0.8.0", "source": { "type": "git", "url": "https://github.com/icewind1991/SMB.git", - "reference": "9277bd20262a01b38a33cc7356e98055f2262d32" + "reference": "764f3fc793a904eb937d619ad097fb076ff199cd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/icewind1991/SMB/zipball/9277bd20262a01b38a33cc7356e98055f2262d32", - "reference": "9277bd20262a01b38a33cc7356e98055f2262d32", + "url": "https://api.github.com/repos/icewind1991/SMB/zipball/764f3fc793a904eb937d619ad097fb076ff199cd", + "reference": "764f3fc793a904eb937d619ad097fb076ff199cd", "shasum": "" }, "require": { - "icewind/streams": "0.2.*", + "icewind/streams": ">=0.2.0", "php": ">=5.3" }, "require-dev": { - "satooshi/php-coveralls": "dev-master" + "phpunit/phpunit": "^4.8", + "satooshi/php-coveralls": "v1.0.0" }, - "time": "2015-08-17 14:20:38", + "time": "2016-03-17 13:29:58", "type": "library", "installation-source": "source", "autoload": { diff --git a/apps/files_external/3rdparty/icewind/smb/README.md b/apps/files_external/3rdparty/icewind/smb/README.md index a0864717b09..32f3c650f87 100644 --- a/apps/files_external/3rdparty/icewind/smb/README.md +++ b/apps/files_external/3rdparty/icewind/smb/README.md @@ -75,7 +75,7 @@ $share = $server->getShare('test'); $content = $share->dir('test'); foreach ($content as $info) { - echo $name->getName() . "\n"; + echo $info->getName() . "\n"; echo "\tsize :" . $info->getSize() . "\n"; } ``` diff --git a/apps/files_external/3rdparty/icewind/smb/composer.json b/apps/files_external/3rdparty/icewind/smb/composer.json index 593eb728716..4ac8b27e725 100644 --- a/apps/files_external/3rdparty/icewind/smb/composer.json +++ b/apps/files_external/3rdparty/icewind/smb/composer.json @@ -10,10 +10,11 @@ ], "require" : { "php": ">=5.3", - "icewind/streams": "0.2.*" + "icewind/streams": ">=0.2.0" }, "require-dev": { - "satooshi/php-coveralls" : "dev-master" + "satooshi/php-coveralls" : "v1.0.0", + "phpunit/phpunit": "^4.8" }, "autoload" : { "psr-4": { diff --git a/apps/files_external/3rdparty/icewind/smb/src/Connection.php b/apps/files_external/3rdparty/icewind/smb/src/Connection.php index c857398c327..f48dcb766e4 100644 --- a/apps/files_external/3rdparty/icewind/smb/src/Connection.php +++ b/apps/files_external/3rdparty/icewind/smb/src/Connection.php @@ -39,13 +39,22 @@ class Connection extends RawConnection { if (!$this->isValid()) { throw new ConnectionException('Connection not valid'); } - $line = $this->readLine(); //first line is prompt - $this->checkConnectionError($line); + $promptLine = $this->readLine(); //first line is prompt + $this->checkConnectionError($promptLine); $output = array(); $line = $this->readLine(); if ($line === false) { - throw new ConnectException('Unknown error'); + if ($promptLine) { //maybe we have some error we missed on the previous line + throw new ConnectException('Unknown error (' . $promptLine . ')'); + } else { + $error = $this->readError(); // maybe something on stderr + if ($error) { + throw new ConnectException('Unknown error (' . $error . ')'); + } else { + throw new ConnectException('Unknown error'); + } + } } $length = mb_strlen(self::DELIMITER); while (mb_substr($line, 0, $length) !== self::DELIMITER) { //next prompt functions as delimiter diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidRequestException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidRequestException.php index 0dccd8b909e..882bf1677bf 100644 --- a/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidRequestException.php +++ b/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidRequestException.php @@ -18,7 +18,10 @@ class InvalidRequestException extends Exception { * @param int $code */ public function __construct($path, $code = 0) { - parent::__construct('Invalid request for ' . $path, $code); + $class = get_class($this); + $parts = explode('\\', $class); + $baseName = array_pop($parts); + parent::__construct('Invalid request for ' . $path . ' (' . $baseName . ')', $code); $this->path = $path; } diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidResourceException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidResourceException.php new file mode 100644 index 00000000000..b5fdb851cab --- /dev/null +++ b/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidResourceException.php @@ -0,0 +1,11 @@ +<?php +/** + * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Licensed under the MIT license: + * http://opensource.org/licenses/MIT + */ + +namespace Icewind\SMB\Exception; + +class InvalidResourceException extends Exception { +} diff --git a/apps/files_external/3rdparty/icewind/smb/src/NativeShare.php b/apps/files_external/3rdparty/icewind/smb/src/NativeShare.php index 1f1d225c00a..27d975514a3 100644 --- a/apps/files_external/3rdparty/icewind/smb/src/NativeShare.php +++ b/apps/files_external/3rdparty/icewind/smb/src/NativeShare.php @@ -7,6 +7,9 @@ namespace Icewind\SMB; +use Icewind\SMB\Exception\InvalidPathException; +use Icewind\SMB\Exception\InvalidResourceException; + class NativeShare extends AbstractShare { /** * @var Server $server @@ -193,11 +196,30 @@ class NativeShare extends AbstractShare { * * @throws \Icewind\SMB\Exception\NotFoundException * @throws \Icewind\SMB\Exception\InvalidTypeException + * @throws \Icewind\SMB\Exception\InvalidPathException + * @throws \Icewind\SMB\Exception\InvalidResourceException */ public function get($source, $target) { + if (!$target) { + throw new InvalidPathException('Invalid target path: Filename cannot be empty'); + } + $targetHandle = @fopen($target, 'wb'); + if (!$targetHandle) { + $error = error_get_last(); + if (is_array($error)) { + $reason = $error['message']; + } else { + $reason = 'Unknown error'; + } + throw new InvalidResourceException('Failed opening local file "' . $target . '" for writing: ' . $reason); + } + $this->connect(); $sourceHandle = $this->state->open($this->buildUrl($source), 'r'); - $targetHandle = fopen($target, 'wb'); + if (!$sourceHandle) { + fclose($targetHandle); + throw new InvalidResourceException('Failed opening remote file "' . $source . '" for reading'); + } while ($data = $this->state->read($sourceHandle, 4096)) { fwrite($targetHandle, $data); @@ -217,8 +239,9 @@ class NativeShare extends AbstractShare { */ public function read($source) { $this->connect(); - $handle = $this->state->open($this->buildUrl($source), 'r'); - return NativeStream::wrap($this->state, $handle, 'r'); + $url = $this->buildUrl($source); + $handle = $this->state->open($url, 'r'); + return NativeStream::wrap($this->state, $handle, 'r', $url); } /** @@ -232,8 +255,9 @@ class NativeShare extends AbstractShare { */ public function write($source) { $this->connect(); - $handle = $this->state->create($this->buildUrl($source)); - return NativeStream::wrap($this->state, $handle, 'w'); + $url = $this->buildUrl($source); + $handle = $this->state->create($url); + return NativeStream::wrap($this->state, $handle, 'w', $url); } /** diff --git a/apps/files_external/3rdparty/icewind/smb/src/NativeStream.php b/apps/files_external/3rdparty/icewind/smb/src/NativeStream.php index 07bd2f1e797..481395b025a 100644 --- a/apps/files_external/3rdparty/icewind/smb/src/NativeStream.php +++ b/apps/files_external/3rdparty/icewind/smb/src/NativeStream.php @@ -7,6 +7,7 @@ namespace Icewind\SMB; +use Icewind\SMB\Exception\Exception; use Icewind\SMB\Exception\InvalidRequestException; use Icewind\Streams\File; @@ -32,19 +33,26 @@ class NativeStream implements File { private $eof = false; /** + * @var string + */ + private $url; + + /** * Wrap a stream from libsmbclient-php into a regular php stream * * @param \Icewind\SMB\NativeState $state * @param resource $smbStream * @param string $mode + * @param string $url * @return resource */ - public static function wrap($state, $smbStream, $mode) { + public static function wrap($state, $smbStream, $mode, $url) { stream_wrapper_register('nativesmb', '\Icewind\SMB\NativeStream'); $context = stream_context_create(array( 'nativesmb' => array( 'state' => $state, - 'handle' => $smbStream + 'handle' => $smbStream, + 'url' => $url ) )); $fh = fopen('nativesmb://', $mode, false, $context); @@ -68,6 +76,7 @@ class NativeStream implements File { $context = stream_context_get_options($this->context); $this->state = $context['nativesmb']['state']; $this->handle = $context['nativesmb']['handle']; + $this->url = $context['nativesmb']['url']; return true; } @@ -89,7 +98,11 @@ class NativeStream implements File { } public function stream_stat() { - return $this->state->fstat($this->handle); + try { + return $this->state->stat($this->url); + } catch (Exception $e) { + return false; + } } public function stream_tell() { diff --git a/apps/files_external/3rdparty/icewind/smb/src/Parser.php b/apps/files_external/3rdparty/icewind/smb/src/Parser.php index 6af70143c52..fc1d7f283a8 100644 --- a/apps/files_external/3rdparty/icewind/smb/src/Parser.php +++ b/apps/files_external/3rdparty/icewind/smb/src/Parser.php @@ -11,6 +11,7 @@ use Icewind\SMB\Exception\AccessDeniedException; use Icewind\SMB\Exception\AlreadyExistsException; use Icewind\SMB\Exception\Exception; use Icewind\SMB\Exception\FileInUseException; +use Icewind\SMB\Exception\InvalidResourceException; use Icewind\SMB\Exception\InvalidTypeException; use Icewind\SMB\Exception\NotEmptyException; use Icewind\SMB\Exception\NotFoundException; @@ -42,6 +43,13 @@ class Parser { $error = $part; } } + + $notFoundMsg = 'Error opening local file '; + if (substr($output[0], 0, strlen($notFoundMsg)) === $notFoundMsg) { + $localPath = substr($output[0], strlen($notFoundMsg)); + throw new InvalidResourceException('Failed opening local file "' . $localPath . '" for writing'); + } + switch ($error) { case ErrorCodes::PathNotFound: case ErrorCodes::ObjectNotFound: diff --git a/apps/files_external/3rdparty/icewind/smb/src/RawConnection.php b/apps/files_external/3rdparty/icewind/smb/src/RawConnection.php index 15478511a72..88ab046ef38 100644 --- a/apps/files_external/3rdparty/icewind/smb/src/RawConnection.php +++ b/apps/files_external/3rdparty/icewind/smb/src/RawConnection.php @@ -95,6 +95,15 @@ class RawConnection { } /** + * read a line of output + * + * @return string + */ + public function readError() { + return trim(stream_get_line($this->getErrorStream(), 4086)); + } + + /** * get all output until the process closes * * @return array diff --git a/apps/files_external/3rdparty/icewind/smb/src/Server.php b/apps/files_external/3rdparty/icewind/smb/src/Server.php index bbc0475d5e4..25f17201397 100644 --- a/apps/files_external/3rdparty/icewind/smb/src/Server.php +++ b/apps/files_external/3rdparty/icewind/smb/src/Server.php @@ -11,7 +11,6 @@ use Icewind\SMB\Exception\AuthenticationException; use Icewind\SMB\Exception\InvalidHostException; class Server { - const CLIENT = 'smbclient'; const LOCALE = 'en_US.UTF-8'; /** @@ -35,6 +34,16 @@ class Server { protected $workgroup; /** + * @var \Icewind\SMB\System + */ + private $system; + + /** + * @var TimeZoneProvider + */ + private $timezoneProvider; + + /** * Check if the smbclient php extension is available * * @return bool @@ -54,6 +63,8 @@ class Server { $this->user = $user; $this->workgroup = $workgroup; $this->password = $password; + $this->system = new System(); + $this->timezoneProvider = new TimeZoneProvider($host, $this->system); } /** @@ -115,8 +126,12 @@ class Server { */ public function listShares() { $workgroupArgument = ($this->workgroup) ? ' -W ' . escapeshellarg($this->workgroup) : ''; - $command = Server::CLIENT . $workgroupArgument . ' --authentication-file=/proc/self/fd/3' . - ' -gL ' . escapeshellarg($this->getHost()); + $command = sprintf('%s %s --authentication-file=%s -gL %s', + $this->system->getSmbclientPath(), + $workgroupArgument, + System::getFD(3), + escapeshellarg($this->getHost()) + ); $connection = new RawConnection($command); $connection->writeAuthentication($this->getUser(), $this->getPassword()); $output = $connection->readAll(); @@ -166,7 +181,6 @@ class Server { * @return string */ public function getTimeZone() { - $command = 'net time zone -S ' . escapeshellarg($this->getHost()); - return exec($command); + return $this->timezoneProvider->get(); } } diff --git a/apps/files_external/3rdparty/icewind/smb/src/Share.php b/apps/files_external/3rdparty/icewind/smb/src/Share.php index d9ab729025d..694bd30bd0d 100644 --- a/apps/files_external/3rdparty/icewind/smb/src/Share.php +++ b/apps/files_external/3rdparty/icewind/smb/src/Share.php @@ -35,6 +35,11 @@ class Share extends AbstractShare { protected $parser; /** + * @var \Icewind\SMB\System + */ + private $system; + + /** * @param Server $server * @param string $name */ @@ -42,7 +47,8 @@ class Share extends AbstractShare { parent::__construct(); $this->server = $server; $this->name = $name; - $this->parser = new Parser(new TimeZoneProvider($this->server->getHost())); + $this->system = new System(); + $this->parser = new Parser(new TimeZoneProvider($this->server->getHost(), $this->system)); } /** @@ -55,9 +61,10 @@ class Share extends AbstractShare { return; } $workgroupArgument = ($this->server->getWorkgroup()) ? ' -W ' . escapeshellarg($this->server->getWorkgroup()) : ''; - $command = sprintf('%s %s --authentication-file=/proc/self/fd/3 %s', - Server::CLIENT, + $command = sprintf('%s %s --authentication-file=%s %s', + $this->system->getSmbclientPath(), $workgroupArgument, + System::getFD(3), escapeshellarg('//' . $this->server->getHost() . '/' . $this->name) ); $this->connection = new Connection($command); @@ -257,14 +264,15 @@ class Share extends AbstractShare { // since returned stream is closed by the caller we need to create a new instance // since we can't re-use the same file descriptor over multiple calls $workgroupArgument = ($this->server->getWorkgroup()) ? ' -W ' . escapeshellarg($this->server->getWorkgroup()) : ''; - $command = sprintf('%s %s --authentication-file=/proc/self/fd/3 %s', - Server::CLIENT, + $command = sprintf('%s %s --authentication-file=%s %s', + $this->system->getSmbclientPath(), $workgroupArgument, + System::getFD(3), escapeshellarg('//' . $this->server->getHost() . '/' . $this->name) ); $connection = new Connection($command); $connection->writeAuthentication($this->server->getUser(), $this->server->getPassword()); - $connection->write('get ' . $source . ' /proc/self/fd/5'); + $connection->write('get ' . $source . ' ' . System::getFD(5)); $connection->write('exit'); $fh = $connection->getFileOutputStream(); stream_context_set_option($fh, 'file', 'connection', $connection); @@ -285,16 +293,17 @@ class Share extends AbstractShare { // since returned stream is closed by the caller we need to create a new instance // since we can't re-use the same file descriptor over multiple calls $workgroupArgument = ($this->server->getWorkgroup()) ? ' -W ' . escapeshellarg($this->server->getWorkgroup()) : ''; - $command = sprintf('%s %s --authentication-file=/proc/self/fd/3 %s', - Server::CLIENT, + $command = sprintf('%s %s --authentication-file=%s %s', + $this->system->getSmbclientPath(), $workgroupArgument, + System::getFD(3), escapeshellarg('//' . $this->server->getHost() . '/' . $this->name) ); $connection = new Connection($command); $connection->writeAuthentication($this->server->getUser(), $this->server->getPassword()); $fh = $connection->getFileInputStream(); - $connection->write('put /proc/self/fd/4 ' . $target); + $connection->write('put ' . System::getFD(4) . ' ' . $target); $connection->write('exit'); // use a close callback to ensure the upload is finished before continuing diff --git a/apps/files_external/3rdparty/icewind/smb/src/System.php b/apps/files_external/3rdparty/icewind/smb/src/System.php new file mode 100644 index 00000000000..192a0b3877d --- /dev/null +++ b/apps/files_external/3rdparty/icewind/smb/src/System.php @@ -0,0 +1,43 @@ +<?php +/** + * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Licensed under the MIT license: + * http://opensource.org/licenses/MIT + */ + +namespace Icewind\SMB; + +use Icewind\SMB\Exception\Exception; + +class System { + private $smbclient; + + private $net; + + public static function getFD($num) { + $folders = array( + '/proc/self/fd', + '/dev/fd' + ); + foreach ($folders as $folder) { + if (file_exists($folder)) { + return $folder . '/' . $num; + } + } + throw new Exception('Cant find file descriptor path'); + } + + public function getSmbclientPath() { + if (!$this->smbclient) { + $this->smbclient = trim(`which smbclient`); + } + return $this->smbclient; + } + + public function getNetPath() { + if (!$this->net) { + $this->net = trim(`which net`); + } + return $this->net; + } +} diff --git a/apps/files_external/3rdparty/icewind/smb/src/TimeZoneProvider.php b/apps/files_external/3rdparty/icewind/smb/src/TimeZoneProvider.php index 22406a4f956..86d7859a6f7 100644 --- a/apps/files_external/3rdparty/icewind/smb/src/TimeZoneProvider.php +++ b/apps/files_external/3rdparty/icewind/smb/src/TimeZoneProvider.php @@ -19,16 +19,31 @@ class TimeZoneProvider { private $timeZone; /** + * @var System + */ + private $system; + + /** * @param string $host + * @param System $system */ - function __construct($host) { + function __construct($host, System $system) { $this->host = $host; + $this->system = $system; } public function get() { if (!$this->timeZone) { - $command = 'net time zone -S ' . escapeshellarg($this->host); - $this->timeZone = exec($command); + $net = $this->system->getNetPath(); + if ($net) { + $command = sprintf('%s time zone -S %s', + $net, + escapeshellarg($this->host) + ); + $this->timeZone = exec($command); + } else { // fallback to server timezone + $this->timeZone = date_default_timezone_get(); + } } return $this->timeZone; } |