summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/avatar.php10
-rw-r--r--lib/private/avatarmanager.php5
-rw-r--r--lib/private/cache/file.php45
-rw-r--r--lib/private/connector/sabre/exceptionloggerplugin.php36
-rw-r--r--lib/private/files/filesystem.php9
-rw-r--r--lib/private/files/view.php2
-rw-r--r--lib/private/helper.php2
-rw-r--r--lib/private/installer.php13
-rw-r--r--lib/private/preview.php3
-rw-r--r--lib/private/preview/font.php19
-rw-r--r--lib/private/repair/repairlegacystorages.php136
-rw-r--r--lib/private/setup.php130
-rw-r--r--lib/private/share/helper.php30
-rw-r--r--lib/private/share/share.php2
-rw-r--r--lib/private/updater.php30
-rw-r--r--lib/private/util.php4
16 files changed, 347 insertions, 129 deletions
diff --git a/lib/private/avatar.php b/lib/private/avatar.php
index 5e234d77bb2..23b3c82771a 100644
--- a/lib/private/avatar.php
+++ b/lib/private/avatar.php
@@ -6,11 +6,15 @@
* See the COPYING-README file.
*/
+ namespace OC;
+
+ use OC_Image;
+
/**
* This class gets and sets users avatars.
*/
-class OC_Avatar implements \OCP\IAvatar {
+class Avatar implements \OCP\IAvatar {
private $view;
@@ -54,8 +58,8 @@ class OC_Avatar implements \OCP\IAvatar {
/**
* sets the users avatar
* @param \OC_Image|resource|string $data OC_Image, imagedata or path to set a new avatar
- * @throws Exception if the provided file is not a jpg or png image
- * @throws Exception if the provided image is not valid
+ * @throws \Exception if the provided file is not a jpg or png image
+ * @throws \Exception if the provided image is not valid
* @throws \OC\NotSquareException if the image is not square
* @return void
*/
diff --git a/lib/private/avatarmanager.php b/lib/private/avatarmanager.php
index 6abe87c4f41..8dc20a5240b 100644
--- a/lib/private/avatarmanager.php
+++ b/lib/private/avatarmanager.php
@@ -8,8 +8,9 @@
namespace OC;
use OCP\IAvatarManager;
+use OC\Avatar;
-/*
+/**
* This class implements methods to access Avatar functionality
*/
class AvatarManager implements IAvatarManager {
@@ -21,6 +22,6 @@ class AvatarManager implements IAvatarManager {
* @return \OCP\IAvatar
*/
function getAvatar($user) {
- return new \OC_Avatar($user);
+ return new Avatar($user);
}
}
diff --git a/lib/private/cache/file.php b/lib/private/cache/file.php
index 3b500c4e45b..6fa7686ea96 100644
--- a/lib/private/cache/file.php
+++ b/lib/private/cache/file.php
@@ -9,22 +9,31 @@
namespace OC\Cache;
+use OC\Files\Filesystem;
+use OC\Files\View;
+
class File {
protected $storage;
/**
* Returns the cache storage for the logged in user
+ *
* @return \OC\Files\View cache storage
*/
protected function getStorage() {
if (isset($this->storage)) {
return $this->storage;
}
- if(\OC_User::isLoggedIn()) {
- \OC\Files\Filesystem::initMountPoints(\OC_User::getUser());
- $this->storage = new \OC\Files\View('/' . \OC_User::getUser() . '/cache');
+ if (\OC_User::isLoggedIn()) {
+ $rootView = new View();
+ $user = \OC::$server->getUserSession()->getUser();
+ Filesystem::initMountPoints($user->getUID());
+ if (!$rootView->file_exists('/' . $user->getUID() . '/cache')) {
+ $rootView->mkdir('/' . $user->getUID() . '/cache');
+ }
+ $this->storage = new View('/' . $user->getUID() . '/cache');
return $this->storage;
- }else{
+ } else {
\OC_Log::write('core', 'Can\'t get cache storage, user not logged in', \OC_Log::ERROR);
throw new \OC\ForbiddenException('Can\t get cache storage, user not logged in');
}
@@ -66,7 +75,7 @@ class File {
/**
* @param string $key
*/
- public function set($key, $value, $ttl=0) {
+ public function set($key, $value, $ttl = 0) {
$storage = $this->getStorage();
$result = false;
$proxyStatus = \OC_FileProxy::$enabled;
@@ -94,20 +103,20 @@ class File {
*/
public function remove($key) {
$storage = $this->getStorage();
- if(!$storage) {
+ if (!$storage) {
return false;
}
return $storage->unlink($key);
}
- public function clear($prefix='') {
+ public function clear($prefix = '') {
$storage = $this->getStorage();
- if($storage and $storage->is_dir('/')) {
- $dh=$storage->opendir('/');
- if(is_resource($dh)) {
+ if ($storage and $storage->is_dir('/')) {
+ $dh = $storage->opendir('/');
+ if (is_resource($dh)) {
while (($file = readdir($dh)) !== false) {
- if($file!='.' and $file!='..' and ($prefix==='' || strpos($file, $prefix) === 0)) {
- $storage->unlink('/'.$file);
+ if ($file != '.' and $file != '..' and ($prefix === '' || strpos($file, $prefix) === 0)) {
+ $storage->unlink('/' . $file);
}
}
}
@@ -117,17 +126,17 @@ class File {
public function gc() {
$storage = $this->getStorage();
- if($storage and $storage->is_dir('/')) {
+ if ($storage and $storage->is_dir('/')) {
$now = time();
- $dh=$storage->opendir('/');
- if(!is_resource($dh)) {
+ $dh = $storage->opendir('/');
+ if (!is_resource($dh)) {
return null;
}
while (($file = readdir($dh)) !== false) {
- if($file!='.' and $file!='..') {
- $mtime = $storage->filemtime('/'.$file);
+ if ($file != '.' and $file != '..') {
+ $mtime = $storage->filemtime('/' . $file);
if ($mtime < $now) {
- $storage->unlink('/'.$file);
+ $storage->unlink('/' . $file);
}
}
}
diff --git a/lib/private/connector/sabre/exceptionloggerplugin.php b/lib/private/connector/sabre/exceptionloggerplugin.php
index 2bd43e56f55..a0dc6e7c182 100644
--- a/lib/private/connector/sabre/exceptionloggerplugin.php
+++ b/lib/private/connector/sabre/exceptionloggerplugin.php
@@ -10,6 +10,10 @@
namespace OC\Connector\Sabre;
+use OCP\ILogger;
+use Sabre\DAV\Exception;
+use Sabre\HTTP\Response;
+
class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin {
private $nonFatalExceptions = array(
'Sabre\DAV\Exception\NotAuthenticated' => true,
@@ -22,13 +26,19 @@ class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin {
'Sabre\DAV\Exception\PreconditionFailed' => true,
);
+ /** @var string */
private $appName;
+ /** @var ILogger */
+ private $logger;
+
/**
* @param string $loggerAppName app name to use when logging
+ * @param ILogger $logger
*/
- public function __construct($loggerAppName = 'webdav') {
+ public function __construct($loggerAppName, $logger) {
$this->appName = $loggerAppName;
+ $this->logger = $logger;
}
/**
@@ -50,14 +60,30 @@ class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin {
/**
* Log exception
*
- * @internal param Exception $e exception
*/
- public function logException($e) {
- $exceptionClass = get_class($e);
+ public function logException(\Exception $ex) {
+ $exceptionClass = get_class($ex);
$level = \OCP\Util::FATAL;
if (isset($this->nonFatalExceptions[$exceptionClass])) {
$level = \OCP\Util::DEBUG;
}
- \OCP\Util::logException($this->appName, $e, $level);
+
+ $message = $ex->getMessage();
+ if ($ex instanceof Exception) {
+ if (empty($message)) {
+ $response = new Response($ex->getHTTPCode());
+ $message = $response->getStatusText();
+ }
+ $message = "HTTP/1.1 {$ex->getHTTPCode()} $message";
+ }
+
+ $exception = [
+ 'Message' => $message,
+ 'Code' => $ex->getCode(),
+ 'Trace' => $ex->getTraceAsString(),
+ 'File' => $ex->getFile(),
+ 'Line' => $ex->getLine(),
+ ];
+ $this->logger->log($level, 'Exception: ' . json_encode($exception), ['app' => $this->appName]);
}
}
diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php
index 04f82d88cd1..c3a062cd2d6 100644
--- a/lib/private/files/filesystem.php
+++ b/lib/private/files/filesystem.php
@@ -395,14 +395,7 @@ class Filesystem {
*/
private static function mountCacheDir($user) {
$cacheBaseDir = \OC_Config::getValue('cache_path', '');
- if ($cacheBaseDir === '') {
- // use local cache dir relative to the user's home
- $subdir = 'cache';
- $view = new \OC\Files\View('/' . $user);
- if(!$view->file_exists($subdir)) {
- $view->mkdir($subdir);
- }
- } else {
+ if ($cacheBaseDir !== '') {
$cacheDir = rtrim($cacheBaseDir, '/') . '/' . $user;
if (!file_exists($cacheDir)) {
mkdir($cacheDir, 0770, true);
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index f14209fd925..8b448abeb89 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -1572,7 +1572,7 @@ class View {
} catch (ReservedWordException $ex) {
throw new InvalidPathException($l10n->t('File name is a reserved word'));
} catch (InvalidCharacterInPathException $ex) {
- throw new InvalidPathException($l10n->t('File name contains at least one invalid characters'));
+ throw new InvalidPathException($l10n->t('File name contains at least one invalid character'));
}
}
}
diff --git a/lib/private/helper.php b/lib/private/helper.php
index fb7049854bb..ebc30395a6b 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -288,7 +288,7 @@ class OC_Helper {
* @return bool avatar set or not
**/
public static function userAvatarSet($user) {
- $avatar = new \OC_Avatar($user);
+ $avatar = new \OC\Avatar($user);
return $avatar->exists();
}
diff --git a/lib/private/installer.php b/lib/private/installer.php
index 087bc6c1edb..3956e503767 100644
--- a/lib/private/installer.php
+++ b/lib/private/installer.php
@@ -202,20 +202,21 @@ class OC_Installer{
/**
* update an app by it's id
- * @param integer $ocsid
+ *
+ * @param integer $ocsId
* @return bool
* @throws Exception
*/
- public static function updateAppByOCSId($ocsid) {
- $appdata = OCSClient::getApplication($ocsid);
- $download = OCSClient::getApplicationDownload($ocsid, 1);
+ public static function updateAppByOCSId($ocsId) {
+ $appData = OCSClient::getApplication($ocsId);
+ $download = OCSClient::getApplicationDownload($ocsId, 1);
if (isset($download['downloadlink']) && trim($download['downloadlink']) !== '') {
$download['downloadlink'] = str_replace(' ', '%20', $download['downloadlink']);
$info = array(
'source' => 'http',
'href' => $download['downloadlink'],
- 'appdata' => $appdata
+ 'appdata' => $appData
);
} else {
throw new \Exception('Could not fetch app info!');
@@ -285,7 +286,7 @@ class OC_Installer{
* @return array
* @throws \Exception
*/
- public static function checkAppsIntegrity($data = array(), $extractDir, $path, $isShipped=false) {
+ public static function checkAppsIntegrity($data, $extractDir, $path, $isShipped=false) {
$l = \OC::$server->getL10N('lib');
//load the info.xml file of the app
if(!is_file($extractDir.'/appinfo/info.xml')) {
diff --git a/lib/private/preview.php b/lib/private/preview.php
index f45cc0858c7..6af1586293f 100644
--- a/lib/private/preview.php
+++ b/lib/private/preview.php
@@ -713,6 +713,7 @@ class Preview {
* - OC\Preview\Illustrator
* - OC\Preview\Postscript
* - OC\Preview\Photoshop
+ * - OC\Preview\Font
*/
if(empty(self::$enabledProviders)) {
self::$enabledProviders = \OC::$server->getConfig()->getSystemValue('enabledPreviewProviders', array(
@@ -772,8 +773,8 @@ class Preview {
'PDF' => 'OC\Preview\PDF',
'AI' => 'OC\Preview\Illustrator',
'PSD' => 'OC\Preview\Photoshop',
- // Requires adding 'eps' => array('application/postscript', null), to lib/private/mimetypes.list.php
'EPS' => 'OC\Preview\Postscript',
+ 'TTF' => 'OC\Preview\Font',
);
foreach ($imagickProviders as $queryFormat => $provider) {
diff --git a/lib/private/preview/font.php b/lib/private/preview/font.php
new file mode 100644
index 00000000000..58d64e8264d
--- /dev/null
+++ b/lib/private/preview/font.php
@@ -0,0 +1,19 @@
+<?php
+/**
+ * @copyright Olivier Paroz 2015 <owncloud@interfasys.ch>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Preview;
+
+// .otf, .ttf and .pfb
+class Font extends Bitmap {
+ /**
+ * {@inheritDoc}
+ */
+ public function getMimeType() {
+ return '/application\/(?:font-sfnt|x-font$)/';
+ }
+} \ No newline at end of file
diff --git a/lib/private/repair/repairlegacystorages.php b/lib/private/repair/repairlegacystorages.php
index ab123afeca6..027cb68eb1b 100644
--- a/lib/private/repair/repairlegacystorages.php
+++ b/lib/private/repair/repairlegacystorages.php
@@ -143,79 +143,105 @@ class RepairLegacyStorages extends BasicEmitter {
$dataDirId = 'local::' . $dataDir;
$count = 0;
+ $hasWarnings = false;
$this->connection->beginTransaction();
- try {
- // note: not doing a direct UPDATE with the REPLACE function
- // because regexp search/extract is needed and it is not guaranteed
- // to work on all database types
- $sql = 'SELECT `id`, `numeric_id` FROM `*PREFIX*storages`'
- . ' WHERE `id` LIKE ?'
- . ' ORDER BY `id`';
- $result = $this->connection->executeQuery($sql, array($dataDirId . '%'));
- while ($row = $result->fetch()) {
- $currentId = $row['id'];
- // one entry is the datadir itself
- if ($currentId === $dataDirId) {
- continue;
- }
+ // note: not doing a direct UPDATE with the REPLACE function
+ // because regexp search/extract is needed and it is not guaranteed
+ // to work on all database types
+ $sql = 'SELECT `id`, `numeric_id` FROM `*PREFIX*storages`'
+ . ' WHERE `id` LIKE ?'
+ . ' ORDER BY `id`';
+ $result = $this->connection->executeQuery($sql, array($dataDirId . '%'));
+
+ while ($row = $result->fetch()) {
+ $currentId = $row['id'];
+ // one entry is the datadir itself
+ if ($currentId === $dataDirId) {
+ continue;
+ }
+ try {
if ($this->fixLegacyStorage($currentId, (int)$row['numeric_id'])) {
$count++;
}
}
+ catch (\OC\RepairException $e) {
+ $hasWarnings = true;
+ $this->emit(
+ '\OC\Repair',
+ 'warning',
+ array('Could not repair legacy storage ' . $currentId . ' automatically.')
+ );
+ }
+ }
- // check for md5 ids, not in the format "prefix::"
- $sql = 'SELECT COUNT(*) AS "c" FROM `*PREFIX*storages`'
- . ' WHERE `id` NOT LIKE \'%::%\'';
- $result = $this->connection->executeQuery($sql);
- $row = $result->fetch();
- // find at least one to make sure it's worth
- // querying the user list
- if ((int)$row['c'] > 0) {
- $userManager = \OC_User::getManager();
-
- // use chunks to avoid caching too many users in memory
- $limit = 30;
- $offset = 0;
-
- do {
- // query the next page of users
- $results = $userManager->search('', $limit, $offset);
- $storageIds = array();
- $userIds = array();
- foreach ($results as $uid => $userObject) {
- $storageId = $dataDirId . $uid . '/';
- if (strlen($storageId) <= 64) {
- // skip short storage ids as they were handled in the previous section
- continue;
- }
- $storageIds[$uid] = $storageId;
+ // check for md5 ids, not in the format "prefix::"
+ $sql = 'SELECT COUNT(*) AS "c" FROM `*PREFIX*storages`'
+ . ' WHERE `id` NOT LIKE \'%::%\'';
+ $result = $this->connection->executeQuery($sql);
+ $row = $result->fetch();
+
+ // find at least one to make sure it's worth
+ // querying the user list
+ if ((int)$row['c'] > 0) {
+ $userManager = \OC_User::getManager();
+
+ // use chunks to avoid caching too many users in memory
+ $limit = 30;
+ $offset = 0;
+
+ do {
+ // query the next page of users
+ $results = $userManager->search('', $limit, $offset);
+ $storageIds = array();
+ $userIds = array();
+ foreach ($results as $uid => $userObject) {
+ $storageId = $dataDirId . $uid . '/';
+ if (strlen($storageId) <= 64) {
+ // skip short storage ids as they were handled in the previous section
+ continue;
}
+ $storageIds[$uid] = $storageId;
+ }
- if (count($storageIds) > 0) {
- // update the storages of these users
- foreach ($storageIds as $uid => $storageId) {
- $numericId = \OC\Files\Cache\Storage::getNumericStorageId($storageId);
+ if (count($storageIds) > 0) {
+ // update the storages of these users
+ foreach ($storageIds as $uid => $storageId) {
+ $numericId = \OC\Files\Cache\Storage::getNumericStorageId($storageId);
+ try {
if (!is_null($numericId) && $this->fixLegacyStorage($storageId, (int)$numericId)) {
$count++;
}
}
+ catch (\OC\RepairException $e) {
+ $hasWarnings = true;
+ $this->emit(
+ '\OC\Repair',
+ 'warning',
+ array('Could not repair legacy storage ' . $storageId . ' automatically.')
+ );
+ }
}
- $offset += $limit;
- } while (count($results) >= $limit);
- }
+ }
+ $offset += $limit;
+ } while (count($results) >= $limit);
+ }
- $this->emit('\OC\Repair', 'info', array('Updated ' . $count . ' legacy home storage ids'));
+ $this->emit('\OC\Repair', 'info', array('Updated ' . $count . ' legacy home storage ids'));
- $this->connection->commit();
- }
- catch (\OC\RepairException $e) {
- $this->connection->rollback();
- throw $e;
- }
+ $this->connection->commit();
- $this->config->setAppValue('core', 'repairlegacystoragesdone', 'yes');
+ if ($hasWarnings) {
+ $this->emit(
+ '\OC\Repair',
+ 'warning',
+ array('Some legacy storages could not be repaired. Please manually fix them then re-run ./occ maintenance:repair')
+ );
+ } else {
+ // if all were done, no need to redo the repair during next upgrade
+ $this->config->setAppValue('core', 'repairlegacystoragesdone', 'yes');
+ }
}
}
diff --git a/lib/private/setup.php b/lib/private/setup.php
index 064afecbfe8..44b6ad56cb8 100644
--- a/lib/private/setup.php
+++ b/lib/private/setup.php
@@ -8,19 +8,34 @@
namespace OC;
+use bantu\IniGetWrapper\IniGetWrapper;
use Exception;
-use OC_L10N;
use OCP\IConfig;
+use OCP\IL10N;
class Setup {
- /** @var IConfig */
+ /** @var \OCP\IConfig */
protected $config;
+ /** @var IniGetWrapper */
+ protected $iniWrapper;
+ /** @var IL10N */
+ protected $l10n;
+ /** @var \OC_Defaults */
+ protected $defaults;
/**
* @param IConfig $config
+ * @param IniGetWrapper $iniWrapper
+ * @param \OC_Defaults $defaults
*/
- function __construct(IConfig $config) {
+ function __construct(IConfig $config,
+ IniGetWrapper $iniWrapper,
+ IL10N $l10n,
+ \OC_Defaults $defaults) {
$this->config = $config;
+ $this->iniWrapper = $iniWrapper;
+ $this->l10n = $l10n;
+ $this->defaults = $defaults;
}
static $dbSetupClasses = array(
@@ -33,13 +48,6 @@ class Setup {
);
/**
- * @return OC_L10N
- */
- public static function getTrans(){
- return \OC::$server->getL10N('lib');
- }
-
- /**
* Wrapper around the "class_exists" PHP function to be able to mock it
* @param string $name
* @return bool
@@ -60,10 +68,11 @@ class Setup {
/**
* Get the available and supported databases of this instance
*
- * @throws Exception
+ * @param bool $allowAllDatabases
* @return array
+ * @throws Exception
*/
- public function getSupportedDatabases() {
+ public function getSupportedDatabases($allowAllDatabases = false) {
$availableDatabases = array(
'sqlite' => array(
'type' => 'class',
@@ -91,8 +100,12 @@ class Setup {
'name' => 'MS SQL'
)
);
- $configuredDatabases = $this->config->getSystemValue('supportedDatabases',
- array('sqlite', 'mysql', 'pgsql'));
+ if ($allowAllDatabases) {
+ $configuredDatabases = array_keys($availableDatabases);
+ } else {
+ $configuredDatabases = $this->config->getSystemValue('supportedDatabases',
+ array('sqlite', 'mysql', 'pgsql'));
+ }
if(!is_array($configuredDatabases)) {
throw new Exception('Supported databases are not properly configured.');
}
@@ -117,11 +130,90 @@ class Setup {
}
/**
+ * Gathers system information like database type and does
+ * a few system checks.
+ *
+ * @return array of system info, including an "errors" value
+ * in case of errors/warnings
+ */
+ public function getSystemInfo($allowAllDatabases = false) {
+ $databases = $this->getSupportedDatabases($allowAllDatabases);
+
+ $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data');
+
+ $errors = array();
+
+ // Create data directory to test whether the .htaccess works
+ // Notice that this is not necessarily the same data directory as the one
+ // that will effectively be used.
+ @mkdir($dataDir);
+ $htAccessWorking = true;
+ if (is_dir($dataDir) && is_writable($dataDir)) {
+ // Protect data directory here, so we can test if the protection is working
+ \OC\Setup::protectDataDirectory();
+
+ try {
+ $htAccessWorking = \OC_Util::isHtaccessWorking();
+ } catch (\OC\HintException $e) {
+ $errors[] = array(
+ 'error' => $e->getMessage(),
+ 'hint' => $e->getHint()
+ );
+ $htAccessWorking = false;
+ }
+ }
+
+ if (\OC_Util::runningOnMac()) {
+ $errors[] = array(
+ 'error' => $this->l10n->t(
+ 'Mac OS X is not supported and %s will not work properly on this platform. ' .
+ 'Use it at your own risk! ',
+ $this->defaults->getName()
+ ),
+ 'hint' => $this->l10n->t('For the best results, please consider using a GNU/Linux server instead.')
+ );
+ }
+
+ if($this->iniWrapper->getString('open_basedir') !== '' && PHP_INT_SIZE === 4) {
+ $errors[] = array(
+ 'error' => $this->l10n->t(
+ 'It seems that this %s instance is running on a 32-bit PHP environment and the open_basedir has been configured in php.ini. ' .
+ 'This will lead to problems with files over 4 GB and is highly discouraged.',
+ $this->defaults->getName()
+ ),
+ 'hint' => $this->l10n->t('Please remove the open_basedir setting within your php.ini or switch to 64-bit PHP.')
+ );
+ }
+ if(!function_exists('curl_init') && PHP_INT_SIZE === 4) {
+ $errors[] = array(
+ 'error' => $this->l10n->t(
+ 'It seems that this %s instance is running on a 32-bit PHP environment and cURL is not installed. ' .
+ 'This will lead to problems with files over 4 GB and is highly discouraged.',
+ $this->defaults->getName()
+ ),
+ 'hint' => $this->l10n->t('Please install the cURL extension and restart your webserver.')
+ );
+ }
+
+ return array(
+ 'hasSQLite' => isset($databases['sqlite']),
+ 'hasMySQL' => isset($databases['mysql']),
+ 'hasPostgreSQL' => isset($databases['pgsql']),
+ 'hasOracle' => isset($databases['oci']),
+ 'hasMSSQL' => isset($databases['mssql']),
+ 'databases' => $databases,
+ 'directory' => $dataDir,
+ 'htaccessWorking' => $htAccessWorking,
+ 'errors' => $errors,
+ );
+ }
+
+ /**
* @param $options
* @return array
*/
- public static function install($options) {
- $l = self::getTrans();
+ public function install($options) {
+ $l = $this->l10n;
$error = array();
$dbType = $options['dbtype'];
@@ -146,7 +238,7 @@ class Setup {
$class = self::$dbSetupClasses[$dbType];
/** @var \OC\Setup\AbstractDatabase $dbSetup */
- $dbSetup = new $class(self::getTrans(), 'db_structure.xml');
+ $dbSetup = new $class($l, 'db_structure.xml');
$error = array_merge($error, $dbSetup->validate($options));
// validate the data directory
@@ -186,7 +278,7 @@ class Setup {
$secret = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(48);
//write the config file
- \OC::$server->getConfig()->setSystemValues([
+ $this->config->setSystemValues([
'passwordsalt' => $salt,
'secret' => $secret,
'trusted_domains' => $trustedDomains,
@@ -281,7 +373,7 @@ class Setup {
* @throws \OC\HintException If .htaccess does not include the current version
*/
public static function updateHtaccess() {
- $setupHelper = new \OC\Setup(\OC::$server->getConfig());
+ $setupHelper = new \OC\Setup(\OC::$server->getConfig(), \OC::$server->getIniWrapper(), \OC::$server->getL10N('lib'), new \OC_Defaults());
if(!$setupHelper->isCurrentHtaccess()) {
throw new \OC\HintException('.htaccess file has the wrong version. Please upload the correct version. Maybe you forgot to replace it after updating?');
}
diff --git a/lib/private/share/helper.php b/lib/private/share/helper.php
index 6059af0196d..55b71ceeeac 100644
--- a/lib/private/share/helper.php
+++ b/lib/private/share/helper.php
@@ -221,4 +221,34 @@ class Helper extends \OC\Share\Constants {
return $expires;
}
+
+ /**
+ * Extracts the necessary remote name from a given link
+ *
+ * Strips away a potential file name, to allow
+ * - user
+ * - user@localhost
+ * - user@http://localhost
+ * - user@http://localhost/
+ * - user@http://localhost/index.php
+ * - user@http://localhost/index.php/s/{shareToken}
+ *
+ * @param string $shareWith
+ * @return string
+ */
+ public static function fixRemoteURLInShareWith($shareWith) {
+ if (strpos($shareWith, '@')) {
+ list($user, $remote) = explode('@', $shareWith, 2);
+
+ $remote = str_replace('\\', '/', $remote);
+ if ($fileNamePosition = strpos($remote, '/index.php')) {
+ $remote = substr($remote, 0, $fileNamePosition);
+ }
+ $remote = rtrim($remote, '/');
+
+ $shareWith = $user . '@' . $remote;
+ }
+
+ return rtrim($shareWith, '/');
+ }
}
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index 4753f6ecbfa..974ebf41f93 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -724,7 +724,7 @@ class Share extends \OC\Share\Constants {
$token = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(self::TOKEN_LENGTH, \OCP\Security\ISecureRandom::CHAR_LOWER . \OCP\Security\ISecureRandom::CHAR_UPPER .
\OCP\Security\ISecureRandom::CHAR_DIGITS);
- $shareWith = rtrim($shareWith, '/');
+ $shareWith = Helper::fixRemoteURLInShareWith($shareWith);
$shareId = self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, null, $token, $itemSourceName);
$send = false;
diff --git a/lib/private/updater.php b/lib/private/updater.php
index 71ada3217e0..4d813ee3d39 100644
--- a/lib/private/updater.php
+++ b/lib/private/updater.php
@@ -12,6 +12,7 @@ use OC\Hooks\BasicEmitter;
use OC_App;
use OC_Util;
use OCP\IConfig;
+use OC\Setup;
/**
* Class that handles autoupdating of ownCloud
@@ -173,6 +174,20 @@ class Updater extends BasicEmitter {
}
/**
+ * Forward messages emitted by the repair routine
+ *
+ * @param Repair $repair repair routine
+ */
+ private function emitRepairMessages(Repair $repair) {
+ $repair->listen('\OC\Repair', 'warning', function ($description) {
+ $this->emit('\OC\Updater', 'repairWarning', array($description));
+ });
+ $repair->listen('\OC\Repair', 'error', function ($description) {
+ $this->emit('\OC\Updater', 'repairError', array($description));
+ });
+ }
+
+ /**
* runs the update actions in maintenance mode, does not upgrade the source files
* except the main .htaccess file
*
@@ -188,13 +203,12 @@ class Updater extends BasicEmitter {
throw new \Exception('Updates between multiple major versions are unsupported.');
}
- // Update htaccess files for apache hosts
- if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) {
- try {
- \OC\Setup::updateHtaccess();
- } catch (\Exception $e) {
- throw new \Exception($e->getMessage());
- }
+ // Update .htaccess files
+ try {
+ Setup::updateHtaccess();
+ Setup::protectDataDirectory();
+ } catch (\Exception $e) {
+ throw new \Exception($e->getMessage());
}
// create empty file in data dir, so we can later find
@@ -204,6 +218,7 @@ class Updater extends BasicEmitter {
// pre-upgrade repairs
$repair = new Repair(Repair::getBeforeUpgradeRepairSteps());
+ $this->emitRepairMessages($repair);
$repair->run();
// simulate DB upgrade
@@ -223,6 +238,7 @@ class Updater extends BasicEmitter {
// post-upgrade repairs
$repair = new Repair(Repair::getRepairSteps());
+ $this->emitRepairMessages($repair);
$repair->run();
//Invalidate update feed
diff --git a/lib/private/util.php b/lib/private/util.php
index 62bbf5cf2aa..72802409da9 100644
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -497,7 +497,7 @@ class OC_Util {
}
$webServerRestart = false;
- $setup = new OC\Setup($config);
+ $setup = new \OC\Setup($config, \OC::$server->getIniWrapper(), \OC::$server->getL10N('lib'), new \OC_Defaults());
$availableDatabases = $setup->getSupportedDatabases();
if (empty($availableDatabases)) {
$errors[] = array(
@@ -702,7 +702,7 @@ class OC_Util {
);
}
- if ($webServerRestart) {
+ if (!\OC::$CLI && $webServerRestart) {
$errors[] = array(
'error' => $l->t('PHP modules have been installed, but they are still listed as missing?'),
'hint' => $l->t('Please ask your server administrator to restart the web server.')