]> source.dussan.org Git - nextcloud-server.git/commitdiff
update icewind/smb to 2.0.3 7774/head
authorRobin Appelman <robin@icewind.nl>
Wed, 10 Jan 2018 11:18:35 +0000 (12:18 +0100)
committerRobin Appelman <robin@icewind.nl>
Wed, 10 Jan 2018 11:18:35 +0000 (12:18 +0100)
Signed-off-by: Robin Appelman <robin@icewind.nl>
17 files changed:
apps/files_external/3rdparty/composer.json
apps/files_external/3rdparty/composer.lock
apps/files_external/3rdparty/composer/ClassLoader.php
apps/files_external/3rdparty/composer/autoload_classmap.php
apps/files_external/3rdparty/composer/autoload_static.php
apps/files_external/3rdparty/composer/installed.json
apps/files_external/3rdparty/icewind/smb/src/ErrorCodes.php
apps/files_external/3rdparty/icewind/smb/src/Exception/Exception.php
apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidParameterException.php [new file with mode: 0644]
apps/files_external/3rdparty/icewind/smb/src/Exception/OutOfSpaceException.php [new file with mode: 0644]
apps/files_external/3rdparty/icewind/smb/src/Exception/RevisionMismatchException.php [new file with mode: 0644]
apps/files_external/3rdparty/icewind/smb/src/NativeState.php
apps/files_external/3rdparty/icewind/smb/src/NotifyHandler.php
apps/files_external/3rdparty/icewind/smb/src/Parser.php
apps/files_external/3rdparty/icewind/smb/src/RawConnection.php
apps/files_external/3rdparty/icewind/smb/src/Server.php
apps/files_external/3rdparty/icewind/smb/src/Share.php

index f1613f0c70b27e692983481d4a2e32ec63412b8f..307a062c7e0e001efbc8ee90a5533b8c4f0b14a8 100644 (file)
@@ -8,7 +8,7 @@
                "classmap-authoritative": true
        },
        "require": {
-               "icewind/smb": "2.0.2",
+               "icewind/smb": "2.0.3",
                "icewind/streams": "0.5.2"
        }
 }
index 0cf5cabdc196b671097af6aa896c67f5a5aa9653..e00a7bd80e41b416738793d00607aa3a3c2f2613 100644 (file)
@@ -4,20 +4,20 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "content-hash": "85f8c3519f909ded38d917d3901f2709",
+    "content-hash": "b6a304e8ab2effa3791b513007fadcbc",
     "packages": [
         {
             "name": "icewind/smb",
-            "version": "v2.0.2",
+            "version": "v2.0.3",
             "source": {
                 "type": "git",
                 "url": "https://github.com/icewind1991/SMB.git",
-                "reference": "6691355d9314ac3a8cb9ec9446e4c26e8aab09d0"
+                "reference": "8394551bf29a37b884edb33dae8acde369177f32"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/icewind1991/SMB/zipball/6691355d9314ac3a8cb9ec9446e4c26e8aab09d0",
-                "reference": "6691355d9314ac3a8cb9ec9446e4c26e8aab09d0",
+                "url": "https://api.github.com/repos/icewind1991/SMB/zipball/8394551bf29a37b884edb33dae8acde369177f32",
+                "reference": "8394551bf29a37b884edb33dae8acde369177f32",
                 "shasum": ""
             },
             "require": {
@@ -45,7 +45,7 @@
                 }
             ],
             "description": "php wrapper for smbclient and libsmbclient-php",
-            "time": "2017-08-16T16:08:57+00:00"
+            "time": "2017-10-18T16:21:10+00:00"
         },
         {
             "name": "icewind/streams",
index 2c72175e7723ad0c73fd3154eb0fecc420810448..c6f6d2322bb369d95560b4ef0799ce0b30b6fdf0 100644 (file)
@@ -43,7 +43,8 @@ namespace Composer\Autoload;
 class ClassLoader
 {
     // PSR-4
-    private $prefixLengthsPsr4 = array();
+    private $firstCharsPsr4 = array();
+    private $prefixLengthsPsr4 = array(); // For BC with legacy static maps
     private $prefixDirsPsr4 = array();
     private $fallbackDirsPsr4 = array();
 
@@ -170,11 +171,10 @@ class ClassLoader
             }
         } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
             // Register directories for a new namespace.
-            $length = strlen($prefix);
-            if ('\\' !== $prefix[$length - 1]) {
+            if ('\\' !== substr($prefix, -1)) {
                 throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
             }
-            $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
+            $this->firstCharsPsr4[$prefix[0]] = true;
             $this->prefixDirsPsr4[$prefix] = (array) $paths;
         } elseif ($prepend) {
             // Prepend directories for an already registered namespace.
@@ -221,11 +221,10 @@ class ClassLoader
         if (!$prefix) {
             $this->fallbackDirsPsr4 = (array) $paths;
         } else {
-            $length = strlen($prefix);
-            if ('\\' !== $prefix[$length - 1]) {
+            if ('\\' !== substr($prefix, -1)) {
                 throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
             }
-            $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
+            $this->firstCharsPsr4[$prefix[0]] = true;
             $this->prefixDirsPsr4[$prefix] = (array) $paths;
         }
     }
@@ -373,15 +372,15 @@ class ClassLoader
         $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
 
         $first = $class[0];
-        if (isset($this->prefixLengthsPsr4[$first])) {
+        if (isset($this->firstCharsPsr4[$first]) || isset($this->prefixLengthsPsr4[$first])) {
             $subPath = $class;
             while (false !== $lastPos = strrpos($subPath, '\\')) {
                 $subPath = substr($subPath, 0, $lastPos);
                 $search = $subPath.'\\';
                 if (isset($this->prefixDirsPsr4[$search])) {
+                    $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
                     foreach ($this->prefixDirsPsr4[$search] as $dir) {
-                        $length = $this->prefixLengthsPsr4[$first][$search];
-                        if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
+                        if (file_exists($file = $dir . $pathEnd)) {
                             return $file;
                         }
                     }
index 4c596a44418a584ace657ca34cca3b463f3e33b9..257bdb64eb5cf90f1a62d597a1f36ffa18aba3f2 100644 (file)
@@ -22,6 +22,7 @@ return array(
     'Icewind\\SMB\\Exception\\ForbiddenException' => $vendorDir . '/icewind/smb/src/Exception/ForbiddenException.php',
     'Icewind\\SMB\\Exception\\HostDownException' => $vendorDir . '/icewind/smb/src/Exception/HostDownException.php',
     'Icewind\\SMB\\Exception\\InvalidHostException' => $vendorDir . '/icewind/smb/src/Exception/InvalidHostException.php',
+    'Icewind\\SMB\\Exception\\InvalidParameterException' => $vendorDir . '/icewind/smb/src/Exception/InvalidParameterException.php',
     'Icewind\\SMB\\Exception\\InvalidPathException' => $vendorDir . '/icewind/smb/src/Exception/InvalidPathException.php',
     'Icewind\\SMB\\Exception\\InvalidRequestException' => $vendorDir . '/icewind/smb/src/Exception/InvalidRequestException.php',
     'Icewind\\SMB\\Exception\\InvalidResourceException' => $vendorDir . '/icewind/smb/src/Exception/InvalidResourceException.php',
@@ -30,6 +31,8 @@ return array(
     'Icewind\\SMB\\Exception\\NoRouteToHostException' => $vendorDir . '/icewind/smb/src/Exception/NoRouteToHostException.php',
     'Icewind\\SMB\\Exception\\NotEmptyException' => $vendorDir . '/icewind/smb/src/Exception/NotEmptyException.php',
     'Icewind\\SMB\\Exception\\NotFoundException' => $vendorDir . '/icewind/smb/src/Exception/NotFoundException.php',
+    'Icewind\\SMB\\Exception\\OutOfSpaceException' => $vendorDir . '/icewind/smb/src/Exception/OutOfSpaceException.php',
+    'Icewind\\SMB\\Exception\\RevisionMismatchException' => $vendorDir . '/icewind/smb/src/Exception/RevisionMismatchException.php',
     'Icewind\\SMB\\Exception\\TimedOutException' => $vendorDir . '/icewind/smb/src/Exception/TimedOutException.php',
     'Icewind\\SMB\\FileInfo' => $vendorDir . '/icewind/smb/src/FileInfo.php',
     'Icewind\\SMB\\IFileInfo' => $vendorDir . '/icewind/smb/src/IFileInfo.php',
index 459de971c4e4f767524175cf6a49e6fa508e986a..5315a31a3eb383878c4f96c00d0ef5086a67aa41 100644 (file)
@@ -6,14 +6,8 @@ namespace Composer\Autoload;
 
 class ComposerStaticInit98fe9b281934250b3a93f69a5ce843b3
 {
-    public static $prefixLengthsPsr4 = array (
-        'I' => 
-        array (
-            'Icewind\\Streams\\Tests\\' => 22,
-            'Icewind\\Streams\\' => 16,
-            'Icewind\\SMB\\Test\\' => 17,
-            'Icewind\\SMB\\' => 12,
-        ),
+    public static $firstCharsPsr4 = array (
+        'I' => true,
     );
 
     public static $prefixDirsPsr4 = array (
@@ -52,6 +46,7 @@ class ComposerStaticInit98fe9b281934250b3a93f69a5ce843b3
         'Icewind\\SMB\\Exception\\ForbiddenException' => __DIR__ . '/..' . '/icewind/smb/src/Exception/ForbiddenException.php',
         'Icewind\\SMB\\Exception\\HostDownException' => __DIR__ . '/..' . '/icewind/smb/src/Exception/HostDownException.php',
         'Icewind\\SMB\\Exception\\InvalidHostException' => __DIR__ . '/..' . '/icewind/smb/src/Exception/InvalidHostException.php',
+        'Icewind\\SMB\\Exception\\InvalidParameterException' => __DIR__ . '/..' . '/icewind/smb/src/Exception/InvalidParameterException.php',
         'Icewind\\SMB\\Exception\\InvalidPathException' => __DIR__ . '/..' . '/icewind/smb/src/Exception/InvalidPathException.php',
         'Icewind\\SMB\\Exception\\InvalidRequestException' => __DIR__ . '/..' . '/icewind/smb/src/Exception/InvalidRequestException.php',
         'Icewind\\SMB\\Exception\\InvalidResourceException' => __DIR__ . '/..' . '/icewind/smb/src/Exception/InvalidResourceException.php',
@@ -60,6 +55,8 @@ class ComposerStaticInit98fe9b281934250b3a93f69a5ce843b3
         'Icewind\\SMB\\Exception\\NoRouteToHostException' => __DIR__ . '/..' . '/icewind/smb/src/Exception/NoRouteToHostException.php',
         'Icewind\\SMB\\Exception\\NotEmptyException' => __DIR__ . '/..' . '/icewind/smb/src/Exception/NotEmptyException.php',
         'Icewind\\SMB\\Exception\\NotFoundException' => __DIR__ . '/..' . '/icewind/smb/src/Exception/NotFoundException.php',
+        'Icewind\\SMB\\Exception\\OutOfSpaceException' => __DIR__ . '/..' . '/icewind/smb/src/Exception/OutOfSpaceException.php',
+        'Icewind\\SMB\\Exception\\RevisionMismatchException' => __DIR__ . '/..' . '/icewind/smb/src/Exception/RevisionMismatchException.php',
         'Icewind\\SMB\\Exception\\TimedOutException' => __DIR__ . '/..' . '/icewind/smb/src/Exception/TimedOutException.php',
         'Icewind\\SMB\\FileInfo' => __DIR__ . '/..' . '/icewind/smb/src/FileInfo.php',
         'Icewind\\SMB\\IFileInfo' => __DIR__ . '/..' . '/icewind/smb/src/IFileInfo.php',
@@ -120,7 +117,7 @@ class ComposerStaticInit98fe9b281934250b3a93f69a5ce843b3
     public static function getInitializer(ClassLoader $loader)
     {
         return \Closure::bind(function () use ($loader) {
-            $loader->prefixLengthsPsr4 = ComposerStaticInit98fe9b281934250b3a93f69a5ce843b3::$prefixLengthsPsr4;
+            $loader->firstCharsPsr4 = ComposerStaticInit98fe9b281934250b3a93f69a5ce843b3::$firstCharsPsr4;
             $loader->prefixDirsPsr4 = ComposerStaticInit98fe9b281934250b3a93f69a5ce843b3::$prefixDirsPsr4;
             $loader->classMap = ComposerStaticInit98fe9b281934250b3a93f69a5ce843b3::$classMap;
 
index aafe1591fa8572122a51ac6875ae1282be46ab9d..8183ba7bb0dc31a77a17307dcabc18bf944ac14b 100644 (file)
@@ -1,33 +1,33 @@
 [
     {
-        "name": "icewind/streams",
-        "version": "0.5.2",
-        "version_normalized": "0.5.2.0",
+        "name": "icewind/smb",
+        "version": "v2.0.3",
+        "version_normalized": "2.0.3.0",
         "source": {
             "type": "git",
-            "url": "https://github.com/icewind1991/Streams.git",
-            "reference": "6bfd2fdbd99319f5e010d0a684409189a562cb1e"
+            "url": "https://github.com/icewind1991/SMB.git",
+            "reference": "8394551bf29a37b884edb33dae8acde369177f32"
         },
         "dist": {
             "type": "zip",
-            "url": "https://api.github.com/repos/icewind1991/Streams/zipball/6bfd2fdbd99319f5e010d0a684409189a562cb1e",
-            "reference": "6bfd2fdbd99319f5e010d0a684409189a562cb1e",
+            "url": "https://api.github.com/repos/icewind1991/SMB/zipball/8394551bf29a37b884edb33dae8acde369177f32",
+            "reference": "8394551bf29a37b884edb33dae8acde369177f32",
             "shasum": ""
         },
         "require": {
-            "php": ">=5.3"
+            "icewind/streams": ">=0.2.0",
+            "php": ">=5.4"
         },
         "require-dev": {
-            "phpunit/phpunit": "^4.8",
-            "satooshi/php-coveralls": "v1.0.0"
+            "phpunit/phpunit": "^4.8"
         },
-        "time": "2016-12-02T14:21:23+00:00",
+        "time": "2017-10-18T16:21:10+00:00",
         "type": "library",
-        "installation-source": "dist",
+        "installation-source": "source",
         "autoload": {
             "psr-4": {
-                "Icewind\\Streams\\Tests\\": "tests/",
-                "Icewind\\Streams\\": "src/"
+                "Icewind\\SMB\\": "src/",
+                "Icewind\\SMB\\Test\\": "tests/"
             }
         },
         "notification-url": "https://packagist.org/downloads/",
                 "email": "icewind@owncloud.com"
             }
         ],
-        "description": "A set of generic stream wrappers"
+        "description": "php wrapper for smbclient and libsmbclient-php"
     },
     {
-        "name": "icewind/smb",
-        "version": "v2.0.2",
-        "version_normalized": "2.0.2.0",
+        "name": "icewind/streams",
+        "version": "0.5.2",
+        "version_normalized": "0.5.2.0",
         "source": {
             "type": "git",
-            "url": "https://github.com/icewind1991/SMB.git",
-            "reference": "6691355d9314ac3a8cb9ec9446e4c26e8aab09d0"
+            "url": "https://github.com/icewind1991/Streams.git",
+            "reference": "6bfd2fdbd99319f5e010d0a684409189a562cb1e"
         },
         "dist": {
             "type": "zip",
-            "url": "https://api.github.com/repos/icewind1991/SMB/zipball/6691355d9314ac3a8cb9ec9446e4c26e8aab09d0",
-            "reference": "6691355d9314ac3a8cb9ec9446e4c26e8aab09d0",
+            "url": "https://api.github.com/repos/icewind1991/Streams/zipball/6bfd2fdbd99319f5e010d0a684409189a562cb1e",
+            "reference": "6bfd2fdbd99319f5e010d0a684409189a562cb1e",
             "shasum": ""
         },
         "require": {
-            "icewind/streams": ">=0.2.0",
-            "php": ">=5.4"
+            "php": ">=5.3"
         },
         "require-dev": {
-            "phpunit/phpunit": "^4.8"
+            "phpunit/phpunit": "^4.8",
+            "satooshi/php-coveralls": "v1.0.0"
         },
-        "time": "2017-08-16T16:08:57+00:00",
+        "time": "2016-12-02T14:21:23+00:00",
         "type": "library",
-        "installation-source": "source",
+        "installation-source": "dist",
         "autoload": {
             "psr-4": {
-                "Icewind\\SMB\\": "src/",
-                "Icewind\\SMB\\Test\\": "tests/"
+                "Icewind\\Streams\\Tests\\": "tests/",
+                "Icewind\\Streams\\": "src/"
             }
         },
         "notification-url": "https://packagist.org/downloads/",
@@ -83,6 +83,6 @@
                 "email": "icewind@owncloud.com"
             }
         ],
-        "description": "php wrapper for smbclient and libsmbclient-php"
+        "description": "A set of generic stream wrappers"
     }
 ]
index 03bd574c185a7a3e9e2d734e2c00222b461f3cea..d36cdaf2c7d59538dd7c5949fcdf13571f88f71b 100644 (file)
@@ -15,7 +15,7 @@ class ErrorCodes {
        const BadHostName = 'NT_STATUS_BAD_NETWORK_NAME';
        const Unsuccessful = 'NT_STATUS_UNSUCCESSFUL';
        const ConnectionRefused = 'NT_STATUS_CONNECTION_REFUSED';
-       const NoLogonServers =  'NT_STATUS_NO_LOGON_SERVERS';
+       const NoLogonServers = 'NT_STATUS_NO_LOGON_SERVERS';
 
        const PathNotFound = 'NT_STATUS_OBJECT_PATH_NOT_FOUND';
        const NoSuchFile = 'NT_STATUS_NO_SUCH_FILE';
@@ -26,4 +26,6 @@ class ErrorCodes {
        const FileIsADirectory = 'NT_STATUS_FILE_IS_A_DIRECTORY';
        const NotADirectory = 'NT_STATUS_NOT_A_DIRECTORY';
        const SharingViolation = 'NT_STATUS_SHARING_VIOLATION';
+       const InvalidParameter = 'NT_STATUS_INVALID_PARAMETER';
+       const RevisionMismatch = 'NT_STATUS_REVISION_MISMATCH';
 }
index 7ac528198a953377f3e9d7c38b8d0c0e1450fa6b..93f2c1b3e2e16c9893805bf32ca3729f5d633dd7 100644 (file)
@@ -14,7 +14,7 @@ class Exception extends \Exception {
                        $message .= ' for ' . $path;
                }
 
-               return new Exception($message, $error);
+               return new Exception($message, is_string($error) ? 0 : $error);
        }
 
        /**
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidParameterException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/InvalidParameterException.php
new file mode 100644 (file)
index 0000000..163b571
--- /dev/null
@@ -0,0 +1,10 @@
+<?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 InvalidParameterException extends InvalidRequestException {}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/OutOfSpaceException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/OutOfSpaceException.php
new file mode 100644 (file)
index 0000000..4c5517a
--- /dev/null
@@ -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 OutOfSpaceException extends InvalidRequestException {
+}
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Exception/RevisionMismatchException.php b/apps/files_external/3rdparty/icewind/smb/src/Exception/RevisionMismatchException.php
new file mode 100644 (file)
index 0000000..e898b5a
--- /dev/null
@@ -0,0 +1,16 @@
+<?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;
+
+use Throwable;
+
+class RevisionMismatchException extends Exception {
+       public function __construct($message = 'Protocol version mismatch', $code = 0, Throwable $previous = null) {
+               parent::__construct($message, $code, $previous);
+       }
+}
index 7ddce831853262d59be34c25a8e2c064bf510ebd..45e0441d2523e57400a7626e53fd72cece61609f 100644 (file)
@@ -31,6 +31,7 @@ class NativeState {
                17  => '\Icewind\SMB\Exception\AlreadyExistsException',
                20  => '\Icewind\SMB\Exception\InvalidTypeException',
                21  => '\Icewind\SMB\Exception\InvalidTypeException',
+               28  => '\Icewind\SMB\Exception\OutOfSpaceException',
                39  => '\Icewind\SMB\Exception\NotEmptyException',
                110 => '\Icewind\SMB\Exception\TimedOutException',
                111 => '\Icewind\SMB\Exception\ConnectionRefusedException',
index 6ad565555bff84c650273955051806635be17547..20ada5cf32068cab7476a7dcc66599974c23e693 100644 (file)
@@ -9,6 +9,8 @@
 namespace Icewind\SMB;
 
 
+use Icewind\SMB\Exception\Exception;
+
 class NotifyHandler implements INotifyHandler {
        /**
         * @var Connection
@@ -22,6 +24,12 @@ class NotifyHandler implements INotifyHandler {
 
        private $listening = true;
 
+       // todo replace with static once <5.6 support is dropped
+       // see error.h
+       private static $exceptionMap = [
+               ErrorCodes::RevisionMismatch => '\Icewind\SMB\Exception\RevisionMismatchException',
+       ];
+
        /**
         * @param Connection $connection
         * @param string $path
@@ -43,6 +51,7 @@ class NotifyHandler implements INotifyHandler {
                stream_set_blocking($this->connection->getOutputStream(), 0);
                $lines = [];
                while (($line = $this->connection->readLine())) {
+                       $this->checkForError($line);
                        $lines[] = $line;
                }
                stream_set_blocking($this->connection->getOutputStream(), 1);
@@ -59,6 +68,7 @@ class NotifyHandler implements INotifyHandler {
        public function listen($callback) {
                if ($this->listening) {
                        $this->connection->read(function ($line) use ($callback) {
+                               $this->checkForError($line);
                                $change = $this->parseChangeLine($line);
                                if ($change) {
                                        return $callback($change);
@@ -80,6 +90,13 @@ class NotifyHandler implements INotifyHandler {
                }
        }
 
+       private function checkForError($line) {
+               if (substr($line, 0, 16) === 'notify returned ') {
+                       $error = substr($line, 16);
+                       throw Exception::fromMap(self::$exceptionMap, $error, 'Notify is not supported with the used smb version');
+               }
+       }
+
        public function stop() {
                $this->listening = false;
                $this->connection->close();
index 5cc5acbdf5616eaef48721f4ab0d9c9ca061efef..3142f9c29e042ce88b840dc8278516cf6c736ade 100644 (file)
@@ -30,6 +30,7 @@ class Parser {
        // todo replace with static once <5.6 support is dropped
        // see error.h
        private static $exceptionMap = [
+               ErrorCodes::LogonFailure      => '\Icewind\SMB\Exception\AuthenticationException',
                ErrorCodes::PathNotFound      => '\Icewind\SMB\Exception\NotFoundException',
                ErrorCodes::ObjectNotFound    => '\Icewind\SMB\Exception\NotFoundException',
                ErrorCodes::NoSuchFile        => '\Icewind\SMB\Exception\NotFoundException',
@@ -38,7 +39,8 @@ class Parser {
                ErrorCodes::DirectoryNotEmpty => '\Icewind\SMB\Exception\NotEmptyException',
                ErrorCodes::FileIsADirectory  => '\Icewind\SMB\Exception\InvalidTypeException',
                ErrorCodes::NotADirectory     => '\Icewind\SMB\Exception\InvalidTypeException',
-               ErrorCodes::SharingViolation  => '\Icewind\SMB\Exception\FileInUseException'
+               ErrorCodes::SharingViolation  => '\Icewind\SMB\Exception\FileInUseException',
+               ErrorCodes::InvalidParameter  => '\Icewind\SMB\Exception\InvalidParameterException'
        ];
 
        /**
index e9349716430c10d12d57322d4e2fa3bd0dc29bfd..42923f09eda4d836f677caed6105b67d53e74938 100644 (file)
@@ -7,6 +7,7 @@
 
 namespace Icewind\SMB;
 
+use Icewind\SMB\Exception\ConnectException;
 use Icewind\SMB\Exception\ConnectionException;
 
 class RawConnection {
@@ -25,6 +26,9 @@ class RawConnection {
         *
         * $pipes[0] holds STDIN for smbclient
         * $pipes[1] holds STDOUT for smbclient
+        * $pipes[3] holds the authfile for smbclient
+        * $pipes[4] holds the stream for writing files
+        * $pipes[5] holds the stream for reading files
         */
        private $pipes;
 
@@ -33,32 +37,44 @@ class RawConnection {
         */
        private $process;
 
-       public function __construct($command, $env = array()) {
+       /**
+        * @var resource|null $authStream
+        */
+       private $authStream = null;
+
+       private $connected = false;
+
+       public function __construct($command, array $env = []) {
                $this->command = $command;
                $this->env = $env;
-               $this->connect();
        }
 
-       private function connect() {
-               $descriptorSpec = array(
-                       0 => array('pipe', 'r'), // child reads from stdin
-                       1 => array('pipe', 'w'), // child writes to stdout
-                       2 => array('pipe', 'w'), // child writes to stderr
-                       3 => array('pipe', 'r'), // child reads from fd#3
-                       4 => array('pipe', 'r'), // child reads from fd#4
-                       5 => array('pipe', 'w')  // child writes to fd#5
-               );
+       public function connect() {
+               if (is_null($this->getAuthStream())) {
+                       throw new ConnectException('Authentication not set before connecting');
+               }
+
+               $descriptorSpec = [
+                       0 => ['pipe', 'r'], // child reads from stdin
+                       1 => ['pipe', 'w'], // child writes to stdout
+                       2 => ['pipe', 'w'], // child writes to stderr
+                       3 => $this->getAuthStream(), // child reads from fd#3
+                       4 => ['pipe', 'r'], // child reads from fd#4
+                       5 => ['pipe', 'w']  // child writes to fd#5
+               ];
+
                setlocale(LC_ALL, Server::LOCALE);
-               $env = array_merge($this->env, array(
+               $env = array_merge($this->env, [
                        'CLI_FORCE_INTERACTIVE' => 'y', // Needed or the prompt isn't displayed!!
-                       'LC_ALL' => Server::LOCALE,
-                       'LANG' => Server::LOCALE,
-                       'COLUMNS' => 8192 // prevent smbclient from line-wrapping it's output
-               ));
+                       'LC_ALL'                => Server::LOCALE,
+                       'LANG'                  => Server::LOCALE,
+                       'COLUMNS'               => 8192 // prevent smbclient from line-wrapping it's output
+               ]);
                $this->process = proc_open($this->command, $descriptorSpec, $this->pipes, '/', $env);
                if (!$this->isValid()) {
                        throw new ConnectionException();
                }
+               $this->connected = true;
        }
 
        /**
@@ -129,7 +145,7 @@ class RawConnection {
        }
 
        public function getAuthStream() {
-               return $this->pipes[3];
+               return $this->authStream;
        }
 
        public function getFileInputStream() {
@@ -143,14 +159,10 @@ class RawConnection {
        public function writeAuthentication($user, $password) {
                $auth = ($password === false)
                        ? "username=$user"
-                       : "username=$user\npassword=$password";
+                       : "username=$user\npassword=$password\n";
 
-               if (fwrite($this->getAuthStream(), $auth) === false) {
-                       fclose($this->getAuthStream());
-                       return false;
-               }
-               fclose($this->getAuthStream());
-               return true;
+               $this->authStream = fopen('php://temp', 'w+');
+               fwrite($this->getAuthStream(), $auth);
        }
 
        public function close($terminate = true) {
@@ -163,8 +175,8 @@ class RawConnection {
                                $status = proc_get_status($this->process);
                                $ppid = $status['pid'];
                                $pids = preg_split('/\s+/', `ps -o pid --no-heading --ppid $ppid`);
-                               foreach($pids as $pid) {
-                                       if(is_numeric($pid)) {
+                               foreach ($pids as $pid) {
+                                       if (is_numeric($pid)) {
                                                //9 is the SIGKILL signal
                                                posix_kill($pid, 9);
                                        }
index 12692eb4c6ef407c14a92f4ca6ec4ae8ae50ec0e..21cc605ed1f99d0495a3a7839b8c8d63891f35a8 100644 (file)
@@ -134,6 +134,7 @@ class Server {
                );
                $connection = new RawConnection($command);
                $connection->writeAuthentication($this->getUser(), $this->getPassword());
+               $connection->connect();
                $output = $connection->readAll();
                $parser = new Parser($this->timezoneProvider);
 
index ba8bbbbb8ca86c16ba62be95185a5dde237179b1..542eaf0887eb15fbc05ff5574f53691ce6fcd219 100644 (file)
@@ -68,8 +68,9 @@ class Share extends AbstractShare {
                );
                $connection = new Connection($command, $this->parser);
                $connection->writeAuthentication($this->server->getUser(), $this->server->getPassword());
+               $connection->connect();
                if (!$connection->isValid()) {
-                       throw new ConnectionException();
+                       throw new ConnectionException($connection->readLine());
                }
                return $connection;
        }
@@ -88,7 +89,6 @@ class Share extends AbstractShare {
 
        protected function reconnect() {
                $this->connection->reconnect();
-               $this->connection->writeAuthentication($this->server->getUser(), $this->server->getPassword());
                if (!$this->connection->isValid()) {
                        throw new ConnectionException();
                }
@@ -318,9 +318,9 @@ class Share extends AbstractShare {
                $modeString = '';
                $modeMap = array(
                        FileInfo::MODE_READONLY => 'r',
-                       FileInfo::MODE_HIDDEN => 'h',
-                       FileInfo::MODE_ARCHIVE => 'a',
-                       FileInfo::MODE_SYSTEM => 's'
+                       FileInfo::MODE_HIDDEN   => 'h',
+                       FileInfo::MODE_ARCHIVE  => 'a',
+                       FileInfo::MODE_SYSTEM   => 's'
                );
                foreach ($modeMap as $modeByte => $string) {
                        if ($mode & $modeByte) {
@@ -413,6 +413,7 @@ class Share extends AbstractShare {
                }
                $path = str_replace('/', '\\', $path);
                $path = str_replace('"', '^"', $path);
+               $path = ltrim($path, '\\');
                return '"' . $path . '"';
        }