]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fixed bug relating to Filesystem{} that prevented webdav logins with files_encryption
authorSam Tuke <samtuke@owncloud.com>
Tue, 5 Feb 2013 16:09:01 +0000 (16:09 +0000)
committerSam Tuke <samtuke@owncloud.com>
Tue, 5 Feb 2013 16:09:01 +0000 (16:09 +0000)
apps/files_encryption/hooks/hooks.php

index cb9993b238952786fffb75c28d19aeb70c9e03c2..065ef9d24107a30c3a0fe0a9acada0046ff308d1 100644 (file)
@@ -37,61 +37,63 @@ class Hooks {
         * @note This method should never be called for users using client side encryption\r
         */\r
        public static function login( $params ) {\r
-               \r
-                       $view = new \OC_FilesystemView( '/' );\r
-\r
-                       $util = new Util( $view, $params['uid'] );\r
-                       \r
-                       if ( ! $util->ready() ) {\r
-                               \r
-                               \OC_Log::write( 'Encryption library', 'User account "' . $params['uid'] . '" is not ready for encryption; configuration started', \OC_Log::DEBUG );\r
-                               \r
-                               return $util->setupServerSide( $params['password'] );\r
+       \r
+               \OC\Files\Filesystem::init( $params['uid'] . '/' . 'files' . '/' );\r
+       \r
+               $view = new \OC_FilesystemView( '/' );\r
 \r
-                       }\r
+               $util = new Util( $view, $params['uid'] );\r
                \r
-                       \OC_FileProxy::$enabled = false;\r
-                       \r
-                       $encryptedKey = Keymanager::getPrivateKey( $view, $params['uid'] );\r
-                       \r
-                       \OC_FileProxy::$enabled = true;\r
+               if ( ! $util->ready() ) {\r
                        \r
-                       $privateKey = Crypt::symmetricDecryptFileContent( $encryptedKey, $params['password'] );\r
+                       \OC_Log::write( 'Encryption library', 'User account "' . $params['uid'] . '" is not ready for encryption; configuration started', \OC_Log::DEBUG );\r
                        \r
-                       $session = new Session();\r
-                       \r
-                       $session->setPrivateKey( $privateKey, $params['uid'] );\r
-                       \r
-                       $view1 = new \OC_FilesystemView( '/' . $params['uid'] );\r
-                       \r
-                       // Set legacy encryption key if it exists, to support \r
-                       // depreciated encryption system\r
-                       if ( \r
-                               $view1->file_exists( 'encryption.key' )\r
-                               && $encLegacyKey = $view1->file_get_contents( 'encryption.key' ) \r
-                       ) {\r
-                       \r
-                               $plainLegacyKey = Crypt::legacyDecrypt( $encLegacyKey, $params['password'] );\r
-                               \r
-                               $session->setLegacyKey( $plainLegacyKey );\r
-                       \r
-                       }\r
-                       \r
-                       $publicKey = Keymanager::getPublicKey( $view, $params['uid'] );\r
-                       \r
-                       // Encrypt existing user files:\r
-                       // This serves to upgrade old versions of the encryption\r
-                       // app (see appinfo/spec.txt)\r
-                       if ( \r
-                               $util->encryptAll( $publicKey,  '/' . $params['uid'] . '/' . 'files', $session->getLegacyKey(), $params['password'] )\r
-                       ) {\r
-                               \r
-                               \OC_Log::write( \r
-                                       'Encryption library', 'Encryption of existing files belonging to "' . $params['uid'] . '" started at login'\r
-                                       , \OC_Log::INFO \r
-                               );\r
+                       return $util->setupServerSide( $params['password'] );\r
+\r
+               }\r
+       \r
+               \OC_FileProxy::$enabled = false;\r
+               \r
+               $encryptedKey = Keymanager::getPrivateKey( $view, $params['uid'] );\r
+               \r
+               \OC_FileProxy::$enabled = true;\r
+               \r
+               $privateKey = Crypt::symmetricDecryptFileContent( $encryptedKey, $params['password'] );\r
+               \r
+               $session = new Session();\r
+               \r
+               $session->setPrivateKey( $privateKey, $params['uid'] );\r
+               \r
+               $view1 = new \OC_FilesystemView( '/' . $params['uid'] );\r
+               \r
+               // Set legacy encryption key if it exists, to support \r
+               // depreciated encryption system\r
+               if ( \r
+                       $view1->file_exists( 'encryption.key' )\r
+                       && $encLegacyKey = $view1->file_get_contents( 'encryption.key' ) \r
+               ) {\r
+               \r
+                       $plainLegacyKey = Crypt::legacyDecrypt( $encLegacyKey, $params['password'] );\r
                        \r
-                       }\r
+                       $session->setLegacyKey( $plainLegacyKey );\r
+               \r
+               }\r
+               \r
+               $publicKey = Keymanager::getPublicKey( $view, $params['uid'] );\r
+               \r
+               // Encrypt existing user files:\r
+               // This serves to upgrade old versions of the encryption\r
+               // app (see appinfo/spec.txt)\r
+               if ( \r
+                       $util->encryptAll( $publicKey,  '/' . $params['uid'] . '/' . 'files', $session->getLegacyKey(), $params['password'] )\r
+               ) {\r
+                       \r
+                       \OC_Log::write( \r
+                               'Encryption library', 'Encryption of existing files belonging to "' . $params['uid'] . '" started at login'\r
+                               , \OC_Log::INFO \r
+                       );\r
+               \r
+               }\r
 \r
                return true;\r
 \r