summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xapps/files_encryption/lib/helper.php27
-rw-r--r--apps/files_encryption/lib/proxy.php6
-rw-r--r--apps/files_encryption/lib/stream.php14
-rw-r--r--apps/files_trashbin/lib/trash.php2
-rw-r--r--settings/personal.php10
-rw-r--r--settings/templates/personal.php18
6 files changed, 68 insertions, 9 deletions
diff --git a/apps/files_encryption/lib/helper.php b/apps/files_encryption/lib/helper.php
index 6eee8fed6a6..f5a5d269a69 100755
--- a/apps/files_encryption/lib/helper.php
+++ b/apps/files_encryption/lib/helper.php
@@ -199,6 +199,12 @@ class Helper {
public static function stripUserFilesPath($path) {
$trimmed = ltrim($path, '/');
$split = explode('/', $trimmed);
+
+ // it is not a file relative to data/user/files
+ if ($split[1] !== 'files') {
+ return false;
+ }
+
$sliced = array_slice($split, 2);
$relPath = implode('/', $sliced);
@@ -206,6 +212,27 @@ class Helper {
}
/**
+ * @brief get path to the correspondig file in data/user/files
+ * @param string $path path to a version or a file in the trash
+ * @return string path to correspondig file relative to data/user/files
+ */
+ public static function getPathToRealFile($path) {
+ $trimmed = ltrim($path, '/');
+ $split = explode('/', $trimmed);
+
+ if ($split[1] !== "files_versions") {
+ return false;
+ }
+
+ $sliced = array_slice($split, 2);
+ $realPath = implode('/', $sliced);
+ //remove the last .v
+ $realPath = substr($realPath, 0, strrpos($realPath, '.v'));
+
+ return $realPath;
+ }
+
+ /**
* @brief redirect to a error page
*/
public static function redirectToErrorPage() {
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
index 735eba911a9..12fee750a6a 100644
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -116,7 +116,7 @@ class Proxy extends \OC_FileProxy {
return true;
}
- $handle = fopen('crypt://' . $relativePath . '.etmp', 'w');
+ $handle = fopen('crypt://' . $path . '.etmp', 'w');
if (is_resource($handle)) {
// write data to stream
@@ -296,14 +296,14 @@ class Proxy extends \OC_FileProxy {
// Open the file using the crypto stream wrapper
// protocol and let it do the decryption work instead
- $result = fopen('crypt://' . $relativePath, $meta['mode']);
+ $result = fopen('crypt://' . $path, $meta['mode']);
} elseif (
self::shouldEncrypt($path)
and $meta ['mode'] !== 'r'
and $meta['mode'] !== 'rb'
) {
- $result = fopen('crypt://' . $relativePath, $meta['mode']);
+ $result = fopen('crypt://' . $path, $meta['mode']);
}
// Re-enable the proxy
diff --git a/apps/files_encryption/lib/stream.php b/apps/files_encryption/lib/stream.php
index 3c1eb2c5f5e..2f7af1410b9 100644
--- a/apps/files_encryption/lib/stream.php
+++ b/apps/files_encryption/lib/stream.php
@@ -73,7 +73,7 @@ class Stream {
private $privateKey;
/**
- * @param $path
+ * @param $path raw path relative to data/
* @param $mode
* @param $options
* @param $opened_path
@@ -93,12 +93,16 @@ class Stream {
$this->userId = $util->getUserId();
- // Strip identifier text from path, this gives us the path relative to data/<user>/files
- $this->relPath = \OC\Files\Filesystem::normalizePath(str_replace('crypt://', '', $path));
-
// rawPath is relative to the data directory
- $this->rawPath = $util->getUserFilesDir() . $this->relPath;
+ $this->rawPath = \OC\Files\Filesystem::normalizePath(str_replace('crypt://', '', $path));
+ // Strip identifier text from path, this gives us the path relative to data/<user>/files
+ $this->relPath = Helper::stripUserFilesPath($this->rawPath);
+ // if raw path doesn't point to a real file, check if it is a version or a file in the trash bin
+ if ($this->relPath === false) {
+ $this->relPath = Helper::getPathToRealFile($this->rawPath);
+ }
+
// Disable fileproxies so we can get the file size and open the source file without recursive encryption
$proxyStatus = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;
diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php
index b9d900dfab4..cdf8d950e60 100644
--- a/apps/files_trashbin/lib/trash.php
+++ b/apps/files_trashbin/lib/trash.php
@@ -693,7 +693,7 @@ class Trashbin {
\OC_Log::write('files_trashbin', 'remove "' . $filename . '" fom trash bin because it is older than ' . $retention_obligation, \OC_log::INFO);
}
}
- $availableSpace = $availableSpace + $size;
+ $availableSpace += $size;
// if size limit for trash bin reached, delete oldest files in trash bin
if ($availableSpace < 0) {
$query = \OC_DB::prepare('SELECT `location`,`type`,`id`,`timestamp` FROM `*PREFIX*files_trash`'
diff --git a/settings/personal.php b/settings/personal.php
index 1e2e1cf6723..4961661e250 100644
--- a/settings/personal.php
+++ b/settings/personal.php
@@ -24,6 +24,15 @@ $email=OC_Preferences::getValue(OC_User::getUser(), 'settings', 'email', '');
$userLang=OC_Preferences::getValue( OC_User::getUser(), 'core', 'lang', OC_L10N::findLanguage() );
$languageCodes=OC_L10N::findAvailableLanguages();
+//check if encryption was enabled in the past
+$enableDecryptAll = false;
+if (OC_App::isEnabled('files_encryption') === false) {
+ $view = new OC\Files\View('/'.OC_User::getUser());
+ if ($view->file_exists('files_encryption/keyfiles')) {
+ $enableDecryptAll = true;
+ }
+}
+
// array of common languages
$commonlangcodes = array(
'en', 'es', 'fr', 'de', 'de_DE', 'ja_JP', 'ar', 'ru', 'nl', 'it', 'pt_BR', 'pt_PT', 'da', 'fi_FI', 'nb_NO', 'sv', 'zh_CN', 'ko'
@@ -80,6 +89,7 @@ $tmpl->assign('activelanguage', $userLang);
$tmpl->assign('passwordChangeSupported', OC_User::canUserChangePassword(OC_User::getUser()));
$tmpl->assign('displayNameChangeSupported', OC_User::canUserChangeDisplayName(OC_User::getUser()));
$tmpl->assign('displayName', OC_User::getDisplayName());
+$tmpl->assign('enableDecryptAll' , true);
$forms=OC_App::getForms('personal');
$tmpl->assign('forms', array());
diff --git a/settings/templates/personal.php b/settings/templates/personal.php
index b9d9b09f5d0..c0f3600a51e 100644
--- a/settings/templates/personal.php
+++ b/settings/templates/personal.php
@@ -110,6 +110,24 @@ if($_['passwordChangeSupported']) {
print_unescaped($form);
};?>
+<?php if($_['enableDecryptAll']): ?>
+<form id="encryption">
+ <fieldset class="personalblock">
+ <legend>
+ <?php p( $l->t( 'Encryption' ) ); ?>
+ </legend>
+ <?php p($l->t( "The encryption app is no longer enabled, decrypt all your file" )); ?>
+ <p>
+ <button
+ type="button"
+ name="submitDecryptAll"><?php p($l->t( "Decrypt all Files" )); ?>
+ </button>
+ </p>
+ <br />
+ </fieldset>
+</form>
+<?php endif; ?>
+
<fieldset class="personalblock">
<legend><strong><?php p($l->t('Version'));?></strong></legend>
<strong><?php p($theme->getName()); ?></strong> <?php p(OC_Util::getVersionString()); ?><br/>