aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2016-07-07 11:29:46 +0200
committerMorris Jobke <hey@morrisjobke.de>2016-07-07 11:29:46 +0200
commitba16fd0d337fa26114f55086198979d147a298c1 (patch)
tree39111cec77d17d5eeb60bd1b609e7a8419310459 /lib/private
parent5ace43f43895cba4b398367e10731f92450d7da2 (diff)
parented28885d73181e61c06802639910014e8a265e42 (diff)
downloadnextcloud-server-ba16fd0d337fa26114f55086198979d147a298c1.tar.gz
nextcloud-server-ba16fd0d337fa26114f55086198979d147a298c1.zip
Merge branch 'master' into sync-master
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/App/DependencyAnalyzer.php4
-rw-r--r--lib/private/Config.php6
-rw-r--r--lib/private/Installer.php2
-rw-r--r--lib/private/Log/Owncloud.php4
-rw-r--r--lib/private/Repair/DropOldTables.php5
-rw-r--r--lib/private/Server.php25
-rw-r--r--lib/private/Setup/AbstractDatabase.php5
-rw-r--r--lib/private/Setup/MySQL.php10
-rw-r--r--lib/private/Setup/OCI.php4
-rw-r--r--lib/private/Setup/PostgreSQL.php11
-rw-r--r--lib/private/Share20/Manager.php30
-rw-r--r--lib/private/User/Database.php10
-rw-r--r--lib/private/legacy/app.php8
-rw-r--r--lib/private/legacy/defaults.php14
-rw-r--r--lib/private/legacy/template.php2
-rw-r--r--lib/private/legacy/util.php12
16 files changed, 101 insertions, 51 deletions
diff --git a/lib/private/App/DependencyAnalyzer.php b/lib/private/App/DependencyAnalyzer.php
index db9130badcd..e97cf2a4013 100644
--- a/lib/private/App/DependencyAnalyzer.php
+++ b/lib/private/App/DependencyAnalyzer.php
@@ -303,12 +303,12 @@ class DependencyAnalyzer {
if (!is_null($minVersion)) {
if ($this->compareSmaller($this->platform->getOcVersion(), $minVersion)) {
- $missing[] = (string)$this->l->t('ownCloud %s or higher is required.', $minVersion);
+ $missing[] = (string)$this->l->t('Server version %s or higher is required.', $minVersion);
}
}
if (!is_null($maxVersion)) {
if ($this->compareBigger($this->platform->getOcVersion(), $maxVersion)) {
- $missing[] = (string)$this->l->t('ownCloud %s or lower is required.', $maxVersion);
+ $missing[] = (string)$this->l->t('Server version %s or lower is required.', $maxVersion);
}
}
return $missing;
diff --git a/lib/private/Config.php b/lib/private/Config.php
index 3cff3ca960d..4b7497decd9 100644
--- a/lib/private/Config.php
+++ b/lib/private/Config.php
@@ -184,10 +184,10 @@ class Config {
// Include file and merge config
foreach ($configFiles as $file) {
- $filePointer = file_exists($file) ? fopen($file, 'r') : false;
+ $fileExistsAndIsReadable = file_exists($file) && is_readable($file);
+ $filePointer = $fileExistsAndIsReadable ? fopen($file, 'r') : false;
if($file === $this->configFilePath &&
- $filePointer === false &&
- @!file_exists($this->configFilePath)) {
+ $filePointer === false) {
// Opening the main config might not be possible, e.g. if the wrong
// permissions are set (likely on a new installation)
continue;
diff --git a/lib/private/Installer.php b/lib/private/Installer.php
index e8872c6662f..cd23f95b857 100644
--- a/lib/private/Installer.php
+++ b/lib/private/Installer.php
@@ -392,7 +392,7 @@ class Installer {
// check if the app is compatible with this version of ownCloud
if(!OC_App::isAppCompatible(\OCP\Util::getVersion(), $info)) {
OC_Helper::rmdirr($extractDir);
- throw new \Exception($l->t("App can't be installed because it is not compatible with this version of ownCloud"));
+ throw new \Exception($l->t("App can't be installed because it is not compatible with this version of the server"));
}
// check if shipped tag is set which is only allowed for apps that are shipped with ownCloud
diff --git a/lib/private/Log/Owncloud.php b/lib/private/Log/Owncloud.php
index 07106be22b1..d76145ebdd3 100644
--- a/lib/private/Log/Owncloud.php
+++ b/lib/private/Log/Owncloud.php
@@ -33,7 +33,7 @@ namespace OC\Log;
/**
* logging utilities
*
- * Log is saved at data/owncloud.log (on default)
+ * Log is saved at data/nextcloud.log (on default)
*/
class Owncloud {
@@ -44,7 +44,7 @@ class Owncloud {
*/
public static function init() {
$systemConfig = \OC::$server->getSystemConfig();
- $defaultLogFile = $systemConfig->getValue("datadirectory", \OC::$SERVERROOT.'/data').'/owncloud.log';
+ $defaultLogFile = $systemConfig->getValue("datadirectory", \OC::$SERVERROOT.'/data').'/nextcloud.log';
self::$logFile = $systemConfig->getValue("logfile", $defaultLogFile);
/**
diff --git a/lib/private/Repair/DropOldTables.php b/lib/private/Repair/DropOldTables.php
index 80d26d3a0e0..bd43ba09d48 100644
--- a/lib/private/Repair/DropOldTables.php
+++ b/lib/private/Repair/DropOldTables.php
@@ -100,7 +100,10 @@ class DropOldTables implements IRepairStep {
'clndr_share_calendar',
'clndr_repeat',
'contacts_addressbooks',
- 'contacts_cards'
+ 'contacts_cards',
+ 'contacts_cards_properties',
+ 'gallery_albums',
+ 'gallery_photos'
];
}
}
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 8345a0b66e0..c663bc44261 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -78,6 +78,7 @@ use OC\Security\SecureRandom;
use OC\Security\TrustedDomainHelper;
use OC\Session\CryptoWrapper;
use OC\Tagging\TagMapper;
+use OCA\Theming\Template;
use OCP\IL10N;
use OCP\IServerContainer;
use OCP\Security\IContentSecurityPolicyManager;
@@ -235,7 +236,7 @@ class Server extends ServerContainer implements IServerContainer {
} else {
$defaultTokenProvider = null;
}
-
+
$userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig());
$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
@@ -618,6 +619,17 @@ class Server extends ServerContainer implements IServerContainer {
$factory = new $factoryClass($this);
return $factory->getManager();
});
+ $this->registerService('ThemingDefaults', function(Server $c) {
+ if($this->getConfig()->getSystemValue('installed', false) && $this->getAppManager()->isInstalled('theming')) {
+ return new Template(
+ $this->getConfig(),
+ $this->getL10N('theming'),
+ $this->getURLGenerator(),
+ new \OC_Defaults()
+ );
+ }
+ return new \OC_Defaults();
+ });
$this->registerService('EventDispatcher', function () {
return new EventDispatcher();
});
@@ -674,7 +686,8 @@ class Server extends ServerContainer implements IServerContainer {
$c->getL10N('core'),
$factory,
$c->getUserManager(),
- $c->getLazyRootFolder()
+ $c->getLazyRootFolder(),
+ $c->getEventDispatcher()
);
return $manager;
@@ -1289,6 +1302,14 @@ class Server extends ServerContainer implements IServerContainer {
}
/**
+ * @internal Not public by intention.
+ * @return \OC_Defaults
+ */
+ public function getThemingDefaults() {
+ return $this->query('ThemingDefaults');
+ }
+
+ /**
* @return \OC\IntegrityCheck\Checker
*/
public function getIntegrityCodeChecker() {
diff --git a/lib/private/Setup/AbstractDatabase.php b/lib/private/Setup/AbstractDatabase.php
index 331617df19d..08ed741f51c 100644
--- a/lib/private/Setup/AbstractDatabase.php
+++ b/lib/private/Setup/AbstractDatabase.php
@@ -42,6 +42,8 @@ abstract class AbstractDatabase {
/** @var string */
protected $dbHost;
/** @var string */
+ protected $dbPort;
+ /** @var string */
protected $tablePrefix;
/** @var IConfig */
protected $config;
@@ -78,11 +80,13 @@ abstract class AbstractDatabase {
$dbPass = $config['dbpass'];
$dbName = $config['dbname'];
$dbHost = !empty($config['dbhost']) ? $config['dbhost'] : 'localhost';
+ $dbPort = !empty($config['dbport']) ? $config['dbport'] : '';
$dbTablePrefix = isset($config['dbtableprefix']) ? $config['dbtableprefix'] : 'oc_';
$this->config->setSystemValues([
'dbname' => $dbName,
'dbhost' => $dbHost,
+ 'dbport' => $dbPort,
'dbtableprefix' => $dbTablePrefix,
]);
@@ -90,6 +94,7 @@ abstract class AbstractDatabase {
$this->dbPassword = $dbPass;
$this->dbName = $dbName;
$this->dbHost = $dbHost;
+ $this->dbPort = $dbPort;
$this->tablePrefix = $dbTablePrefix;
}
diff --git a/lib/private/Setup/MySQL.php b/lib/private/Setup/MySQL.php
index 1467eb734d7..1ff7b278b86 100644
--- a/lib/private/Setup/MySQL.php
+++ b/lib/private/Setup/MySQL.php
@@ -100,8 +100,14 @@ class MySQL extends AbstractDatabase {
'tablePrefix' => $this->tablePrefix,
);
- // adding port support
- if (strpos($this->dbHost, ':')) {
+ // adding port support through installer
+ if(!empty($this->dbPort)) {
+ if (ctype_digit($this->dbPort)) {
+ $connectionParams['port'] = $this->dbPort;
+ } else {
+ $connectionParams['unix_socket'] = $this->dbPort;
+ }
+ } else if (strpos($this->dbHost, ':')) {
// Host variable may carry a port or socket.
list($host, $portOrSocket) = explode(':', $this->dbHost, 2);
if (ctype_digit($portOrSocket)) {
diff --git a/lib/private/Setup/OCI.php b/lib/private/Setup/OCI.php
index 1da3656f9ab..2366a014c53 100644
--- a/lib/private/Setup/OCI.php
+++ b/lib/private/Setup/OCI.php
@@ -63,12 +63,14 @@ class OCI extends AbstractDatabase {
public function setupDatabase($username) {
$e_host = addslashes($this->dbHost);
+ // casting to int to avoid malicious input
+ $e_port = (int)$this->dbPort;
$e_dbname = addslashes($this->dbName);
//check if the database user has admin right
if ($e_host == '') {
$easy_connect_string = $e_dbname; // use dbname as easy connect name
} else {
- $easy_connect_string = '//'.$e_host.'/'.$e_dbname;
+ $easy_connect_string = '//'.$e_host.(!empty($e_port) ? ":{$e_port}" : "").'/'.$e_dbname;
}
$this->logger->debug('connect string: ' . $easy_connect_string, ['app' => 'setup.oci']);
$connection = @oci_connect($this->dbUser, $this->dbPassword, $easy_connect_string);
diff --git a/lib/private/Setup/PostgreSQL.php b/lib/private/Setup/PostgreSQL.php
index 702227ef3ff..464d1e02e21 100644
--- a/lib/private/Setup/PostgreSQL.php
+++ b/lib/private/Setup/PostgreSQL.php
@@ -34,8 +34,11 @@ class PostgreSQL extends AbstractDatabase {
$e_user = addslashes($this->dbUser);
$e_password = addslashes($this->dbPassword);
- // Fix database with port connection
- if(strpos($e_host, ':')) {
+ // adding port support through installer
+ if(!empty($this->dbPort)) {
+ // casting to int to avoid malicious input
+ $port = (int)$this->dbPort;
+ } else if(strpos($e_host, ':')) {
list($e_host, $port)=explode(':', $e_host, 2);
} else {
$port=false;
@@ -51,8 +54,8 @@ class PostgreSQL extends AbstractDatabase {
$connection = @pg_connect($connection_string);
if(!$connection)
- throw new \OC\DatabaseSetupException($this->trans->t('PostgreSQL username and/or password not valid'),
- $this->trans->t('You need to enter either an existing account or the administrator.'));
+ throw new \OC\DatabaseSetupException($this->trans->t('PostgreSQL connection failed'),
+ $this->trans->t('Please check your connection details.'));
}
$e_user = pg_escape_string($this->dbUser);
//check for roles creation rights in postgresql
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index 2c08e616f82..9383255bc73 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -26,6 +26,7 @@ namespace OC\Share20;
use OC\Cache\CappedMemoryCache;
use OC\Files\Mount\MoveableMount;
+use OC\HintException;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
@@ -42,6 +43,8 @@ use OCP\Share\Exceptions\GenericShareException;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager;
use OCP\Share\IProviderFactory;
+use Symfony\Component\EventDispatcher\EventDispatcher;
+use Symfony\Component\EventDispatcher\GenericEvent;
/**
* This class is the communication hub for all sharing related operations.
@@ -70,6 +73,8 @@ class Manager implements IManager {
private $rootFolder;
/** @var CappedMemoryCache */
private $sharingDisabledForUsersCache;
+ /** @var EventDispatcher */
+ private $eventDispatcher;
/**
@@ -85,6 +90,7 @@ class Manager implements IManager {
* @param IProviderFactory $factory
* @param IUserManager $userManager
* @param IRootFolder $rootFolder
+ * @param EventDispatcher $eventDispatcher
*/
public function __construct(
ILogger $logger,
@@ -96,7 +102,8 @@ class Manager implements IManager {
IL10N $l,
IProviderFactory $factory,
IUserManager $userManager,
- IRootFolder $rootFolder
+ IRootFolder $rootFolder,
+ EventDispatcher $eventDispatcher
) {
$this->logger = $logger;
$this->config = $config;
@@ -108,6 +115,7 @@ class Manager implements IManager {
$this->factory = $factory;
$this->userManager = $userManager;
$this->rootFolder = $rootFolder;
+ $this->eventDispatcher = $eventDispatcher;
$this->sharingDisabledForUsersCache = new CappedMemoryCache();
}
@@ -138,16 +146,11 @@ class Manager implements IManager {
}
// Let others verify the password
- $accepted = true;
- $message = '';
- \OCP\Util::emitHook('\OC\Share', 'verifyPassword', [
- 'password' => $password,
- 'accepted' => &$accepted,
- 'message' => &$message
- ]);
-
- if (!$accepted) {
- throw new \Exception($message);
+ try {
+ $event = new GenericEvent($password);
+ $this->eventDispatcher->dispatch('OCP\PasswordPolicy::validate', $event);
+ } catch (HintException $e) {
+ throw new \Exception($e->getHint());
}
}
@@ -242,8 +245,11 @@ class Manager implements IManager {
throw new GenericShareException($message_t, $message_t, 404);
}
+
// Check that read permissions are always set
- if (($share->getPermissions() & \OCP\Constants::PERMISSION_READ) === 0) {
+ // Link shares are allowed to have no read permissions to allow upload to hidden folders
+ if ($share->getShareType() !== \OCP\Share::SHARE_TYPE_LINK &&
+ ($share->getPermissions() & \OCP\Constants::PERMISSION_READ) === 0) {
throw new \InvalidArgumentException('Shares need at least read permissions');
}
diff --git a/lib/private/User/Database.php b/lib/private/User/Database.php
index 1dcac287e1e..85cbddca359 100644
--- a/lib/private/User/Database.php
+++ b/lib/private/User/Database.php
@@ -51,6 +51,8 @@
namespace OC\User;
use OC\Cache\CappedMemoryCache;
+use Symfony\Component\EventDispatcher\EventDispatcher;
+use Symfony\Component\EventDispatcher\GenericEvent;
/**
* Class for user management in a SQL Database (e.g. MySQL, SQLite)
@@ -58,12 +60,14 @@ use OC\Cache\CappedMemoryCache;
class Database extends \OC\User\Backend implements \OCP\IUserBackend {
/** @var CappedMemoryCache */
private $cache;
-
+ /** @var EventDispatcher */
+ private $eventDispatcher;
/**
* OC_User_Database constructor.
*/
- public function __construct() {
+ public function __construct($eventDispatcher = null) {
$this->cache = new CappedMemoryCache();
+ $this->eventDispatcher = $eventDispatcher ? $eventDispatcher : \OC::$server->getEventDispatcher();
}
/**
@@ -115,6 +119,8 @@ class Database extends \OC\User\Backend implements \OCP\IUserBackend {
*/
public function setPassword($uid, $password) {
if ($this->userExists($uid)) {
+ $event = new GenericEvent($password);
+ $this->eventDispatcher->dispatch('OCP\PasswordPolicy::validate', $event);
$query = \OC_DB::prepare('UPDATE `*PREFIX*users` SET `password` = ? WHERE `uid` = ?');
$result = $query->execute(array(\OC::$server->getHasher()->hash($password), $uid));
diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php
index 5fac1790424..87553cca805 100644
--- a/lib/private/legacy/app.php
+++ b/lib/private/legacy/app.php
@@ -421,7 +421,9 @@ class OC_App {
$settings = array();
// by default, settings only contain the help menu
- if (OC_Util::getEditionString() === '' &&
+ /*
+ * FIXME: Add help sidebar back once documentation is properly branded.
+ if (OC_Util::getEditionString() === '' &&
\OC::$server->getSystemConfig()->getValue('knowledgebaseenabled', true) == true
) {
$settings = array(
@@ -433,7 +435,7 @@ class OC_App {
"icon" => $urlGenerator->imagePath("settings", "help.svg")
)
);
- }
+ }*/
// if the user is logged-in
if (OC_User::isLoggedIn()) {
@@ -1137,7 +1139,7 @@ class OC_App {
$version = \OCP\Util::getVersion();
if (!self::isAppCompatible($version, $info)) {
throw new \Exception(
- $l->t('App "%s" cannot be installed because it is not compatible with this version of ownCloud.',
+ $l->t('App "%s" cannot be installed because it is not compatible with this version of the server.',
array($info['name'])
)
);
diff --git a/lib/private/legacy/defaults.php b/lib/private/legacy/defaults.php
index bcfd5374e0a..2a97cfe89ed 100644
--- a/lib/private/legacy/defaults.php
+++ b/lib/private/legacy/defaults.php
@@ -51,19 +51,19 @@ class OC_Defaults {
$this->l = \OC::$server->getL10N('lib');
$version = \OCP\Util::getVersion();
- $this->defaultEntity = 'ownCloud'; /* e.g. company name, used for footers and copyright notices */
- $this->defaultName = 'ownCloud'; /* short name, used when referring to the software */
- $this->defaultTitle = 'ownCloud'; /* can be a longer name, for titles */
- $this->defaultBaseUrl = 'https://owncloud.org';
- $this->defaultSyncClientUrl = 'https://owncloud.org/install/#install-clients';
+ $this->defaultEntity = 'Nextcloud'; /* e.g. company name, used for footers and copyright notices */
+ $this->defaultName = 'Nextcloud'; /* short name, used when referring to the software */
+ $this->defaultTitle = 'Nextcloud'; /* can be a longer name, for titles */
+ $this->defaultBaseUrl = 'https://nextcloud.com';
+ $this->defaultSyncClientUrl = 'https://nextcloud.com/install';
$this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/owncloud/id543672169?mt=8';
$this->defaultiTunesAppId = '543672169';
$this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.owncloud.android';
$this->defaultDocBaseUrl = 'https://doc.owncloud.org';
$this->defaultDocVersion = $version[0] . '.' . $version[1]; // used to generate doc links
- $this->defaultSlogan = $this->l->t('web services under your control');
+ $this->defaultSlogan = $this->l->t('a safe home for all your data');
$this->defaultLogoClaim = '';
- $this->defaultMailHeaderColor = '#1d2d44'; /* header color of mail notifications */
+ $this->defaultMailHeaderColor = '#0082c9'; /* header color of mail notifications */
$themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
if (file_exists($themePath)) {
diff --git a/lib/private/legacy/template.php b/lib/private/legacy/template.php
index 5023e3a60c8..e2956508090 100644
--- a/lib/private/legacy/template.php
+++ b/lib/private/legacy/template.php
@@ -80,7 +80,7 @@ class OC_Template extends \OC\Template\Base {
$parts = explode('/', $app); // fix translation when app is something like core/lostpassword
$l10n = \OC::$server->getL10N($parts[0]);
- $themeDefaults = new OC_Defaults();
+ $themeDefaults = \OC::$server->getThemingDefaults();
list($path, $template) = $this->findTemplate($theme, $app, $name);
diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php
index 78445dab020..3c56008a48b 100644
--- a/lib/private/legacy/util.php
+++ b/lib/private/legacy/util.php
@@ -648,12 +648,8 @@ class OC_Util {
if(OC_Util::runningOnWindows()) {
$errors[] = [
'error' => $l->t('Microsoft Windows Platform is not supported'),
- 'hint' => $l->t('Running ownCloud Server on the Microsoft Windows platform is not supported. We suggest you ' .
- 'use a Linux server in a virtual machine if you have no option for migrating the server itself. ' .
- 'Find Linux packages as well as easy to deploy virtual machine images on <a href="%s">%s</a>. ' .
- 'For migrating existing installations to Linux you can find some tips and a migration script ' .
- 'in <a href="%s">our documentation</a>.',
- ['https://owncloud.org/install/', 'owncloud.org/install/', 'https://owncloud.org/?p=8045'])
+ 'hint' => $l->t('Running Nextcloud Server on the Microsoft Windows platform is not supported. We suggest you ' .
+ 'use a Linux server in a virtual machine if you have no option for migrating the server itself.')
];
}
@@ -704,7 +700,7 @@ class OC_Util {
. '%sgiving the webserver write access to the root directory%s.',
array('<a href="' . $urlGenerator->linkToDocs('admin-dir_permissions') . '" target="_blank" rel="noreferrer">', '</a>'));
$errors[] = array(
- 'error' => 'Data directory (' . $CONFIG_DATADIRECTORY . ') not writable by ownCloud',
+ 'error' => 'Data directory (' . $CONFIG_DATADIRECTORY . ') not writable',
'hint' => $permissionsHint
);
} else {
@@ -814,7 +810,7 @@ class OC_Util {
}
$errors[] = [
'error' => $l->t('PHP setting "%s" is not set to "%s".', [$setting[0], var_export($setting[1], true)]),
- 'hint' => $l->t('Adjusting this setting in php.ini will make ownCloud run again')
+ 'hint' => $l->t('Adjusting this setting in php.ini will make Nextcloud run again')
];
$webServerRestart = true;
}