summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xapps/files_encryption/lib/crypt.php5
-rw-r--r--apps/files_encryption/lib/session.php28
-rw-r--r--lib/public/share.php2
3 files changed, 30 insertions, 5 deletions
diff --git a/apps/files_encryption/lib/crypt.php b/apps/files_encryption/lib/crypt.php
index 18e9535bf35..2e5912a8683 100755
--- a/apps/files_encryption/lib/crypt.php
+++ b/apps/files_encryption/lib/crypt.php
@@ -763,7 +763,7 @@ class Crypt {
$util = new Util( $view, $user );
// Check that the user is encryption capable
- if ( $util->ready() ) {
+ if ( $util->ready() && $user == 'ownCloud' ) {
// Construct array of just UIDs for Keymanager{}
$userIds[] = $user;
@@ -827,16 +827,13 @@ class Crypt {
foreach ( $content as $c) {
$path = substr($c['path'], 5);
if ( $filesView->is_dir($path) ) {
- error_log("dive into $path");
$result &= self::updateKeyfile($path);
} else {
- error_log("encKeyFileToMultipleUsers $path");
$shares = \OCP\Share::getUsersSharingFile( $path, true );
$result &= self::encKeyfileToMultipleUsers($shares, $path);
}
}
} else {
- error_log("encKeyFileToMultipleUsers single file: " . $path);
$shares = \OCP\Share::getUsersSharingFile( $path, true );
$result = self::encKeyfileToMultipleUsers($shares, $path);
}
diff --git a/apps/files_encryption/lib/session.php b/apps/files_encryption/lib/session.php
index 769a40b359f..ebf7edcd715 100644
--- a/apps/files_encryption/lib/session.php
+++ b/apps/files_encryption/lib/session.php
@@ -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
diff --git a/lib/public/share.php b/lib/public/share.php
index d1297c6e59e..720337c3c38 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -219,7 +219,7 @@ class Share {
}
if ($result->fetchRow()) {
- $shares[] = self::SHARE_TYPE_LINK;
+ $shares[] = "ownCloud";
}
}