]> source.dussan.org Git - nextcloud-server.git/commitdiff
create keypair for ownCloud with empty passphrase, will be used for public link shares
authorBjörn Schießle <schiessle@owncloud.com>
Wed, 13 Feb 2013 16:57:45 +0000 (17:57 +0100)
committerBjörn Schießle <schiessle@owncloud.com>
Wed, 13 Feb 2013 16:57:45 +0000 (17:57 +0100)
apps/files_encryption/lib/crypt.php
apps/files_encryption/lib/session.php
lib/public/share.php

index 18e9535bf35f641ca9e9635e6b1adbe9218f2b51..2e5912a86832dec18863191f33d0c9803c81d0d9 100755 (executable)
@@ -763,7 +763,7 @@ class Crypt {
                        $util = new Util( $view, $user );\r
                                \r
                        // Check that the user is encryption capable\r
-                       if ( $util->ready() ) {\r
+                       if ( $util->ready() && $user == 'ownCloud' ) {\r
                                // Construct array of just UIDs for Keymanager{}\r
                                $userIds[] = $user;\r
                                        \r
@@ -827,16 +827,13 @@ class Crypt {
                        foreach ( $content as $c) {\r
                                $path = substr($c['path'], 5);\r
                                if ( $filesView->is_dir($path) ) {\r
-                                       error_log("dive into $path");\r
                                        $result &= self::updateKeyfile($path);\r
                                } else {\r
-                                       error_log("encKeyFileToMultipleUsers $path");\r
                                        $shares = \OCP\Share::getUsersSharingFile( $path, true );\r
                                        $result &= self::encKeyfileToMultipleUsers($shares, $path);\r
                                }\r
                        }\r
                } else {\r
-                       error_log("encKeyFileToMultipleUsers single file: " . $path);\r
                        $shares = \OCP\Share::getUsersSharingFile( $path, true );\r
                        $result = self::encKeyfileToMultipleUsers($shares, $path);\r
                }\r
index 769a40b359f4f7249c9fcc44353de603f66cdd63..ebf7edcd715938a126bf52a12e3b87199b019934 100644 (file)
@@ -27,6 +27,34 @@ namespace OCA\Encryption;
  */
 
 class Session {
+       
+       /**
+        * @brief if session is started, check if ownCloud key pair is set up, if not create it
+        * 
+        * The ownCloud key pair is used to allow public link sharing even if encryption is enabled
+        */
+       public function __construct() {
+               $view = new \OC\Files\View('/');
+               if (!$view->is_dir('owncloud_private_key')) {
+                       $view->mkdir('owncloud_private_key');
+               }
+               
+               if (!$view->file_exists("/public-keys/owncloud.public.key") || !$view->file_exists("/owncloud_private_key/owncloud.private.key") ) {
+                       
+                       $keypair = Crypt::createKeypair();
+                       
+                       \OC_FileProxy::$enabled = false;
+                       // Save public key
+                       $view->file_put_contents( '/public-keys/owncloud.public.key', $keypair['publicKey'] );
+                       // Encrypt private key empthy passphrase
+                       $encryptedPrivateKey = Crypt::symmetricEncryptFileContent( $keypair['privateKey'], '' );
+                       // Save private key
+                       error_log("encrypted private key: " . $encryptedPrivateKey );
+                       $view->file_put_contents( '/owncloud_private_key/owncloud.private.key', $encryptedPrivateKey );
+                       
+                       \OC_FileProxy::$enabled = true;
+               }
+       }
 
        /**
         * @brief Sets user private key to session
index d1297c6e59ec8239db16c06bbd6b612afb8b6988..720337c3c38c897734140c34184257e32a1273f0 100644 (file)
@@ -219,7 +219,7 @@ class Share {
                        }
                        
                        if ($result->fetchRow()) {
-                               $shares[] = self::SHARE_TYPE_LINK;
+                               $shares[] = "ownCloud";
                        }
                }