diff --git a/apps/files_trashbin/tests/ExpirationTest.php b/apps/files_trashbin/tests/ExpirationTest.php index 366c79dbc52d..09318b32f843 100644 --- a/apps/files_trashbin/tests/ExpirationTest.php +++ b/apps/files_trashbin/tests/ExpirationTest.php @@ -223,7 +223,8 @@ private function getMockedConfig($returnValue){ 'deleteUserValue', 'deleteAllUserValues', 'deleteAppFromAllUsers', - 'getUsersForUserValue' + 'getUsersForUserValue', + 'isSystemConfigReadOnly' ] ) ->getMock() diff --git a/apps/files_versions/tests/ExpirationTest.php b/apps/files_versions/tests/ExpirationTest.php index 8d94703b5fd4..f062818afbeb 100644 --- a/apps/files_versions/tests/ExpirationTest.php +++ b/apps/files_versions/tests/ExpirationTest.php @@ -192,7 +192,8 @@ private function getMockedConfig($returnValue){ 'deleteUserValue', 'deleteAllUserValues', 'deleteAppFromAllUsers', - 'getUsersForUserValue' + 'getUsersForUserValue', + 'isSystemConfigReadOnly' ] ) ->getMock() diff --git a/lib/base.php b/lib/base.php index 8fe7964fab63..895e9b15c8c5 100644 --- a/lib/base.php +++ b/lib/base.php @@ -235,7 +235,7 @@ public static function checkConfig() { // Check if config is writable $configFileWritable = is_writable($configFilePath); - if (!$configFileWritable && !OC_Helper::isReadOnlyConfigEnabled() + if (!$configFileWritable && !\OC::$server->getConfig()->isSystemConfigReadOnly() || !$configFileWritable && self::checkUpgrade(false)) { $urlGenerator = \OC::$server->getURLGenerator(); diff --git a/lib/private/AllConfig.php b/lib/private/AllConfig.php index fc2149a81a09..fc3f32b3e0af 100644 --- a/lib/private/AllConfig.php +++ b/lib/private/AllConfig.php @@ -31,7 +31,6 @@ use Doctrine\DBAL\Platforms\OraclePlatform; use OC\Cache\CappedMemoryCache; use OCP\IDBConnection; -use OCP\PreConditionNotMetException; /** * Class to combine all the configuration options ownCloud offers @@ -445,4 +444,15 @@ public function getUsersForUserValue($appName, $key, $value) { return $userIDs; } + + /** + * In some environments the system config file is readonly. Find out if this + * is the case. + * + * @return boolean + * @since 10.0.3 + */ + public function isSystemConfigReadOnly() { + return $this->systemConfig->isReadOnly(); + } } diff --git a/lib/private/Config.php b/lib/private/Config.php index 5f8019d91e83..b41531e81791 100644 --- a/lib/private/Config.php +++ b/lib/private/Config.php @@ -105,6 +105,9 @@ public function getValue($key, $default = null) { * If value is null, the config key will be deleted */ public function setValues(array $configs) { + if ($this->isReadOnly()) { + throw new \Exception('Config file is read only.'); + } $needsUpdate = false; foreach ($configs as $key => $value) { if ($value !== null) { @@ -127,6 +130,9 @@ public function setValues(array $configs) { * @param mixed $value value */ public function setValue($key, $value) { + if ($this->isReadOnly()) { + throw new \Exception('Config file is read only.'); + } if ($this->set($key, $value)) { // Write changes $this->writeData(); @@ -155,6 +161,9 @@ protected function set($key, $value) { * @param string $key */ public function deleteKey($key) { + if ($this->isReadOnly()) { + throw new \Exception('Config file is read only.'); + } if ($this->delete($key)) { // Write changes $this->writeData(); @@ -272,5 +281,12 @@ private function writeData() { \OC_Util::clearOpcodeCache(); } } + + public function isReadOnly() { + if (!$this->getValue('installed', false)) { + return false; + } + return $this->getValue('config_is_read_only', false); + } } diff --git a/lib/private/SystemConfig.php b/lib/private/SystemConfig.php index d90dde6bca72..72cc8dae5e91 100644 --- a/lib/private/SystemConfig.php +++ b/lib/private/SystemConfig.php @@ -157,4 +157,8 @@ protected function removeSensitiveValue($keysToRemove, $value) { return $value; } + + public function isReadOnly() { + return $this->config->isReadOnly(); + } } diff --git a/lib/private/legacy/helper.php b/lib/private/legacy/helper.php index 4d04cd346217..665796d77c96 100644 --- a/lib/private/legacy/helper.php +++ b/lib/private/legacy/helper.php @@ -657,12 +657,4 @@ private static function getGlobalStorageInfo() { return ['free' => $free, 'used' => $used, 'total' => $total, 'relative' => $relative]; } - - /** - * Returns whether the config file is set manually to read-only - * @return bool - */ - public static function isReadOnlyConfigEnabled() { - return \OC::$server->getConfig()->getSystemValue('config_is_read_only', false); - } } diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php index e3b0894a189f..c22db5083efc 100644 --- a/lib/private/legacy/util.php +++ b/lib/private/legacy/util.php @@ -715,7 +715,7 @@ public static function checkServer(\OCP\IConfig $config) { } // Check if config folder is writable. - if(!OC_Helper::isReadOnlyConfigEnabled()) { + if(!\OC::$server->getConfig()->isSystemConfigReadOnly()) { if (!is_writable(OC::$configDir) or !is_readable(OC::$configDir)) { $errors[] = [ 'error' => $l->t('Cannot write into "config" directory'), @@ -726,21 +726,6 @@ public static function checkServer(\OCP\IConfig $config) { } } - // Check if there is a writable install folder. - if ($config->getSystemValue('appstoreenabled', true)) { - if (OC_App::getInstallPath() === null - || !is_writable(OC_App::getInstallPath()) - || !is_readable(OC_App::getInstallPath()) - ) { - $errors[] = [ - 'error' => $l->t('Cannot write into "apps" directory'), - 'hint' => $l->t('This can usually be fixed by ' - . '%sgiving the webserver write access to the apps directory%s' - . ' or disabling the appstore in the config file.', - ['', '']) - ]; - } - } // Create root dir. if ($config->getSystemValue('installed', false)) { if (!is_dir($CONFIG_DATADIRECTORY)) { diff --git a/lib/public/IConfig.php b/lib/public/IConfig.php index a79599670a27..a7736ffcba65 100644 --- a/lib/public/IConfig.php +++ b/lib/public/IConfig.php @@ -223,4 +223,13 @@ public function deleteAppFromAllUsers($appName); * @since 8.0.0 */ public function getUsersForUserValue($appName, $key, $value); + + /** + * In some environments the system config file is readonly. Find out if this + * is the case. + * + * @return boolean + * @since 10.0.3 + */ + public function isSystemConfigReadOnly(); } diff --git a/settings/Panels/Admin/Mail.php b/settings/Panels/Admin/Mail.php index cb455d14a0f6..f33d5d63aaee 100644 --- a/settings/Panels/Admin/Mail.php +++ b/settings/Panels/Admin/Mail.php @@ -46,6 +46,7 @@ public function getPriority() { public function getPanel() { $template = new Template('settings', 'panels/admin/mail'); // Should we display sendmail as an option? + $template->assign('read-only', $this->config->isSystemConfigReadOnly()); $template->assign('sendmail_is_available', $this->helper->findBinaryPath('sendmail')); $template->assign('loglevel', $this->config->getSystemValue("loglevel", 2)); $template->assign('mail_domain', $this->config->getSystemValue("mail_domain", '')); diff --git a/settings/Panels/Admin/SecurityWarning.php b/settings/Panels/Admin/SecurityWarning.php index 0c6442f4c9bb..a44d03eb954f 100644 --- a/settings/Panels/Admin/SecurityWarning.php +++ b/settings/Panels/Admin/SecurityWarning.php @@ -68,7 +68,7 @@ public function getPanel() { // warn if php is not setup properly to get system variables with getenv $path = getenv('PATH'); $template->assign('getenvServerNotWorking', empty($path)); - $template->assign('readOnlyConfigEnabled', $this->helper->isReadOnlyConfigEnabled()); + $template->assign('readOnlyConfigEnabled', $this->config->isSystemConfigReadOnly()); $template->assign('isAnnotationsWorking', $this->helper->isAnnotationsWorking()); try { if ($this->dbconnection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) { diff --git a/settings/Panels/Helper.php b/settings/Panels/Helper.php index 22c6372b4e1e..513b2514bf35 100644 --- a/settings/Panels/Helper.php +++ b/settings/Panels/Helper.php @@ -47,10 +47,6 @@ public function findBinaryPath($path) { return (bool) \OC_Helper::findBinaryPath($path); } - public function isReadOnlyConfigEnabled() { - return \OC_Helper::isReadOnlyConfigEnabled(); - } - public function isAnnotationsWorking() { return \OC_Util::isAnnotationsWorking(); } diff --git a/settings/templates/panels/admin/mail.php b/settings/templates/panels/admin/mail.php index 6418b9d8e45f..9b1ea23109d8 100644 --- a/settings/templates/panels/admin/mail.php +++ b/settings/templates/panels/admin/mail.php @@ -22,87 +22,94 @@ $mail_smtpmode[] = 'qmail'; } ?>
+ + ' />@ + ' /> +
+ +> + + + + /> + +
+> + + ' /> + : + ' /> +
+ + +