aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/lib
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_encryption/lib')
-rwxr-xr-xapps/files_encryption/lib/keymanager.php4
-rw-r--r--apps/files_encryption/lib/proxy.php2
-rw-r--r--apps/files_encryption/lib/stream.php2
-rw-r--r--apps/files_encryption/lib/util.php56
4 files changed, 52 insertions, 12 deletions
diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php
index 99516949afa..9bb062d0fdb 100755
--- a/apps/files_encryption/lib/keymanager.php
+++ b/apps/files_encryption/lib/keymanager.php
@@ -391,8 +391,10 @@ class Keymanager {
$result = true;
}
- if ( !result ) {
+ if ( ! $result ) {
+
\OC_Log::write( 'Encryption library', 'Could not delete shareKey; does not exist: "' . $shareKeyPath, \OC_Log::ERROR );
+
}
\OC_FileProxy::$enabled = false;
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
index a1eb76666d6..d5aa0f74f11 100644
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -140,7 +140,7 @@ class Proxy extends \OC_FileProxy {
if ( \OCP\Share::isEnabled() ) {
// Find out who, if anyone, is sharing the file
- $shareUids = \OCP\Share::getUsersSharingFile( $filePath, true );
+ $shareUids = \OCP\Share::getUsersSharingFile( $filePath, true, true, true );
$userIds = array_merge( $userIds, $shareUids );
diff --git a/apps/files_encryption/lib/stream.php b/apps/files_encryption/lib/stream.php
index 86439b4864f..9d01c2ca6c5 100644
--- a/apps/files_encryption/lib/stream.php
+++ b/apps/files_encryption/lib/stream.php
@@ -127,7 +127,7 @@ class Stream {
if ( ! is_resource( $this->handle ) ) {
- \OCP\Util::writeLog( 'files_encryption', 'failed to open file "'.$this->rootView . '"', \OCP\Util::ERROR );
+ \OCP\Util::writeLog( 'files_encryption', 'failed to open file "' . $this->relPath . '"', \OCP\Util::ERROR );
} else {
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 5276dae99a1..f6386ad84d9 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -638,7 +638,7 @@ class Util {
/**
* @brief Filter an array of UIDs to return only ones ready for sharing
* @param array $unfilteredUsers users to be checked for sharing readiness
- * @return array $userIds filtered users
+ * @return multi-dimensional array. keys: ready, unready
*/
public function filterShareReadyUsers( $unfilteredUsers ) {
@@ -649,6 +649,8 @@ class Util {
foreach ( $unfilteredUsers as $user ) {
$util = new Util( $this->view, $user );
+
+ $readyIds = $unreadyIds = array();
// Check that the user is encryption capable, or is the
// public system user 'ownCloud' (for public shares)
@@ -657,22 +659,26 @@ class Util {
or $user == 'ownCloud'
) {
- // Construct array of just UIDs for Keymanager{}
- $userIds[] = $user;
+ // Construct array of ready UIDs for Keymanager{}
+ $readyIds[] = $user;
} else {
-
+
+ // Construct array of unready UIDs for Keymanager{}
+ $unreadyIds[] = $user;
+
// Log warning; we can't do necessary setup here
// because we don't have the user passphrase
- // TODO: Provide user feedback indicating that
- // sharing failed
\OC_Log::write( 'Encryption library', '"'.$user.'" is not setup for encryption', \OC_Log::WARN );
}
}
- return $userIds;
+ return array (
+ 'ready' => $userIds
+ , 'unready' => $unreadyIds
+ );
}
@@ -778,8 +784,18 @@ class Util {
// Make sure users are capable of sharing
$filteredUids = $this->filterShareReadyUsers( $users );
+// trigger_error( print_r($filteredUids, 1) );
+
+ if ( ! empty( $filteredUids['unready'] ) ) {
+
+ // Notify user of unready userDir
+ // TODO: Move this out of here; it belongs somewhere else
+ \OCP\JSON::error();
+
+ }
+
// Get public keys for each user, ready for generating sharekeys
- $userPubKeys = Keymanager::getPublicKeys( $this->view, $filteredUids ); // TODO: check this includes the owner's public key
+ $userPubKeys = Keymanager::getPublicKeys( $this->view, $filteredUids['ready'] ); // TODO: check this includes the owner's public key
\OC_FileProxy::$enabled = false;
@@ -814,8 +830,30 @@ class Util {
return true;
}
+
+ /**
+ * @brief Returns the users who are sharing a file, including the file owner
+ * @param $path Relative path of the file, like files/file.txt
+ * @return $users array of UIDs
+ * @note This wraps the OCP\Share method, but includes the owner even if
+ * the file isn't registered in sharing API
+ */
+ public function getUsersSharingFile( $path ) {
+
+ $users = \OCP\Share::getUsersSharingFile( $path, true, true );
+
+ // FIXME: this is returning empty :/
+ $owner = \OC\Files\Filesystem::getOwner( $path );
+
+// trigger_error( var_export( $owner, 1));
+
+ $users[] = $owner;
+
+ return array_unique( $users );
+
+ }
- /**
+ /**
* @brief get uid of the owners of the file and the path to the file
* @param $filename
* @return array