Merge pull request #12627 from nupplaphil/feat/config_warning

Check `node.config.php` file permission
This commit is contained in:
Hypolite Petovan 2023-01-07 11:41:44 -05:00 committed by GitHub
commit 450dd433a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 71 additions and 35 deletions

View file

@ -218,6 +218,22 @@ class ConfigFileManager
} }
} }
/**
* 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 * Saves overridden config entries back into the data.config.php
* *
@ -244,7 +260,9 @@ class ConfigFileManager
* (as is the case with 'x'). The file pointer is positioned on the beginning of the file. * (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 { try {
// We do want an exclusive lock, so we wait until every LOCK_SH (config reading) is unlocked // We do want an exclusive lock, so we wait until every LOCK_SH (config reading) is unlocked

View file

@ -181,6 +181,11 @@ abstract class DI
return self::$dice->create(Core\Config\Capability\IManageConfigValues::class); 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 public static function keyValue(): Core\KeyValueStorage\Capabilities\IManageKeyValuePairs
{ {
return self::$dice->create(Core\KeyValueStorage\Capabilities\IManageKeyValuePairs::class); return self::$dice->create(Core\KeyValueStorage\Capabilities\IManageKeyValuePairs::class);

View file

@ -23,6 +23,7 @@ namespace Friendica\Module\Admin;
use Friendica\App; use Friendica\App;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\Config\Util\ConfigFileManager;
use Friendica\Core\Config\ValueObject\Cache; use Friendica\Core\Config\ValueObject\Cache;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
@ -114,6 +115,10 @@ class Summary extends BaseAdmin
$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'); $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. Until then database updates won\'t be applied automatically, admin settings and console configuration changes won\'t be saved.', ConfigFileManager::CONFIG_DATA_FILE);
}
// Check server vitality // Check server vitality
if (!self::checkSelfHostMeta()) { if (!self::checkSelfHostMeta()) {
$well_known = DI::baseUrl()->get() . Probe::HOST_META; $well_known = DI::baseUrl()->get() . Probe::HOST_META;

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 2023.03-dev\n" "Project-Id-Version: 2023.03-dev\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-01-05 10:33-0500\n" "POT-Creation-Date: 2023-01-07 14:32+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -2731,36 +2731,36 @@ msgstr ""
msgid "Enter a valid existing folder" msgid "Enter a valid existing folder"
msgstr "" msgstr ""
#: src/Core/Update.php:70 #: src/Core/Update.php:80
#, php-format #, php-format
msgid "" msgid ""
"Updates from version %s are not supported. Please update at least to version " "Updates from version %s are not supported. Please update at least to version "
"2021.01 and wait until the postupdate finished version 1383." "2021.01 and wait until the postupdate finished version 1383."
msgstr "" msgstr ""
#: src/Core/Update.php:81 #: src/Core/Update.php:91
#, php-format #, php-format
msgid "" msgid ""
"Updates from postupdate version %s are not supported. Please update at least " "Updates from postupdate version %s are not supported. Please update at least "
"to version 2021.01 and wait until the postupdate finished version 1383." "to version 2021.01 and wait until the postupdate finished version 1383."
msgstr "" msgstr ""
#: src/Core/Update.php:156 #: src/Core/Update.php:186
#, php-format #, php-format
msgid "%s: executing pre update %d" msgid "%s: executing pre update %d"
msgstr "" msgstr ""
#: src/Core/Update.php:198 #: src/Core/Update.php:228
#, php-format #, php-format
msgid "%s: executing post update %d" msgid "%s: executing post update %d"
msgstr "" msgstr ""
#: src/Core/Update.php:272 #: src/Core/Update.php:302
#, php-format #, php-format
msgid "Update %s failed. See error logs." msgid "Update %s failed. See error logs."
msgstr "" msgstr ""
#: src/Core/Update.php:312 #: src/Core/Update.php:342
#, php-format #, php-format
msgid "" msgid ""
"\n" "\n"
@ -2772,16 +2772,16 @@ msgid ""
"might be invalid." "might be invalid."
msgstr "" msgstr ""
#: src/Core/Update.php:318 #: src/Core/Update.php:348
#, php-format #, php-format
msgid "The error message is\\n[pre]%s[/pre]" msgid "The error message is\\n[pre]%s[/pre]"
msgstr "" msgstr ""
#: src/Core/Update.php:322 src/Core/Update.php:350 #: src/Core/Update.php:352 src/Core/Update.php:380
msgid "[Friendica Notify] Database update" msgid "[Friendica Notify] Database update"
msgstr "" msgstr ""
#: src/Core/Update.php:344 #: src/Core/Update.php:374
#, php-format #, php-format
msgid "" msgid ""
"\n" "\n"
@ -3265,7 +3265,7 @@ msgstr ""
msgid "Title/Description:" msgid "Title/Description:"
msgstr "" msgstr ""
#: src/Model/Profile.php:1023 src/Module/Admin/Summary.php:217 #: src/Model/Profile.php:1023 src/Module/Admin/Summary.php:222
#: src/Module/Moderation/Summary.php:77 #: src/Module/Moderation/Summary.php:77
msgid "Summary" msgid "Summary"
msgstr "" msgstr ""
@ -3593,7 +3593,7 @@ msgstr ""
#: src/Module/Admin/Federation.php:207 src/Module/Admin/Logs/Settings.php:79 #: src/Module/Admin/Federation.php:207 src/Module/Admin/Logs/Settings.php:79
#: src/Module/Admin/Logs/View.php:84 src/Module/Admin/Queue.php:72 #: src/Module/Admin/Logs/View.php:84 src/Module/Admin/Queue.php:72
#: src/Module/Admin/Site.php:435 src/Module/Admin/Storage.php:138 #: src/Module/Admin/Site.php:435 src/Module/Admin/Storage.php:138
#: src/Module/Admin/Summary.php:216 src/Module/Admin/Themes/Details.php:90 #: src/Module/Admin/Summary.php:221 src/Module/Admin/Themes/Details.php:90
#: src/Module/Admin/Themes/Index.php:111 src/Module/Admin/Tos.php:77 #: src/Module/Admin/Themes/Index.php:111 src/Module/Admin/Tos.php:77
#: src/Module/Moderation/Users/Create.php:61 #: src/Module/Moderation/Users/Create.php:61
#: src/Module/Moderation/Users/Pending.php:96 #: src/Module/Moderation/Users/Pending.php:96
@ -4976,12 +4976,12 @@ msgstr ""
msgid "Database (legacy)" msgid "Database (legacy)"
msgstr "" msgstr ""
#: src/Module/Admin/Summary.php:56 #: src/Module/Admin/Summary.php:57
#, php-format #, php-format
msgid "Template engine (%s) error: %s" msgid "Template engine (%s) error: %s"
msgstr "" msgstr ""
#: src/Module/Admin/Summary.php:60 #: src/Module/Admin/Summary.php:61
#, php-format #, php-format
msgid "" msgid ""
"Your DB still runs with MyISAM tables. You should change the engine type to " "Your DB still runs with MyISAM tables. You should change the engine type to "
@ -4992,7 +4992,7 @@ msgid ""
"automatic conversion.<br />" "automatic conversion.<br />"
msgstr "" msgstr ""
#: src/Module/Admin/Summary.php:65 #: src/Module/Admin/Summary.php:66
#, php-format #, php-format
msgid "" msgid ""
"Your DB still runs with InnoDB tables in the Antelope file format. You " "Your DB still runs with InnoDB tables in the Antelope file format. You "
@ -5003,7 +5003,7 @@ msgid ""
"installation for an automatic conversion.<br />" "installation for an automatic conversion.<br />"
msgstr "" msgstr ""
#: src/Module/Admin/Summary.php:75 #: src/Module/Admin/Summary.php:76
#, php-format #, php-format
msgid "" msgid ""
"Your table_definition_cache is too low (%d). This can lead to the database " "Your table_definition_cache is too low (%d). This can lead to the database "
@ -5011,39 +5011,39 @@ msgid ""
"to %d. See <a href=\"%s\">here</a> for more information.<br />" "to %d. See <a href=\"%s\">here</a> for more information.<br />"
msgstr "" msgstr ""
#: src/Module/Admin/Summary.php:85 #: src/Module/Admin/Summary.php:86
#, php-format #, php-format
msgid "" msgid ""
"There is a new version of Friendica available for download. Your current " "There is a new version of Friendica available for download. Your current "
"version is %1$s, upstream version is %2$s" "version is %1$s, upstream version is %2$s"
msgstr "" msgstr ""
#: src/Module/Admin/Summary.php:94 #: src/Module/Admin/Summary.php:95
msgid "" msgid ""
"The database update failed. Please run \"php bin/console.php dbstructure " "The database update failed. Please run \"php bin/console.php dbstructure "
"update\" from the command line and have a look at the errors that might " "update\" from the command line and have a look at the errors that might "
"appear." "appear."
msgstr "" msgstr ""
#: src/Module/Admin/Summary.php:98 #: src/Module/Admin/Summary.php:99
msgid "" msgid ""
"The last update failed. Please run \"php bin/console.php dbstructure update" "The last update failed. Please run \"php bin/console.php dbstructure update"
"\" from the command line and have a look at the errors that might appear. " "\" from the command line and have a look at the errors that might appear. "
"(Some of the errors are possibly inside the logfile.)" "(Some of the errors are possibly inside the logfile.)"
msgstr "" msgstr ""
#: src/Module/Admin/Summary.php:103 #: src/Module/Admin/Summary.php:104
msgid "The worker was never executed. Please check your database structure!" msgid "The worker was never executed. Please check your database structure!"
msgstr "" msgstr ""
#: src/Module/Admin/Summary.php:105 #: src/Module/Admin/Summary.php:106
#, php-format #, php-format
msgid "" msgid ""
"The last worker execution was on %s UTC. This is older than one hour. Please " "The last worker execution was on %s UTC. This is older than one hour. Please "
"check your crontab settings." "check your crontab settings."
msgstr "" msgstr ""
#: src/Module/Admin/Summary.php:110 #: src/Module/Admin/Summary.php:111
#, php-format #, php-format
msgid "" msgid ""
"Friendica's configuration now is stored in config/local.config.php, please " "Friendica's configuration now is stored in config/local.config.php, please "
@ -5052,7 +5052,7 @@ msgid ""
"with the transition." "with the transition."
msgstr "" msgstr ""
#: src/Module/Admin/Summary.php:114 #: src/Module/Admin/Summary.php:115
#, php-format #, php-format
msgid "" msgid ""
"Friendica's configuration now is stored in config/local.config.php, please " "Friendica's configuration now is stored in config/local.config.php, please "
@ -5061,7 +5061,15 @@ msgid ""
"with the transition." "with the transition."
msgstr "" msgstr ""
#: src/Module/Admin/Summary.php:120 #: src/Module/Admin/Summary.php:119
#, php-format
msgid ""
"Friendica's configuration store \"%s\" isn't writable. Until then database "
"updates won't be applied automatically, admin settings and console "
"configuration changes won't be saved."
msgstr ""
#: src/Module/Admin/Summary.php:125
#, php-format #, php-format
msgid "" msgid ""
"<a href=\"%s\">%s</a> is not reachable on your system. This is a severe " "<a href=\"%s\">%s</a> is not reachable on your system. This is a severe "
@ -5069,50 +5077,50 @@ msgid ""
"href=\"%s\">the installation page</a> for help." "href=\"%s\">the installation page</a> for help."
msgstr "" msgstr ""
#: src/Module/Admin/Summary.php:138 #: src/Module/Admin/Summary.php:143
#, php-format #, php-format
msgid "The logfile '%s' is not usable. No logging possible (error: '%s')" msgid "The logfile '%s' is not usable. No logging possible (error: '%s')"
msgstr "" msgstr ""
#: src/Module/Admin/Summary.php:152 #: src/Module/Admin/Summary.php:157
#, php-format #, php-format
msgid "The debug logfile '%s' is not usable. No logging possible (error: '%s')" msgid "The debug logfile '%s' is not usable. No logging possible (error: '%s')"
msgstr "" msgstr ""
#: src/Module/Admin/Summary.php:168 #: src/Module/Admin/Summary.php:173
#, php-format #, php-format
msgid "" msgid ""
"Friendica's system.basepath was updated from '%s' to '%s'. Please remove the " "Friendica's system.basepath was updated from '%s' to '%s'. Please remove the "
"system.basepath from your db to avoid differences." "system.basepath from your db to avoid differences."
msgstr "" msgstr ""
#: src/Module/Admin/Summary.php:176 #: src/Module/Admin/Summary.php:181
#, php-format #, php-format
msgid "" msgid ""
"Friendica's current system.basepath '%s' is wrong and the config file '%s' " "Friendica's current system.basepath '%s' is wrong and the config file '%s' "
"isn't used." "isn't used."
msgstr "" msgstr ""
#: src/Module/Admin/Summary.php:184 #: src/Module/Admin/Summary.php:189
#, php-format #, php-format
msgid "" msgid ""
"Friendica's current system.basepath '%s' is not equal to the config file " "Friendica's current system.basepath '%s' is not equal to the config file "
"'%s'. Please fix your configuration." "'%s'. Please fix your configuration."
msgstr "" msgstr ""
#: src/Module/Admin/Summary.php:195 #: src/Module/Admin/Summary.php:200
msgid "Message queues" msgid "Message queues"
msgstr "" msgstr ""
#: src/Module/Admin/Summary.php:201 #: src/Module/Admin/Summary.php:206
msgid "Server Settings" msgid "Server Settings"
msgstr "" msgstr ""
#: src/Module/Admin/Summary.php:219 #: src/Module/Admin/Summary.php:224
msgid "Version" msgid "Version"
msgstr "" msgstr ""
#: src/Module/Admin/Summary.php:223 #: src/Module/Admin/Summary.php:228
msgid "Active addons" msgid "Active addons"
msgstr "" msgstr ""