]> source.dussan.org Git - nextcloud-server.git/commitdiff
Allow read-only configuration
authorLukas Reschke <lukas@owncloud.com>
Tue, 25 Nov 2014 15:12:12 +0000 (16:12 +0100)
committerLukas Reschke <lukas@owncloud.com>
Tue, 25 Nov 2014 15:26:47 +0000 (16:26 +0100)
Workaround required for IIS setups running ownCloud to prevent dataloss.

Long-term solution would be to move some configuration settings to the database

config/config.sample.php
lib/base.php
lib/private/helper.php
settings/admin.php
settings/templates/admin.php

index bf26172c494e4ebf04c9bd75a2d856bf82915ac2..b5e62d0366c18750ab738c7bd413dc4d95974034 100644 (file)
@@ -434,6 +434,15 @@ $CONFIG = array(
  */
 'check_for_working_htaccess' => true,
 
+/**
+ * In certain environments it is desired to have a read-only config file.
+ * When this switch is set to ``true`` ownCloud will not verify whether the
+ * configuration is writable. However, it will not be possible to configure
+ * all options via the web-interface. Furthermore, when updating ownCloud
+ * it is required to make the config file writable again for the update
+ * process.
+ */
+'config_is_read_only' => false,
 
 /**
  * Logging
index 82c0c7aa6d0e2ed75dc0957dfc00afb3890b1e4d..0c9dbb30a730ca90ffcb2e9e2828ebaca37e98fe 100644 (file)
@@ -194,9 +194,9 @@ class OC {
 
        public static function checkConfig() {
                $l = \OC::$server->getL10N('lib');
-               if (file_exists(self::$configDir . "/config.php")
-                       and !is_writable(self::$configDir . "/config.php")
-               ) {
+               $configFileWritable = file_exists(self::$configDir . "/config.php") && is_writable(self::$configDir . "/config.php");
+               if (!$configFileWritable && !OC_Helper::isReadOnlyConfigEnabled()
+                       || !$configFileWritable && \OCP\Util::needUpgrade()) {
                        if (self::$CLI) {
                                echo $l->t('Cannot write into "config" directory!')."\n";
                                echo $l->t('This can usually be fixed by giving the webserver write access to the config directory')."\n";
index be448b8ff9bf3cb372956fd35e3cbc9302023189..5f46c1311cc17cbbe24ffba0466b56b4f9414d90 100644 (file)
@@ -974,4 +974,12 @@ class OC_Helper {
                return array('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);
+       }
 }
index a669974891cb50131b7d5e602957f94f90cba39d..50a4ac4f1c89b3b841291c304fab5069cef04a6c 100644 (file)
@@ -33,6 +33,7 @@ $template->assign('mail_smtppassword', $config->getSystemValue("mail_smtppasswor
 $template->assign('entries', $entries);
 $template->assign('entriesremain', $entriesRemaining);
 $template->assign('htaccessworking', $htAccessWorking);
+$template->assign('readOnlyConfigEnabled', OC_Helper::isReadOnlyConfigEnabled());
 $template->assign('isLocaleWorking', OC_Util::isSetLocaleWorking());
 $template->assign('isPhpCharSetUtf8', OC_Util::isPhpCharSetUtf8());
 $template->assign('isAnnotationsWorking', OC_Util::isAnnotationsWorking());
index 166e36a360591e3b76920c963c25cf42b2097002..d29ea4c7f7fc3c523ee342a231bae70f0e2e8ead 100644 (file)
@@ -86,14 +86,28 @@ if (!$_['isConnectedViaHTTPS']) {
 // is htaccess working ?
 if (!$_['htaccessworking']) {
        ?>
-<div class="section">
-       <h2><?php p($l->t('Security Warning'));?></h2>
+       <div class="section">
+               <h2><?php p($l->t('Security Warning')); ?></h2>
 
        <span class="securitywarning">
                <?php p($l->t('Your data directory and your files are probably accessible from the internet. The .htaccess file is not working. We strongly suggest that you configure your webserver in a way that the data directory is no longer accessible or you move the data directory outside the webserver document root.')); ?>
        </span>
 
-</div>
+       </div>
+<?php
+}
+
+// is read only config enabled
+if ($_['readOnlyConfigEnabled']) {
+?>
+<div class="section">
+       <h2><?php p($l->t('Read-Only config enabled'));?></h2>
+
+       <span class="securitywarning">
+               <?php p($l->t('The Read-Only config has been enabled. This prevents setting some configurations via the web-interface. Furthermore, the file needs to be made writable manually for every update.')); ?>
+       </span>
+
+       </div>
 <?php
 }
 // Are doc blocks accessible?