summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php6
-rw-r--r--lib/private/activity/event.php2
-rw-r--r--lib/private/app.php4
-rw-r--r--lib/private/app/codechecker/infochecker.php146
-rw-r--r--lib/private/appframework/utility/simplecontainer.php4
-rw-r--r--lib/private/connector/sabre/file.php7
-rw-r--r--lib/private/connector/sabre/listenerplugin.php12
-rw-r--r--lib/private/db/querybuilder/quotehelper.php2
-rw-r--r--lib/private/encryption/decryptall.php5
-rw-r--r--lib/private/files/storage/common.php4
-rw-r--r--lib/private/files/storage/dav.php9
-rw-r--r--lib/private/files/storage/local.php2
-rw-r--r--lib/private/files/storage/polyfill/copydirectory.php2
-rw-r--r--lib/private/files/storage/wrapper/permissionsmask.php2
-rw-r--r--lib/private/files/type/detection.php35
-rw-r--r--lib/private/files/view.php104
-rw-r--r--lib/private/http/client/client.php2
-rw-r--r--lib/private/lock/dblockingprovider.php36
-rw-r--r--lib/private/preview.php6
-rw-r--r--lib/private/security/certificatemanager.php2
-rw-r--r--lib/private/server.php4
-rw-r--r--lib/private/share/share.php5
-rw-r--r--lib/private/templatelayout.php9
-rw-r--r--lib/private/updater.php7
-rw-r--r--lib/private/user.php14
-rw-r--r--lib/private/user/dummy.php169
-rw-r--r--lib/private/util.php2
-rw-r--r--lib/public/icontainer.php1
-rw-r--r--lib/public/sabrepluginevent.php82
-rw-r--r--lib/public/sabrepluginexception.php41
30 files changed, 446 insertions, 280 deletions
diff --git a/lib/base.php b/lib/base.php
index acb9814dd76..f99acaaa80a 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -228,7 +228,7 @@ class OC {
public static function checkConfig() {
$l = \OC::$server->getL10N('lib');
- // Create config in case it does not already exists
+ // Create config if it does not already exist
$configFilePath = self::$configDir .'/config.php';
if(!file_exists($configFilePath)) {
@touch($configFilePath);
@@ -314,7 +314,7 @@ class OC {
}
/**
- * check if the instance needs to preform an upgrade
+ * check if the instance needs to perform an upgrade
*
* @return bool
* @deprecated use \OCP\Util::needUpgrade() instead
@@ -567,7 +567,7 @@ class OC {
//try to configure php to enable big file uploads.
//this doesn´t work always depending on the webserver and php configuration.
- //Let´s try to overwrite some defaults anyways
+ //Let´s try to overwrite some defaults anyway
//try to set the maximum execution time to 60min
@set_time_limit(3600);
diff --git a/lib/private/activity/event.php b/lib/private/activity/event.php
index fe6fc485b7b..247113d54a9 100644
--- a/lib/private/activity/event.php
+++ b/lib/private/activity/event.php
@@ -90,7 +90,7 @@ class Event implements IEvent {
}
/**
- * Set the author of the activity
+ * Set the timestamp of the activity
*
* @param int $timestamp
* @return IEvent
diff --git a/lib/private/app.php b/lib/private/app.php
index 6c9f7615228..5122a4964d4 100644
--- a/lib/private/app.php
+++ b/lib/private/app.php
@@ -411,7 +411,7 @@ class OC_App {
/**
* Returns the Settings Navigation
*
- * @return string
+ * @return string[]
*
* This function returns an array containing all settings pages added. The
* entries are sorted by the key 'order' ascending.
@@ -837,7 +837,7 @@ class OC_App {
$info['active'] = $active;
- if (isset($info['shipped']) and ($info['shipped'] == 'true')) {
+ if (self::isShipped($app)) {
$info['internal'] = true;
$info['level'] = self::officialApp;
$info['removable'] = false;
diff --git a/lib/private/app/codechecker/infochecker.php b/lib/private/app/codechecker/infochecker.php
new file mode 100644
index 00000000000..91580bde07d
--- /dev/null
+++ b/lib/private/app/codechecker/infochecker.php
@@ -0,0 +1,146 @@
+<?php
+/**
+ * @author Morris Jobke <hey@morrisjobke.de>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OC\App\CodeChecker;
+
+use OC\App\InfoParser;
+use OC\Hooks\BasicEmitter;
+
+class InfoChecker extends BasicEmitter {
+
+ /** @var InfoParser */
+ private $infoParser;
+
+ private $mandatoryFields = [
+ 'author',
+ 'description',
+ 'id',
+ 'licence',
+ 'name',
+ ];
+ private $optionalFields = [
+ 'bugs',
+ 'category',
+ 'default_enable',
+ 'dependencies',
+ 'documentation',
+ 'namespace',
+ 'ocsid',
+ 'public',
+ 'remote',
+ 'repository',
+ 'require',
+ 'requiremin',
+ 'types',
+ 'version',
+ 'website',
+ ];
+ private $deprecatedFields = [
+ 'info',
+ 'shipped',
+ 'standalone',
+ ];
+
+ public function __construct(InfoParser $infoParser) {
+ $this->infoParser = $infoParser;
+ }
+
+ /**
+ * @param string $appId
+ * @return array
+ */
+ public function analyse($appId) {
+ $appPath = \OC_App::getAppPath($appId);
+ if ($appPath === false) {
+ throw new \RuntimeException("No app with given id <$appId> known.");
+ }
+
+ $errors = [];
+
+ $info = $this->infoParser->parse($appPath . '/appinfo/info.xml');
+
+ foreach ($info as $key => $value) {
+ if(is_array($value)) {
+ $value = json_encode($value);
+ }
+ if (in_array($key, $this->mandatoryFields)) {
+ $this->emit('InfoChecker', 'mandatoryFieldFound', [$key, $value]);
+ continue;
+ }
+
+ if (in_array($key, $this->optionalFields)) {
+ $this->emit('InfoChecker', 'optionalFieldFound', [$key, $value]);
+ continue;
+ }
+
+ if (in_array($key, $this->deprecatedFields)) {
+ // skip empty arrays - empty arrays for remote and public are always added
+ if($value === '[]' && in_array($key, ['public', 'remote', 'info'])) {
+ continue;
+ }
+ $this->emit('InfoChecker', 'deprecatedFieldFound', [$key, $value]);
+ continue;
+ }
+
+ $this->emit('InfoChecker', 'unusedFieldFound', [$key, $value]);
+ }
+
+ foreach ($this->mandatoryFields as $key) {
+ if(!isset($info[$key])) {
+ $this->emit('InfoChecker', 'mandatoryFieldMissing', [$key]);
+ $errors[] = [
+ 'type' => 'mandatoryFieldMissing',
+ 'field' => $key,
+ ];
+ }
+ }
+
+ $versionFile = $appPath . '/appinfo/version';
+ if (is_file($versionFile)) {
+ $version = trim(file_get_contents($versionFile));
+ if(isset($info['version'])) {
+ if($info['version'] !== $version) {
+ $this->emit('InfoChecker', 'differentVersions',
+ [$version, $info['version']]);
+ $errors[] = [
+ 'type' => 'differentVersions',
+ 'message' => 'appinfo/version: ' . $version .
+ ' - appinfo/info.xml: ' . $info['version'],
+ ];
+ } else {
+ $this->emit('InfoChecker', 'sameVersions', [$versionFile]);
+ }
+ } else {
+ $this->emit('InfoChecker', 'migrateVersion', [$version]);
+ }
+ } else {
+ if(!isset($info['version'])) {
+ $this->emit('InfoChecker', 'mandatoryFieldMissing', ['version']);
+ $errors[] = [
+ 'type' => 'mandatoryFieldMissing',
+ 'field' => 'version',
+ ];
+ }
+ }
+
+ return $errors;
+ }
+}
diff --git a/lib/private/appframework/utility/simplecontainer.php b/lib/private/appframework/utility/simplecontainer.php
index 5d7ea48752b..3de6d9ba5bc 100644
--- a/lib/private/appframework/utility/simplecontainer.php
+++ b/lib/private/appframework/utility/simplecontainer.php
@@ -45,7 +45,7 @@ class SimpleContainer extends Container implements IContainer {
/**
* @param ReflectionClass $class the class to instantiate
- * @return stdClass the created class
+ * @return \stdClass the created class
*/
private function buildClass(ReflectionClass $class) {
$constructor = $class->getConstructor();
@@ -74,7 +74,7 @@ class SimpleContainer extends Container implements IContainer {
* If a parameter is not registered in the container try to instantiate it
* by using reflection to find out how to build the class
* @param string $name the class name to resolve
- * @return stdClass
+ * @return \stdClass
* @throws QueryException if the class could not be found or instantiated
*/
public function resolve($name) {
diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php
index 17659c96b07..f4acc8290bc 100644
--- a/lib/private/connector/sabre/file.php
+++ b/lib/private/connector/sabre/file.php
@@ -261,10 +261,13 @@ class File extends Node implements IFile {
* @throws ServiceUnavailable
*/
public function get() {
-
//throw exception if encryption is disabled but files are still encrypted
try {
- return $this->fileView->fopen(ltrim($this->path, '/'), 'rb');
+ $res = $this->fileView->fopen(ltrim($this->path, '/'), 'rb');
+ if ($res === false) {
+ throw new ServiceUnavailable("Could not open file");
+ }
+ return $res;
} catch (GenericEncryptionException $e) {
// returning 503 will allow retry of the operation at a later point in time
throw new ServiceUnavailable("Encryption not ready: " . $e->getMessage());
diff --git a/lib/private/connector/sabre/listenerplugin.php b/lib/private/connector/sabre/listenerplugin.php
index d0d40f4dc86..ec628add28b 100644
--- a/lib/private/connector/sabre/listenerplugin.php
+++ b/lib/private/connector/sabre/listenerplugin.php
@@ -21,6 +21,9 @@
namespace OC\Connector\Sabre;
+use OCP\AppFramework\Http;
+use OCP\SabrePluginEvent;
+use OCP\SabrePluginException;
use Sabre\DAV\ServerPlugin;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -49,9 +52,16 @@ class ListenerPlugin extends ServerPlugin {
* in case the system is in maintenance mode.
*
* @return bool
+ * @throws \Exception
*/
public function emitListener() {
- $this->dispatcher->dispatch('OC\Connector\Sabre::beforeMethod');
+ $event = new SabrePluginEvent();
+
+ $this->dispatcher->dispatch('OC\Connector\Sabre::beforeMethod', $event);
+
+ if ($event->getStatusCode() !== Http::STATUS_OK) {
+ throw new SabrePluginException($event->getMessage(), $event->getStatusCode());
+ }
return true;
}
diff --git a/lib/private/db/querybuilder/quotehelper.php b/lib/private/db/querybuilder/quotehelper.php
index 0735f313abc..4b62fee6a6c 100644
--- a/lib/private/db/querybuilder/quotehelper.php
+++ b/lib/private/db/querybuilder/quotehelper.php
@@ -52,7 +52,7 @@ class QuoteHelper {
return (string) $string;
}
- if ($string === null || $string === '*') {
+ if ($string === null || $string === 'null' || $string === '*') {
return $string;
}
diff --git a/lib/private/encryption/decryptall.php b/lib/private/encryption/decryptall.php
index e59be17886d..c1875f16abd 100644
--- a/lib/private/encryption/decryptall.php
+++ b/lib/private/encryption/decryptall.php
@@ -80,6 +80,11 @@ class DecryptAll {
$this->input = $input;
$this->output = $output;
+ if (!empty($user) && $this->userManager->userExists($user) === false) {
+ $this->output->writeln('User "' . $user . '" does not exist. Please check the username and try again');
+ return false;
+ }
+
$this->output->writeln('prepare encryption modules...');
if ($this->prepareEncryptionModules($user) === false) {
return false;
diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php
index a5ed5fd3996..2d579fa2b60 100644
--- a/lib/private/files/storage/common.php
+++ b/lib/private/files/storage/common.php
@@ -260,7 +260,7 @@ abstract class Common implements Storage {
$dh = $this->opendir($path);
if (is_resource($dh)) {
while (($file = readdir($dh)) !== false) {
- if ($file !== '.' and $file !== '..') {
+ if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
if ($this->is_dir($path . '/' . $file)) {
mkdir($target . '/' . $file);
$this->addLocalFolder($path . '/' . $file, $target . '/' . $file);
@@ -283,7 +283,7 @@ abstract class Common implements Storage {
$dh = $this->opendir($dir);
if (is_resource($dh)) {
while (($item = readdir($dh)) !== false) {
- if ($item == '.' || $item == '..') continue;
+ if (\OC\Files\Filesystem::isIgnoredDir($item)) continue;
if (strstr(strtolower($item), strtolower($query)) !== false) {
$files[] = $dir . '/' . $item;
}
diff --git a/lib/private/files/storage/dav.php b/lib/private/files/storage/dav.php
index c1cf17abdee..171afd649c6 100644
--- a/lib/private/files/storage/dav.php
+++ b/lib/private/files/storage/dav.php
@@ -370,6 +370,7 @@ class DAV extends Common {
case 'c':
case 'c+':
//emulate these
+ $tempManager = \OC::$server->getTempManager();
if (strrpos($path, '.') !== false) {
$ext = substr($path, strrpos($path, '.'));
} else {
@@ -379,12 +380,16 @@ class DAV extends Common {
if (!$this->isUpdatable($path)) {
return false;
}
- $tmpFile = $this->getCachedFile($path);
+ if ($mode === 'w' or $mode === 'w+') {
+ $tmpFile = $tempManager->getTemporaryFile($ext);
+ } else {
+ $tmpFile = $this->getCachedFile($path);
+ }
} else {
if (!$this->isCreatable(dirname($path))) {
return false;
}
- $tmpFile = Files::tmpFile($ext);
+ $tmpFile = $tempManager->getTemporaryFile($ext);
}
Close::registerCallback($tmpFile, array($this, 'writeBack'));
self::$tempFiles[$tmpFile] = $path;
diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php
index 3676fe69131..4b6b08a16fd 100644
--- a/lib/private/files/storage/local.php
+++ b/lib/private/files/storage/local.php
@@ -283,7 +283,7 @@ class Local extends \OC\Files\Storage\Common {
$files = array();
$physicalDir = $this->getSourcePath($dir);
foreach (scandir($physicalDir) as $item) {
- if ($item == '.' || $item == '..')
+ if (\OC\Files\Filesystem::isIgnoredDir($item))
continue;
$physicalItem = $physicalDir . '/' . $item;
diff --git a/lib/private/files/storage/polyfill/copydirectory.php b/lib/private/files/storage/polyfill/copydirectory.php
index 1b4873a3a76..73c6d3d5436 100644
--- a/lib/private/files/storage/polyfill/copydirectory.php
+++ b/lib/private/files/storage/polyfill/copydirectory.php
@@ -72,7 +72,7 @@ trait CopyDirectory {
$dh = $this->opendir($source);
$result = true;
while ($file = readdir($dh)) {
- if ($file !== '.' and $file !== '..') {
+ if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
if ($this->is_dir($source . '/' . $file)) {
$this->mkdir($target . '/' . $file);
$result = $this->copyRecursive($source . '/' . $file, $target . '/' . $file);
diff --git a/lib/private/files/storage/wrapper/permissionsmask.php b/lib/private/files/storage/wrapper/permissionsmask.php
index 50c3f2a6268..8d40d023630 100644
--- a/lib/private/files/storage/wrapper/permissionsmask.php
+++ b/lib/private/files/storage/wrapper/permissionsmask.php
@@ -66,7 +66,7 @@ class PermissionsMask extends Wrapper {
}
public function isSharable($path) {
- return $this->checkMask(Constants::PERMISSION_SHARE) and parent::isSharable($parm);
+ return $this->checkMask(Constants::PERMISSION_SHARE) and parent::isSharable($path);
}
public function getPermissions($path) {
diff --git a/lib/private/files/type/detection.php b/lib/private/files/type/detection.php
index 3dc3975fb2a..0c647ab44c6 100644
--- a/lib/private/files/type/detection.php
+++ b/lib/private/files/type/detection.php
@@ -49,15 +49,22 @@ class Detection implements IMimeTypeDetector {
private $urlGenerator;
/** @var string */
- private $configDir;
+ private $customConfigDir;
+
+ /** @var string */
+ private $defaultConfigDir;
/**
* @param IURLGenerator $urlGenerator
- * @param string $configDir
+ * @param string $customConfigDir
+ * @param string $defaultConfigDir
*/
- public function __construct(IURLGenerator $urlGenerator, $configDir) {
+ public function __construct(IURLGenerator $urlGenerator,
+ $customConfigDir,
+ $defaultConfigDir) {
$this->urlGenerator = $urlGenerator;
- $this->configDir = $configDir;
+ $this->customConfigDir = $customConfigDir;
+ $this->defaultConfigDir = $defaultConfigDir;
}
/**
@@ -71,7 +78,9 @@ class Detection implements IMimeTypeDetector {
* @param string $mimetype
* @param string|null $secureMimeType
*/
- public function registerType($extension, $mimetype, $secureMimeType = null) {
+ public function registerType($extension,
+ $mimetype,
+ $secureMimeType = null) {
$this->mimetypes[$extension] = array($mimetype, $secureMimeType);
$this->secureMimeTypes[$mimetype] = $secureMimeType ?: $mimetype;
}
@@ -102,10 +111,10 @@ class Detection implements IMimeTypeDetector {
return;
}
- $this->mimeTypeAlias = json_decode(file_get_contents($this->configDir . '/mimetypealiases.dist.json'), true);
+ $this->mimeTypeAlias = json_decode(file_get_contents($this->defaultConfigDir . '/mimetypealiases.dist.json'), true);
- if (file_exists($this->configDir . '/mimetypealiases.json')) {
- $custom = json_decode(file_get_contents($this->configDir . '/mimetypealiases.json'), true);
+ if (file_exists($this->customConfigDir . '/mimetypealiases.json')) {
+ $custom = json_decode(file_get_contents($this->customConfigDir . '/mimetypealiases.json'), true);
$this->mimeTypeAlias = array_merge($this->mimeTypeAlias, $custom);
}
}
@@ -126,15 +135,15 @@ class Detection implements IMimeTypeDetector {
return;
}
- $mimetypemapping = json_decode(file_get_contents($this->configDir . '/mimetypemapping.dist.json'), true);
+ $mimetypeMapping = json_decode(file_get_contents($this->defaultConfigDir . '/mimetypemapping.dist.json'), true);
//Check if need to load custom mappings
- if (file_exists($this->configDir . '/mimetypemapping.json')) {
- $custom = json_decode(file_get_contents($this->configDir . '/mimetypemapping.json'), true);
- $mimetypemapping = array_merge($mimetypemapping, $custom);
+ if (file_exists($this->customConfigDir . '/mimetypemapping.json')) {
+ $custom = json_decode(file_get_contents($this->customConfigDir . '/mimetypemapping.json'), true);
+ $mimetypeMapping = array_merge($mimetypeMapping, $custom);
}
- $this->registerTypeArray($mimetypemapping);
+ $this->registerTypeArray($mimetypeMapping);
}
/**
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index 9afa9d40b20..95b688fef5c 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -153,7 +153,10 @@ class View {
return '/';
}
- if (strpos($path, $this->fakeRoot) !== 0) {
+ // missing slashes can cause wrong matches!
+ $root = rtrim($this->fakeRoot, '/') . '/';
+
+ if (strpos($path, $root) !== 0) {
return null;
} else {
$path = substr($path, strlen($this->fakeRoot));
@@ -759,59 +762,72 @@ class View {
$this->lockFile($path2, ILockingProvider::LOCK_SHARED);
$this->lockFile($path1, ILockingProvider::LOCK_SHARED);
+ $lockTypePath1 = ILockingProvider::LOCK_SHARED;
+ $lockTypePath2 = ILockingProvider::LOCK_SHARED;
- $exists = $this->file_exists($path2);
- if ($this->shouldEmitHooks()) {
- \OC_Hook::emit(
- Filesystem::CLASSNAME,
- Filesystem::signal_copy,
- array(
- Filesystem::signal_param_oldpath => $this->getHookPath($path1),
- Filesystem::signal_param_newpath => $this->getHookPath($path2),
- Filesystem::signal_param_run => &$run
- )
- );
- $this->emit_file_hooks_pre($exists, $path2, $run);
- }
- if ($run) {
- $mount1 = $this->getMount($path1);
- $mount2 = $this->getMount($path2);
- $storage1 = $mount1->getStorage();
- $internalPath1 = $mount1->getInternalPath($absolutePath1);
- $storage2 = $mount2->getStorage();
- $internalPath2 = $mount2->getInternalPath($absolutePath2);
-
- $this->changeLock($path2, ILockingProvider::LOCK_EXCLUSIVE);
-
- if ($mount1->getMountPoint() == $mount2->getMountPoint()) {
- if ($storage1) {
- $result = $storage1->copy($internalPath1, $internalPath2);
- } else {
- $result = false;
- }
- } else {
- $result = $storage2->copyFromStorage($storage1, $internalPath1, $internalPath2);
- }
-
- $this->updater->update($path2);
-
- $this->changeLock($path2, ILockingProvider::LOCK_SHARED);
+ try {
- if ($this->shouldEmitHooks() && $result !== false) {
+ $exists = $this->file_exists($path2);
+ if ($this->shouldEmitHooks()) {
\OC_Hook::emit(
Filesystem::CLASSNAME,
- Filesystem::signal_post_copy,
+ Filesystem::signal_copy,
array(
Filesystem::signal_param_oldpath => $this->getHookPath($path1),
- Filesystem::signal_param_newpath => $this->getHookPath($path2)
+ Filesystem::signal_param_newpath => $this->getHookPath($path2),
+ Filesystem::signal_param_run => &$run
)
);
- $this->emit_file_hooks_post($exists, $path2);
+ $this->emit_file_hooks_pre($exists, $path2, $run);
}
+ if ($run) {
+ $mount1 = $this->getMount($path1);
+ $mount2 = $this->getMount($path2);
+ $storage1 = $mount1->getStorage();
+ $internalPath1 = $mount1->getInternalPath($absolutePath1);
+ $storage2 = $mount2->getStorage();
+ $internalPath2 = $mount2->getInternalPath($absolutePath2);
+
+ $this->changeLock($path2, ILockingProvider::LOCK_EXCLUSIVE);
+ $lockTypePath2 = ILockingProvider::LOCK_EXCLUSIVE;
+
+ if ($mount1->getMountPoint() == $mount2->getMountPoint()) {
+ if ($storage1) {
+ $result = $storage1->copy($internalPath1, $internalPath2);
+ } else {
+ $result = false;
+ }
+ } else {
+ $result = $storage2->copyFromStorage($storage1, $internalPath1, $internalPath2);
+ }
- $this->unlockFile($path2, ILockingProvider::LOCK_SHARED);
- $this->unlockFile($path1, ILockingProvider::LOCK_SHARED);
+ $this->updater->update($path2);
+
+ $this->changeLock($path2, ILockingProvider::LOCK_SHARED);
+ $lockTypePath2 = ILockingProvider::LOCK_SHARED;
+
+ if ($this->shouldEmitHooks() && $result !== false) {
+ \OC_Hook::emit(
+ Filesystem::CLASSNAME,
+ Filesystem::signal_post_copy,
+ array(
+ Filesystem::signal_param_oldpath => $this->getHookPath($path1),
+ Filesystem::signal_param_newpath => $this->getHookPath($path2)
+ )
+ );
+ $this->emit_file_hooks_post($exists, $path2);
+ }
+
+ }
+ } catch (\Exception $e) {
+ $this->unlockFile($path2, $lockTypePath2);
+ $this->unlockFile($path1, $lockTypePath1);
+ throw $e;
}
+
+ $this->unlockFile($path2, $lockTypePath2);
+ $this->unlockFile($path1, $lockTypePath1);
+
}
return $result;
}
@@ -1656,7 +1672,7 @@ class View {
if ($trimmed === '') {
throw new InvalidPathException($l10n->t('Empty filename is not allowed'));
}
- if ($trimmed === '.' || $trimmed === '..') {
+ if (\OC\Files\Filesystem::isIgnoredDir($trimmed)) {
throw new InvalidPathException($l10n->t('Dot files are not allowed'));
}
diff --git a/lib/private/http/client/client.php b/lib/private/http/client/client.php
index b0aff10a413..1907937e55e 100644
--- a/lib/private/http/client/client.php
+++ b/lib/private/http/client/client.php
@@ -62,7 +62,7 @@ class Client implements IClient {
$dataDir = $this->config->getSystemValue('datadirectory');
$this->client->setDefaultOption('verify', $dataDir.'/'.$this->certificateManager->getCertificateBundle());
} else {
- $this->client->setDefaultOption('verify', \OC::$SERVERROOT . '/config/ca-bundle.crt');
+ $this->client->setDefaultOption('verify', \OC::$SERVERROOT . '/resources/config/ca-bundle.crt');
}
$this->client->setDefaultOption('headers/User-Agent', 'ownCloud Server Crawler');
diff --git a/lib/private/lock/dblockingprovider.php b/lib/private/lock/dblockingprovider.php
index bfa86a6920e..a08357a6024 100644
--- a/lib/private/lock/dblockingprovider.php
+++ b/lib/private/lock/dblockingprovider.php
@@ -58,9 +58,17 @@ class DBLockingProvider extends AbstractLockingProvider {
$this->timeFactory = $timeFactory;
}
- protected function initLockField($path) {
+ /**
+ * Insert a file locking row if it does not exists.
+ *
+ * @param string $path
+ * @param int $lock
+ * @return int number of inserted rows
+ */
+
+ protected function initLockField($path, $lock = 0) {
$expire = $this->getExpireTime();
- $this->connection->insertIfNotExist('*PREFIX*file_locks', ['key' => $path, 'lock' => 0, 'ttl' => $expire], ['key']);
+ return $this->connection->insertIfNotExist('*PREFIX*file_locks', ['key' => $path, 'lock' => $lock, 'ttl' => $expire], ['key']);
}
/**
@@ -98,18 +106,23 @@ class DBLockingProvider extends AbstractLockingProvider {
$this->logger->warning("Trying to acquire a lock for '$path' while inside a transition");
}
- $this->initLockField($path);
$expire = $this->getExpireTime();
if ($type === self::LOCK_SHARED) {
- $result = $this->connection->executeUpdate(
- 'UPDATE `*PREFIX*file_locks` SET `lock` = `lock` + 1, `ttl` = ? WHERE `key` = ? AND `lock` >= 0',
- [$expire, $path]
- );
+ $result = $this->initLockField($path,1);
+ if ($result <= 0) {
+ $result = $this->connection->executeUpdate (
+ 'UPDATE `*PREFIX*file_locks` SET `lock` = `lock` + 1, `ttl` = ? WHERE `key` = ? AND `lock` >= 0',
+ [$expire, $path]
+ );
+ }
} else {
- $result = $this->connection->executeUpdate(
- 'UPDATE `*PREFIX*file_locks` SET `lock` = -1, `ttl` = ? WHERE `key` = ? AND `lock` = 0',
- [$expire, $path]
- );
+ $result = $this->initLockField($path,-1);
+ if ($result <= 0) {
+ $result = $this->connection->executeUpdate(
+ 'UPDATE `*PREFIX*file_locks` SET `lock` = -1, `ttl` = ? WHERE `key` = ? AND `lock` = 0',
+ [$expire, $path]
+ );
+ }
}
if ($result !== 1) {
throw new LockedException($path);
@@ -122,7 +135,6 @@ class DBLockingProvider extends AbstractLockingProvider {
* @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
*/
public function releaseLock($path, $type) {
- $this->initLockField($path);
if ($type === self::LOCK_SHARED) {
$this->connection->executeUpdate(
'UPDATE `*PREFIX*file_locks` SET `lock` = `lock` - 1 WHERE `key` = ? AND `lock` > 0',
diff --git a/lib/private/preview.php b/lib/private/preview.php
index f2ff40c51f7..de964b72df2 100644
--- a/lib/private/preview.php
+++ b/lib/private/preview.php
@@ -772,12 +772,6 @@ class Preview {
throw new NotFoundException('File not found.');
}
- if ($cachedPath = $this->isCached($this->info->getId())) {
- header('Content-Type: ' . $this->info->getMimetype());
- $this->userView->readfile($cachedPath);
- return;
- }
-
if (is_null($this->preview)) {
$this->getPreview();
}
diff --git a/lib/private/security/certificatemanager.php b/lib/private/security/certificatemanager.php
index 4d470f69a66..ded81863a73 100644
--- a/lib/private/security/certificatemanager.php
+++ b/lib/private/security/certificatemanager.php
@@ -110,7 +110,7 @@ class CertificateManager implements ICertificateManager {
}
// Append the default certificates
- $defaultCertificates = file_get_contents(\OC::$SERVERROOT . '/config/ca-bundle.crt');
+ $defaultCertificates = file_get_contents(\OC::$SERVERROOT . '/resources/config/ca-bundle.crt');
fwrite($fh_certs, $defaultCertificates);
fclose($fh_certs);
}
diff --git a/lib/private/server.php b/lib/private/server.php
index d5f4f532c1c..9f99ead849b 100644
--- a/lib/private/server.php
+++ b/lib/private/server.php
@@ -470,7 +470,9 @@ class Server extends SimpleContainer implements IServerContainer {
$this->registerService('MimeTypeDetector', function(Server $c) {
return new \OC\Files\Type\Detection(
$c->getURLGenerator(),
- \OC::$configDir);
+ \OC::$SERVERROOT . '/config/',
+ \OC::$SERVERROOT . '/resources/config/'
+ );
});
$this->registerService('MimeTypeLoader', function(Server $c) {
return new \OC\Files\Type\Loader(
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index 802b146cfb6..07c7f31a853 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -2441,6 +2441,11 @@ class Share extends Constants {
if (isset($row['stime'])) {
$row['stime'] = (int) $row['stime'];
}
+ if (isset($row['expiration']) && $row['share_type'] !== self::SHARE_TYPE_LINK) {
+ // discard expiration date for non-link shares, which might have been
+ // set by ancient bugs
+ $row['expiration'] = null;
+ }
}
/**
diff --git a/lib/private/templatelayout.php b/lib/private/templatelayout.php
index 93bf6cbd307..ae3c1093b20 100644
--- a/lib/private/templatelayout.php
+++ b/lib/private/templatelayout.php
@@ -116,9 +116,14 @@ class OC_TemplateLayout extends OC_Template {
}
}
$userDisplayName = OC_User::getDisplayName();
+ $appsMgmtActive = strpos(\OC::$server->getRequest()->getRequestUri(), \OC::$server->getURLGenerator()->linkToRoute('settings.AppSettings.viewApps')) === 0;
+ if ($appsMgmtActive) {
+ $l = \OC::$server->getL10N('lib');
+ $this->assign('application', $l->t('Apps'));
+ }
$this->assign('user_displayname', $userDisplayName);
$this->assign('user_uid', OC_User::getUser());
- $this->assign('appsmanagement_active', strpos(\OC::$server->getRequest()->getRequestUri(), \OC::$server->getURLGenerator()->linkToRoute('settings.AppSettings.viewApps')) === 0 );
+ $this->assign('appsmanagement_active', $appsMgmtActive);
$this->assign('enableAvatars', $this->config->getSystemValue('enable_avatars', true));
$this->assign('userAvatarSet', \OC_Helper::userAvatarSet(OC_User::getUser()));
} else if ($renderAs == 'error') {
@@ -148,7 +153,7 @@ class OC_TemplateLayout extends OC_Template {
} else {
// Add the js files
$jsFiles = self::findJavascriptFiles(OC_Util::$scripts);
- $this->assign('jsfiles', array(), false);
+ $this->assign('jsfiles', array());
if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') {
$this->append( 'jsfiles', OC_Helper::linkToRoute('js_config', array('v' => self::$versionHash)));
}
diff --git a/lib/private/updater.php b/lib/private/updater.php
index 71e9732c307..b33180c3425 100644
--- a/lib/private/updater.php
+++ b/lib/private/updater.php
@@ -279,13 +279,6 @@ class Updater extends BasicEmitter {
throw new \Exception($e->getMessage());
}
- // FIXME: Some users do not upload the new ca-bundle.crt, let's catch this
- // in the update. For a newer release we shall use an integrity check after
- // the update.
- if(!file_exists(\OC::$configDir .'/ca-bundle.crt')) {
- throw new \Exception('Please upload the ca-bundle.crt file into the \'config\' directory.');
- }
-
// create empty file in data dir, so we can later find
// out that this is indeed an ownCloud data directory
// (in case it didn't exist before)
diff --git a/lib/private/user.php b/lib/private/user.php
index 92807246144..ee1ff6f3766 100644
--- a/lib/private/user.php
+++ b/lib/private/user.php
@@ -146,6 +146,10 @@ class OC_User {
self::$_usedBackends[$backend] = new OC_User_Database();
self::getManager()->registerBackend(self::$_usedBackends[$backend]);
break;
+ case 'dummy':
+ self::$_usedBackends[$backend] = new \Test\Util\User\Dummy();
+ self::getManager()->registerBackend(self::$_usedBackends[$backend]);
+ break;
default:
\OCP\Util::writeLog('core', 'Adding default user backend ' . $backend . '.', \OCP\Util::DEBUG);
$className = 'OC_USER_' . strToUpper($backend);
@@ -277,11 +281,13 @@ class OC_User {
OC_Hook::emit("OC_User", "pre_login", array("run" => &$run, "uid" => $uid));
if ($uid) {
- self::setUserId($uid);
- self::setDisplayName($uid);
- self::getUserSession()->setLoginName($uid);
+ if (self::getUser() !== $uid) {
+ self::setUserId($uid);
+ self::setDisplayName($uid);
+ self::getUserSession()->setLoginName($uid);
- OC_Hook::emit("OC_User", "post_login", array("uid" => $uid, 'password' => ''));
+ OC_Hook::emit("OC_User", "post_login", array("uid" => $uid, 'password' => ''));
+ }
return true;
}
return false;
diff --git a/lib/private/user/dummy.php b/lib/private/user/dummy.php
deleted file mode 100644
index 3779f7b5ddf..00000000000
--- a/lib/private/user/dummy.php
+++ /dev/null
@@ -1,169 +0,0 @@
-<?php
-/**
- * @author Andreas Fischer <bantu@owncloud.com>
- * @author Arthur Schiwon <blizzz@owncloud.com>
- * @author Jörn Friedrich Dreyer <jfd@butonic.de>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <icewind@owncloud.com>
- * @author Robin McCorkell <rmccorkell@karoshi.org.uk>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-/**
- * dummy user backend, does not keep state, only for testing use
- */
-class OC_User_Dummy extends OC_User_Backend implements \OCP\IUserBackend {
- private $users = array();
- private $displayNames = array();
-
- /**
- * Create a new user
- *
- * @param string $uid The username of the user to create
- * @param string $password The password of the new user
- * @return bool
- *
- * Creates a new user. Basic checking of username is done in OC_User
- * itself, not in its subclasses.
- */
- public function createUser($uid, $password) {
- if (isset($this->users[$uid])) {
- return false;
- } else {
- $this->users[$uid] = $password;
- return true;
- }
- }
-
- /**
- * delete a user
- *
- * @param string $uid The username of the user to delete
- * @return bool
- *
- * Deletes a user
- */
- public function deleteUser($uid) {
- if (isset($this->users[$uid])) {
- unset($this->users[$uid]);
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Set password
- *
- * @param string $uid The username
- * @param string $password The new password
- * @return bool
- *
- * Change the password of a user
- */
- public function setPassword($uid, $password) {
- if (isset($this->users[$uid])) {
- $this->users[$uid] = $password;
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Check if the password is correct
- *
- * @param string $uid The username
- * @param string $password The password
- * @return string
- *
- * Check if the password is correct without logging in the user
- * returns the user id or false
- */
- public function checkPassword($uid, $password) {
- if (isset($this->users[$uid]) && $this->users[$uid] === $password) {
- return $uid;
- } else {
- return false;
- }
- }
-
- /**
- * Get a list of all users
- *
- * @param string $search
- * @param null|int $limit
- * @param null|int $offset
- * @return string[] an array of all uids
- */
- public function getUsers($search = '', $limit = null, $offset = null) {
- if (empty($search)) {
- return array_keys($this->users);
- }
- $result = array();
- foreach (array_keys($this->users) as $user) {
- if (stripos($user, $search) !== false) {
- $result[] = $user;
- }
- }
- return $result;
- }
-
- /**
- * check if a user exists
- *
- * @param string $uid the username
- * @return boolean
- */
- public function userExists($uid) {
- return isset($this->users[$uid]);
- }
-
- /**
- * @return bool
- */
- public function hasUserListings() {
- return true;
- }
-
- /**
- * counts the users in the database
- *
- * @return int|bool
- */
- public function countUsers() {
- return 0;
- }
-
- public function setDisplayName($uid, $displayName) {
- $this->displayNames[$uid] = $displayName;
- }
-
- public function getDisplayName($uid) {
- return isset($this->displayNames[$uid])? $this->displayNames[$uid]: $uid;
- }
-
- /**
- * Backend name to be shown in user management
- * @return string the name of the backend to be shown
- */
- public function getBackendName(){
- return 'Dummy';
- }
-}
diff --git a/lib/private/util.php b/lib/private/util.php
index eb1de5be5a4..667d358655f 100644
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -1433,7 +1433,7 @@ class OC_Util {
if ($trimmed === '') {
return false;
}
- if ($trimmed === '.' || $trimmed === '..') {
+ if (\OC\Files\Filesystem::isIgnoredDir($trimmed)) {
return false;
}
foreach (str_split($trimmed) as $char) {
diff --git a/lib/public/icontainer.php b/lib/public/icontainer.php
index ffd1d16c97e..64d5a7d8c1a 100644
--- a/lib/public/icontainer.php
+++ b/lib/public/icontainer.php
@@ -31,6 +31,7 @@
namespace OCP;
use Closure;
+use OCP\AppFramework\QueryException;
/**
diff --git a/lib/public/sabrepluginevent.php b/lib/public/sabrepluginevent.php
new file mode 100644
index 00000000000..fed3237166d
--- /dev/null
+++ b/lib/public/sabrepluginevent.php
@@ -0,0 +1,82 @@
+<?php
+/**
+ * @author Joas Schilling <nickvergessen@owncloud.com>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCP;
+
+
+use OCP\AppFramework\Http;
+use Symfony\Component\EventDispatcher\Event;
+
+/**
+ * @since 8.2.0
+ */
+class SabrePluginEvent extends Event {
+
+ /** @var int */
+ protected $statusCode;
+
+ /** @var string */
+ protected $message;
+
+ /**
+ * @since 8.2.0
+ */
+ public function __construct() {
+ $this->message = '';
+ $this->statusCode = Http::STATUS_OK;
+ }
+
+ /**
+ * @param int $statusCode
+ * @return self
+ * @since 8.2.0
+ */
+ public function setStatusCode($statusCode) {
+ $this->statusCode = (int) $statusCode;
+ return $this;
+ }
+
+ /**
+ * @param string $message
+ * @return self
+ * @since 8.2.0
+ */
+ public function setMessage($message) {
+ $this->message = (string) $message;
+ return $this;
+ }
+
+ /**
+ * @return int
+ * @since 8.2.0
+ */
+ public function getStatusCode() {
+ return $this->statusCode;
+ }
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getMessage() {
+ return $this->message;
+ }
+}
diff --git a/lib/public/sabrepluginexception.php b/lib/public/sabrepluginexception.php
new file mode 100644
index 00000000000..5dba3b90a02
--- /dev/null
+++ b/lib/public/sabrepluginexception.php
@@ -0,0 +1,41 @@
+<?php
+/**
+ * @author Joas Schilling <nickvergessen@owncloud.com>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCP;
+
+
+use Sabre\DAV\Exception;
+
+/**
+ * @since 8.2.0
+ */
+class SabrePluginException extends Exception {
+
+ /**
+ * Returns the HTTP statuscode for this exception
+ *
+ * @return int
+ * @since 8.2.0
+ */
+ public function getHTTPCode() {
+ return $this->code;
+ }
+}