diff options
Diffstat (limited to 'apps/files_encryption')
-rw-r--r-- | apps/files_encryption/hooks/hooks.php | 4 | ||||
-rw-r--r-- | apps/files_encryption/l10n/en_GB.php | 1 | ||||
-rw-r--r-- | apps/files_encryption/l10n/nb_NO.php | 1 | ||||
-rw-r--r-- | apps/files_encryption/l10n/ru.php | 1 | ||||
-rw-r--r-- | apps/files_encryption/l10n/sv.php | 1 | ||||
-rw-r--r-- | apps/files_encryption/lib/proxy.php | 41 | ||||
-rw-r--r-- | apps/files_encryption/lib/session.php | 2 | ||||
-rw-r--r-- | apps/files_encryption/tests/hooks.php | 13 | ||||
-rwxr-xr-x | apps/files_encryption/tests/webdav.php | 3 |
9 files changed, 54 insertions, 13 deletions
diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php index f546ef72373..6f739947b0c 100644 --- a/apps/files_encryption/hooks/hooks.php +++ b/apps/files_encryption/hooks/hooks.php @@ -490,7 +490,7 @@ class Hooks { // create destination folder if not exists
if (!$view->file_exists(dirname($newShareKeyPath))) {
- $view->mkdir(dirname($newShareKeyPath), 0750, true);
+ mkdir($view->getLocalFile($newShareKeyPath), 0750, true);
}
$view->rename($oldShareKeyPath, $newShareKeyPath);
@@ -501,7 +501,7 @@ class Hooks { // create destination folder if not exists
if (!$view->file_exists(dirname($newKeyfilePath))) {
- $view->mkdir(dirname($newKeyfilePath), 0750, true);
+ mkdir(dirname($view->getLocalFile($newKeyfilePath)), 0750, true);
}
$view->rename($oldKeyfilePath, $newKeyfilePath);
diff --git a/apps/files_encryption/l10n/en_GB.php b/apps/files_encryption/l10n/en_GB.php index 150173da63b..b2da4f2acdf 100644 --- a/apps/files_encryption/l10n/en_GB.php +++ b/apps/files_encryption/l10n/en_GB.php @@ -17,6 +17,7 @@ $TRANSLATIONS = array( "Following users are not set up for encryption:" => "Following users are not set up for encryption:", "Initial encryption started... This can take some time. Please wait." => "Initial encryption started... This can take some time. Please wait.", "Initial encryption running... Please try again later." => "Initial encryption running... Please try again later.", +"Go directly to your %spersonal settings%s." => "Go directly to your %spersonal settings%s.", "Encryption" => "Encryption", "Enable recovery key (allow to recover users files in case of password loss):" => "Enable recovery key (allow to recover users files in case of password loss):", "Recovery key password" => "Recovery key password", diff --git a/apps/files_encryption/l10n/nb_NO.php b/apps/files_encryption/l10n/nb_NO.php index 6d275c0b16b..bdfcebefb5b 100644 --- a/apps/files_encryption/l10n/nb_NO.php +++ b/apps/files_encryption/l10n/nb_NO.php @@ -17,6 +17,7 @@ $TRANSLATIONS = array( "Following users are not set up for encryption:" => "Følgende brukere er ikke satt opp for kryptering:", "Initial encryption started... This can take some time. Please wait." => "Førstegangs kryptering startet... Dette kan ta litt tid. Vennligst vent.", "Initial encryption running... Please try again later." => "Førstegangs kryptering kjører... Prøv igjen senere.", +"Go directly to your %spersonal settings%s." => "Gå direkte til dine %spersonlige innstillinger%s.", "Encryption" => "Kryptering", "Enable recovery key (allow to recover users files in case of password loss):" => "Aktiver gjenopprettingsnøkkel (tillat å gjenopprette brukerfiler i tilfelle tap av passord):", "Recovery key password" => "Passord for gjenopprettingsnøkkel", diff --git a/apps/files_encryption/l10n/ru.php b/apps/files_encryption/l10n/ru.php index 367565dfffc..fe3e0b06bfe 100644 --- a/apps/files_encryption/l10n/ru.php +++ b/apps/files_encryption/l10n/ru.php @@ -17,6 +17,7 @@ $TRANSLATIONS = array( "Following users are not set up for encryption:" => "Для следующих пользователей шифрование не настроено:", "Initial encryption started... This can take some time. Please wait." => "Начато начальное шифрование... Это может занять какое-то время. Пожалуйста, подождите.", "Initial encryption running... Please try again later." => "Работает первоначальное шифрование... Пожалуйста, повторите попытку позже.", +"Go directly to your %spersonal settings%s." => "Перейти напряму к вашим %spersonal settings%s.", "Encryption" => "Шифрование", "Enable recovery key (allow to recover users files in case of password loss):" => "Включить ключ восстановления (позволяет пользователям восстановить файлы при потере пароля):", "Recovery key password" => "Пароль для ключа восстановления", diff --git a/apps/files_encryption/l10n/sv.php b/apps/files_encryption/l10n/sv.php index 76ed616ca5c..2360f8ff8cc 100644 --- a/apps/files_encryption/l10n/sv.php +++ b/apps/files_encryption/l10n/sv.php @@ -17,6 +17,7 @@ $TRANSLATIONS = array( "Following users are not set up for encryption:" => "Följande användare har inte aktiverat kryptering:", "Initial encryption started... This can take some time. Please wait." => "Initiala krypteringen har påbörjats... Detta kan ta lite tid. Var god vänta.", "Initial encryption running... Please try again later." => "Initiala krypteringen körs... Var god försök igen senare.", +"Go directly to your %spersonal settings%s." => "Gå direkt till dina %segna inställningar%s.", "Encryption" => "Kryptering", "Enable recovery key (allow to recover users files in case of password loss):" => "Aktivera återställningsnyckel (för att kunna återfå användarens filer vid glömt eller förlorat lösenord):", "Recovery key password" => "Lösenord för återställningsnyckel", diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php index fd91073b8de..b1af4676852 100644 --- a/apps/files_encryption/lib/proxy.php +++ b/apps/files_encryption/lib/proxy.php @@ -41,6 +41,39 @@ class Proxy extends \OC_FileProxy { private static $fopenMode = array(); // remember the fopen mode private static $enableEncryption = false; // Enable encryption for the given path + + /** + * check if path is excluded from encryption + * + * @param string $path relative to data/ + * @param string $uid user + * @return boolean + */ + private function isExcludedPath($path, $uid) { + + $view = new \OC\Files\View(); + + // files outside of the files-folder are excluded + if(strpos($path, '/' . $uid . '/files') !== 0) { + return true; + } + + if (!$view->file_exists($path)) { + $path = dirname($path); + } + + // we don't encrypt server-to-server shares + list($storage, ) = \OC\Files\Filesystem::resolvePath($path); + /** + * @var \OCP\Files\Storage $storage + */ + if ($storage->instanceOfStorage('OCA\Files_Sharing\External\Storage')) { + return true; + } + + return false; + } + /** * Check if a file requires encryption * @param string $path @@ -50,7 +83,7 @@ class Proxy extends \OC_FileProxy { * Tests if server side encryption is enabled, and if we should call the * crypt stream wrapper for the given file */ - private static function shouldEncrypt($path, $mode = 'w') { + private function shouldEncrypt($path, $mode = 'w') { $userId = Helper::getUser($path); $session = new Session(new \OC\Files\View()); @@ -59,7 +92,7 @@ class Proxy extends \OC_FileProxy { if ( $session->getInitialized() !== Session::INIT_SUCCESSFUL // encryption successful initialized || Crypt::mode() !== 'server' // we are not in server-side-encryption mode - || strpos($path, '/' . $userId . '/files') !== 0 // path is not in files/ + || $this->isExcludedPath($path, $userId) // if path is excluded from encryption || substr($path, 0, 8) === 'crypt://' // we are already in crypt mode ) { return false; @@ -85,7 +118,7 @@ class Proxy extends \OC_FileProxy { */ public function preFile_put_contents($path, &$data) { - if (self::shouldEncrypt($path)) { + if ($this->shouldEncrypt($path)) { if (!is_resource($data)) { @@ -219,7 +252,7 @@ class Proxy extends \OC_FileProxy { public function preFopen($path, $mode) { self::$fopenMode[$path] = $mode; - self::$enableEncryption = self::shouldEncrypt($path, $mode); + self::$enableEncryption = $this->shouldEncrypt($path, $mode); } diff --git a/apps/files_encryption/lib/session.php b/apps/files_encryption/lib/session.php index 93be6691f96..ef18b924dd8 100644 --- a/apps/files_encryption/lib/session.php +++ b/apps/files_encryption/lib/session.php @@ -100,6 +100,8 @@ class Session { $privateKey = Crypt::decryptPrivateKey($encryptedKey, ''); $this->setPublicSharePrivateKey($privateKey); + $this->setInitialized(\OCA\Encryption\Session::INIT_SUCCESSFUL); + \OC_FileProxy::$enabled = $proxyStatus; } } diff --git a/apps/files_encryption/tests/hooks.php b/apps/files_encryption/tests/hooks.php index a2e3ea30f04..79699a3ef35 100644 --- a/apps/files_encryption/tests/hooks.php +++ b/apps/files_encryption/tests/hooks.php @@ -301,19 +301,20 @@ class Test_Encryption_Hooks extends \PHPUnit_Framework_TestCase { '/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keyfiles/' . $this->filename . '.key')); - // make subfolder + // make subfolder and sub-subfolder $this->rootView->mkdir('/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files/' . $this->folder); + $this->rootView->mkdir('/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files/' . $this->folder . '/' . $this->folder); - $this->assertTrue($this->rootView->is_dir('/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files/' . $this->folder)); + $this->assertTrue($this->rootView->is_dir('/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files/' . $this->folder . '/' . $this->folder)); // move the file out of the shared folder $root = $this->rootView->getRoot(); $this->rootView->chroot('/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files/'); - $this->rootView->rename($this->filename, '/' . $this->folder . '/' . $this->filename); + $this->rootView->rename($this->filename, '/' . $this->folder . '/' . $this->folder . '/' . $this->filename); $this->rootView->chroot($root); $this->assertFalse($this->rootView->file_exists('/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files/' . $this->filename)); - $this->assertTrue($this->rootView->file_exists('/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files/' . $this->folder . '/' . $this->filename)); + $this->assertTrue($this->rootView->file_exists('/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files/' . $this->folder . '/' . $this->folder . '/' . $this->filename)); // keys should be renamed too $this->assertFalse($this->rootView->file_exists( @@ -324,10 +325,10 @@ class Test_Encryption_Hooks extends \PHPUnit_Framework_TestCase { . $this->filename . '.key')); $this->assertTrue($this->rootView->file_exists( - '/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/share-keys/' . $this->folder . '/' + '/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/share-keys/' . $this->folder . '/' . $this->folder . '/' . $this->filename . '.' . self::TEST_ENCRYPTION_HOOKS_USER1 . '.shareKey')); $this->assertTrue($this->rootView->file_exists( - '/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keyfiles/' . $this->folder . '/' + '/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keyfiles/' . $this->folder . '/' . $this->folder . '/' . $this->filename . '.key')); // cleanup diff --git a/apps/files_encryption/tests/webdav.php b/apps/files_encryption/tests/webdav.php index 84db54ff30b..73bc9ce08de 100755 --- a/apps/files_encryption/tests/webdav.php +++ b/apps/files_encryption/tests/webdav.php @@ -235,7 +235,8 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase { $view = new \OC\Files\View($root); $publicDir = new OC_Connector_Sabre_Directory($view, $view->getFileInfo('')); $objectTree = new \OC\Connector\Sabre\ObjectTree(); - $objectTree->init($publicDir, $view); + $mountManager = \OC\Files\Filesystem::getMountManager(); + $objectTree->init($publicDir, $view, $mountManager); // Fire up server $server = new \Sabre\DAV\Server($publicDir); |