]> source.dussan.org Git - nextcloud-server.git/commitdiff
update icewind/smb to 3.5.2
authorRobin Appelman <robin@icewind.nl>
Thu, 20 Jan 2022 15:09:41 +0000 (16:09 +0100)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Thu, 20 Jan 2022 19:14:12 +0000 (19:14 +0000)
Signed-off-by: Robin Appelman <robin@icewind.nl>
apps/files_external/3rdparty/composer.json
apps/files_external/3rdparty/composer.lock
apps/files_external/3rdparty/composer/ClassLoader.php
apps/files_external/3rdparty/composer/installed.json
apps/files_external/3rdparty/composer/installed.php
apps/files_external/3rdparty/icewind/smb/src/KerberosApacheAuth.php

index 21ae38a99964285c934cac3c30b71b298dd96b5f..e343521add37f2e7e604a85198dfc7119bf80fd8 100644 (file)
@@ -9,6 +9,6 @@
        },
        "require": {
                "icewind/streams": "0.7.4",
-               "icewind/smb": "3.5.1"
+               "icewind/smb": "3.5.2"
        }
 }
index 6235bf98e5c735f60aa4be1e193d9fc81a5c9a1d..918dd7da08d475f03629d3f209a80dd29a2f1a36 100644 (file)
@@ -4,20 +4,20 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "ed821b15824934fd2d245faca1f35aad",
+    "content-hash": "524c99fd87297e01d004eb5a4e53b04c",
     "packages": [
         {
             "name": "icewind/smb",
-            "version": "v3.5.1",
+            "version": "v3.5.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/icewind1991/SMB.git",
-                "reference": "c1ce4fbb2ff1786846d9d0b3850b395ca94cf563"
+                "reference": "0a425bd21acf7ae112b135dca34640e1b1a825c3"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/icewind1991/SMB/zipball/c1ce4fbb2ff1786846d9d0b3850b395ca94cf563",
-                "reference": "c1ce4fbb2ff1786846d9d0b3850b395ca94cf563",
+                "url": "https://api.github.com/repos/icewind1991/SMB/zipball/0a425bd21acf7ae112b135dca34640e1b1a825c3",
+                "reference": "0a425bd21acf7ae112b135dca34640e1b1a825c3",
                 "shasum": ""
             },
             "require": {
@@ -49,9 +49,9 @@
             "description": "php wrapper for smbclient and libsmbclient-php",
             "support": {
                 "issues": "https://github.com/icewind1991/SMB/issues",
-                "source": "https://github.com/icewind1991/SMB/tree/v3.5.1"
+                "source": "https://github.com/icewind1991/SMB/tree/v3.5.2"
             },
-            "time": "2021-11-04T14:28:18+00:00"
+            "time": "2022-01-20T14:51:51+00:00"
         },
         {
             "name": "icewind/streams",
     "prefer-lowest": false,
     "platform": [],
     "platform-dev": [],
-    "plugin-api-version": "2.1.0"
+    "plugin-api-version": "2.2.0"
 }
index 0cd6055d1b7943ea1a8c5f45630517b4f2d56b59..afef3fa2ad83f114c8de5487e869f9c9b8a459bf 100644 (file)
@@ -149,7 +149,7 @@ class ClassLoader
 
     /**
      * @return string[] Array of classname => path
-     * @psalm-var array<string, string>
+     * @psalm-return array<string, string>
      */
     public function getClassMap()
     {
index c2e3ffb0e4b77e163169c8f2290915512c7de158..2c9b1c087dfc0314e6895fbb2bd3d521ecbaf842 100644 (file)
@@ -2,17 +2,17 @@
     "packages": [
         {
             "name": "icewind/smb",
-            "version": "v3.5.1",
-            "version_normalized": "3.5.1.0",
+            "version": "v3.5.2",
+            "version_normalized": "3.5.2.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/icewind1991/SMB.git",
-                "reference": "c1ce4fbb2ff1786846d9d0b3850b395ca94cf563"
+                "reference": "0a425bd21acf7ae112b135dca34640e1b1a825c3"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/icewind1991/SMB/zipball/c1ce4fbb2ff1786846d9d0b3850b395ca94cf563",
-                "reference": "c1ce4fbb2ff1786846d9d0b3850b395ca94cf563",
+                "url": "https://api.github.com/repos/icewind1991/SMB/zipball/0a425bd21acf7ae112b135dca34640e1b1a825c3",
+                "reference": "0a425bd21acf7ae112b135dca34640e1b1a825c3",
                 "shasum": ""
             },
             "require": {
@@ -25,7 +25,7 @@
                 "phpunit/phpunit": "^8.5|^9.3.8",
                 "psalm/phar": "^4.3"
             },
-            "time": "2021-11-04T14:28:18+00:00",
+            "time": "2022-01-20T14:51:51+00:00",
             "type": "library",
             "installation-source": "dist",
             "autoload": {
@@ -46,7 +46,7 @@
             "description": "php wrapper for smbclient and libsmbclient-php",
             "support": {
                 "issues": "https://github.com/icewind1991/SMB/issues",
-                "source": "https://github.com/icewind1991/SMB/tree/v3.5.1"
+                "source": "https://github.com/icewind1991/SMB/tree/v3.5.2"
             },
             "install-path": "../icewind/smb"
         },
index 2b4e3329b365aeba1f0bd02a51bf9f72d4959aee..255420e1003218082e6fa2b1d5d63c6a719d4d4f 100644 (file)
@@ -5,7 +5,7 @@
         'type' => 'library',
         'install_path' => __DIR__ . '/../',
         'aliases' => array(),
-        'reference' => 'cd72330b8f669e3dc81388be5a92171404f36fec',
+        'reference' => '0bed61f949bc7a8c69cd154919e78b704e28c99e',
         'name' => 'files_external/3rdparty',
         'dev' => true,
     ),
             'type' => 'library',
             'install_path' => __DIR__ . '/../',
             'aliases' => array(),
-            'reference' => 'cd72330b8f669e3dc81388be5a92171404f36fec',
+            'reference' => '0bed61f949bc7a8c69cd154919e78b704e28c99e',
             'dev_requirement' => false,
         ),
         'icewind/smb' => array(
-            'pretty_version' => 'v3.5.1',
-            'version' => '3.5.1.0',
+            'pretty_version' => 'v3.5.2',
+            'version' => '3.5.2.0',
             'type' => 'library',
             'install_path' => __DIR__ . '/../icewind/smb',
             'aliases' => array(),
-            'reference' => 'c1ce4fbb2ff1786846d9d0b3850b395ca94cf563',
+            'reference' => '0a425bd21acf7ae112b135dca34640e1b1a825c3',
             'dev_requirement' => false,
         ),
         'icewind/streams' => array(
index 03551aa6f3496a08c774d6b9a1cbf171ac486ec9..c49918be114a647148751cd3feec038185dd6d99 100644 (file)
@@ -31,35 +31,65 @@ class KerberosApacheAuth extends KerberosAuth implements IAuth {
        /** @var string */
        private $ticketPath = "";
 
-       // only working with specific library (mod_auth_kerb, krb5, smbclient) versions
-       /** @var bool */
-       private $saveTicketInMemory = false;
-
        /** @var bool */
        private $init = false;
 
+       /** @var string|false */
+       private $ticketName;
+
+       public function __construct() {
+               $this->ticketName = getenv("KRB5CCNAME");
+       }
+
+
+       /**
+        * Copy the ticket to a temporary location and use that ticket for authentication
+        *
+        * @return void
+        */
+       public function copyTicket(): void {
+               if (!$this->checkTicket()) {
+                       return;
+               }
+               $krb5 = new \KRB5CCache();
+               $krb5->open($this->ticketName);
+               $tmpFilename = tempnam("/tmp", "krb5cc_php_");
+               $tmpCacheFile = "FILE:" . $tmpFilename;
+               $krb5->save($tmpCacheFile);
+               $this->ticketPath = $tmpFilename;
+               $this->ticketName = $tmpCacheFile;
+       }
+
        /**
-        * @param bool $saveTicketInMemory
+        * Pass the ticket to smbclient by memory instead of path
+        *
+        * @return void
         */
-       public function __construct(bool $saveTicketInMemory = false) {
-               $this->saveTicketInMemory = $saveTicketInMemory;
+       public function passTicketFromMemory(): void {
+               if (!$this->checkTicket()) {
+                       return;
+               }
+               $krb5 = new \KRB5CCache();
+               $krb5->open($this->ticketName);
+               $this->ticketName = (string)$krb5->getName();
        }
 
        /**
         * Check if a valid kerberos ticket is present
         *
         * @return bool
+        * @psalm-assert-if-true string $this->ticketName
         */
        public function checkTicket(): bool {
                //read apache kerberos ticket cache
-               $cacheFile = getenv("KRB5CCNAME");
-               if (!$cacheFile) {
+               if (!$this->ticketName) {
                        return false;
                }
 
                $krb5 = new \KRB5CCache();
-               $krb5->open($cacheFile);
-               return (bool)$krb5->isValid();
+               $krb5->open($this->ticketName);
+               /** @psalm-suppress MixedArgument */
+               return count($krb5->getEntries()) > 0;
        }
 
        private function init(): void {
@@ -75,28 +105,13 @@ class KerberosApacheAuth extends KerberosAuth implements IAuth {
                }
 
                //read apache kerberos ticket cache
-               $cacheFile = getenv("KRB5CCNAME");
-               if (!$cacheFile) {
+               if (!$this->checkTicket()) {
                        throw new Exception('No kerberos ticket cache environment variable (KRB5CCNAME) found.');
                }
 
-               $krb5 = new \KRB5CCache();
-               $krb5->open($cacheFile);
-               if (!$krb5->isValid()) {
-                       throw new Exception('Kerberos ticket cache is not valid.');
-               }
-
-
-               if ($this->saveTicketInMemory) {
-                       putenv("KRB5CCNAME=" . (string)$krb5->getName());
-               } else {
-                       //workaround: smbclient is not working with the original apache ticket cache.
-                       $tmpFilename = tempnam("/tmp", "krb5cc_php_");
-                       $tmpCacheFile = "FILE:" . $tmpFilename;
-                       $krb5->save($tmpCacheFile);
-                       $this->ticketPath = $tmpFilename;
-                       putenv("KRB5CCNAME=" . $tmpCacheFile);
-               }
+               // note that even if the ticketname is the value we got from `getenv("KRB5CCNAME")` we still need to set the env variable ourselves
+               // this is because `getenv` also reads the variables passed from the SAPI (apache-php) and we need to set the variable in the OS's env
+               putenv("KRB5CCNAME=" . $this->ticketName);
        }
 
        public function getExtraCommandLineArguments(): string {
@@ -106,7 +121,11 @@ class KerberosApacheAuth extends KerberosAuth implements IAuth {
 
        public function setExtraSmbClientOptions($smbClientState): void {
                $this->init();
-               parent::setExtraSmbClientOptions($smbClientState);
+               try {
+                       parent::setExtraSmbClientOptions($smbClientState);
+               } catch (Exception $e) {
+                       // suppress
+               }
        }
 
        public function __destruct() {