diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2012-08-09 15:45:34 +0200 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2012-08-09 15:45:34 +0200 |
commit | bd7d5667330e1f9c8674602ea489805def2ba4f4 (patch) | |
tree | 2266d908c47391932cdbf62e169768cb17ebb8a1 /apps | |
parent | a969c23e59e26f2d82a1f8626444a59ae003c30e (diff) | |
download | nextcloud-server-bd7d5667330e1f9c8674602ea489805def2ba4f4.tar.gz nextcloud-server-bd7d5667330e1f9c8674602ea489805def2ba4f4.zip |
change private key passphrase; disable file proxy for keymanager operations
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_encryption/lib/keymanager.php | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php index 62c5082a2f7..8d56ac97dc5 100644 --- a/apps/files_encryption/lib/keymanager.php +++ b/apps/files_encryption/lib/keymanager.php @@ -36,10 +36,15 @@ class Keymanager { */
public static function getPrivateKey() {
- $user = \OCP\User::getUser();
+ \OC_FileProxy::$enabled = false;
+
+ $user = \OCP\User::getUser();
$view = new \OC_FilesystemView( '/' . $user . '/' . 'files_encryption' );
+ $result = $view->file_get_contents( '/' . $user.'.private.key' );
+
+ \OC_FileProxy::$enabled = true;
- return $view->file_get_contents( '/' . $user.'.private.key' );
+ return $result;
}
/**
@@ -75,6 +80,8 @@ class Keymanager { }
}
+ \OC_FileProxy::$enabled = false;
+
$view = new \OC_FilesystemView( '/public-keys/' );
$keylist = array();
@@ -83,6 +90,8 @@ class Keymanager { $keylist['key'.++$count] = $view->file_get_contents($user.'.public.key');
}
+ \OC_FileProxy::$enabled = true;
+
return $keylist;
}
@@ -108,8 +117,14 @@ class Keymanager { $keypath = str_replace('/'.$user.'/files/', '', $keypath);
}
+ \OC_FileProxy::$enabled = false;
+
$view = new \OC_FilesystemView('/'.$user.'/files_encryption/keyfiles/');
- return $view->file_get_contents($keypath.'.key');
+ $result = $view->file_get_contents($keypath.'.key');
+
+ \OC_FileProxy::$enabled = true;
+
+ return $result;
}
/**
@@ -208,11 +223,16 @@ class Keymanager { */
public static function changePasswd($oldpasswd, $newpasswd) {
if ( \OCP\User::checkPassword(\OCP\User::getUser(), $newpasswd) ) {
- return Crypt::changekeypasscode($oldpasswd, $newpasswd);
- } else {
- return false;
+ $key = Keymanager::getPrivateKey();
+ if ( ($key = Crypt::symmetricDecryptFileContent($key,$oldpasswd)) ) {
+ if ( ($key = Crypt::symmetricEncryptFileContent($key, $newpasswd)) ) {
+ Keymanager::setPrivateKey($key);
+ return true;
+
+ }
+ }
}
-
+ return false;
}
}
\ No newline at end of file |