mirror of
https://github.com/minetest/minetest.git
synced 2024-12-27 00:17:29 +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"
|
||||
|
||||
|
||||
/* This protects the following from being set:
|
||||
* 'secure.*' settings
|
||||
* some security-relevant settings
|
||||
/*
|
||||
* This protects the following from being set:
|
||||
* - 'secure.*' settings
|
||||
* - some security-relevant settings
|
||||
* (better solution pending)
|
||||
* some mapgen settings
|
||||
* - some mapgen settings
|
||||
* (not security-criticial, just to avoid messing up user configs)
|
||||
*/
|
||||
#define CHECK_SETTING_SECURITY(L, name) \
|
||||
@ -27,14 +28,16 @@
|
||||
|
||||
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)
|
||||
throw LuaError("Attempted to set secure setting.");
|
||||
|
||||
bool is_mainmenu = false;
|
||||
#if CHECK_CLIENT_BUILD()
|
||||
is_mainmenu = ModApiBase::getGuiEngine(L) != nullptr;
|
||||
#endif
|
||||
if (!is_mainmenu && (name == "mg_name" || name == "mg_flags")) {
|
||||
if (name == "mg_name" || name == "mg_flags") {
|
||||
errorstream << "Tried to set global setting " << name << ", ignoring. "
|
||||
"minetest.set_mapgen_setting() should be used instead." << std::endl;
|
||||
infostream << script_get_backtrace(L) << std::endl;
|
||||
@ -45,11 +48,9 @@ static inline int checkSettingSecurity(lua_State* L, const std::string &name)
|
||||
"main_menu_script", "shader_path", "texture_path", "screenshot_path",
|
||||
"serverlist_file", "serverlist_url", "map-dir", "contentdb_url",
|
||||
};
|
||||
if (!is_mainmenu) {
|
||||
for (const char *name2 : disallowed) {
|
||||
if (name == name2)
|
||||
throw LuaError("Attempted to set disallowed setting.");
|
||||
}
|
||||
for (const char *name2 : disallowed) {
|
||||
if (name == name2)
|
||||
throw LuaError("Attempted to set disallowed setting.");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user