Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
f2de4cb3
Commit
f2de4cb3
authored
11 years ago
by
Björn Schießle
Browse files
Options
Downloads
Patches
Plain Diff
some performance improvements, check for system wide mounts only once while writing share keys
parent
2e56f0e2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/files_encryption/lib/keymanager.php
+25
-40
25 additions, 40 deletions
apps/files_encryption/lib/keymanager.php
with
25 additions
and
40 deletions
apps/files_encryption/lib/keymanager.php
+
25
−
40
View file @
f2de4cb3
...
...
@@ -335,58 +335,26 @@ class Keymanager {
* @brief store share key
*
* @param \OC_FilesystemView $view
* @param string $path relative path of the file, including filename
* @param $userId
* @param string $path where the share key is stored
* @param $shareKey
* @internal param string $key
* @internal param string $dbClassName
* @return bool true/false
* @note The keyfile is not encrypted here. Client code must
* asymmetrically encrypt the keyfile before passing it to this method
*/
public
static
function
setShareKey
(
\OC_FilesystemView
$view
,
$path
,
$userId
,
$shareKey
)
{
// Here we need the currently logged in user, while userId can be a different user
$util
=
new
Util
(
$view
,
\OCP\User
::
getUser
());
list
(
$owner
,
$filename
)
=
$util
->
getUidAndFilename
(
$path
);
// in case of system wide mount points the keys are stored directly in the data directory
if
(
self
::
isSystemWideMountPoint
(
$filename
))
{
$basePath
=
'/files_encryption/share-keys'
;
}
else
{
$basePath
=
'/'
.
$owner
.
'/files_encryption/share-keys'
;
}
$shareKeyPath
=
self
::
keySetPreparation
(
$view
,
$filename
,
$basePath
,
$owner
);
// try reusing key file if part file
if
(
self
::
isPartialFilePath
(
$shareKeyPath
))
{
$writePath
=
$basePath
.
'/'
.
self
::
fixPartialFilePath
(
$shareKeyPath
)
.
'.'
.
$userId
.
'.shareKey'
;
}
else
{
$writePath
=
$basePath
.
'/'
.
$shareKeyPath
.
'.'
.
$userId
.
'.shareKey'
;
}
private
static
function
setShareKey
(
\OC_FilesystemView
$view
,
$path
,
$shareKey
)
{
$proxyStatus
=
\OC_FileProxy
::
$enabled
;
\OC_FileProxy
::
$enabled
=
false
;
$result
=
$view
->
file_put_contents
(
$
writeP
ath
,
$shareKey
);
$result
=
$view
->
file_put_contents
(
$
p
ath
,
$shareKey
);
\OC_FileProxy
::
$enabled
=
$proxyStatus
;
if
(
is_int
(
$result
)
&&
$result
>
0
)
{
if
(
is_int
(
$result
)
&&
$result
>
0
)
{
return
true
;
}
else
{
return
false
;
}
}
/**
...
...
@@ -400,23 +368,40 @@ class Keymanager {
// $shareKeys must be an array with the following format:
// [userId] => [encrypted key]
// Here we need the currently logged in user, while userId can be a different user
$util
=
new
Util
(
$view
,
\OCP\User
::
getUser
());
list
(
$owner
,
$filename
)
=
$util
->
getUidAndFilename
(
$path
);
// in case of system wide mount points the keys are stored directly in the data directory
if
(
self
::
isSystemWideMountPoint
(
$filename
))
{
$basePath
=
'/files_encryption/share-keys'
;
}
else
{
$basePath
=
'/'
.
$owner
.
'/files_encryption/share-keys'
;
}
$shareKeyPath
=
self
::
keySetPreparation
(
$view
,
$filename
,
$basePath
,
$owner
);
$result
=
true
;
foreach
(
$shareKeys
as
$userId
=>
$shareKey
)
{
if
(
!
self
::
setShareKey
(
$view
,
$path
,
$userId
,
$shareKey
))
{
// try reusing key file if part file
if
(
self
::
isPartialFilePath
(
$shareKeyPath
))
{
$writePath
=
$basePath
.
'/'
.
self
::
fixPartialFilePath
(
$shareKeyPath
)
.
'.'
.
$userId
.
'.shareKey'
;
}
else
{
$writePath
=
$basePath
.
'/'
.
$shareKeyPath
.
'.'
.
$userId
.
'.shareKey'
;
}
if
(
!
self
::
setShareKey
(
$view
,
$writePath
,
$shareKey
))
{
// If any of the keys are not set, flag false
$result
=
false
;
}
}
// Returns false if any of the keys weren't set
return
$result
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment