Fixed bug relating to Filesystem{} that prevented webdav logins with files_encryption

This commit is contained in:
Sam Tuke 2013-02-05 16:09:01 +00:00
parent a1f200c1e5
commit 221b69dd0e
1 changed files with 51 additions and 49 deletions

View File

@ -38,60 +38,62 @@ class Hooks {
*/ */
public static function login( $params ) { public static function login( $params ) {
$view = new \OC_FilesystemView( '/' ); \OC\Files\Filesystem::init( $params['uid'] . '/' . 'files' . '/' );
$util = new Util( $view, $params['uid'] ); $view = new \OC_FilesystemView( '/' );
if ( ! $util->ready() ) { $util = new Util( $view, $params['uid'] );
\OC_Log::write( 'Encryption library', 'User account "' . $params['uid'] . '" is not ready for encryption; configuration started', \OC_Log::DEBUG ); if ( ! $util->ready() ) {
return $util->setupServerSide( $params['password'] ); \OC_Log::write( 'Encryption library', 'User account "' . $params['uid'] . '" is not ready for encryption; configuration started', \OC_Log::DEBUG );
} return $util->setupServerSide( $params['password'] );
\OC_FileProxy::$enabled = false; }
$encryptedKey = Keymanager::getPrivateKey( $view, $params['uid'] ); \OC_FileProxy::$enabled = false;
\OC_FileProxy::$enabled = true; $encryptedKey = Keymanager::getPrivateKey( $view, $params['uid'] );
$privateKey = Crypt::symmetricDecryptFileContent( $encryptedKey, $params['password'] ); \OC_FileProxy::$enabled = true;
$session = new Session(); $privateKey = Crypt::symmetricDecryptFileContent( $encryptedKey, $params['password'] );
$session->setPrivateKey( $privateKey, $params['uid'] ); $session = new Session();
$view1 = new \OC_FilesystemView( '/' . $params['uid'] ); $session->setPrivateKey( $privateKey, $params['uid'] );
// Set legacy encryption key if it exists, to support $view1 = new \OC_FilesystemView( '/' . $params['uid'] );
// depreciated encryption system
if (
$view1->file_exists( 'encryption.key' )
&& $encLegacyKey = $view1->file_get_contents( 'encryption.key' )
) {
$plainLegacyKey = Crypt::legacyDecrypt( $encLegacyKey, $params['password'] ); // Set legacy encryption key if it exists, to support
// depreciated encryption system
if (
$view1->file_exists( 'encryption.key' )
&& $encLegacyKey = $view1->file_get_contents( 'encryption.key' )
) {
$session->setLegacyKey( $plainLegacyKey ); $plainLegacyKey = Crypt::legacyDecrypt( $encLegacyKey, $params['password'] );
} $session->setLegacyKey( $plainLegacyKey );
$publicKey = Keymanager::getPublicKey( $view, $params['uid'] ); }
// Encrypt existing user files: $publicKey = Keymanager::getPublicKey( $view, $params['uid'] );
// This serves to upgrade old versions of the encryption
// app (see appinfo/spec.txt)
if (
$util->encryptAll( $publicKey, '/' . $params['uid'] . '/' . 'files', $session->getLegacyKey(), $params['password'] )
) {
\OC_Log::write( // Encrypt existing user files:
'Encryption library', 'Encryption of existing files belonging to "' . $params['uid'] . '" started at login' // This serves to upgrade old versions of the encryption
, \OC_Log::INFO // app (see appinfo/spec.txt)
); if (
$util->encryptAll( $publicKey, '/' . $params['uid'] . '/' . 'files', $session->getLegacyKey(), $params['password'] )
) {
} \OC_Log::write(
'Encryption library', 'Encryption of existing files belonging to "' . $params['uid'] . '" started at login'
, \OC_Log::INFO
);
}
return true; return true;