* @note This method should never be called for users using client side encryption\r
*/\r
public static function login($params) {\r
+\r
+ if (\OCP\App::isEnabled('files_encryption') === false) {\r
+ return true;\r
+ }\r
+\r
+\r
$l = new \OC_L10N('files_encryption');\r
\r
$view = new \OC_FilesystemView('/');\r
* @note This method should never be called for users using client side encryption\r
*/\r
public static function postCreateUser($params) {\r
- $view = new \OC_FilesystemView('/');\r
-\r
- $util = new Util($view, $params['uid']);\r
\r
- Helper::setupUser($util, $params['password']);\r
+ if (\OCP\App::isEnabled('files_encryption')) {\r
+ $view = new \OC_FilesystemView('/');\r
+ $util = new Util($view, $params['uid']);\r
+ Helper::setupUser($util, $params['password']);\r
+ }\r
}\r
\r
/**\r
* @note This method should never be called for users using client side encryption\r
*/\r
public static function postDeleteUser($params) {\r
- $view = new \OC_FilesystemView('/');\r
\r
- // cleanup public key\r
- $publicKey = '/public-keys/' . $params['uid'] . '.public.key';\r
+ if (\OCP\App::isEnabled('files_encryption')) {\r
+ $view = new \OC_FilesystemView('/');\r
\r
- // Disable encryption proxy to prevent recursive calls\r
- $proxyStatus = \OC_FileProxy::$enabled;\r
- \OC_FileProxy::$enabled = false;\r
+ // cleanup public key\r
+ $publicKey = '/public-keys/' . $params['uid'] . '.public.key';\r
\r
- $view->unlink($publicKey);\r
+ // Disable encryption proxy to prevent recursive calls\r
+ $proxyStatus = \OC_FileProxy::$enabled;\r
+ \OC_FileProxy::$enabled = false;\r
\r
- \OC_FileProxy::$enabled = $proxyStatus;\r
+ $view->unlink($publicKey);\r
+\r
+ \OC_FileProxy::$enabled = $proxyStatus;\r
+ }\r
}\r
\r
/**\r
* @brief If the password can't be changed within ownCloud, than update the key password in advance.\r
*/\r
public static function preSetPassphrase($params) {\r
- if ( ! \OC_User::canUserChangePassword($params['uid']) ) {\r
- self::setPassphrase($params);\r
+ if (\OCP\App::isEnabled('files_encryption')) {\r
+ if ( ! \OC_User::canUserChangePassword($params['uid']) ) {\r
+ self::setPassphrase($params);\r
+ }\r
}\r
}\r
\r
* @param array $params keys: uid, password\r
*/\r
public static function setPassphrase($params) {\r
+\r
+ if (\OCP\App::isEnabled('files_encryption') === false) {\r
+ return true;\r
+ }\r
+\r
// Only attempt to change passphrase if server-side encryption\r
// is in use (client-side encryption does not have access to\r
// the necessary keys)\r
*/\r
public static function preShared($params) {\r
\r
+ if (\OCP\App::isEnabled('files_encryption') === false) {\r
+ return true;\r
+ }\r
+\r
$l = new \OC_L10N('files_encryption');\r
$users = array();\r
$view = new \OC\Files\View('/public-keys/');\r
// [run] => whether emitting script should continue to run\r
// TODO: Should other kinds of item be encrypted too?\r
\r
+ if (\OCP\App::isEnabled('files_encryption') === false) {\r
+ return true;\r
+ }\r
+\r
if ($params['itemType'] === 'file' || $params['itemType'] === 'folder') {\r
\r
$view = new \OC_FilesystemView('/');\r
// [shareWith] => test1\r
// [itemParent] =>\r
\r
+ if (\OCP\App::isEnabled('files_encryption') === false) {\r
+ return true;\r
+ }\r
+\r
if ($params['itemType'] === 'file' || $params['itemType'] === 'folder') {\r
\r
$view = new \OC_FilesystemView('/');\r
* of the stored versions along the actual file\r
*/\r
public static function postRename($params) {\r
+\r
+ if (\OCP\App::isEnabled('files_encryption') === false) {\r
+ return true;\r
+ }\r
+\r
// Disable encryption proxy to prevent recursive calls\r
$proxyStatus = \OC_FileProxy::$enabled;\r
\OC_FileProxy::$enabled = false;\r
}
}
+ /**
+ * @brief get file owner and path
+ * @param string $filename
+ * @return array with the oweners uid and the owners path
+ */
+ public static function getUidAndFilename($filename) {
+
+ $uid = \OC\Files\Filesystem::getOwner($filename);
+ \OC\Files\Filesystem::initMountPoints($uid);
+
+ if ($uid != \OCP\User::getUser()) {
+ $info = \OC\Files\Filesystem::getFileInfo($filename);
+ $ownerView = new \OC\Files\View('/' . $uid . '/files');
+ $filename = $ownerView->getPath($info['fileid']);
+ }
+ return array($uid, '/files/' . $filename);
+ }
+
/**
* Update the mtime and ETag of all parent folders
*
*/
static public function correctFolder($path, $time) {
if ($path !== '' && $path !== '/') {
- $parent = dirname($path);
- if ($parent === '.' || $parent === '\\') {
- $parent = '';
- }
+
+ list($owner, $realPath) = self::getUidAndFilename(dirname($path));
+
/**
* @var \OC\Files\Storage\Storage $storage
* @var string $internalPath
*/
- list($storage, $internalPath) = self::resolvePath($parent);
- if ($storage) {
- $cache = $storage->getCache();
- $id = $cache->getId($internalPath);
- if ($id !== -1) {
- $cache->update($id, array('mtime' => $time, 'etag' => $storage->getETag($internalPath)));
- self::correctFolder($parent, $time);
+ $view = new \OC\Files\View('/' . $owner);
+
+ list($storage, $internalPath) = $view->resolvePath($realPath);
+ $cache = $storage->getCache();
+ $id = $cache->getId($internalPath);
+
+ while ($id !== -1) {
+ $cache->update($id, array('mtime' => $time, 'etag' => $storage->getETag($internalPath)));
+ $realPath = dirname($realPath);
+ // check storage for parent in case we change the storage in this step
+ list($storage, $internalPath) = $view->resolvePath($realPath);
+ if ($internalPath) {
+ $cache = $storage->getCache();
+ $id = $cache->getId($internalPath);
} else {
- Util::writeLog('core', 'Path not in cache: '.$internalPath, Util::ERROR);
+ $id = -1;
}
}
}
*/
private $scanner;
+ private $stateFilesEncryption;
+
/**
* @var \OC\Files\Cache\Cache $cache
*/
private static $user;
public function setUp() {
+
+ // remember files_encryption state
+ $this->stateFilesEncryption = \OC_App::isEnabled('files_encryption');
+ // we want to tests with the encryption app disabled
+ \OC_App::disable('files_encryption');
+
$this->storage = new \OC\Files\Storage\Temporary(array());
$textData = "dummy file data\n";
$imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo.png');
if (!self::$user) {
self::$user = uniqid();
}
+
+ \OC_User::createUser(self::$user, 'password');
+ \OC_User::setUserId(self::$user);
+
\OC\Files\Filesystem::init(self::$user, '/' . self::$user . '/files');
Filesystem::clearMounts();
if ($this->cache) {
$this->cache->clear();
}
+ $result = \OC_User::deleteUser(self::$user);
+ $this->assertTrue($result);
Filesystem::tearDown();
+ // reset app files_encryption
+ if ($this->stateFilesEncryption) {
+ \OC_App::enable('files_encryption');
+ }
}
public function testWrite() {