mirror of
https://github.com/minetest/minetest.git
synced 2024-11-26 09:33:45 +01:00
Fix changing secure settings from mainmenu
forgotten in ea4ae55e24d2c27524490cb8e0d3c34aa46e3da3 closes #15454
This commit is contained in:
parent
9b6a399011
commit
f493e73aeb
@ -12,11 +12,12 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
|
|
||||||
/* This protects the following from being set:
|
/*
|
||||||
* 'secure.*' settings
|
* This protects the following from being set:
|
||||||
* some security-relevant settings
|
* - 'secure.*' settings
|
||||||
|
* - some security-relevant settings
|
||||||
* (better solution pending)
|
* (better solution pending)
|
||||||
* some mapgen settings
|
* - some mapgen settings
|
||||||
* (not security-criticial, just to avoid messing up user configs)
|
* (not security-criticial, just to avoid messing up user configs)
|
||||||
*/
|
*/
|
||||||
#define CHECK_SETTING_SECURITY(L, name) \
|
#define CHECK_SETTING_SECURITY(L, name) \
|
||||||
@ -27,14 +28,16 @@
|
|||||||
|
|
||||||
static inline int checkSettingSecurity(lua_State* L, const std::string &name)
|
static inline int checkSettingSecurity(lua_State* L, const std::string &name)
|
||||||
{
|
{
|
||||||
|
#if CHECK_CLIENT_BUILD()
|
||||||
|
// Main menu is allowed everything
|
||||||
|
if (ModApiBase::getGuiEngine(L) != nullptr)
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (ScriptApiSecurity::isSecure(L) && name.compare(0, 7, "secure.") == 0)
|
if (ScriptApiSecurity::isSecure(L) && name.compare(0, 7, "secure.") == 0)
|
||||||
throw LuaError("Attempted to set secure setting.");
|
throw LuaError("Attempted to set secure setting.");
|
||||||
|
|
||||||
bool is_mainmenu = false;
|
if (name == "mg_name" || name == "mg_flags") {
|
||||||
#if CHECK_CLIENT_BUILD()
|
|
||||||
is_mainmenu = ModApiBase::getGuiEngine(L) != nullptr;
|
|
||||||
#endif
|
|
||||||
if (!is_mainmenu && (name == "mg_name" || name == "mg_flags")) {
|
|
||||||
errorstream << "Tried to set global setting " << name << ", ignoring. "
|
errorstream << "Tried to set global setting " << name << ", ignoring. "
|
||||||
"minetest.set_mapgen_setting() should be used instead." << std::endl;
|
"minetest.set_mapgen_setting() should be used instead." << std::endl;
|
||||||
infostream << script_get_backtrace(L) << std::endl;
|
infostream << script_get_backtrace(L) << std::endl;
|
||||||
@ -45,12 +48,10 @@ static inline int checkSettingSecurity(lua_State* L, const std::string &name)
|
|||||||
"main_menu_script", "shader_path", "texture_path", "screenshot_path",
|
"main_menu_script", "shader_path", "texture_path", "screenshot_path",
|
||||||
"serverlist_file", "serverlist_url", "map-dir", "contentdb_url",
|
"serverlist_file", "serverlist_url", "map-dir", "contentdb_url",
|
||||||
};
|
};
|
||||||
if (!is_mainmenu) {
|
|
||||||
for (const char *name2 : disallowed) {
|
for (const char *name2 : disallowed) {
|
||||||
if (name == name2)
|
if (name == name2)
|
||||||
throw LuaError("Attempted to set disallowed setting.");
|
throw LuaError("Attempted to set disallowed setting.");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user