]> source.dussan.org Git - nextcloud-server.git/commitdiff
key creation should never override a private or public key
authorFlorin Peter <github@florin-peter.de>
Mon, 20 May 2013 19:22:03 +0000 (21:22 +0200)
committerFlorin Peter <github@florin-peter.de>
Mon, 20 May 2013 19:22:03 +0000 (21:22 +0200)
apps/files_encryption/lib/util.php

index 9ba7b3b3a3197a07eeb41eee0c1c590314b22c54..8147982d4830dbf908141c0aa7b7b253ea674c6d 100644 (file)
@@ -212,9 +212,10 @@ class Util
                }
 
                // Create user keypair
+               // we should never override a keyfile
                if (
                        !$this->view->file_exists($this->publicKeyPath)
-                       or !$this->view->file_exists($this->privateKeyPath)
+                       && !$this->view->file_exists($this->privateKeyPath)
                ) {
 
                        // Generate keypair
@@ -233,6 +234,15 @@ class Util
 
                        \OC_FileProxy::$enabled = true;
 
+               } else {
+                       // check if public-key exists but private-key is missing
+                       if($this->view->file_exists($this->publicKeyPath) &&  !$this->view->file_exists($this->privateKeyPath)) {
+                               \OC_Log::write('Encryption library', 'public key exists but private key is missing for "' . $this->userId . '"', \OC_Log::FATAL);
+                               return false;
+                       } else if(!$this->view->file_exists($this->publicKeyPath) &&  $this->view->file_exists($this->privateKeyPath)) {
+                               \OC_Log::write('Encryption library', 'private key exists but public key is missing for "' . $this->userId . '"', \OC_Log::FATAL);
+                               return false;
+                       }
                }
 
                // If there's no record for this user's encryption preferences