}
}
+ /**
+ * Checks, if the node.config.php is writable
+ *
+ * @return bool
+ */
+ public function dataIsWritable(): bool
+ {
+ $filename = $this->configDir . '/' . self::CONFIG_DATA_FILE;
+
+ if (file_exists($filename)) {
+ return is_writable($filename);
+ } else {
+ return is_writable($this->configDir);
+ }
+ }
+
/**
* Saves overridden config entries back into the data.config.php
*
{
$filename = $this->configDir . '/' . self::CONFIG_DATA_FILE;
+ // fail at a early stage, if we already know that we cannot save the data
+ if (!$this->dataIsWritable()) {
+ throw new ConfigFileException(sprintf('Cannot open file "%s" in mode c+', $filename));
+ }
+
if (file_exists($filename)) {
$fileExists = true;
} else {
/**
* Creates a read-write stream
*
- * @see https://www.php.net/manual/en/function.fopen.php
+ * @see https://www.php.net/manual/en/function.fopen.php
* @note Open the file for reading and writing. If the file does not exist, it is created.
* If it exists, it is neither truncated (as opposed to 'w'), nor the call to this function fails
* (as is the case with 'x'). The file pointer is positioned on the beginning of the file.
*
*/
- $configStream = fopen($filename, 'c+');
+ if (($configStream = @fopen($filename, 'c+')) !== false) {
+ throw new ConfigFileException(sprintf('Cannot open file "%s" in mode c+', $filename));
+ }
try {
// We do want an exclusive lock, so we wait until every LOCK_SH (config reading) is unlocked
return self::$dice->create(Core\Config\Capability\IManageConfigValues::class);
}
+ public static function configFileManager(): Core\Config\Util\ConfigFileManager
+ {
+ return self::$dice->create(Core\Config\Util\ConfigFileManager::class);
+ }
+
public static function keyValue(): Core\KeyValueStorage\Capabilities\IManageKeyValuePairs
{
return self::$dice->create(Core\KeyValueStorage\Capabilities\IManageKeyValuePairs::class);
use Friendica\App;
use Friendica\Core\Addon;
+use Friendica\Core\Config\Util\ConfigFileManager;
use Friendica\Core\Config\ValueObject\Cache;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
$warningtext[] = DI::l10n()->t('Friendica\'s configuration now is stored in config/local.config.php, please copy config/local-sample.config.php and move your config from <code>config/local.ini.php</code>. See <a href="%s">the Config help page</a> for help with the transition.', DI::baseUrl()->get() . '/help/Config');
}
+ if (!DI::configFileManager()->dataIsWritable()) {
+ $warningtext[] = DI::l10n()->t('Friendica\'s configuration store "%s" isn\'t writable. Beware that updates, gui changes and console changes aren\'t working reliable.', ConfigFileManager::CONFIG_DATA_FILE);
+ }
+
// Check server vitality
if (!self::checkSelfHostMeta()) {
$well_known = DI::baseUrl()->get() . Probe::HOST_META;