mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Prevent games from setting secure settings (#10460)
This commit is contained in:
parent
f46509d5e2
commit
e80fc22dd9
@ -34,12 +34,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
// The maximum number of identical world names allowed
|
// The maximum number of identical world names allowed
|
||||||
#define MAX_WORLD_NAMES 100
|
#define MAX_WORLD_NAMES 100
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
bool getGameMinetestConfig(const std::string &game_path, Settings &conf)
|
bool getGameMinetestConfig(const std::string &game_path, Settings &conf)
|
||||||
{
|
{
|
||||||
std::string conf_path = game_path + DIR_DELIM + "minetest.conf";
|
std::string conf_path = game_path + DIR_DELIM + "minetest.conf";
|
||||||
return conf.readConfigFile(conf_path.c_str());
|
return conf.readConfigFile(conf_path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
struct GameFindPath
|
struct GameFindPath
|
||||||
{
|
{
|
||||||
std::string path;
|
std::string path;
|
||||||
@ -330,8 +335,11 @@ void loadGameConfAndInitWorld(const std::string &path, const std::string &name,
|
|||||||
// files that were loaded before.
|
// files that were loaded before.
|
||||||
g_settings->clearDefaults();
|
g_settings->clearDefaults();
|
||||||
set_default_settings(g_settings);
|
set_default_settings(g_settings);
|
||||||
|
|
||||||
Settings game_defaults;
|
Settings game_defaults;
|
||||||
getGameMinetestConfig(gamespec.path, game_defaults);
|
getGameMinetestConfig(gamespec.path, game_defaults);
|
||||||
|
game_defaults.removeSecureSettings();
|
||||||
|
|
||||||
g_settings->overrideDefaults(&game_defaults);
|
g_settings->overrideDefaults(&game_defaults);
|
||||||
|
|
||||||
infostream << "Initializing world at " << final_path << std::endl;
|
infostream << "Initializing world at " << final_path << std::endl;
|
||||||
|
@ -53,9 +53,6 @@ struct SubgameSpec
|
|||||||
bool isValid() const { return (!id.empty() && !path.empty()); }
|
bool isValid() const { return (!id.empty() && !path.empty()); }
|
||||||
};
|
};
|
||||||
|
|
||||||
// minetest.conf
|
|
||||||
bool getGameMinetestConfig(const std::string &game_path, Settings &conf);
|
|
||||||
|
|
||||||
SubgameSpec findSubgame(const std::string &id);
|
SubgameSpec findSubgame(const std::string &id);
|
||||||
SubgameSpec findWorldSubgame(const std::string &world_path);
|
SubgameSpec findWorldSubgame(const std::string &world_path);
|
||||||
|
|
||||||
|
@ -1039,6 +1039,19 @@ void Settings::deregisterChangedCallback(const std::string &name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Settings::removeSecureSettings()
|
||||||
|
{
|
||||||
|
for (const auto &name : getNames()) {
|
||||||
|
if (name.compare(0, 7, "secure.") != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
errorstream << "Secure setting " << name
|
||||||
|
<< " isn't allowed, so was ignored."
|
||||||
|
<< std::endl;
|
||||||
|
remove(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Settings::doCallbacks(const std::string &name) const
|
void Settings::doCallbacks(const std::string &name) const
|
||||||
{
|
{
|
||||||
MutexAutoLock lock(m_callback_mutex);
|
MutexAutoLock lock(m_callback_mutex);
|
||||||
|
@ -207,6 +207,8 @@ public:
|
|||||||
void deregisterChangedCallback(const std::string &name,
|
void deregisterChangedCallback(const std::string &name,
|
||||||
SettingsChangedCallback cbf, void *userdata = NULL);
|
SettingsChangedCallback cbf, void *userdata = NULL);
|
||||||
|
|
||||||
|
void removeSecureSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/***********************
|
/***********************
|
||||||
* Reading and writing *
|
* Reading and writing *
|
||||||
|
Loading…
Reference in New Issue
Block a user