diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2015-06-03 11:12:44 +0200 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2015-06-03 11:59:06 +0200 |
commit | 7eb2b31e34bf89a2c0fbf8c6d49aa1eed5899681 (patch) | |
tree | 49f844cd946b36b5f3d471da08f98eb4c9a0fdaf /lib/private/encryption | |
parent | 410a836702c363cfeb0c7a83dce0d6fcca0c5d7e (diff) | |
download | nextcloud-server-7eb2b31e34bf89a2c0fbf8c6d49aa1eed5899681.tar.gz nextcloud-server-7eb2b31e34bf89a2c0fbf8c6d49aa1eed5899681.zip |
make sure that we always use the correct owner for both source and target
Diffstat (limited to 'lib/private/encryption')
-rw-r--r-- | lib/private/encryption/keys/storage.php | 55 |
1 files changed, 24 insertions, 31 deletions
diff --git a/lib/private/encryption/keys/storage.php b/lib/private/encryption/keys/storage.php index 692633f98da..fa317851a56 100644 --- a/lib/private/encryption/keys/storage.php +++ b/lib/private/encryption/keys/storage.php @@ -232,22 +232,8 @@ class Storage implements IStorage { */ public function renameKeys($source, $target) { - list($owner, $source) = $this->util->getUidAndFilename($source); - list(, $target) = $this->util->getUidAndFilename($target); - $systemWideSource = $this->util->isSystemWideMountPoint($source, $owner); - $systemWideTarget = $this->util->isSystemWideMountPoint($target, $owner); - - if ($systemWideSource) { - $sourcePath = $this->keys_base_dir . $source . '/'; - } else { - $sourcePath = '/' . $owner . $this->keys_base_dir . $source . '/'; - } - - if ($systemWideTarget) { - $targetPath = $this->keys_base_dir . $target . '/'; - } else { - $targetPath = '/' . $owner . $this->keys_base_dir . $target . '/'; - } + $sourcePath = $this->getPathToKeys($source); + $targetPath = $this->getPathToKeys($target); if ($this->view->file_exists($sourcePath)) { $this->keySetPreparation(dirname($targetPath)); @@ -259,6 +245,7 @@ class Storage implements IStorage { return false; } + /** * copy keys if a file was renamed * @@ -268,21 +255,8 @@ class Storage implements IStorage { */ public function copyKeys($source, $target) { - list($owner, $source) = $this->util->getUidAndFilename($source); - list(, $target) = $this->util->getUidAndFilename($target); - $systemWideTarget = $this->util->isSystemWideMountPoint($target, $owner); - $systemWideSource = $this->util->isSystemWideMountPoint($source, $owner); - - if ($systemWideSource) { - $sourcePath = $this->keys_base_dir . $source . '/'; - } else { - $sourcePath = '/' . $owner . $this->keys_base_dir . $source . '/'; - } - if ($systemWideTarget) { - $targetPath = $this->keys_base_dir . $target . '/'; - } else { - $targetPath = '/' . $owner . $this->keys_base_dir . $target . '/'; - } + $sourcePath = $this->getPathToKeys($source); + $targetPath = $this->getPathToKeys($target); if ($this->view->file_exists($sourcePath)) { $this->keySetPreparation(dirname($targetPath)); @@ -294,6 +268,25 @@ class Storage implements IStorage { } /** + * get system wide path and detect mount points + * + * @param string $path + * @return string + */ + protected function getPathToKeys($path) { + list($owner, $relativePath) = $this->util->getUidAndFilename($path); + $systemWideMountPoint = $this->util->isSystemWideMountPoint($relativePath, $owner); + + if ($systemWideMountPoint) { + $systemPath = $this->keys_base_dir . $relativePath . '/'; + } else { + $systemPath = '/' . $owner . $this->keys_base_dir . $relativePath . '/'; + } + + return $systemPath; + } + + /** * Make preparations to filesystem for saving a key file * * @param string $path relative to the views root |