From 2a2633608033dde904ba67c8e390e4e6b2d00f7a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Fri, 21 Jun 2013 10:37:51 +0200 Subject: [PATCH] check openssl dependency for the encryption app MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit commit 1345201c9da99a82f198e41fba24da6b0d7ae59a Author: Björn Schießle Date: Thu Jun 20 16:27:46 2013 +0200 add l10n support commit bf2c79c8de8710e839a4a55642a91874c374fa1c Author: Björn Schießle Date: Thu Jun 20 16:19:10 2013 +0200 only init session if openssl extension is loaded commit cbd52af6afbaa310bb1a534db64ff5e476dfd5d7 Author: Björn Schießle Date: Thu Jun 20 12:25:40 2013 +0200 first disable app and than show error page commit 55baf593179c433642de59552592e6b0f1932880 Author: Björn Schießle Date: Thu Jun 20 12:17:34 2013 +0200 typo fixed commit 1d9bef0b058e7cc3d511b81ae12d5a07660c75b2 Author: Björn Schießle Date: Thu Jun 20 12:15:40 2013 +0200 move dependency check to the encryption app commit c186e95da526f0470e20f014f1bd9513db5518ff Author: Björn Schießle Date: Thu Jun 20 11:13:11 2013 +0200 make sure that openssl is installed and loaded Conflicts: apps/files_encryption/appinfo/app.php --- apps/files_encryption/appinfo/app.php | 32 +++++++++++++++------------ apps/files_encryption/hooks/hooks.php | 14 +++++++----- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/apps/files_encryption/appinfo/app.php b/apps/files_encryption/appinfo/app.php index f55fb6ef766..80c04bb0cd2 100644 --- a/apps/files_encryption/appinfo/app.php +++ b/apps/files_encryption/appinfo/app.php @@ -10,7 +10,7 @@ OC::$CLASSPATH['OCA\Encryption\Session'] = 'files_encryption/lib/session.php'; OC::$CLASSPATH['OCA\Encryption\Capabilities'] = 'files_encryption/lib/capabilities.php'; OC::$CLASSPATH['OCA\Encryption\Helper'] = 'files_encryption/lib/helper.php'; -if(!OC_Config::getValue('maintenance', false)) { +if (!OC_Config::getValue('maintenance', false)) { OC_FileProxy::register(new OCA\Encryption\Proxy()); // User related hooks @@ -24,22 +24,26 @@ if(!OC_Config::getValue('maintenance', false)) { stream_wrapper_register('crypt', 'OCA\Encryption\Stream'); -// check if we are logged in -if (OCP\User::isLoggedIn()) { + // check if we are logged in + if (OCP\User::isLoggedIn()) { - // ensure filesystem is loaded - if(!\OC\Files\Filesystem::$loaded) { - \OC_Util::setupFS(); - } + // ensure filesystem is loaded + if (!\OC\Files\Filesystem::$loaded) { + \OC_Util::setupFS(); + } - $view = new OC_FilesystemView('/'); + $view = new OC_FilesystemView('/'); + + $sessionReady = false; + if (extension_loaded("openssl")) { + $session = new \OCA\Encryption\Session($view); + $sessionReady = true; + } - $user = \OCP\USER::getUser(); - // check if user has a private key - if ( - !$view->file_exists('/' . $user . '/files_encryption/' . $user . '.private.key') - && OCA\Encryption\Crypt::mode() === 'server' - ) { + $user = \OCP\USER::getUser(); + // check if user has a private key + if ($sessionReady === false || (!$view->file_exists('/' . $user . '/files_encryption/' . $user . '.private.key') && OCA\Encryption\Crypt::mode() === 'server') + ) { // Force the user to log-in again if the encryption key isn't unlocked // (happens when a user is logged in before the encryption app is diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php index 7698b95cfd3..e39e068cc5d 100644 --- a/apps/files_encryption/hooks/hooks.php +++ b/apps/files_encryption/hooks/hooks.php @@ -38,11 +38,15 @@ class Hooks { * @note This method should never be called for users using client side encryption */ public static function login($params) { - - // Manually initialise Filesystem{} singleton with correct - // fake root path, in order to avoid fatal webdav errors - // NOTE: disabled because this give errors on webdav! - //\OC\Files\Filesystem::init( $params['uid'], '/' . 'files' . '/' ); + $l = new \OC_L10N('files_encryption'); + //check if openssl is available + if(!extension_loaded("openssl") ) { + $error_msg = $l->t("PHP module OpenSSL is not installed."); + $hint = $l->t('Please ask your server administrator to install the module. For now the encryption app was disabled.'); + \OC_App::disable('files_encryption'); + \OCP\Util::writeLog('Encryption library', $error_msg . ' ' . $hint, \OCP\Util::ERROR); + \OCP\Template::printErrorPage($error_msg, $hint); + } $view = new \OC_FilesystemView('/'); -- 2.39.5